mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-26 01:00:36 +08:00
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:
1 parent
94dddcd420
commit
c2fb94dd95
5 files changed
+57
-2
No files matched your search
@@ -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);
|
||||
|
||||
|
||||
Reference in new issue
Block a user