From 5b3b4b66e7b27912943b1379d081729f9a2c92cc Mon Sep 17 00:00:00 2001 From: Florin Sarbu Date: Tue, 18 Jun 2024 12:50:28 +0000 Subject: [PATCH] u-boot-imx: Fixes for kirkstone Reworked 0002-fixup-imx8mm-evk-fdt-addr.patch, 0003-add-imx8mm-resin-hooks.patch and bundled these 2 patches into 0001-imx8mm-lpddr4-evk-Integrate-with-BalenaOS.patch Reworked 0002-fix-return-vaue-propagatin-out-of-environ.patch Signed-off-by: Florin Sarbu --- ...m-lpddr4-evk-Integrate-with-BalenaOS.patch | 62 +++++++++++ ...eturn-vaue-propagatin-out-of-environ.patch | 101 +++++++++++------- .../0002-fixup-imx8mm-evk-fdt-addr.patch | 14 --- .../files/0003-add-imx8mm-resin-hooks.patch | 36 ------- .../recipes-bsp/u-boot/u-boot-imx_%.bbappend | 3 +- 5 files changed, 127 insertions(+), 89 deletions(-) create mode 100644 layers/meta-balena-fsl-arm/recipes-bsp/u-boot/files/0001-imx8mm-lpddr4-evk-Integrate-with-BalenaOS.patch delete mode 100644 layers/meta-balena-fsl-arm/recipes-bsp/u-boot/files/0002-fixup-imx8mm-evk-fdt-addr.patch delete mode 100644 layers/meta-balena-fsl-arm/recipes-bsp/u-boot/files/0003-add-imx8mm-resin-hooks.patch diff --git a/layers/meta-balena-fsl-arm/recipes-bsp/u-boot/files/0001-imx8mm-lpddr4-evk-Integrate-with-BalenaOS.patch b/layers/meta-balena-fsl-arm/recipes-bsp/u-boot/files/0001-imx8mm-lpddr4-evk-Integrate-with-BalenaOS.patch new file mode 100644 index 00000000..4502ffd2 --- /dev/null +++ b/layers/meta-balena-fsl-arm/recipes-bsp/u-boot/files/0001-imx8mm-lpddr4-evk-Integrate-with-BalenaOS.patch @@ -0,0 +1,62 @@ +From 2e8da1984b3715ff0f5ccd836d1f7ce1178eeec8 Mon Sep 17 00:00:00 2001 +From: Florin Sarbu +Date: Tue, 18 Jun 2024 13:08:35 +0000 +Subject: [PATCH] imx8mm-lpddr4-evk: Integrate with BalenaOS + +Signed-off-by: Florin Sarbu +--- + include/configs/imx8mm_evk.h | 15 +++++++++------ + 1 file changed, 9 insertions(+), 6 deletions(-) + +diff --git a/include/configs/imx8mm_evk.h b/include/configs/imx8mm_evk.h +index 3d992ffa134..cbd53f2df9b 100644 +--- a/include/configs/imx8mm_evk.h ++++ b/include/configs/imx8mm_evk.h +@@ -130,8 +130,8 @@ + "image=Image\0" \ + "splashimage=0x50000000\0" \ + "console=ttymxc1,115200\0" \ +- "fdt_addr_r=0x43000000\0" \ +- "fdt_addr=0x43000000\0" \ ++ "fdt_addr_r=0x44000000\0" \ ++ "fdt_addr=0x44000000\0" \ + "fdt_high=0xffffffffffffffff\0" \ + "boot_fit=no\0" \ + "fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \ +@@ -140,19 +140,21 @@ + "mmcpart=1\0" \ + "mmcroot=" CONFIG_MMCROOT " rootwait rw\0" \ + "mmcautodetect=yes\0" \ +- "mmcargs=setenv bootargs ${jh_clk} ${mcore_clk} console=${console} root=${mmcroot}\0 " \ ++ "mmcargs=setenv bootargs ${jh_clk} ${mcore_clk} console=${console} ${resin_kernel_root} ${os_cmdline}\0 " \ + "loadbootscript=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${bsp_script};\0" \ + "bootscript=echo Running bootscript from mmc ...; " \ + "source\0" \ +- "loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}\0" \ +- "loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr_r} ${fdtfile}\0" \ ++ "loadimage=if load ${resin_dev_type} ${resin_dev_index}:${resin_root_part} ${loadaddr} boot/${image}; then run balena_kernel_load_crc_save; else false; fi;\0" \ ++ "loadfdt=if load ${resin_dev_type} ${resin_dev_index}:${resin_root_part} ${fdt_addr} boot/${fdtfile}; then run balena_fdt_load_crc_save; else false; fi;\0" \ + "mmcboot=echo Booting from mmc ...; " \ + "run mmcargs; " \ + "if test ${boot_fit} = yes || test ${boot_fit} = try; then " \ + "bootm ${loadaddr}; " \ + "else " \ + "if run loadfdt; then " \ +- "booti ${loadaddr} - ${fdt_addr_r}; " \ ++ "run balena_kernel_load_crc_check;" \ ++ "run balena_fdt_load_crc_check;" \ ++ "booti ${loadaddr} - ${fdt_addr}; " \ + "else " \ + "echo WARN: Cannot load the DT; " \ + "fi; " \ +@@ -178,6 +180,7 @@ + "fi; " \ + "fi;\0" \ + "bsp_bootcmd=echo Running BSP bootcmd ...; " \ ++ "setenv resin_kernel_load_addr ${loadaddr}; run resin_set_kernel_root; run set_os_cmdline; " \ + "mmc dev ${mmcdev}; if mmc rescan; then " \ + "if run loadbootscript; then " \ + "run bootscript; " \ +-- +2.17.1 + diff --git a/layers/meta-balena-fsl-arm/recipes-bsp/u-boot/files/0002-fix-return-vaue-propagatin-out-of-environ.patch b/layers/meta-balena-fsl-arm/recipes-bsp/u-boot/files/0002-fix-return-vaue-propagatin-out-of-environ.patch index e209c448..526c964c 100644 --- a/layers/meta-balena-fsl-arm/recipes-bsp/u-boot/files/0002-fix-return-vaue-propagatin-out-of-environ.patch +++ b/layers/meta-balena-fsl-arm/recipes-bsp/u-boot/files/0002-fix-return-vaue-propagatin-out-of-environ.patch @@ -4,10 +4,6 @@ Date: Tue, 20 Dec 2022 07:25:59 +0100 Subject: [PATCH] cmd: exit: Fix return value propagation out of environment scripts -NOTE: This is backported to NXP uboot-imx based on the backport here - -https://github.com/balena-os/balena-compulab-imx9/blob/master/layers/meta-balena-imx9/recipes-bsp/u-boot/files/0002-fix-return-vaue-propagatin-out-of-environ.patch#L184C1-L187C77 - We backport this patch in the Compulab u-boot to fix the exit cmd which previously had no effect and caused the balenaOS flasher image to never get loaded. @@ -59,12 +55,39 @@ Reviewed-by: Hector Palacios Signed-off-by: Marek Vasut Upstream-status: Inappropriate [backport] -Signed-off-by: Alex J Lennon +Signed-off-by: Alexandru Costache +--- + cmd/exit.c | 7 +++++-- + common/cli.c | 7 ++++--- + common/cli_hush.c | 21 +++++++++++++++------ + doc/usage/cmd/exit.rst | 4 +++- + 4 files changed, 27 insertions(+), 12 deletions(-) -diff -ur git.org/common/cli.c git/common/cli.c ---- git.org/common/cli.c 2023-11-20 09:34:25.161848184 +0000 -+++ git/common/cli.c 2023-11-20 09:43:12.420878425 +0000 -@@ -132,7 +132,7 @@ +diff --git a/cmd/exit.c b/cmd/exit.c +index 2c7132693a..7bf241ec73 100644 +--- a/cmd/exit.c ++++ b/cmd/exit.c +@@ -10,10 +10,13 @@ + static int do_exit(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) + { ++ int r; ++ ++ r = 0; + if (argc > 1) +- return dectoul(argv[1], NULL); ++ r = simple_strtoul(argv[1], NULL, 10); + +- return 0; ++ return -r - 2; + } + + U_BOOT_CMD( +diff --git a/common/cli.c b/common/cli.c +index a7e3d84b68..8b30a23147 100644 +--- a/common/cli.c ++++ b/common/cli.c +@@ -131,7 +131,7 @@ int run_command_list(const char *cmd, int len, int flag) #if defined(CONFIG_CMD_RUN) int do_run(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { @@ -73,48 +96,49 @@ diff -ur git.org/common/cli.c git/common/cli.c if (argc < 2) return CMD_RET_USAGE; -@@ -146,8 +146,9 @@ +@@ -145,8 +145,9 @@ int do_run(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return 1; } - if (run_command(arg, flag | CMD_FLAG_ENV) != 0) - return 1; + ret = run_command(arg, flag | CMD_FLAG_ENV); -+ if(ret) -+ return ret; ++ if (ret) ++ return ret; } return 0; } -diff -ur git.org/common/cli_hush.c git/common/cli_hush.c ---- git.org/common/cli_hush.c 2023-11-20 09:34:25.161848184 +0000 -+++ git/common/cli_hush.c 2023-11-20 09:48:58.198043179 +0000 -@@ -1902,7 +1902,7 @@ +diff --git a/common/cli_hush.c b/common/cli_hush.c +index 1467ff81b3..b8940b1973 100644 +--- a/common/cli_hush.c ++++ b/common/cli_hush.c +@@ -1902,7 +1902,7 @@ static int run_list_real(struct pipe *pi) last_return_code = -rcode - 2; return -2; /* exit */ } - last_return_code=(rcode == 0) ? 0 : 1; -+ last_return_code=rcode; ++ last_return_code = rcode; #endif #ifndef __U_BOOT__ pi->num_progs = save_num_progs; /* restore number of programs */ -@@ -3212,7 +3212,15 @@ +@@ -3212,7 +3212,15 @@ static int parse_stream_outer(struct in_str *inp, int flag) printf("exit not allowed from main input shell.\n"); continue; } - break; + /* -+ * DANGER -+ * Return code -2 is special in this context, -+ * it indicates exit from inner pipe instead -+ * of return code itself, the return code is -+ * stored in 'last_return_code' variable! -+ * DANGER -+ */ -+ return -2; ++ * DANGER ++ * Return code -2 is special in this context, ++ * it indicates exit from inner pipe instead ++ * of return code itself, the return code is ++ * stored in 'last_return_code' variable! ++ * DANGER ++ */ ++ return -2; } if (code == -1) flag_repeat = 0; -@@ -3249,9 +3257,9 @@ +@@ -3249,9 +3257,9 @@ int parse_string_outer(const char *s, int flag) #endif /* __U_BOOT__ */ { struct in_str input; @@ -125,34 +149,35 @@ diff -ur git.org/common/cli_hush.c git/common/cli_hush.c if (!s) return 1; if (!*s) -@@ -3263,11 +3271,12 @@ +@@ -3263,11 +3271,12 @@ int parse_string_outer(const char *s, int flag) setup_string_in_str(&input, p); rcode = parse_stream_outer(&input, flag); free(p); - return rcode; -+ return rcode == -2 ? last_return_code : rcode; ++ return rcode == -2 ? last_return_code : rcode; } else { #endif setup_string_in_str(&input, s); - return parse_stream_outer(&input, flag); -+ rcode = parse_stream_outer(&input, flag); -+ return rcode == -2 ? last_return_code : rcode; ++ rcode = parse_stream_outer(&input, flag); ++ return rcode == -2 ? last_return_code : rcode; #ifdef __U_BOOT__ } #endif -@@ -3287,7 +3296,7 @@ +@@ -3287,7 +3296,7 @@ int parse_file_outer(void) setup_file_in_str(&input); #endif rcode = parse_stream_outer(&input, FLAG_PARSE_SEMICOLON); - return rcode; -+ return rcode == -2 ? last_return_code : rcode; ++ return rcode == -2 ? last_return_code : rcode; } #ifdef __U_BOOT__ -diff -ur git.org/doc/usage/exit.rst git/doc/usage/exit.rst ---- git.org/doc/usage/exit.rst 2023-11-20 09:34:23.409866921 +0000 -+++ git/doc/usage/exit.rst 2023-11-20 09:49:38.985720362 +0000 -@@ -37,4 +37,6 @@ +diff --git a/doc/usage/cmd/exit.rst b/doc/usage/cmd/exit.rst +index 769223c477..3edb12809c 100644 +--- a/doc/usage/cmd/exit.rst ++++ b/doc/usage/cmd/exit.rst +@@ -37,4 +37,6 @@ executed. Return value ------------ @@ -160,3 +185,5 @@ diff -ur git.org/doc/usage/exit.rst git/doc/usage/exit.rst +$? is default set to 0 (true). In case zero or positive integer parameter +is passed to the command, the return value is the parameter value. In case +negative integer parameter is passed to the command, the return value is 0. +-- +2.37.2 diff --git a/layers/meta-balena-fsl-arm/recipes-bsp/u-boot/files/0002-fixup-imx8mm-evk-fdt-addr.patch b/layers/meta-balena-fsl-arm/recipes-bsp/u-boot/files/0002-fixup-imx8mm-evk-fdt-addr.patch deleted file mode 100644 index 28a230db..00000000 --- a/layers/meta-balena-fsl-arm/recipes-bsp/u-boot/files/0002-fixup-imx8mm-evk-fdt-addr.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff -ur git.org/include/configs/imx8mm_evk.h git/include/configs/imx8mm_evk.h ---- git.org/include/configs/imx8mm_evk.h 2023-09-19 17:04:45.921296582 +0100 -+++ git/include/configs/imx8mm_evk.h 2023-09-19 17:06:34.504395138 +0100 -@@ -138,8 +138,8 @@ - "image=Image\0" \ - "splashimage=0x50000000\0" \ - "console=ttymxc1,115200\0" \ -- "fdt_addr_r=0x43000000\0" \ -- "fdt_addr=0x43000000\0" \ -+ "fdt_addr_r=0x44000000\0" \ -+ "fdt_addr=0x44000000\0" \ - "fdt_high=0xffffffffffffffff\0" \ - "boot_fit=no\0" \ - "fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \ diff --git a/layers/meta-balena-fsl-arm/recipes-bsp/u-boot/files/0003-add-imx8mm-resin-hooks.patch b/layers/meta-balena-fsl-arm/recipes-bsp/u-boot/files/0003-add-imx8mm-resin-hooks.patch deleted file mode 100644 index 9eb841bd..00000000 --- a/layers/meta-balena-fsl-arm/recipes-bsp/u-boot/files/0003-add-imx8mm-resin-hooks.patch +++ /dev/null @@ -1,36 +0,0 @@ ---- git.org/include/configs/imx8mm_evk.h 2023-11-20 10:23:22.490132843 +0000 -+++ git/include/configs/imx8mm_evk.h 2023-11-20 12:34:36.580202049 +0000 -@@ -148,19 +148,21 @@ - "mmcpart=" __stringify(CONFIG_SYS_MMC_IMG_LOAD_PART) "\0" \ - "mmcroot=" CONFIG_MMCROOT " rootwait rw\0" \ - "mmcautodetect=yes\0" \ -- "mmcargs=setenv bootargs ${jh_clk} console=${console} root=${mmcroot}\0 " \ -+ "mmcargs=setenv bootargs ${jh_clk} console=${console} ${resin_kernel_root} ${os_cmdline}\0 " \ - "loadbootscript=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${bsp_script};\0" \ - "bootscript=echo Running bootscript from mmc ...; " \ - "source\0" \ -- "loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}\0" \ -- "loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr_r} ${fdtfile}\0" \ -+ "loadimage=if load ${resin_dev_type} ${resin_dev_index}:${resin_root_part} ${loadaddr} boot/${image}; then run balena_kernel_load_crc_save; else false; fi;\0" \ -+ "loadfdt=if load ${resin_dev_type} ${resin_dev_index}:${resin_root_part} ${fdt_addr} boot/${fdtfile}; then run balena_fdt_load_crc_save; else false; fi;\0" \ - "mmcboot=echo Booting from mmc ...; " \ - "run mmcargs; " \ - "if test ${boot_fit} = yes || test ${boot_fit} = try; then " \ - "bootm ${loadaddr}; " \ - "else " \ - "if run loadfdt; then " \ -- "booti ${loadaddr} - ${fdt_addr_r}; " \ -+ "run balena_kernel_load_crc_check;" \ -+ "run balena_fdt_load_crc_check;" \ -+ "booti ${loadaddr} - ${fdt_addr}; " \ - "else " \ - "echo WARN: Cannot load the DT; " \ - "fi; " \ -@@ -186,6 +188,7 @@ - "fi; " \ - "fi;\0" \ - "bsp_bootcmd=echo Running BSP bootcmd ...; " \ -+ "setenv resin_kernel_load_addr ${loadaddr}; run resin_set_kernel_root; run set_os_cmdline; " \ - "mmc dev ${mmcdev}; if mmc rescan; then " \ - "if run loadbootscript; then " \ - "run bootscript; " \ diff --git a/layers/meta-balena-fsl-arm/recipes-bsp/u-boot/u-boot-imx_%.bbappend b/layers/meta-balena-fsl-arm/recipes-bsp/u-boot/u-boot-imx_%.bbappend index 75023b70..64c44a4b 100644 --- a/layers/meta-balena-fsl-arm/recipes-bsp/u-boot/u-boot-imx_%.bbappend +++ b/layers/meta-balena-fsl-arm/recipes-bsp/u-boot/u-boot-imx_%.bbappend @@ -7,8 +7,7 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/files:" SRC_URI:append:imx8mm-lpddr4-evk = " \ file://0001-nitrogen8mm_env-common-Force-using-default-environment.patch \ file://0002-fix-return-vaue-propagatin-out-of-environ.patch \ - file://0002-fixup-imx8mm-evk-fdt-addr.patch \ - file://0003-add-imx8mm-resin-hooks.patch \ + file://0001-imx8mm-lpddr4-evk-Integrate-with-BalenaOS.patch \ file://balenaos_tweaks-imx.cfg \ file://increase-early-malloc.cfg \ "