diff mbox series

[OpenWrt-Devel,OpenWrt-Devel,6/7] at91: Add uboot environment's

Message ID 8c7ee1f19568ae661a704dcbeb164cc63f279485.1559063196.git.sandeep.sheriker@microchip.com
State Superseded
Delegated to: Hauke Mehrtens
Headers show
Series at91 patch series. | expand

Commit Message

Sandeep Sheriker M May 28, 2019, 5:21 p.m. UTC
From: Sandeep Sheriker Mallikarjun <sandeepsheriker.mallikarjun@microchip.com>

Add uboot environment's to sdcard image.

Signed-off-by: Sandeep Sheriker Mallikarjun <sandeepsheriker.mallikarjun@microchip.com>
Signed-off-by: Sandeep Sheriker M <sandeep.sheriker@microchip.com>
---
 target/linux/at91/image/Makefile      | 21 ++++++++++++++++++---
 target/linux/at91/image/uboot-env.txt | 14 ++++++++++++++
 2 files changed, 32 insertions(+), 3 deletions(-)
 create mode 100644 target/linux/at91/image/uboot-env.txt
diff mbox series

Patch

diff --git a/target/linux/at91/image/Makefile b/target/linux/at91/image/Makefile
index 3d2462a..052a8d2 100644
--- a/target/linux/at91/image/Makefile
+++ b/target/linux/at91/image/Makefile
@@ -40,6 +40,7 @@  define Device/dtb
   KERNEL := kernel-bin | lzma | uImage lzma
 endef
 
+
 define Build/at91-sdcard
   $(if $(findstring ext4,$@), \
   rm -f $@.boot
@@ -56,7 +57,12 @@  define Build/at91-sdcard
 
   mcopy -i $@.boot \
 	$(KDIR)/$(DEVICE_NAME)-fit-zImage.itb \
-	::$(DEVICE_NAME:at91-%=%)-fit.itb ,
+	::$(DEVICE_NAME:at91-%=%)-fit.itb
+
+  $(CP) uboot-env.txt $@-uboot-env.txt
+  sed -i '2d;3d' $@-uboot-env.txt
+  sed -i '2i board='"$(DEVICE_NAME:at91-%=%)"'' $@-uboot-env.txt
+  sed -i '3i board_name='"$(DEVICE_NAME:at91-%=%)"'' $@-uboot-env.txt ,
 
   mcopy -i $@.boot $(BIN_DIR)/u-boot-*_mmc/u-boot.bin ::u-boot.bin
 
@@ -64,7 +70,16 @@  define Build/at91-sdcard
     $(BIN_DIR)/at91bootstrap-*sd*/at91bootstrap.bin ::BOOT.bin
 
   mcopy -i $@.boot \
-	$(KDIR)/$(DEVICE_NAME)-fit-zImage.itb ::$(DEVICE_NAME)-fit.itb)
+	$(KDIR)/$(DEVICE_NAME)-fit-zImage.itb ::$(DEVICE_NAME)-fit.itb
+
+  $(CP) uboot-env.txt $@-uboot-env.txt
+  sed -i '2d;3d' $@-uboot-env.txt
+  sed -i '2i board='"$(DEVICE_NAME)"'' $@-uboot-env.txt
+  sed -i '3i board_name='"$(DEVICE_NAME)"'' $@-uboot-env.txt)
+
+  mkenvimage -s 0x4000 -o $@-uboot.env $@-uboot-env.txt
+
+  mcopy -i $@.boot $@-uboot.env ::uboot.env
 
   ./gen_at91_sdcard_img.sh \
       $@.img \
@@ -75,7 +90,7 @@  define Build/at91-sdcard
 
   gzip -nc9 $@.img > $@
 
-  rm -f $@.img $@.boot )
+  rm -f $@.img $@.boot $@-uboot.env $@-uboot-env.txt)
 endef
 
 define Device/evaluation-sdimage
diff --git a/target/linux/at91/image/uboot-env.txt b/target/linux/at91/image/uboot-env.txt
new file mode 100644
index 0000000..80d051b
--- /dev/null
+++ b/target/linux/at91/image/uboot-env.txt
@@ -0,0 +1,14 @@ 
+/* Do Not remove First 2 lines, Makefile will modify these lines with proper board names */
+board=at91sam9x25ek
+board_name=at91sam9x25ek
+bootargs=console=ttyS0,115200 earlyprintk root=/dev/mmcblk0p2 rw rootwait rootfstype=ext4
+bootargsd2=console=ttyS0,115200 earlyprintk root=/dev/mmcblk1p2 rw rootwait rootfstype=ext4
+bootargsxx=console=ttyS0,115200 earlyprintk root=/dev/mmcblk0p2 rw rootwait rootfstype=ext4
+bootcmd=run setbootargs; run fatload_mmc; bootm 0x21000000
+bootdelay=1
+fatload_mmc=if test ${board_name} = sama5d2_xplained || test ${board_name} = sama5d27_som1_ek; then fatload mmc 1:1 0x21000000 ${board_name}-fit.itb; else fatload mmc 0:1 0x21000000 ${board_name}-fit.itb; fi
+setbootargs=if test ${board_name} = sama5d2_xplained || test ${board_name} = sama5d27_som1_ek; then setenv bootargs ${bootargsd2}; else setenv bootargs ${bootargsxx}; fi
+ethact=gmac0
+stderr=serial
+stdin=serial
+stdout=serial