Skip to content

Commit

Permalink
px4/mpfs: Store FPGA version string in version library at boot
Browse files Browse the repository at this point in the history
Also simplify the size of static strings, just set them to 64 bytes.

Signed-off-by: Jukka Laitinen <[email protected]>
  • Loading branch information
jlaitine committed May 15, 2024
1 parent 713745a commit f75a3ca
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions platforms/nuttx/src/px4/microchip/mpfs/version/board_mcu_version.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@

#define HW_INFO_FPGA_PREFIX "FPGA: "
#define HW_INFO_FPGA_SUFFIX "%u.%u"
#define HW_INFO_FPGA_VER_DIGITS 3
#define HW_INFO_FPGA_REV_DIGITS 5

#define HW_INFO_SIZE (int) arraySize(HW_INFO_INIT_PREFIX) + HW_INFO_VER_DIGITS + HW_INFO_REV_DIGITS + sizeof(HW_INFO_FPGA_PREFIX) + HW_INFO_FPGA_VER_DIGITS + HW_INFO_FPGA_REV_DIGITS + 1
#define FPGA_VER_REGISTER 0x42000000
#define MPFS_SYS_SERVICE_CR 0x37020050
#define MPFS_SYS_SERVICE_SR 0x37020054
Expand All @@ -86,7 +83,8 @@ static unsigned hw_version = 0;
static unsigned hw_revision = 0;
static unsigned fpga_version_major;
static unsigned fpga_version_minor;
static char hw_info[HW_INFO_SIZE] = {0};
static char hw_info[64] = {0};
static char fpga_info[64] = {0};

static mfguid_t device_serial_number = { 0 };

Expand Down Expand Up @@ -148,6 +146,11 @@ const char *board_bl_version_string(void)
return device_boot_info.bl_version;
}

const char *board_fpga_version_string(void)
{
return fpga_info;
}

int board_get_px4_guid(px4_guid_t px4_guid)
{
uint8_t *pb = (uint8_t *) &px4_guid[0];
Expand Down Expand Up @@ -291,8 +294,7 @@ int board_determine_hw_info(void)

determine_hw(fpga_version);

snprintf(hw_info, sizeof(hw_info), HW_INFO_INIT_PREFIX HW_INFO_SUFFIX " " HW_INFO_FPGA_PREFIX HW_INFO_FPGA_SUFFIX,
hw_version, hw_revision, fpga_version_major, fpga_version_minor);
snprintf(hw_info, sizeof(hw_info), HW_INFO_INIT_PREFIX HW_INFO_SUFFIX, hw_version, hw_revision);

/* HW version */

Expand Down Expand Up @@ -324,8 +326,10 @@ int board_determine_hw_info(void)

/* FPGA version */

snprintf(ver_str.component_version1, sizeof(ver_str.component_version1),
HW_INFO_FPGA_PREFIX HW_INFO_FPGA_SUFFIX " (0x%x)", fpga_version_major, fpga_version_minor, getreg32(FPGA_VER_REGISTER));
snprintf(fpga_info, sizeof(fpga_info),
HW_INFO_FPGA_PREFIX HW_INFO_FPGA_SUFFIX " (0x%04x)", fpga_version_major, fpga_version_minor,
getreg32(FPGA_VER_REGISTER));
strncpy(ver_str.component_version1, fpga_info, min(sizeof(ver_str.component_version1), sizeof(fpga_info)));
ver.component_version1 = fpga_version;

/* Make local copies of guid and hwinfo */
Expand Down

0 comments on commit f75a3ca

Please sign in to comment.