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
Signed-off-by: Jukka Laitinen <[email protected]>
  • Loading branch information
jlaitine committed May 15, 2024
1 parent 545cdd4 commit 6ec7cf2
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions platforms/nuttx/src/px4/microchip/mpfs/version/board_mcu_version.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@
#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 HW_INFO_SIZE (int) arraySize(HW_INFO_INIT_PREFIX) + HW_INFO_VER_DIGITS + HW_INFO_REV_DIGITS
#define FPGA_INFO_SIZE (int) arraySize(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 @@ -87,6 +89,7 @@ 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 fpga_info[FPGA_INFO_SIZE] = {0};

static mfguid_t device_serial_number = { 0 };

Expand Down Expand Up @@ -148,6 +151,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 +299,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 +331,9 @@ int board_determine_hw_info(void)

/* FPGA version */

snprintf(ver_str.component_version1, sizeof(ver_str.component_version1),
snprintf(fpga_info, sizeof(fpga_info),
HW_INFO_FPGA_PREFIX HW_INFO_FPGA_SUFFIX " (0x%x)", 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 6ec7cf2

Please sign in to comment.