Merge PR #19575 (changes to pr-extendend_hw_ver_rev_format)

- 4096 of 3 hex digits each for rev and ver is enough.
    #defines used in SPI versions do not be long format, use use the macro
 - Board provides a prefix and the formatting is sized and built in
 - No need for funky board_get_base_eeprom_mtd_manifest interface
    Original mft is used where the abstraction is done with the MFT interface

Co-authored-by: David Sidrane <David.Sidrane@Nscdg.com>
This commit is contained in:
Igor Mišić 2022-07-04 12:15:46 +02:00 committed by Beat Küng
parent f7d542e720
commit 4b503c310e
44 changed files with 199 additions and 188 deletions

View File

@ -303,7 +303,7 @@ else
then
# Check for the mini using build with px4io fw file
# but not a px4IO
if ver hwtypecmp V540 V560
if ver hwtypecmp V5004000 V5006000
then
param set SYS_USE_IO 0
else

View File

@ -115,7 +115,7 @@
#define GPIO_HW_REV_SENSE /* PC3 */ ADC1_GPIO(13)
#define GPIO_HW_VER_DRIVE /* PG0 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTG|GPIO_PIN0)
#define GPIO_HW_VER_SENSE /* PC2 */ ADC1_GPIO(12)
#define HW_INFO_INIT "V5%04x%04x"
#define HW_INFO_INIT_PREFIX "VAM"
#define BOARD_TAP_ESC_MODE 2 // select closed-loop control mode for the esc
// #define BOARD_USE_ESC_CURRENT_REPORT

View File

@ -83,7 +83,9 @@
#define GPIO_HW_VER_REV_DRIVE /* PB1 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN1)
#define GPIO_HW_REV_SENSE /* PA0 */ ADC1_GPIO(0)
#define GPIO_HW_VER_SENSE /* PA1 */ ADC1_GPIO(1)
#define HW_INFO_INIT "CANGPS%04x%04x"
#define HW_INFO_INIT_PREFIX "CANGPS"
#define CANGPS00 HW_VER_REV(0x0,0x0) // CANGPS
#define FLASH_BASED_PARAMS

View File

