[PATCH v1 1/2] imx8mm: configs: add support for distro boot commands

From: Alice Guo alice.guo@nxp.com
Supported boot device types in iMX8MM: MMC, QSPI, DHCP.
BOOTENV introduces other environment variables, so the size of ENV should be increased. CONFIG_CMD_PART is added for command part and CONFIG_CMD_FS_GENERIC is for command fstype.
CONFIG_BOOTCOMMAND which is defined in include/configs/imx8mm_evk.h is moved to the place before BOOTENV because "run distro_bootcmd" is not required to be the default boot mode. scriptaddr is the location in RAM where boot.scr.uimg/boot.scr will be loaded to prior to execution. script_offset_f is the location of boot.scr.uimg/boot.scr in QSPI and script_size_f is the size of boot.scr.uimg/boot.scr. kernel_addr_r is the location in RAM where the kernel will be loaded to.
Signed-off-by: Alice Guo alice.guo@nxp.com --- configs/imx8mm_evk_defconfig | 4 ++- include/configs/imx8mm_evk.h | 47 +++++++++++++++++++++++++++--------- 2 files changed, 38 insertions(+), 13 deletions(-)
diff --git a/configs/imx8mm_evk_defconfig b/configs/imx8mm_evk_defconfig index 91d3bc3ac9..993b7b8835 100644 --- a/configs/imx8mm_evk_defconfig +++ b/configs/imx8mm_evk_defconfig @@ -5,7 +5,7 @@ CONFIG_SPL_GPIO_SUPPORT=y CONFIG_SPL_LIBCOMMON_SUPPORT=y CONFIG_SPL_LIBGENERIC_SUPPORT=y CONFIG_SYS_MALLOC_F_LEN=0x10000 -CONFIG_ENV_SIZE=0x1000 +CONFIG_ENV_SIZE=0x2000 CONFIG_ENV_OFFSET=0x400000 CONFIG_SYS_I2C_MXC_I2C1=y CONFIG_SYS_I2C_MXC_I2C2=y @@ -49,6 +49,8 @@ CONFIG_CMD_EXT2=y CONFIG_CMD_EXT4=y CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_FAT=y +CONFIG_CMD_PART=y +CONFIG_CMD_FS_GENERIC=y CONFIG_OF_CONTROL=y CONFIG_SPL_OF_CONTROL=y CONFIG_ENV_OVERWRITE=y diff --git a/include/configs/imx8mm_evk.h b/include/configs/imx8mm_evk.h index 83521ad401..e6a1a0557a 100644 --- a/include/configs/imx8mm_evk.h +++ b/include/configs/imx8mm_evk.h @@ -32,8 +32,43 @@
#endif
+#define CONFIG_BOOTCOMMAND \ + "mmc dev ${mmcdev}; if mmc rescan; then " \ + "if run loadbootscript; then " \ + "run bootscript; " \ + "else " \ + "if run loadimage; then " \ + "run mmcboot; " \ + "else run netboot; " \ + "fi; " \ + "fi; " \ + "fi;" + +#define BOOTENV_DEV_QSPI(devtypeu, devtypel, instance) \ + "bootcmd_" #devtypel #instance "=sf probe " #instance " 0 0 && " \ + "sf read $scriptaddr $script_offset_f $script_size_f && " \ + "source ${scriptaddr}; echo SCRIPT FAILED: continuing...;\0" + +#define BOOTENV_DEV_NAME_QSPI(devtypeu, devtypel, instance) \ + #devtypel #instance " " + +#ifndef CONFIG_SPL_BUILD +#define BOOT_TARGET_DEVICES(func) \ + func(MMC, mmc, 1) \ + func(MMC, mmc, 2) \ + func(QSPI, qspi, 0) \ + func(DHCP, dhcp, na) + +#include <config_distro_bootcmd.h> +#endif + /* Initial environment variables */ #define CONFIG_EXTRA_ENV_SETTINGS \ + BOOTENV \ + "scriptaddr=0x43500000\0" \ + "script_offset_f=0x500000\0" \ + "script_size_f=0x100000\0" \ + "kernel_addr_r=0x40880000\0" \ "script=boot.scr\0" \ "image=Image\0" \ "console=ttymxc1,115200\0" \ @@ -84,18 +119,6 @@ "fi; " \ "fi;\0"
-#define CONFIG_BOOTCOMMAND \ - "mmc dev ${mmcdev}; if mmc rescan; then " \ - "if run loadbootscript; then " \ - "run bootscript; " \ - "else " \ - "if run loadimage; then " \ - "run mmcboot; " \ - "else run netboot; " \ - "fi; " \ - "fi; " \ - "fi;" - /* Link Definitions */ #define CONFIG_LOADADDR 0x40480000
-- 2.17.1

From: Alice Guo alice.guo@nxp.com
Distro Boot requires a U-Boot-specific script named boot.scr or boot.scr.uimg which contains boot commands to boot the system. The boot.cmd is such a file. Use mkimage to generate boot.scr or boot.scr.uimg from boot.cmd, and the command is: mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "Distro Boot Script" -d boot.cmd boot.scr.uimg
QSPI in iMX8MM platform is only used to store bootloader and script so that we do not load image or .dtb file from QSPI as is shown in boot.cmd file.
The boot.cmd file is an example script and can be modified based on needs.
Signed-off-by: Alice Guo alice.guo@nxp.com --- board/freescale/imx8mm_evk/boot.cmd | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 board/freescale/imx8mm_evk/boot.cmd
diff --git a/board/freescale/imx8mm_evk/boot.cmd b/board/freescale/imx8mm_evk/boot.cmd new file mode 100644 index 0000000000..fdfceec263 --- /dev/null +++ b/board/freescale/imx8mm_evk/boot.cmd @@ -0,0 +1,35 @@ +setenv bootargs console=${console} root=${mmcroot}; + +for boot_target in ${boot_targets}; +do + if test "${boot_target}" = "mmc1" ; then + if fatload mmc 1:${mmcpart} ${kernel_addr_r} ${image}; then + if fatload mmc 1:${mmcpart} ${fdt_addr} ${fdt_file}; then + echo Load image and .dtb from SD card(mmc1); + booti ${kernel_addr_r} - ${fdt_addr}; + exit; + fi + fi + fi + + if test "${boot_target}" = "mmc2" ; then + if fatload mmc 2:${mmcpart} ${kernel_addr_r} ${image}; then + if fatload mmc 2:${mmcpart} ${fdt_addr} ${fdt_file}; then + echo Load image and .dtb from eMMC(mmc2); + booti ${kernel_addr_r} - ${fdt_addr}; + exit; + fi + fi + fi + + if test "${boot_target}" = "dhcp" ; then + if dhcp ${kernel_addr_r} ${serverip}:${image}; then + if dhcp ${fdt_addr} ${serverip}:${fdt_file}; then + echo Load image and .dtb from net(dhcp); + booti ${kernel_addr_r} - ${fdt_addr}; + exit; + fi + fi + fi + +done -- 2.17.1
participants (1)
-
Alice Guo (OSS)