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 <peter.vanderperk@nxp.com>
This commit is contained in:
Peter van der Perk authored and Peter van der Perk committed 2026-10-05 11:23:10 +02:00
1 parent 94dddcd420
commit c2fb94dd95
5 files changed
+57 -2

No files matched your search

+6
View File
@@ -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
+6
View File
@@ -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
+11
View File
@@ -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));
@@ -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
@@ -39,6 +39,8 @@
#include <px4_platform_common/px4_config.h>
#include <px4_platform_common/defines.h>
#include <px4_platform_common/board_common.h>
#include <stdio.h>
#include "arm_internal.h"
#ifdef CONFIG_ARCH_FAMILY_IMXRT117x
# include <hardware/rt117x/imxrt117x_ocotp.h>
@@ -52,6 +54,8 @@
#define CHIP_TAG "i.MX RT11?0 r??"
#define CHIP_TAG_LEN sizeof(CHIP_TAG)-1
/* Room for the optional " <flash part name>" 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 " <flash part name>" 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);