@ -104,7 +104,7 @@ static const px4_hw_mft_item_t hw_mft_list_v0000[] = {
static px4_hw_mft_list_entry_t mft_lists[] = {
// ver/rev
{0x00000000, hw_mft_list_v0000, arraySize(hw_mft_list_v0000)},
{CANGPS00, hw_mft_list_v0000, arraySize(hw_mft_list_v0000)},
};
/************************************************************************************

View File

@ -11,13 +11,13 @@ icm20689 -R 2 -s start
bmi088 -A -R 2 -s start
bmi088 -G -R 2 -s start
if ver hwtypecmp VD00
if ver hwtypecmp VD000000
then
# Internal SPI BMI088
bmi088 -A -R 2 -s start
bmi088 -G -R 2 -s start
fi
if ver hwtypecmp VD01
if ver hwtypecmp VD000001
then
# Internal SPI ICM-20602
icm20602 -R 2 -s start

View File

@ -152,12 +152,12 @@
#define GPIO_HW_REV_SENSE /* PC3 */ GPIO_ADC12_INP13
#define GPIO_HW_VER_DRIVE /* PG0 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTG|GPIO_PIN0)
#define GPIO_HW_VER_SENSE /* PC2 */ GPIO_ADC123_INP12
#define HW_INFO_INIT "VD%04x%04x"
#define HW_INFO_INIT_PREFIX "VD"
#define BOARD_NUM_SPI_CFG_HW_VERSIONS 2
#define VD00000000 HW_VER_REV(0x0,0x0) // Durandal, Ver 0 Rev 0
#define VD00000001 HW_VER_REV(0x0,0x1) // Durandal, Ver 0 Rev 1
#define VD00 HW_VER_REV(0x0,0x0) // Durandal, Ver 0 Rev 0
#define VD01 HW_VER_REV(0x0,0x1) // Durandal, Ver 0 Rev 1
/* CAN Silence
*

View File

@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2012-2019 PX4 Development Team. All rights reserved.
* Copyright (c) 2012-2019, 2022 PX4 Development Team. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -206,7 +206,6 @@ stm32_boardinitialize(void)
*
****************************************************************************/
__EXPORT int board_app_initialize(uintptr_t arg)
{
/* Power on Interfaces */
@ -219,6 +218,13 @@ __EXPORT int board_app_initialize(uintptr_t arg)
px4_platform_init();
// Use the default HW_VER_REV(0x0,0x0) for Ramtron
stm32_spiinitialize();
/* Configure the HW based on the manifest */
px4_platform_configure();
if (OK == board_determine_hw_info()) {
syslog(LOG_INFO, "[boot] Rev 0x%1x : Ver 0x%1x %s\n", board_get_hw_revision(), board_get_hw_version(),
@ -228,7 +234,7 @@ __EXPORT int board_app_initialize(uintptr_t arg)
syslog(LOG_ERR, "[boot] Failed to read HW revision and version\n");
}
/* configure SPI interfaces (after we determined the HW version) */
/* Configure the actual SPI interfaces (after we determined the HW version) */
stm32_spiinitialize();
@ -268,9 +274,5 @@ __EXPORT int board_app_initialize(uintptr_t arg)
#endif /* CONFIG_MMCSD */
/* Configure the HW based on the manifest */
px4_platform_configure();
return OK;
}

View File

@ -83,8 +83,8 @@ static const px4_hw_mft_item_t hw_mft_list_durandal[] = {
static px4_hw_mft_list_entry_t mft_lists[] = {
// ver_rev
{VD00000000, hw_mft_list_durandal, arraySize(hw_mft_list_durandal)},
{VD00000001, hw_mft_list_durandal, arraySize(hw_mft_list_durandal)},
{VD00, hw_mft_list_durandal, arraySize(hw_mft_list_durandal)},
{VD01, hw_mft_list_durandal, arraySize(hw_mft_list_durandal)},
};
/************************************************************************************

View File

@ -185,7 +185,10 @@
#define GPIO_HW_REV_SENSE /* PC3 */ ADC1_GPIO(13)
#define GPIO_HW_VER_DRIVE /* PG0 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTG|GPIO_PIN0)
#define GPIO_HW_VER_SENSE /* PC2 */ ADC1_GPIO(12)
#define HW_INFO_INIT "V5%04x%04x"
#define HW_INFO_INIT_PREFIX "VPIX32V5"
#define VPIX32V500 HW_VER_REV(0x0,0x0) // PIX32V5 Rev 0
#define VPIX32V540 HW_VER_REV(0x4,0x0) // HolyBro mini no can 2,3
/* CAN Silence
*

View File

@ -129,8 +129,8 @@ static const px4_hw_mft_item_t hw_mft_list_v0540[] = {
};
static px4_hw_mft_list_entry_t mft_lists[] = {
{0x00000000, hw_mft_list_v0500, arraySize(hw_mft_list_v0500)},
{0x00040000, hw_mft_list_v0540, arraySize(hw_mft_list_v0540)}, // HolyBro mini no can 2,3
{VPIX32V500, hw_mft_list_v0500, arraySize(hw_mft_list_v0500)},
{VPIX32V540, hw_mft_list_v0540, arraySize(hw_mft_list_v0540)}, // HolyBro mini no can 2,3
};
/************************************************************************************

View File

@ -142,7 +142,10 @@
#define GPIO_HW_VER_REV_DRIVE /* PG0 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTG|GPIO_PIN0)
#define GPIO_HW_REV_SENSE /* PF5 */ ADC3_GPIO(15)
#define GPIO_HW_VER_SENSE /* PF4 */ ADC3_GPIO(14)
#define HW_INFO_INIT "V1%04x%04x"
#define HW_INFO_INIT_PREFIX "V1"
#define V10006 HW_VER_REV(0x0,0x6) // V1006 Rev 6
#define V10100 HW_VER_REV(0x1,0x0) // V1010 Rev 0
/* PWM
*/

View File

@ -90,8 +90,8 @@ static const px4_hw_mft_item_t hw_mft_list_fc0100[] = {
};
static px4_hw_mft_list_entry_t mft_lists[] = {
{0x00000006, hw_mft_list_fc0006, arraySize(hw_mft_list_fc0006)},
{0x00010000, hw_mft_list_fc0100, arraySize(hw_mft_list_fc0100)}
{V10006, hw_mft_list_fc0006, arraySize(hw_mft_list_fc0006)},
{V10100, hw_mft_list_fc0100, arraySize(hw_mft_list_fc0100)}
};
/************************************************************************************

View File

@ -182,7 +182,8 @@
#define GPIO_HW_VER_REV_DRIVE /* PG0 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTG|GPIO_PIN0)
#define GPIO_HW_REV_SENSE /* PH4 */ GPIO_ADC3_INP15
#define GPIO_HW_VER_SENSE /* PH3 */ GPIO_ADC3_INP14
#define HW_INFO_INIT "V2%04x%04x"
#define HW_INFO_INIT_PREFIX "V2"
#define V20300 HW_VER_REV(0x3,0x0)
/* PE6 is nARMED --> FCv2 this goes to TP13
* The GPIO will be set as input while not armed HW will have external HW Pull UP.

View File

@ -83,7 +83,7 @@ static const px4_hw_mft_item_t hw_mft_list_fc0200[] = {
};
static px4_hw_mft_list_entry_t mft_lists[] = {
{0x00030000, hw_mft_list_fc0200, arraySize(hw_mft_list_fc0200)},
{V20300, hw_mft_list_fc0200, arraySize(hw_mft_list_fc0200)},
};
/************************************************************************************

View File

@ -192,7 +192,9 @@
#define GPIO_HW_VER_REV_DRIVE /* GPIO_AD_B0_01 GPIO1_IO01 */ (GPIO_PORT1 | GPIO_PIN1 | GPIO_OUTPUT | GPIO_OUTPUT_ONE | HW_IOMUX)
#define GPIO_HW_REV_SENSE /* GPIO_AD_B1_08 GPIO1 Pin 24 */ ADC1_GPIO(13, 24)
#define GPIO_HW_VER_SENSE /* GPIO_AD_B1_04 GPIO1 Pin 20 */ ADC1_GPIO(9, 20)
#define HW_INFO_INIT "V5%04x%04x"
#define HW_INFO_INIT_PREFIX "V5"
#define V500 HW_VER_REV(0x0,0x0) // FMUV5, Rev 0
#define V540 HW_VER_REV(0x4,0x0) // mini no can 2,3, Rev 0
/* CAN Silence
*

View File

@ -88,8 +88,8 @@ static const px4_hw_mft_item_t hw_mft_list_v0540[] = {
};
static px4_hw_mft_list_entry_t mft_lists[] = {
{0x0000, hw_mft_list_v0500, arraySize(hw_mft_list_v0500)},
{0x0400, hw_mft_list_v0540, arraySize(hw_mft_list_v0540)},
{V500, hw_mft_list_v0500, arraySize(hw_mft_list_v0500)},
{V540, hw_mft_list_v0540, arraySize(hw_mft_list_v0540)},
};
/************************************************************************************

View File

@ -9,9 +9,9 @@ param set-default BAT2_V_DIV 18.1
param set-default BAT1_A_PER_V 36.367515152
param set-default BAT2_A_PER_V 36.367515152
if ver hwtypecmp V500050000 V500050002 V500060000 V500060002
if ver hwtypecmp V5005000 V5005002 V5006000 V5006002
then
# CUAV V5+ (V500050000/V500050002) and V5nano (V560/V562) have 3 IMUs
# CUAV V5+ (V550/V552) and V5nano (V560/V562) have 3 IMUs
# Multi-EKF (IMUs only)
param set-default EKF2_MULTI_IMU 3
param set-default SENS_IMU_MODE 0

View File

@ -5,7 +5,7 @@
board_adc start
if ver hwtypecmp V500050002 V500060002
if ver hwtypecmp V5005002 V5006002
then
# Internal SPI bus ICM-42688-P
icm42688p -s -R 2 -q start

View File

@ -188,15 +188,16 @@
#define GPIO_HW_REV_SENSE /* PC3 */ ADC1_GPIO(13)
#define GPIO_HW_VER_DRIVE /* PG0 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTG|GPIO_PIN0)
#define GPIO_HW_VER_SENSE /* PC2 */ ADC1_GPIO(12)
#define HW_INFO_INIT "V5%04x%04x"
#define HW_INFO_INIT_PREFIX "V5"
#define BOARD_NUM_SPI_CFG_HW_VERSIONS 3
#define V500000000 HW_VER_REV(0x0,0x0) // FMUV5, Rev 0
#define V500010005 HW_VER_REV(0x1,0x5) // CUAV V5, Rev 5
#define V500040000 HW_VER_REV(0x4,0x0) // HolyBro mini no can 2,3, Rev 0
#define V500050000 HW_VER_REV(0x5,0x0) // CUAV V5+, Rev 0
#define V500050002 HW_VER_REV(0x5,0x2) // CUAV V5+ ICM42688P, Rev 2
#define V500060000 HW_VER_REV(0x6,0x0) // CUAV V5nano with can 2, Rev 0
#define V500060002 HW_VER_REV(0x6,0x2) // CUAV V5nano ICM42688P, Rev 2
#define V500 HW_VER_REV(0x0,0x0) // FMUV5, Rev 0
#define V515 HW_VER_REV(0x1,0x5) // CUAV V5, Rev 5
#define V540 HW_VER_REV(0x4,0x0) // HolyBro mini no can 2,3, Rev 0
#define V550 HW_VER_REV(0x5,0x0) // CUAV V5+, Rev 0
#define V552 HW_VER_REV(0x5,0x2) // CUAV V5+ ICM42688P, Rev 2
#define V560 HW_VER_REV(0x6,0x0) // CUAV V5nano with can 2, Rev 0
#define V562 HW_VER_REV(0x6,0x2) // CUAV V5nano ICM42688P, Rev 2
/* CAN Silence
*

View File

@ -157,13 +157,13 @@ static const px4_hw_mft_item_t hw_mft_list_v0600[] = {
static px4_hw_mft_list_entry_t mft_lists[] = {
{V500000000, hw_mft_list_v0500, arraySize(hw_mft_list_v0500)},
{V500010005, hw_mft_list_v0500, arraySize(hw_mft_list_v0500)}, // Alias for CUAV V5 R:5 V:1
{V500040000, hw_mft_list_v0540, arraySize(hw_mft_list_v0540)}, // HolyBro mini no can 2,3
{V500050000, hw_mft_list_v0500, arraySize(hw_mft_list_v0500)}, // Alias for CUAV V5+ R:0 V:5
{V500050002, hw_mft_list_v0500, arraySize(hw_mft_list_v0500)}, // Alias for CUAV V5+ R:2 V:5 ICM42688P
{V500060000, hw_mft_list_v0600, arraySize(hw_mft_list_v0600)}, // CUAV V5nano R:0 V:6 with can 2
{V500060002, hw_mft_list_v0500, arraySize(hw_mft_list_v0500)}, // Alias for CUAV V5nano R:2 V:6 ICM42688P
{V500, hw_mft_list_v0500, arraySize(hw_mft_list_v0500)},
{V515, hw_mft_list_v0500, arraySize(hw_mft_list_v0500)}, // Alias for CUAV V5 R:5 V:1
{V540, hw_mft_list_v0540, arraySize(hw_mft_list_v0540)}, // HolyBro mini no can 2,3
{V550, hw_mft_list_v0500, arraySize(hw_mft_list_v0500)}, // Alias for CUAV V5+ R:0 V:5
{V552, hw_mft_list_v0500, arraySize(hw_mft_list_v0500)}, // Alias for CUAV V5+ R:2 V:5 ICM42688P
{V560, hw_mft_list_v0600, arraySize(hw_mft_list_v0600)}, // CUAV V5nano R:0 V:6 with can 2
{V562, hw_mft_list_v0500, arraySize(hw_mft_list_v0500)}, // Alias for CUAV V5nano R:2 V:6 ICM42688P
};
/************************************************************************************

View File

@ -36,7 +36,7 @@
#include <nuttx/spi/spi.h>
constexpr px4_spi_bus_all_hw_t px4_spi_buses_all_hw[BOARD_NUM_SPI_CFG_HW_VERSIONS] = {
initSPIHWVersion(V500000000, {
initSPIHWVersion(V500, {
initSPIBus(SPI::Bus::SPI1, {
initSPIDevice(DRV_IMU_DEVTYPE_ICM20689, SPI::CS{GPIO::PortF, GPIO::Pin2}, SPI::DRDY{GPIO::PortB, GPIO::Pin4}),
initSPIDevice(DRV_IMU_DEVTYPE_ICM20602, SPI::CS{GPIO::PortF, GPIO::Pin3}, SPI::DRDY{GPIO::PortC, GPIO::Pin5}),
@ -61,7 +61,7 @@ constexpr px4_spi_bus_all_hw_t px4_spi_buses_all_hw[BOARD_NUM_SPI_CFG_HW_VERSION
}),
}),
initSPIHWVersion(V500050002, {
initSPIHWVersion(V552, {
initSPIBus(SPI::Bus::SPI1, {
initSPIDevice(DRV_IMU_DEVTYPE_ICM20689, SPI::CS{GPIO::PortF, GPIO::Pin2}, SPI::DRDY{GPIO::PortB, GPIO::Pin4}),
initSPIDevice(DRV_IMU_DEVTYPE_ICM42688P, SPI::CS{GPIO::PortF, GPIO::Pin11}, SPI::DRDY{GPIO::PortC, GPIO::Pin5}),
@ -86,7 +86,7 @@ constexpr px4_spi_bus_all_hw_t px4_spi_buses_all_hw[BOARD_NUM_SPI_CFG_HW_VERSION
}),
}),
initSPIHWVersion(V500060002, {
initSPIHWVersion(V562, {
initSPIBus(SPI::Bus::SPI1, {
initSPIDevice(DRV_IMU_DEVTYPE_ICM20689, SPI::CS{GPIO::PortF, GPIO::Pin2}, SPI::DRDY{GPIO::PortB, GPIO::Pin4}),
initSPIDevice(DRV_IMU_DEVTYPE_ICM42688P, SPI::CS{GPIO::PortF, GPIO::Pin11}, SPI::DRDY{GPIO::PortC, GPIO::Pin5}),

View File

@ -3,7 +3,7 @@
# board specific MAVLink startup script.
#------------------------------------------------------------------------------
if ver hwtypecmp V5X00090000 V5X00090001 V5X000a0000 V5X000a0001 V5X00080000 V5X00080001 V5X00100001
if ver hwtypecmp V5X009000 V5X009001 V5X00a000 V5X00a001 V5X008000 V5X008001 V5X010001
then
# Start MAVLink on the UART connected to the mission computer
mavlink start -d /dev/ttyS4 -b 3000000 -r 290000 -m onboard_low_bandwidth -x -z

View File

@ -5,7 +5,7 @@
set HAVE_PM2 yes
if ver hwtypecmp V5X50 V5X51 V5X52
if ver hwtypecmp V5X005000 V5X005001 V5X005002
then
set HAVE_PM2 no
fi
@ -48,11 +48,11 @@ then
fi
fi
if ver hwtypecmp V5X00000000 V5X00000001 V5X00000002 V5X00010000
if ver hwtypecmp V5X000000 V5X000001 V5X000002 V5X001000
then
#FMUv5Xbase board orientation
if ver hwtypecmp V5X00000000 V5X00000001
if ver hwtypecmp V5X000000 V5X000001
then
# Internal SPI BMI088
bmi088 -A -R 4 -s start
@ -74,7 +74,7 @@ then
else
#SKYNODE base fmu board orientation
if ver hwtypecmp V5X00090000 V5X00090001 V5X000a0000 V5X000a0001 V5X00080000 V5X00080001 V5X00100001
if ver hwtypecmp V5X009000 V5X009001 V5X00a000 V5X00a001 V5X008000 V5X008001 V5X010001
then
# Internal SPI BMI088
bmi088 -A -R 2 -s start
@ -104,7 +104,7 @@ ist8310 -X -b 1 -R 10 start
if param compare SENS_INT_BARO_EN 1
then
bmp388 -I -a 0x77 start
if ver hwtypecmp V5X00000000 V5X00010000 V5X00080000 V5X00090000 V5X000a0000
if ver hwtypecmp V5X000000 V5X001000 V5X008000 V5X009000 V5X00a000
then
bmp388 -I start
else

View File

@ -184,23 +184,23 @@
#define GPIO_HW_VER_REV_DRIVE /* PG0 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTG|GPIO_PIN0)
#define GPIO_HW_REV_SENSE /* PF5 */ ADC3_GPIO(15)
#define GPIO_HW_VER_SENSE /* PF4 */ ADC3_GPIO(14)
#define HW_INFO_INIT "V5X%04x%04x"
#define HW_INFO_INIT_PREFIX "V5X"
#define BOARD_NUM_SPI_CFG_HW_VERSIONS 6
// Base FMUM
#define V5X00000000 HW_VER_REV(0x0,0x0) // FMUV5X, Rev 0
#define V5X00010000 HW_VER_REV(0x1,0x0) // NO PX4IO, Rev 0
#define V5X00000001 HW_VER_REV(0x0,0x1) // FMUV5X I2C2 BMP388, Rev 1
#define V5X00000002 HW_VER_REV(0x0,0x2) // FMUV5X, Rev 2
#define V5X00050000 HW_VER_REV(0x5,0x0) // FMUV5X, HB Mini Rev 0
#define V5X00050001 HW_VER_REV(0x5,0x1) // FMUV5X I2C2 BMP388, HB Mini Rev 1
#define V5X00050002 HW_VER_REV(0x5,0x2) // FMUV5X, HB Mini Rev 2
#define V5X00090000 HW_VER_REV(0x9,0x0) // NO USB, Rev 0
#define V5X00090001 HW_VER_REV(0x9,0x1) // NO USB I2C2 BMP388, Rev 1
#define V5X00090002 HW_VER_REV(0x9,0x2) // NO USB I2C2 BMP388, Rev 2
#define V5X000a0000 HW_VER_REV(0xa,0x0) // NO USB (Q), Rev 0
#define V5X000a0001 HW_VER_REV(0xa,0x1) // NO USB (Q) I2C2 BMP388, Rev 1
#define V5X000a0002 HW_VER_REV(0xa,0x2) // NO USB (Q) I2C2 BMP388, Rev 2
#define V5X00100001 HW_VER_REV(0x10,0x1) // NO USB (Q) I2C2 BMP388, Rev 1
#define V5X00 HW_VER_REV(0x0,0x0) // FMUV5X, Rev 0
#define V5X10 HW_VER_REV(0x1,0x0) // NO PX4IO, Rev 0
#define V5X01 HW_VER_REV(0x0,0x1) // FMUV5X I2C2 BMP388, Rev 1
#define V5X02 HW_VER_REV(0x0,0x2) // FMUV5X, Rev 2
#define V5X50 HW_VER_REV(0x5,0x0) // FMUV5X, HB Mini Rev 0
#define V5X51 HW_VER_REV(0x5,0x1) // FMUV5X I2C2 BMP388, HB Mini Rev 1
#define V5X52 HW_VER_REV(0x5,0x2) // FMUV5X, HB Mini Rev 2
#define V5X90 HW_VER_REV(0x9,0x0) // NO USB, Rev 0
#define V5X91 HW_VER_REV(0x9,0x1) // NO USB I2C2 BMP388, Rev 1
#define V5X92 HW_VER_REV(0x9,0x2) // NO USB I2C2 BMP388, Rev 2
#define V5Xa0 HW_VER_REV(0xa,0x0) // NO USB (Q), Rev 0
#define V5Xa1 HW_VER_REV(0xa,0x1) // NO USB (Q) I2C2 BMP388, Rev 1
#define V5Xa2 HW_VER_REV(0xa,0x2) // NO USB (Q) I2C2 BMP388, Rev 2
#define V5X101 HW_VER_REV(0x10,0x1) // NO USB (Q) I2C2 BMP388, Rev 1
#define UAVCAN_NUM_IFACES_RUNTIME 1

View File

@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2012-2020 PX4 Development Team. All rights reserved.
* Copyright (c) 2012-2022 PX4 Development Team. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -54,9 +54,7 @@
#include <errno.h>
#include <nuttx/config.h>
extern "C" {
#include <nuttx/board.h>
}
#include <nuttx/spi/spi.h>
#include <nuttx/sdio.h>
#include <nuttx/mmcsd.h>
@ -222,8 +220,13 @@ __EXPORT int board_app_initialize(uintptr_t arg)
px4_platform_init();
/* Enable base EEPROM MTD to read hardware information*/
px4_mtd_config(board_get_base_eeprom_mtd_manifest());
// Use the default HW_VER_REV(0x0,0x0) for Ramtron
stm32_spiinitialize();
/* Configure the HW based on the manifest */
px4_platform_configure();
if (OK == board_determine_hw_info()) {
syslog(LOG_INFO, "[boot] Rev 0x%1x : Ver 0x%1x %s\n", board_get_hw_revision(), board_get_hw_version(),
@ -233,11 +236,13 @@ __EXPORT int board_app_initialize(uintptr_t arg)
syslog(LOG_ERR, "[boot] Failed to read HW revision and version\n");
}
/* Configure the Actual SPI interfaces (after we determined the HW version) */
stm32_spiinitialize();
board_spi_reset(10, 0xffff);
/* configure the DMA allocator */
/* Configure the DMA allocator */
if (board_dma_alloc_init() < 0) {
syslog(LOG_ERR, "[boot] DMA alloc FAILED\n");
@ -269,10 +274,6 @@ __EXPORT int board_app_initialize(uintptr_t arg)
#endif /* CONFIG_MMCSD */
/* Configure the HW based on the manifest */
px4_platform_configure();
int hw_version = board_get_hw_version();
if (hw_version == 0x9 || hw_version == 0xa) {

View File

@ -159,20 +159,20 @@ static const px4_hw_mft_item_t hw_mft_list_v0509[] = {
static px4_hw_mft_list_entry_t mft_lists[] = {
// ver_rev
{V5X00000000, hw_mft_list_v0500, arraySize(hw_mft_list_v0500)}, // FMUV5X, Rev 0
{V5X00000001, hw_mft_list_v0500, arraySize(hw_mft_list_v0500)}, // FMUV5X, Rev 1
{V5X00000002, hw_mft_list_v0500, arraySize(hw_mft_list_v0500)}, // FMUV5X, Rev 2
{V5X00010000, hw_mft_list_v0510, arraySize(hw_mft_list_v0510)}, // NO PX4IO, Rev 0
{V5X00050000, hw_mft_list_v0550, arraySize(hw_mft_list_v0550)}, // FMUV5X, HB Mini Rev 0
{V5X00050001, hw_mft_list_v0550, arraySize(hw_mft_list_v0550)}, // FMUV5X, HB Mini Rev 1
{V5X00050002, hw_mft_list_v0550, arraySize(hw_mft_list_v0550)}, // FMUV5X, HB Mini Rev 2
{V5X00090000, hw_mft_list_v0509, arraySize(hw_mft_list_v0509)}, // NO USB, Rev 0
{V5X00090001, hw_mft_list_v0509, arraySize(hw_mft_list_v0509)}, // NO USB I2C2 BMP388, Rev 1
{V5X00090002, hw_mft_list_v0509, arraySize(hw_mft_list_v0509)}, // NO USB I2C2 BMP388, Rev 2
{V5X000a0000, hw_mft_list_v0509, arraySize(hw_mft_list_v0509)}, // NO USB (Q), Rev 0
{V5X000a0001, hw_mft_list_v0509, arraySize(hw_mft_list_v0509)}, // NO USB (Q) I2C2 BMP388, Rev 1
{V5X000a0002, hw_mft_list_v0509, arraySize(hw_mft_list_v0509)}, // NO USB (Q) I2C2 BMP388, Rev 2
{V5X00100001, hw_mft_list_v0509, arraySize(hw_mft_list_v0509)}, // NO USB I2C2 BMP388, Rev 1
{V5X00, hw_mft_list_v0500, arraySize(hw_mft_list_v0500)}, // FMUV5X, Rev 0
{V5X01, hw_mft_list_v0500, arraySize(hw_mft_list_v0500)}, // FMUV5X, Rev 1
{V5X02, hw_mft_list_v0500, arraySize(hw_mft_list_v0500)}, // FMUV5X, Rev 2
{V5X10, hw_mft_list_v0510, arraySize(hw_mft_list_v0510)}, // NO PX4IO, Rev 0
{V5X50, hw_mft_list_v0550, arraySize(hw_mft_list_v0550)}, // FMUV5X, HB Mini Rev 0
{V5X51, hw_mft_list_v0550, arraySize(hw_mft_list_v0550)}, // FMUV5X, HB Mini Rev 1
{V5X52, hw_mft_list_v0550, arraySize(hw_mft_list_v0550)}, // FMUV5X, HB Mini Rev 2
{V5X90, hw_mft_list_v0509, arraySize(hw_mft_list_v0509)}, // NO USB, Rev 0
{V5X91, hw_mft_list_v0509, arraySize(hw_mft_list_v0509)}, // NO USB I2C2 BMP388, Rev 1
{V5X92, hw_mft_list_v0509, arraySize(hw_mft_list_v0509)}, // NO USB I2C2 BMP388, Rev 2
{V5Xa0, hw_mft_list_v0509, arraySize(hw_mft_list_v0509)}, // NO USB (Q), Rev 0
{V5Xa1, hw_mft_list_v0509, arraySize(hw_mft_list_v0509)}, // NO USB (Q) I2C2 BMP388, Rev 1
{V5Xa2, hw_mft_list_v0509, arraySize(hw_mft_list_v0509)}, // NO USB (Q) I2C2 BMP388, Rev 2
{V5X101, hw_mft_list_v0509, arraySize(hw_mft_list_v0509)}, // NO USB I2C2 BMP388, Rev 1
};
/************************************************************************************

View File

@ -102,20 +102,14 @@ static const px4_mtd_entry_t imu_eeprom = {
};
static const px4_mtd_manifest_t board_mtd_config = {
.nconfigs = 2,
.nconfigs = 3,
.entries = {
&fmum_fram,
&base_eeprom,
&imu_eeprom
}
};
static const px4_mtd_manifest_t board_mtd_base_eeprom_config = {
.nconfigs = 1,
.entries = {
&base_eeprom
}
};
static const px4_mft_entry_s mtd_mft = {
.type = MTD,
.pmft = (void *) &board_mtd_config,
@ -132,8 +126,3 @@ const px4_mft_s *board_get_manifest(void)
{
return &mft;
}
const px4_mtd_manifest_t *board_get_base_eeprom_mtd_manifest(void)
{
return &board_mtd_base_eeprom_config;
}

View File

@ -173,7 +173,8 @@
#define GPIO_HW_VER_REV_DRIVE /* PG0 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTG|GPIO_PIN0)
#define GPIO_HW_REV_SENSE /* PH4 */ GPIO_ADC3_INP15
#define GPIO_HW_VER_SENSE /* PH3 */ GPIO_ADC3_INP14
#define HW_INFO_INIT "V6U%04x%04x"
#define HW_INFO_INIT_PREFIX "V6U"
#define V6U00 HW_VER_REV(0x0,0x0)
/* HEATER
* PWM in future

View File

@ -82,7 +82,7 @@ static const px4_hw_mft_item_t hw_mft_list_v0600[] = {
};
static px4_hw_mft_list_entry_t mft_lists[] = {
{0x00000000, hw_mft_list_v0600, arraySize(hw_mft_list_v0600)},
{V6U00, hw_mft_list_v0600, arraySize(hw_mft_list_v0600)},
};
/************************************************************************************

View File

@ -4,7 +4,7 @@
#------------------------------------------------------------------------------
set HAVE_PM2 yes
if ver hwtypecmp V6X00050000 V6X00050001 V6X00050003 V6X00050004
if ver hwtypecmp V6X005000 V6X005001 V6X005003 V6X005004
then
set HAVE_PM2 no
fi
@ -47,7 +47,7 @@ then
fi
fi
if ver hwtypecmp V6X00000004 V6X00010004 V6X00050004
if ver hwtypecmp V6X000004 V6X001004 V6X005004
then
# Internal SPI bus ICM20649
icm20649 -s -R 6 start
@ -60,7 +60,7 @@ fi
# Internal SPI bus ICM42688p
icm42688p -R 6 -s start
if ver hwtypecmp V6X00000003 V6X00010003 V6X00000004 V6X00010004 V6X00050003 V6X00050004
if ver hwtypecmp V6X000003 V6X001003 V6X000004 V6X001004 V6X005003 V6X005004
then
# Internal SPI bus ICM-42670-P (hard-mounted)
icm42670p -R 10 -s start
@ -78,7 +78,7 @@ ist8310 -X -b 1 -R 10 start
# Possible internal Baro
bmp388 -I -a 0x77 start
if ver hwtypecmp V6X00000000 V6X00010000
if ver hwtypecmp V6X000000 V6X001000
then
bmp388 -I start
else

View File

@ -211,21 +211,21 @@
#define GPIO_HW_VER_REV_DRIVE /* PG0 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTG|GPIO_PIN0)
#define GPIO_HW_REV_SENSE /* PH4 */ GPIO_ADC3_INP15
#define GPIO_HW_VER_SENSE /* PH3 */ GPIO_ADC3_INP14
#define HW_INFO_INIT "V6X%04x%04x"
#define HW_INFO_INIT_PREFIX "V6X"
#define BOARD_NUM_SPI_CFG_HW_VERSIONS 6 // Rev 0 and Rev 3,4 Sensor sets
// Base/FMUM
#define V6X00000000 HW_VER_REV(0x0,0x0) // FMUV6X, Rev 0
#define V6X00000001 HW_VER_REV(0x0,0x1) // FMUV6X, BMI388 I2C2 Rev 1
#define V6X00000003 HW_VER_REV(0x0,0x3) // FMUV6X, Sensor Set Rev 3
#define V6X00000004 HW_VER_REV(0x0,0x4) // FMUV6X, Sensor Set Rev 4
#define V6X00010000 HW_VER_REV(0x1,0x0) // NO PX4IO, Rev 0
#define V6X00010003 HW_VER_REV(0x1,0x3) // NO PX4IO, Sensor Set Rev 3
#define V6X00010004 HW_VER_REV(0x1,0x4) // NO PX4IO, Sensor Set Rev 4
#define V6X00050000 HW_VER_REV(0x5,0x0) // FMUV6X, HB Mini Rev 0
#define V6X00050001 HW_VER_REV(0x5,0x1) // FMUV6X, BMI388 I2C2 HB Mini Rev 1
#define V6X00050003 HW_VER_REV(0x5,0x3) // FMUV6X, Sensor Set HB Mini Rev 3
#define V6X00050004 HW_VER_REV(0x5,0x4) // FMUV6X, Sensor Set HB Mini Rev 4
#define V6X00 HW_VER_REV(0x0,0x0) // FMUV6X, Rev 0
#define V6X01 HW_VER_REV(0x0,0x1) // FMUV6X, BMI388 I2C2 Rev 1
#define V6X03 HW_VER_REV(0x0,0x3) // FMUV6X, Sensor Set Rev 3
#define V6X04 HW_VER_REV(0x0,0x4) // FMUV6X, Sensor Set Rev 4
#define V6X10 HW_VER_REV(0x1,0x0) // NO PX4IO, Rev 0
#define V6X13 HW_VER_REV(0x1,0x3) // NO PX4IO, Sensor Set Rev 3
#define V6X14 HW_VER_REV(0x1,0x4) // NO PX4IO, Sensor Set Rev 4
#define V6X50 HW_VER_REV(0x5,0x0) // FMUV6X, HB Mini Rev 0
#define V6X51 HW_VER_REV(0x5,0x1) // FMUV6X, BMI388 I2C2 HB Mini Rev 1
#define V6X53 HW_VER_REV(0x5,0x3) // FMUV6X, Sensor Set HB Mini Rev 3
#define V6X54 HW_VER_REV(0x5,0x4) // FMUV6X, Sensor Set HB Mini Rev 4
#define UAVCAN_NUM_IFACES_RUNTIME 1

View File

@ -52,7 +52,6 @@
#include <string.h>
#include <debug.h>
#include <errno.h>
#include <syslog.h>
#include <nuttx/config.h>
#include <nuttx/board.h>
@ -71,6 +70,7 @@
#include <systemlib/px4_macros.h>
#include <px4_arch/io_timer.h>
#include <px4_platform_common/init.h>
#include <px4_platform_common/px4_manifest.h>
#include <px4_platform/gpio.h>
#include <px4_platform/board_determine_hw_info.h>
#include <px4_platform/board_dma_alloc.h>
@ -219,6 +219,13 @@ __EXPORT int board_app_initialize(uintptr_t arg)
px4_platform_init();
// Use the default HW_VER_REV(0x0,0x0) for Ramtron
stm32_spiinitialize();
/* Configure the HW based on the manifest */
px4_platform_configure();
if (OK == board_determine_hw_info()) {
syslog(LOG_INFO, "[boot] Rev 0x%1x : Ver 0x%1x %s\n", board_get_hw_revision(), board_get_hw_version(),
@ -228,11 +235,13 @@ __EXPORT int board_app_initialize(uintptr_t arg)
syslog(LOG_ERR, "[boot] Failed to read HW revision and version\n");
}
/* Configure the Actual SPI interfaces (after we determined the HW version) */
stm32_spiinitialize();
board_spi_reset(10, 0xffff);
/* configure the DMA allocator */
/* Configure the DMA allocator */
if (board_dma_alloc_init() < 0) {
syslog(LOG_ERR, "[boot] DMA alloc FAILED\n");
@ -264,13 +273,10 @@ __EXPORT int board_app_initialize(uintptr_t arg)
if (ret != OK) {
led_on(LED_RED);
return ret;
}
#endif /* CONFIG_MMCSD */
/* Configure the HW based on the manifest */
px4_platform_configure();
return OK;
}

View File

@ -139,17 +139,17 @@ static const px4_hw_mft_item_t hw_mft_list_v0650[] = {
static px4_hw_mft_list_entry_t mft_lists[] = {
// ver_rev
{V6X00000000, hw_mft_list_v0600, arraySize(hw_mft_list_v0600)},
{V6X00000001, hw_mft_list_v0600, arraySize(hw_mft_list_v0600)}, // BMP388 moved to I2C2
{V6X00000003, hw_mft_list_v0600, arraySize(hw_mft_list_v0600)}, // BMP388 moved to I2C2, Sensor Set 3
{V6X00050000, hw_mft_list_v0650, arraySize(hw_mft_list_v0650)}, // HB Mini
{V6X00050001, hw_mft_list_v0650, arraySize(hw_mft_list_v0650)}, // BMP388 moved to I2C2 HB Mini
{V6X00050003, hw_mft_list_v0650, arraySize(hw_mft_list_v0650)}, // BMP388 moved to I2C2, HB Mini Sensor Set 3
{V6X00050004, hw_mft_list_v0650, arraySize(hw_mft_list_v0650)}, // BMP388 moved to I2C2, HB Mini Sensor Set 4
{V6X00010000, hw_mft_list_v0610, arraySize(hw_mft_list_v0610)}, // No PX4IO
{V6X00010003, hw_mft_list_v0610, arraySize(hw_mft_list_v0610)}, // No PX4IO BMP388 moved to I2C2, Sensor Set 3
{V6X00000004, hw_mft_list_v0600, arraySize(hw_mft_list_v0600)}, // BMP388 moved to I2C2, Sensor Set 4
{V6X00010004, hw_mft_list_v0610, arraySize(hw_mft_list_v0610)}, // No PX4IO BMP388 moved to I2C2, Sensor Set 4
{V6X00, hw_mft_list_v0600, arraySize(hw_mft_list_v0600)},
{V6X01, hw_mft_list_v0600, arraySize(hw_mft_list_v0600)}, // BMP388 moved to I2C2
{V6X03, hw_mft_list_v0600, arraySize(hw_mft_list_v0600)}, // BMP388 moved to I2C2, Sensor Set 3
{V6X50, hw_mft_list_v0650, arraySize(hw_mft_list_v0650)}, // HB Mini
{V6X51, hw_mft_list_v0650, arraySize(hw_mft_list_v0650)}, // BMP388 moved to I2C2 HB Mini
{V6X53, hw_mft_list_v0650, arraySize(hw_mft_list_v0650)}, // BMP388 moved to I2C2, HB Mini Sensor Set 3
{V6X54, hw_mft_list_v0650, arraySize(hw_mft_list_v0650)}, // BMP388 moved to I2C2, HB Mini Sensor Set 4
{V6X10, hw_mft_list_v0610, arraySize(hw_mft_list_v0610)}, // No PX4IO
{V6X13, hw_mft_list_v0610, arraySize(hw_mft_list_v0610)}, // No PX4IO BMP388 moved to I2C2, Sensor Set 3
{V6X04, hw_mft_list_v0600, arraySize(hw_mft_list_v0600)}, // BMP388 moved to I2C2, Sensor Set 4
{V6X14, hw_mft_list_v0610, arraySize(hw_mft_list_v0610)}, // No PX4IO BMP388 moved to I2C2, Sensor Set 4
};
/************************************************************************************

View File

@ -173,8 +173,8 @@
#define GPIO_HW_VER_REV_DRIVE /* PG0 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTG|GPIO_PIN0)
#define GPIO_HW_REV_SENSE /* PF5 */ ADC3_GPIO(15)
#define GPIO_HW_VER_SENSE /* PF4 */ ADC3_GPIO(14)
#define HW_INFO_INIT "V5X%04x%04x"
#define HW_INFO_INIT_PREFIX "SDSA"
#define SDSA0501 HW_VER_REV(0x05,0x01)
/* HEATER
* PWM in future
*/

View File

@ -88,7 +88,7 @@ static const px4_hw_mft_item_t hw_mft_list_v0501[] = {
static px4_hw_mft_list_entry_t mft_lists[] = {
{0x0501, hw_mft_list_v0501, arraySize(hw_mft_list_v0501)},
{SDSA0501, hw_mft_list_v0501, arraySize(hw_mft_list_v0501)},
};

View File

@ -265,6 +265,9 @@
# define HW_VER_REV(v,r) ((uint32_t)((v) & 0xffff) << 16) | ((uint32_t)(r) & 0xffff)
#endif
#define HW_INFO_REV_DIGITS 3
#define HW_INFO_VER_DIGITS 3
/* Default LED logical to color mapping */
#if defined(BOARD_OVERLOAD_LED)

View File

@ -100,6 +100,6 @@ __EXPORT int px4_mtd_config(const px4_mtd_manifest_t *mft_mtd);
* 0 (get !=null) item by type's value is returned at get;
*
************************************************************************************/
__EXPORT int px4_mtd_query(const char *type, const char *val, const char **get = nullptr);
__EXPORT int px4_mtd_query(const char *type, const char *val, const char **get);
__END_DECLS

View File

@ -32,9 +32,10 @@
****************************************************************************/
#pragma once
#include "micro_hal.h"
__BEGIN_DECLS
#define HW_INFO_SUFFIX "%0" STRINGIFY(HW_INFO_VER_DIGITS) "x%0" STRINGIFY(HW_INFO_REV_DIGITS) "x"
/************************************************************************************
* Name: board_determine_hw_info
*

View File

@ -71,6 +71,7 @@ __BEGIN_DECLS
* Function for writing hardware info to EEPROM
*
* Input Parameters:
* *path - path to mtd_mft
* *mtd_mft_unk - pointer to mtd_mft to write hw_info
*
* Returned Value:
@ -80,9 +81,9 @@ __BEGIN_DECLS
************************************************************************************/
#if !defined(BOARD_HAS_SIMPLE_HW_VERSIONING) && defined(BOARD_HAS_VERSIONING)
__EXPORT int board_set_eeprom_hw_info(mtd_mft_t *mtd_mft_unk);
__EXPORT int board_set_eeprom_hw_info(const char *path, mtd_mft_t *mtd_mft_unk);
#else
static inline int board_set_eeprom_hw_info(mtd_mft_t *mtd_mft_unk) { return -ENOSYS; }
static inline int board_set_eeprom_hw_info(const char *path, mtd_mft_t *mtd_mft_unk) { return -ENOSYS; }
#endif
/************************************************************************************
@ -101,9 +102,9 @@ static inline int board_set_eeprom_hw_info(mtd_mft_t *mtd_mft_unk) { return -ENO
************************************************************************************/
#if !defined(BOARD_HAS_SIMPLE_HW_VERSIONING) && defined(BOARD_HAS_VERSIONING)
__EXPORT int board_get_eeprom_hw_info(mtd_mft_t *mtd_mft);
__EXPORT int board_get_eeprom_hw_info(const char *path, mtd_mft_t *mtd_mft);
#else
static inline int board_get_eeprom_hw_info(mtd_mft_t *mtd_mft) { return -ENOSYS; }
static inline int board_get_eeprom_hw_info(const char *path, mtd_mft_t *mtd_mft) { return -ENOSYS; }
#endif
__END_DECLS

View File

@ -100,7 +100,7 @@ __EXPORT int px4_mft_query(const px4_mft_s *mft, px4_manifest_types_e type,
if (mft->mfts[m]->type == type)
switch (type) {
case MTD:
return px4_mtd_query(sub, val);
return px4_mtd_query(sub, val, nullptr);
break;
case MFT:

View File

@ -44,7 +44,7 @@
static int hw_version = 0;
static int hw_revision = 0;
static char hw_info[] = HW_INFO_INIT;
static char hw_info[] = HW_INFO_INIT_PREFIX HW_INFO_SUFFIX;
__EXPORT const char *board_get_hw_type_name(void)
{

View File

@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (C) 2019 PX4 Development Team. All rights reserved.
* Copyright (C) 2019, 2022 PX4 Development Team. All rights reserved.
* Author: @author David Sidrane <david_s5@nscdg.com>
*
* Redistribution and use in source and binary forms, with or without
@ -53,7 +53,8 @@
# define GPIO_HW_VER_DRIVE GPIO_HW_VER_REV_DRIVE
# endif
#define HW_INFO_SIZE 20 //<! Size to fit hw_info string
#define HW_INFO_SIZE (int) arraySize(HW_INFO_INIT_PREFIX) + HW_INFO_VER_DIGITS + HW_INFO_REV_DIGITS
/****************************************************************************
* Private Data
@ -196,7 +197,7 @@ static int read_id_dn(int *id, uint32_t gpio_drive, uint32_t gpio_sense, int adc
/* Are Resistors in place ?*/
uint32_t dn_sum = 0;
uint16_t dn = 0;
uint32_t dn = 0;
if ((high ^ low) && low == 0) {
/* Yes - Fire up the ADC (it has once control) */
@ -207,14 +208,14 @@ static int read_id_dn(int *id, uint32_t gpio_drive, uint32_t gpio_sense, int adc
for (unsigned av = 0; av < samples; av++) {
dn = px4_arch_adc_sample(HW_REV_VER_ADC_BASE, adc_channel);
if (dn == 0xffff) {
if (dn == UINT32_MAX) {
break;
}
dn_sum += dn;
}
if (dn != 0xffff) {
if (dn != UINT32_MAX) {
*id = dn_sum / samples;
rv = OK;
}
@ -344,12 +345,8 @@ int board_determine_hw_info()
if (rv == OK) {
int hw_info_size = snprintf(hw_info, HW_INFO_SIZE, HW_INFO_INIT, hw_version, hw_revision);
snprintf(hw_info, sizeof(hw_info), HW_INFO_INIT_PREFIX HW_INFO_SUFFIX, hw_version, hw_revision);
if ((hw_info_size < 0) || (hw_info_size >= HW_INFO_SIZE)) {
printf("[boot] Error, hw_info string hasn't been completely written\n");
rv = -1;
}
}
}

View File

@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (C) 2017 PX4 Development Team. All rights reserved.
* Copyright (C) 2017, 2022 PX4 Development Team. All rights reserved.
* Author: @author David Sidrane <david_s5@nscdg.com>
*
* Redistribution and use in source and binary forms, with or without
@ -41,6 +41,7 @@
#include <px4_arch/adc.h>
#include <px4_platform_common/micro_hal.h>
#include <px4_platform_common/px4_config.h>
#include <px4_platform_common/px4_manifest.h>
#include <px4_platform/board_determine_hw_info.h>
#include <px4_platform/board_hw_eeprom_rev_ver.h>
#include <stdio.h>
@ -57,7 +58,8 @@
# define GPIO_HW_VER_DRIVE GPIO_HW_VER_REV_DRIVE
# endif
#define HW_INFO_SIZE 20 //<! Size to fit hw_info string
#define HW_INFO_SIZE (int) arraySize(HW_INFO_INIT_PREFIX) + HW_INFO_VER_DIGITS + HW_INFO_REV_DIGITS
/****************************************************************************
* Private Data
@ -66,8 +68,6 @@ static int hw_version = 0;
static int hw_revision = 0;
static char hw_info[HW_INFO_SIZE] = {0};
static const char *mtd_mft_path = "/fs/mtd_mft";
/****************************************************************************
* Protected Functions
****************************************************************************/
@ -445,16 +445,19 @@ __EXPORT int board_get_hw_revision()
int board_determine_hw_info()
{
// ADC hw version range: {0x1 - 0xF}
// MFT supported?
const char *path;
int rvmft = px4_mtd_query("MTD_MFT", NULL, &path);
// Read ADC jumpering hw_info
int rv = determine_hw_info(&hw_revision, &hw_version);
if (rv == OK) {
/* EEPROM hw version range: {0x10 - 0xFFFF} */
if (hw_version == HW_VERSION_EEPROM) {
if (rvmft == OK && path != NULL && hw_version == HW_VERSION_EEPROM) {
mtd_mft_v0_t mtd_mft = {MTD_MFT_v0};
rv = board_get_eeprom_hw_info((mtd_mft_t *)&mtd_mft);
rv = board_get_eeprom_hw_info(path, (mtd_mft_t *)&mtd_mft);
if (rv == OK) {
hw_version = mtd_mft.hw_extended_ver;
@ -463,13 +466,7 @@ int board_determine_hw_info()
}
if (rv == OK) {
int hw_info_size = snprintf(hw_info, HW_INFO_SIZE, HW_INFO_INIT, hw_version, hw_revision);
if ((hw_info_size < 0) || (hw_info_size >= HW_INFO_SIZE)) {
printf("[boot] Error, hw_info string hasn't been completely written\n");
rv = -1;
}
snprintf(hw_info, sizeof(hw_info), HW_INFO_INIT_PREFIX HW_INFO_SUFFIX, hw_version, hw_revision);
}
return rv;
@ -490,10 +487,10 @@ int board_determine_hw_info()
*
************************************************************************************/
int board_set_eeprom_hw_info(mtd_mft_t *mtd_mft_unk)
int board_set_eeprom_hw_info(const char *path, mtd_mft_t *mtd_mft_unk)
{
if (mtd_mft_unk == NULL) {
return -1;
if (mtd_mft_unk == NULL || path == NULL) {
return -EINVAL;
}
// Later this will be a demux on type
@ -509,7 +506,7 @@ int board_set_eeprom_hw_info(mtd_mft_t *mtd_mft_unk)
return -EINVAL;
}
int fd = open(mtd_mft_path, O_WRONLY);
int fd = open(path, O_WRONLY);
if (fd < 0) {
return -errno;
@ -545,13 +542,13 @@ int board_set_eeprom_hw_info(mtd_mft_t *mtd_mft_unk)
* -1 - Error while reading from EEPROM
*
************************************************************************************/
__EXPORT int board_get_eeprom_hw_info(mtd_mft_t *mtd_mft)
__EXPORT int board_get_eeprom_hw_info(const char *path, mtd_mft_t *mtd_mft)
{
if (mtd_mft == NULL) {
if (mtd_mft == NULL || path == NULL) {
return -EINVAL;
}
int fd = open(mtd_mft_path, O_RDONLY);
int fd = open(path, O_RDONLY);
if (fd < 0) {
return -errno;

View File

@ -46,6 +46,7 @@
#include <stdbool.h>
#include <string.h>
#include <version/version.h>
#include <version/version.h>
/* string constants for version commands */
static const char sz_ver_hw_str[] = "hw";
@ -141,11 +142,11 @@ extern "C" __EXPORT int ver_main(int argc, char *argv[])
int r = px4_board_hw_revision();
if (v >= 0) {
snprintf(vb, sizeof(vb), "0x%08X", v);
snprintf(vb, sizeof(vb), "0x%0" STRINGIFY(HW_INFO_VER_DIGITS) "X", v);
}
if (r >= 0) {
snprintf(rb, sizeof(rb), "0x%08X", r);
snprintf(rb, sizeof(rb), "0x%0" STRINGIFY(HW_INFO_REV_DIGITS) "X", r);
}
printf("HW type: %s\n", strlen(px4_board_sub_type()) ? px4_board_sub_type() : "NA");