board: toradex: misc cleanups
Subsystems (2)
cover board: toradex: misc cleanups
From: Francesco Dolcini <[email protected]>
A small series with small and misc cleanups on Toradex boards (based on next)
Francesco Dolcini (15):
board: toradex: tdx-cfg-block: fix carrier config block buffer
over-read
board: toradex: smarc-imx8mp: fix always-false phandle check
board: toradex: aquila-am69: initialize ret in spl_board_init()
board: toradex: apalis_imx6: fix do_fuse argv[1] NULL deref
board: toradex: colibri_imx6: fix do_fuse argv[1] NULL deref
board: toradex: apalis-imx8: report detected SoC variant in board_name
board: toradex: colibri-imx8x: report detected SoC variant in
board_name
board: toradex: colibri_imx7: un-nest board_late_init from
CONFIG_USB_EHCI_MX7
configs: verdin-imx8mm: remove empty #if/#endif block
board: toradex: apalis_imx6: remove dead ldo_mode_set()
board: toradex: colibri_imx6: remove dead ldo_mode_set()
board: toradex: apalis_imx6: drop dead TDX_APALIS_IMX6_V1_0 Kconfig
option
board: toradex: common: fix stale #endif comments in tdx-common.c
board: toradex: apalis_imx6: fix stale #endif comment in
board_late_init()
configs: colibri_imx7: add missing defined() in EMMC #elif
board/toradex/apalis-imx8/apalis-imx8.c | 2 +- board/toradex/apalis_imx6/Kconfig | 10 ---------- board/toradex/apalis_imx6/apalis_imx6.c | 10 +--------- board/toradex/apalis_imx6/do_fuse.c | 4 ++-- board/toradex/aquila-am69/aquila-am69.c | 2 +- board/toradex/colibri-imx8x/colibri-imx8x.c | 2 +- board/toradex/colibri_imx6/colibri_imx6.c | 8 -------- board/toradex/colibri_imx6/do_fuse.c | 4 ++-- board/toradex/colibri_imx7/colibri_imx7.c | 3 +-- board/toradex/common/tdx-cfg-block.c | 2 +- board/toradex/common/tdx-common.c | 4 ++-- board/toradex/smarc-imx8mp/smarc-imx8mp.c | 2 +- include/configs/colibri_imx7.h | 2 +- include/configs/verdin-imx8mm.h | 4 ---- 14 files changed, 14 insertions(+), 45 deletions(-)
Signature · 1 line
2.47.3
PATCH 1/15 board: toradex: tdx-cfg-block: fix carrier config block buffer over-read
From: Francesco Dolcini <[email protected]>
read_tdx_cfg_block_carrier() allocates config_block with size TDX_CFG_BLOCK_EXTRA_MAX_SIZE (64 bytes), but the tag-parsing loop bound-checks offset against TDX_CFG_BLOCK_MAX_SIZE, which is 512 on any board with the config block in MMC. A malformed/garbage carrier EEPROM can walk the loop well past the 64-byte allocation.
Use TDX_CFG_BLOCK_EXTRA_MAX_SIZE, matching the actual buffer size.
--- board/toradex/common/tdx-cfg-block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
board/toradex/common/tdx-cfg-block.c +1 -1
@@ -613,7 +613,7 @@ int read_tdx_cfg_block_carrier(void) offset =4 ;while (offset +sizeof (struct toradex_tag ) + -sizeof (struct toradex_hw ) <TDX_CFG_BLOCK_MAX_SIZE ) { +sizeof (struct toradex_hw ) <TDX_CFG_BLOCK_EXTRA_MAX_SIZE ) { tag = (struct toradex_tag *)(config_block + offset); offset +=4 ;if (tag->id ==TAG_INVALID )
Signature · 1 line
2.47.3
PATCH 2/15 board: toradex: smarc-imx8mp: fix always-false phandle check
In reply to Francesco DolciniFrom: Francesco Dolcini <[email protected]>
fdt_get_phandle() returns uint32_t and 0 on failure, so "phandle < 0" is never true. On a missing pinctrl phandle this fell through to fdt_setprop_u32(..., "pinctrl-0", 0), corrupting the DT instead of bailing out.
--- board/toradex/smarc-imx8mp/smarc-imx8mp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
board/toradex/smarc-imx8mp/smarc-imx8mp.c +1 -1
@@ -62,7 +62,7 @@ static void ft_board_assign_uart(void *blob)return ; phandle =fdt_get_phandle (blob, pinctrl_offset); -if (phandle <0 ) +if (!phandle)return ;fdt_setprop_u32 (blob, uart_offset,"pinctrl-0" , phandle);
Signature · 1 line
2.47.3
PATCH 3/15 board: toradex: aquila-am69: initialize ret in spl_board_init()
In reply to Francesco DolciniFrom: Francesco Dolcini <[email protected]>
If CONFIG_ESM_K3 is disabled, ret is read uninitialized by the subsequent "IS_ENABLED(CONFIG_ESM_PMIC) && ret == 0" check, making whether ESM PMIC init runs depend on stack garbage.
--- board/toradex/aquila-am69/aquila-am69.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
board/toradex/aquila-am69/aquila-am69.c +1 -1
@@ -204,7 +204,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)void spl_board_init (void ) {struct udevice *dev; -int ret; +int ret =0 ;if (IS_ENABLED (CONFIG_ESM_K3 )) {const char *const esms[] = {"esm@700000" ,"esm@40800000" ,"esm@42080000" };
Signature · 1 line
2.47.3
PATCH 4/15 board: toradex: apalis_imx6: fix do_fuse argv[1] NULL deref
In reply to Francesco DolciniFrom: Francesco Dolcini <[email protected]>
argv[0] is the command name itself, so argv[1] is only valid once argc >= 2. Running "updt_fuse" with no arguments has argc == 1 but still dereferences argv[1] in strcmp(), reading past the argv array.
--- board/toradex/apalis_imx6/do_fuse.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
board/toradex/apalis_imx6/do_fuse.c +2 -2
@@ -54,10 +54,10 @@ int do_updt_fuse(struct cmd_tbl *cmdtp, int flag, int argc, {unsigned val;int ret; -int confirmed = argc >=1 && !strcmp (argv[1 ],"-y" ); +int confirmed = argc >=2 && !strcmp (argv[1 ],"-y" );/* can be used in scripts for command availability check */ -if (argc >=1 && !strcmp (argv[1 ],"-n" )) +if (argc >=2 && !strcmp (argv[1 ],"-n" ))return CMD_RET_SUCCESS ;/* boot cfg */
Signature · 1 line
2.47.3
PATCH 5/15 board: toradex: colibri_imx6: fix do_fuse argv[1] NULL deref
In reply to Francesco DolciniFrom: Francesco Dolcini <[email protected]>
argv[0] is the command name itself, so argv[1] is only valid once argc >= 2. Running "updt_fuse" with no arguments has argc == 1 but still dereferences argv[1] in strcmp(), reading past the argv array.
--- board/toradex/colibri_imx6/do_fuse.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
board/toradex/colibri_imx6/do_fuse.c +2 -2
@@ -54,10 +54,10 @@ int do_updt_fuse(struct cmd_tbl *cmdtp, int flag, int argc, {unsigned val;int ret; -int confirmed = argc >=1 && !strcmp (argv[1 ],"-y" ); +int confirmed = argc >=2 && !strcmp (argv[1 ],"-y" );/* can be used in scripts for command availability check */ -if (argc >=1 && !strcmp (argv[1 ],"-n" )) +if (argc >=2 && !strcmp (argv[1 ],"-n" ))return CMD_RET_SUCCESS ;/* boot cfg */
Signature · 1 line
2.47.3
PATCH 6/15 board: toradex: apalis-imx8: report detected SoC variant in board_name
In reply to Francesco DolciniFrom: Francesco Dolcini <[email protected]>
board_late_init() hardcoded "board_name" to "Apalis iMX8QM" even though select_dt_from_module_version() (called right after) already detects QP modules via is_imx8qp() and sets "soc" accordingly. board_name now matches the detected variant.
--- board/toradex/apalis-imx8/apalis-imx8.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
board/toradex/apalis-imx8/apalis-imx8.c +1 -1
@@ -361,7 +361,7 @@ int board_late_init(void) {#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG /* TODO move to common */ -env_set ("board_name" ,"Apalis iMX8QM" ); +env_set ("board_name" ,is_imx8qp () ?"Apalis iMX8QP" :"Apalis iMX8QM" );env_set ("board_rev" ,"v1.0" );#endif
Signature · 1 line
2.47.3
PATCH 7/15 board: toradex: colibri-imx8x: report detected SoC variant in board_name
In reply to Francesco DolciniFrom: Francesco Dolcini <[email protected]>
board_late_init() hardcoded "board_name" to "Colibri iMX8QXP" even though select_dt_from_module_version() (called right after) already detects DX modules via is_imx8dx() and sets "soc" accordingly. board_name now matches the detected variant.
--- board/toradex/colibri-imx8x/colibri-imx8x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
board/toradex/colibri-imx8x/colibri-imx8x.c +1 -1
@@ -141,7 +141,7 @@ int board_late_init(void) {#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG /* TODO move to common */ -env_set ("board_name" ,"Colibri iMX8QXP" ); +env_set ("board_name" ,is_imx8dx () ?"Colibri iMX8DX" :"Colibri iMX8QXP" );env_set ("board_rev" ,"v1.0" );#endif
Signature · 1 line
2.47.3
PATCH 8/15 board: toradex: colibri_imx7: un-nest board_late_init from CONFIG_USB_EHCI_MX7
In reply to Francesco DolciniFrom: Francesco Dolcini <[email protected]>
board_late_init() (USB recovery bootcmd and NAND/eMMC variant selection) was nested inside "#ifdef CONFIG_USB_EHCI_MX7", which guards the unrelated board_fix_fdt() USB quirk. CONFIG_USB_EHCI_MX7 defaults to y but is user-selectable, so disabling it silently dropped board_late_init() entirely.
--- board/toradex/colibri_imx7/colibri_imx7.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
board/toradex/colibri_imx7/colibri_imx7.c +1 -2
@@ -342,6 +342,7 @@ int board_fix_fdt(void *rw_fdt_blob) return 0; } +#endif /* CONFIG_USB_EHCI_MX7 */ #if defined(CONFIG_BOARD_LATE_INIT )int board_late_init (void )
@@ -369,5 +370,3 @@ int board_late_init(void) return 0; }#endif /* CONFIG_BOARD_LATE_INIT */ - -#endif /* CONFIG_USB_EHCI_MX7 */
Signature · 1 line
2.47.3
PATCH 9/15 configs: verdin-imx8mm: remove empty #if/#endif block
In reply to Francesco DolciniFrom: Francesco Dolcini <[email protected]>
The CONFIG_ENV_IS_IN_MMC block has no content, only a comment; it has never contained any code since the file was introduced.
--- include/configs/verdin-imx8mm.h | 4 ---- 1 file changed, 4 deletions(-)
include/configs/verdin-imx8mm.h +0 -4
@@ -51,10 +51,6 @@#define CFG_SYS_INIT_RAM_ADDR 0x40000000#define CFG_SYS_INIT_RAM_SIZE SZ_2M -#if defined(CONFIG_ENV_IS_IN_MMC ) -/* Environment in eMMC, before config block at the end of 1st "boot sector" */ -#endif -#define CFG_SYS_SDRAM_BASE 0x40000000/* SDRAM configuration */
Signature · 1 line
2.47.3
PATCH 10/15 board: toradex: apalis_imx6: remove dead ldo_mode_set()
In reply to Francesco DolciniFrom: Francesco Dolcini <[email protected]>
CONFIG_LDO_BYPASS_CHECK is never defined by any Kconfig/defconfig in the tree; it's leftover from the NXP freescale board template this file was copied from at initial import. The guarded stub has never been compiled in.
--- board/toradex/apalis_imx6/apalis_imx6.c | 8 -------- 1 file changed, 8 deletions(-)
board/toradex/apalis_imx6/apalis_imx6.c +0 -8
@@ -781,14 +781,6 @@ int misc_init_r(void)return 0 ; } -#ifdef CONFIG_LDO_BYPASS_CHECK -/* TODO, use external pmic, for now always ldo_enable */ -void ldo_mode_set (int ldo_bypass) -{ -return ; -} -#endif -#ifdef CONFIG_XPL_BUILD #include <spl.h> #include <linux/libfdt.h>
Signature · 1 line
2.47.3
PATCH 11/15 board: toradex: colibri_imx6: remove dead ldo_mode_set()
In reply to Francesco DolciniFrom: Francesco Dolcini <[email protected]>
CONFIG_LDO_BYPASS_CHECK is never defined by any Kconfig/defconfig in the tree; it's leftover from the NXP freescale board template this file was copied from at initial import. The guarded stub has never been compiled in.
--- board/toradex/colibri_imx6/colibri_imx6.c | 8 -------- 1 file changed, 8 deletions(-)
board/toradex/colibri_imx6/colibri_imx6.c +0 -8
@@ -700,14 +700,6 @@ int misc_init_r(void)return 0 ; } -#ifdef CONFIG_LDO_BYPASS_CHECK -/* TODO, use external pmic, for now always ldo_enable */ -void ldo_mode_set (int ldo_bypass) -{ -return ; -} -#endif -#ifdef CONFIG_XPL_BUILD #include <spl.h> #include <linux/libfdt.h>
Signature · 1 line
2.47.3
PATCH 12/15 board: toradex: apalis_imx6: drop dead TDX_APALIS_IMX6_V1_0 Kconfig option
In reply to Francesco DolciniFrom: Francesco Dolcini <[email protected]>
All code reading CONFIG_TDX_APALIS_IMX6_V1_0 was removed when V1.0 HW support was dropped, but the Kconfig prompt itself was left behind. Enabling it currently has no effect at all.
--- board/toradex/apalis_imx6/Kconfig | 10 ---------- 1 file changed, 10 deletions(-)
board/toradex/apalis_imx6/Kconfig +0 -10
@@ -39,16 +39,6 @@ config TDX_CMD_IMX_MFGR If executed on already fused modules it doesn't change any fuse setting. default y -config TDX_APALIS_IMX6_V1_0 - bool "Apalis iMX6 V1.0 HW" - help - Apalis iMX6 V1.0 HW has a different pinout for the UART. - The UARTs must be used in DCE mode, RTS/CTS are swapped and - thus unusable on standard carrier boards. - This option configures DCE mode unconditionally. Whithout this - option the config block stating V1.0 HW selects DCE mode, - otherwise the UARTs are configuered in DTE mode. - source "board/toradex/common/Kconfig" endif
Signature · 1 line
2.47.3
PATCH 13/15 board: toradex: common: fix stale #endif comments in tdx-common.c
In reply to Francesco DolciniFrom: Francesco Dolcini <[email protected]>
get_board_rev()/CONFIG_REVISION_TAG were renamed to get_board_revision()/CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG, but two trailing #endif comments still named the old macros.
--- board/toradex/common/tdx-common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
board/toradex/common/tdx-common.c +2 -2
@@ -46,7 +46,7 @@ u32 get_board_revision(void) ((tdx_hw_tag.ver_minor &0xf ) <<4 ) | ((tdx_hw_tag.ver_assembly & 0xf) + 0xa); } -#endif /* CONFIG_TDX_CFG_BLOCK */ +#endif /* CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG */ #ifdef CONFIG_SERIAL_TAG void get_board_serial (struct tag_serialnr *serialnr)
@@ -306,7 +306,7 @@ u32 get_board_revision(void) {return 0 ; } -#endif /* CONFIG_REVISION_TAG */ +#endif /* CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG */ #ifdef CONFIG_SERIAL_TAG u32 get_board_serial (void )
Signature · 1 line
2.47.3
PATCH 14/15 board: toradex: apalis_imx6: fix stale #endif comment in board_late_init()
In reply to Francesco DolciniFrom: Francesco Dolcini <[email protected]>
The inner #endif at line 743 closes the
"#if defined(CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG)" block, not CONFIG_BOARD_LATE_INIT (which is closed further down, already correctly labeled). Introduced when two adjacent #endif's were collapsed into one while dropping V1.0 HW support.
--- board/toradex/apalis_imx6/apalis_imx6.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
board/toradex/apalis_imx6/apalis_imx6.c +1 -1
@@ -740,7 +740,7 @@ int board_late_init(void) rev =get_board_revision ();snprintf (env_str,ARRAY_SIZE (env_str),"%.4x" , rev);env_set ("board_rev" , env_str); -#endif /* CONFIG_BOARD_LATE_INIT */ +#endif /* CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG */ if (IS_ENABLED (CONFIG_USB ) &&is_boot_from_usb ()) {env_set ("bootdelay" ,"0" );
Signature · 1 line
2.47.3
PATCH 15/15 configs: colibri_imx7: add missing defined() in EMMC #elif
In reply to Francesco DolciniFrom: Francesco Dolcini <[email protected]>
"#elif CONFIG_TARGET_COLIBRI_IMX7_EMMC" was missing defined(), unlike every other conditional on this symbol in the file. Harmless today since an undefined macro evaluates to 0 in a preprocessor expression, but inconsistent and -Wundef-unsafe.
--- include/configs/colibri_imx7.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/configs/colibri_imx7.h +1 -1
@@ -17,7 +17,7 @@#define CFG_SYS_FSL_ESDHC_ADDR 0#ifdef CONFIG_TARGET_COLIBRI_IMX7_NAND #define CFG_SYS_FSL_USDHC_NUM 1 -#elif CONFIG_TARGET_COLIBRI_IMX7_EMMC +#elif defined(CONFIG_TARGET_COLIBRI_IMX7_EMMC )#define CFG_SYS_FSL_USDHC_NUM 2#endif
Signature · 1 line
2.47.3