@@ -26,6 +26,15 @@ define Build/boot-scr
mkimage -A arm -O linux -T script -C none -a 0 -e 0 -d $@-new.bootscript $@-boot.scr
endef
+define Build/uenv-txt
+ rm -f $@-uEnv.txt
+ sed \
+ -e 's#@ROOT@#$(SIGNATURE)#g' \
+ -e 's#@DTB@#$(DEVICE_DTS)#g' \
+ -e 's#@KERNEL@#$(KERNEL_NAME)#g' \
+ $(DEVICE_NAME).uenv > $@-uEnv.txt
+endef
+
define Build/boot-img
rm -f $@.boot
mkfs.fat -C $@.boot $$(( $(CONFIG_TARGET_KERNEL_PARTSIZE) * 1024 ))
@@ -40,6 +49,7 @@ define Build/boot-img-ext4
$(foreach dts,$(DEVICE_DTS), $(CP) $(DTS_DIR)/$(dts).dtb $@.boot;)
$(CP) $(IMAGE_KERNEL) $@.boot/$(KERNEL_NAME)
-$(CP) $@-boot.scr $@.boot/boot.scr
+ -$(CP) $@-uEnv.txt $@.boot/uEnv.txt
make_ext4fs -J -l $(CONFIG_TARGET_KERNEL_PARTSIZE)M $@.bootimg $@.boot
endef
@@ -5,7 +5,7 @@ define Device/globalscale-espressobin
KERNEL := kernel-bin
DEVICE_TITLE := ESPRESSObin (Marvell Armada 3700 Community Board)
IMAGES := sdcard.img.gz
- IMAGE/sdcard.img.gz := boot-scr | boot-img-ext4 | sdcard-img-ext4 | gzip | append-metadata
+ IMAGE/sdcard.img.gz := uenv-txt | boot-scr | boot-img-ext4 | sdcard-img-ext4 | gzip | append-metadata
DEVICE_DTS := armada-3720-espressobin
DTS_DIR := $(DTS_DIR)/marvell
SUPPORTED_DEVICES := globalscale,espressobin
@@ -1,10 +1,18 @@
+if test -z "${owrt_uenv_ver}"; then
+ load mmc 0:1 ${loadaddr} uEnv.txt
+ env import -t ${loadaddr}
+ env delete ${old_or_temp_vars}
+ saveenv
+ boot
+fi
+
setenv bootargs "root=PARTUUID=@ROOT@-02 rw rootwait"
if test -n "${console}"; then
setenv bootargs "${bootargs} ${console}"
fi
-load mmc 0:1 ${fdt_addr} armada-3720-espressobin.dtb
-load mmc 0:1 ${kernel_addr} Image
+load mmc 0:1 ${fdt_addr}${fdt_addr_r} armada-3720-espressobin.dtb
+load mmc 0:1 ${kernel_addr}${kernel_addr_r} Image
-booti ${kernel_addr} - ${fdt_addr}
+booti ${kernel_addr}${kernel_addr_r} - ${fdt_addr}${fdt_addr_r}
new file mode 100644
@@ -0,0 +1,25 @@
+owrt_uenv_ver=1
+old_or_temp_vars=devnum devtype fileaddr filesize root uenv_ver old_or_temp_vars
+boot_a_script=ext4load ${devtype} ${devnum}:${distro_bootpart} ${loadaddr} ${prefix}${script}; run set_owrt_uenv_ver; if test "${script}" = "uEnv.txt"; then env import -t ${loadaddr}; elif test "${script}" = "boot.scr"; then source ${loadaddr}; fi; run upg_owrt_uenv; run boot_owrt
+boot_owrt=setenv bootargs "${console} ${root} rw rootwait ${extra_params}"; ext4load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr}${fdt_addr_r} ${fdt_name}; ext4load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr}${kernel_addr_r} ${image_name}; booti ${kernel_addr}${kernel_addr_r} - ${fdt_addr}${fdt_addr_r}
+boot_prefixes=/ /boot/
+boot_scripts=uEnv.txt boot.scr
+boot_targets=usb0 scsi0 mmc0 mmc1
+bootcmd=run distro_bootcmd
+bootcmd_mmc0=setenv devnum 0; run mmc_boot
+bootcmd_mmc1=setenv devnum 1; run mmc_boot
+bootcmd_scsi0=setenv devnum 0; run scsi_boot
+bootcmd_usb0=setenv devnum 0; run usb_boot
+distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done
+distro_bootpart=1
+extra_params=pci=pcie_bus_safe
+fdt_name=@DTB@.dtb
+image_name=@KERNEL@
+mmc_boot=if mmc dev ${devnum}; then setenv devtype mmc; run scan_dev_for_boot; fi
+root=root=PARTUUID=@ROOT@-02
+scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for prefix in ${boot_prefixes}; do run scan_dev_for_scripts; done;
+scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${script}; then echo Found U-Boot script ${prefix}${script}; run boot_a_script; echo SCRIPT FAILED: continuing...; fi; done
+scsi_boot=scsi scan; if scsi dev ${devnum}; then setenv devtype scsi; run scan_dev_for_boot; fi
+set_owrt_uenv_ver=if test -n ${owrt_uenv_ver}; then setenv uenv_ver ${owrt_uenv_ver}; fi
+upg_owrt_uenv=if test ${uenv_ver} != ${owrt_uenv_ver}; then env delete ${old_or_temp_vars}; saveenv; echo U-Boot environment changed to version ${owrt_uenv_ver}; boot; fi
+usb_boot=usb start; if usb dev ${devnum}; then setenv devtype usb; run scan_dev_for_boot; fi
This commit adds U-Boot environment defaults which extend the bootloader to automatically boot the ESPRESSObin board from other connected mediums i.e. SATA disk or USB disk. The assigned boot probe order is as follows: 1. USB (usb0), 2. SATA (scsi0), 3. µSD (mmc0), 4. eMMC (mmc1). U-Boot will iterate through them utill it'll find on one of devices the uEnv.txt file. If not found, it'll fall back to loading using boot.scr (loading from boot.scr is compatible only with U-Boot version 2017.03 or later). There is also self update mechanism implemented which will trigger if the variable 'owrt_uenv_ver' is changed. This commit also adds compatibility with newer U-Boot versions in which kernel_addr and fdt_addr environment variables changed names to kernel_addr_r and fdt_addr_r. The bootloader environment preparation needs to be done for every new deployment and for every board with U-Boot 2015.01 version. 1. Connect/insert boot device with OpenWrt, 2. Power on the board and enter U-Boot command line, 3. Execute following commands: usb start scsi scan ext4load mmc 0:1 $loadaddr uEnv.txt || ext4load scsi 0:1 $loadaddr uEnv.txt || ext4load usb 0:1 $loadaddr uEnv.txt env import -t $loadaddr env delete $old_or_temp_vars saveenv reset 4. Now board should automatically find boot medium with OpenWrt installation and boot it. Signed-off-by: Tomasz Maciej Nowak <tomek_n@o2.pl> --- target/linux/mvebu/image/Makefile | 10 ++++++++ target/linux/mvebu/image/cortex-a53.mk | 2 +- .../image/globalscale-espressobin.bootscript | 14 ++++++++--- .../mvebu/image/globalscale-espressobin.uenv | 25 +++++++++++++++++++ 4 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 target/linux/mvebu/image/globalscale-espressobin.uenv