From c2fb94dd95891c7cc307f4446df00ccf174ea2ea Mon Sep 17 00:00:00 2001 From: Peter van der Perk Date: Fri, 2 Oct 2026 11:26:00 +0200 Subject: [PATCH] feat(imxrt): report the boot flash part name in the MCU version The fmu-v6xrt boards can be fitted with either of two octal flash parts, and nothing told the user which one is on the board. The identity is already known: the bootloader stage reads the JEDEC ID to pick a config, and the app stage recognises the config from the installed read sequence, so no extra flash access is needed to report it. Keep the part name behind a weak board_get_flash_type_name() and append it to the chip tag when the board provides one, so `ver mcu` and the logged chip name read e.g. "i.MX RT1170 rA0 IS25WX512M". Boards that do not implement it are unaffected and their tag is unchanged. Signed-off-by: Peter van der Perk --- boards/agam/fmu-v6xrt/src/init.c | 6 ++++++ boards/ark/fmu-v6xrt/src/init.c | 6 ++++++ boards/px4/fmu-v6xrt/src/init.c | 11 ++++++++++ .../px4_platform_common/board_common.h | 15 +++++++++++++ .../px4/nxp/imxrt/version/board_mcu_version.c | 21 +++++++++++++++++-- 5 files changed, 57 insertions(+), 2 deletions(-) diff --git a/boards/agam/fmu-v6xrt/src/init.c b/boards/agam/fmu-v6xrt/src/init.c index ed422950b9b..c7396b7a46c 100644 --- a/boards/agam/fmu-v6xrt/src/init.c +++ b/boards/agam/fmu-v6xrt/src/init.c @@ -165,6 +165,12 @@ __EXPORT void board_on_reset(int status) } } +/* This board is fitted with one flash type, see g_flash_fast_config */ +const char *board_get_flash_type_name(void) +{ + return "MX25UM51345G"; +} + #if defined(CONFIG_BOARD_BOOTLOADER_FIXUP) /**************************************************************************** * Name: imxrt_octl_flash_initialize diff --git a/boards/ark/fmu-v6xrt/src/init.c b/boards/ark/fmu-v6xrt/src/init.c index eec1dbe4182..510fe5617ba 100644 --- a/boards/ark/fmu-v6xrt/src/init.c +++ b/boards/ark/fmu-v6xrt/src/init.c @@ -165,6 +165,12 @@ __EXPORT void board_on_reset(int status) } } +/* This board is fitted with one flash type, see g_flash_fast_config */ +const char *board_get_flash_type_name(void) +{ + return "MX25UM51345G"; +} + #if defined(CONFIG_BOARD_BOOTLOADER_FIXUP) /**************************************************************************** * Name: imxrt_octl_flash_initialize diff --git a/boards/px4/fmu-v6xrt/src/init.c b/boards/px4/fmu-v6xrt/src/init.c index cad033eb059..ee202e06369 100644 --- a/boards/px4/fmu-v6xrt/src/init.c +++ b/boards/px4/fmu-v6xrt/src/init.c @@ -176,6 +176,14 @@ struct flexspi_nor_config_s g_bootConfig; extern const struct flexspi_nor_config_s g_flash_fast_config_is25wx512m; +/* Part name of the flash we booted from, set by imxrt_octl_flash_initialize */ +static const char *g_flash_type; + +const char *board_get_flash_type_name(void) +{ + return g_flash_type; +} + /* JEDEC ID (RDID 0x9F): manufacturer | type << 8 | density << 16 */ #define JEDEC_ID_MASK 0xffffffu #define JEDEC_ID_ISSI 0x1A5B9Du /* IS25WX512M; anything else is the MX25UM51345G */ @@ -249,6 +257,8 @@ void imxrt_octl_flash_initialize(void) } if (fast_config != NULL) { + g_flash_type = (fast_config == &g_flash_fast_config_is25wx512m) ? "IS25WX512M" : "MX25UM51345G"; + /* Keep the bootloader's setup, just record the config for the ROM API. */ memcpy((struct flexspi_nor_config_s *)&g_bootConfig, fast_config, sizeof(struct flexspi_nor_config_s)); @@ -281,6 +291,7 @@ void imxrt_octl_flash_initialize(void) ROM_FLEXSPI_NorFlash_Init(instance, (struct flexspi_nor_config_s *)&g_bootConfig); fast_config = imxrt_octl_flash_select(); + g_flash_type = (fast_config == &g_flash_fast_config_is25wx512m) ? "IS25WX512M" : "MX25UM51345G"; memcpy((struct flexspi_nor_config_s *)&g_bootConfig, fast_config, sizeof(struct flexspi_nor_config_s)); diff --git a/platforms/common/include/px4_platform_common/board_common.h b/platforms/common/include/px4_platform_common/board_common.h index 272856aaffd..b96379b2275 100644 --- a/platforms/common/include/px4_platform_common/board_common.h +++ b/platforms/common/include/px4_platform_common/board_common.h @@ -1135,6 +1135,21 @@ int board_get_px4_guid_formated(char *format_buffer, int size); __EXPORT int board_mcu_version(char *rev, const char **revstr, const char **errata); #endif // !defined(BOARD_OVERRIDE_CPU_VERSION) +/************************************************************************************ + * Name: board_get_flash_type_name + * + * Description: + * Optional. Boards that identify their external flash at boot provide the part + * name, so it can be reported next to the chip version. Weak: test the symbol + * before calling it, boards that do not identify their flash do not define it. + * Spelled out rather than using NuttX's weak_function, this header is also + * used by builds that do not provide that macro. + * + * Returned Value: + * The flash part name, or NULL if it is not known + */ +__EXPORT const char *board_get_flash_type_name(void) __attribute__((weak)); + #if defined(BOARD_HAS_POWER_CONTROL) /************************************************************************************ * Name: board_register_power_state_notification_cb diff --git a/platforms/nuttx/src/px4/nxp/imxrt/version/board_mcu_version.c b/platforms/nuttx/src/px4/nxp/imxrt/version/board_mcu_version.c index 94c75844d8a..f2c27c0b977 100644 --- a/platforms/nuttx/src/px4/nxp/imxrt/version/board_mcu_version.c +++ b/platforms/nuttx/src/px4/nxp/imxrt/version/board_mcu_version.c @@ -39,6 +39,8 @@ #include #include +#include +#include #include "arm_internal.h" #ifdef CONFIG_ARCH_FAMILY_IMXRT117x # include @@ -52,6 +54,8 @@ #define CHIP_TAG "i.MX RT11?0 r??" #define CHIP_TAG_LEN sizeof(CHIP_TAG)-1 +/* Room for the optional " " suffix */ +#define CHIP_STR_LEN sizeof(CHIP_TAG)+16 #define SI_REV(n) ((n & 0x7000000) >> 24) #define DIFPROG_TYPE(n) ((n & 0xF000) >> 12) @@ -61,13 +65,18 @@ int board_mcu_version(char *rev, const char **revstr, const char **errata) { uint32_t info = getreg32(IMXRT_ANADIG_MISC_MISC_DIFPROG); - static char chip[sizeof(CHIP_TAG)] = CHIP_TAG; + static char chip[CHIP_STR_LEN] = CHIP_TAG; *revstr = chip; chip[CHIP_TAG_LEN - 6] = '0' + DIFPROG_TYPE(info); chip[CHIP_TAG_LEN - 2] = 'A' + (DIFPROG_REV_MAJOR(info) - 10); chip[CHIP_TAG_LEN - 1] = '0' + DIFPROG_REV_MINOR(info); + /* Optional, only boards that identify their flash provide the name */ + if (board_get_flash_type_name != NULL && board_get_flash_type_name() != NULL) { + snprintf(&chip[CHIP_TAG_LEN], CHIP_STR_LEN - CHIP_TAG_LEN, " %s", board_get_flash_type_name()); + } + *rev = '0' + SI_REV(getreg32(IMXRT_OCOTP_FUSE(18))); if (errata) { @@ -92,16 +101,24 @@ int board_mcu_version(char *rev, const char **revstr, const char **errata) // 876543210 #define CHIP_TAG "i.MX RT10?? r?.?" #define CHIP_TAG_LEN sizeof(CHIP_TAG)-1 +/* Room for the optional " " suffix */ +#define CHIP_STR_LEN sizeof(CHIP_TAG)+16 int board_mcu_version(char *rev, const char **revstr, const char **errata) { uint32_t info = getreg32(IMXRT_USB_ANALOG_DIGPROG); - static char chip[sizeof(CHIP_TAG)] = CHIP_TAG; + static char chip[CHIP_STR_LEN] = CHIP_TAG; chip[CHIP_TAG_LEN - 1] = '0' + DIGPROG_MINOR(info); chip[CHIP_TAG_LEN - 3] = '1' + DIGPROG_MAJOR_LOWER(info); chip[CHIP_TAG_LEN - 6] = getreg32(0x401F867C) == 0x10 ? '4' : '2'; chip[CHIP_TAG_LEN - 7] = DIGPROG_MAJOR_UPPER(info) == 0x6a ? '5' : '6'; + + /* Optional, only boards that identify their flash provide the name */ + if (board_get_flash_type_name != NULL && board_get_flash_type_name() != NULL) { + snprintf(&chip[CHIP_TAG_LEN], CHIP_STR_LEN - CHIP_TAG_LEN, " %s", board_get_flash_type_name()); + } + *revstr = chip; *rev = '0' + DIGPROG_MINOR(info);