diff --git a/docs/extra-build-config.md b/docs/extra-build-config.md index 150d23643..9c206ca0d 100644 --- a/docs/extra-build-config.md +++ b/docs/extra-build-config.md @@ -82,7 +82,7 @@ By default SD card media is used as boot media. To switch the boot media from SD card to USB memory, the following variables are supported in local.conf: `CMDLINE_ROOT_PARTITION` and `BOOT_MEDIA`. The default value of `CMDLINE_ROOT_PARTITION` is "/dev/mmcblk0p2" to mount SD card. If you want to mount USB memory partition, set CMDLINE_ROOT_PARTITION to "/dev/sda2". -`BOOT_MEDIA` allows `mmc` and `usb`. The "mmc" is required to load an image from the SD card, following the u-boot specification. Similarly, if you want to load a boot image file from USB memory, set BOOT_MEDIA to "usb". +`BOOT_MEDIA` allows `mmc` and `usb`. When U-Boot bootflow runs the boot script, the kernel is loaded from the device and partition holding the script. `BOOT_MEDIA` (device 0, partition 1) is only used when `devtype`, `devnum` and `distro_bootpart` are not set, for example when sourcing the script manually. For example, if you want to use USB boot, please define the following parameters in your local.conf file. diff --git a/recipes-bsp/rpi-u-boot-scr/files/boot.cmd.in b/recipes-bsp/rpi-u-boot-scr/files/boot.cmd.in index 58fd86a76..8b157ab05 100644 --- a/recipes-bsp/rpi-u-boot-scr/files/boot.cmd.in +++ b/recipes-bsp/rpi-u-boot-scr/files/boot.cmd.in @@ -1,4 +1,17 @@ fdt addr ${fdt_addr} && fdt get value bootargs /chosen bootargs -fatload @@BOOT_MEDIA@@ 0:1 ${kernel_addr_r} @@KERNEL_IMAGETYPE@@ -if test ! -e @@BOOT_MEDIA@@ 0:1 uboot.env; then saveenv; fi; + +# Load the kernel from the bootflow device; fall back to BOOT_MEDIA 0:1. +if test -n "${devtype}" -a -n "${devnum}" -a -n "${distro_bootpart}"; then + fatload ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} @@KERNEL_IMAGETYPE@@ +else + fatload @@BOOT_MEDIA@@ 0:1 ${kernel_addr_r} @@KERNEL_IMAGETYPE@@ +fi + +# uboot.env lives on mmc 0:1. Only create it when booted from there (not +# on another image's SD card) and without the per-boot bootflow variables. +if test "${devtype}" = mmc -a "${devnum}" = 0 -a "${distro_bootpart}" = 1 -a ! -e mmc 0:1 uboot.env; then + env delete devtype devnum distro_bootpart prefix + saveenv +fi + @@KERNEL_BOOTCMD@@ ${kernel_addr_r} - ${fdt_addr}