mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-25 08:17:34 +08:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0c3e896101 | |||
| d8f8dbacc8 | |||
| c5c62857fe | |||
| 833555d01e | |||
| 64e3f51d3a | |||
| d9df4db473 | |||
| ac497e21c6 | |||
| d0ecc77ee7 | |||
| ca36255094 | |||
| 0d414de38c | |||
| 0aa6ae473b | |||
| 4c36cbbd8a | |||
| 9f1f0590a7 |
@@ -313,7 +313,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
|
||||
|
||||
@@ -115,9 +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 {'V','5','x', 'x',0}
|
||||
#define HW_INFO_INIT_VER 2
|
||||
#define HW_INFO_INIT_REV 3
|
||||
#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
|
||||
|
||||
@@ -72,7 +72,9 @@ static const px4_mft_entry_s mtd_mft = {
|
||||
|
||||
static const px4_mft_s mft = {
|
||||
.nmft = 1,
|
||||
.mfts = &mtd_mft
|
||||
.mfts = {
|
||||
&mtd_mft
|
||||
}
|
||||
};
|
||||
|
||||
const px4_mft_s *board_get_manifest(void)
|
||||
|
||||
@@ -83,9 +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 {'C','A','N','G','P','S','x', 'x',0}
|
||||
#define HW_INFO_INIT_VER 6
|
||||
#define HW_INFO_INIT_REV 7
|
||||
#define HW_INFO_INIT_PREFIX "CANGPS"
|
||||
|
||||
#define CANGPS00 HW_VER_REV(0x0,0x0) // CANGPS
|
||||
|
||||
#define FLASH_BASED_PARAMS
|
||||
|
||||
|
||||
@@ -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
|
||||
{0x0000, hw_mft_list_v0000, arraySize(hw_mft_list_v0000)},
|
||||
{CANGPS00, hw_mft_list_v0000, arraySize(hw_mft_list_v0000)},
|
||||
};
|
||||
|
||||
/************************************************************************************
|
||||
@@ -127,7 +127,7 @@ __EXPORT px4_hw_mft_item board_query_manifest(px4_hw_mft_item_id_t id)
|
||||
static px4_hw_mft_list_entry boards_manifest = px4_hw_mft_list_uninitialized;
|
||||
|
||||
if (boards_manifest == px4_hw_mft_list_uninitialized) {
|
||||
uint32_t ver_rev = board_get_hw_version() << 8;
|
||||
uint32_t ver_rev = board_get_hw_version() << 16;
|
||||
ver_rev |= board_get_hw_revision();
|
||||
|
||||
for (unsigned i = 0; i < arraySize(mft_lists); i++) {
|
||||
@@ -138,7 +138,7 @@ __EXPORT px4_hw_mft_item board_query_manifest(px4_hw_mft_item_id_t id)
|
||||
}
|
||||
|
||||
if (boards_manifest == px4_hw_mft_list_uninitialized) {
|
||||
syslog(LOG_ERR, "[boot] Board %4" PRIx32 " is not supported!\n", ver_rev);
|
||||
syslog(LOG_ERR, "[boot] Board %08" PRIx32 " is not supported!\n", ver_rev);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -152,9 +152,7 @@
|
||||
#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 {'V','D','x', 'x',0}
|
||||
#define HW_INFO_INIT_VER 2
|
||||
#define HW_INFO_INIT_REV 3
|
||||
#define HW_INFO_INIT_PREFIX "VD"
|
||||
|
||||
#define BOARD_NUM_SPI_CFG_HW_VERSIONS 2
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ __EXPORT px4_hw_mft_item board_query_manifest(px4_hw_mft_item_id_t id)
|
||||
static px4_hw_mft_list_entry boards_manifest = px4_hw_mft_list_uninitialized;
|
||||
|
||||
if (boards_manifest == px4_hw_mft_list_uninitialized) {
|
||||
uint32_t ver_rev = board_get_hw_version() << 8;
|
||||
uint32_t ver_rev = board_get_hw_version() << 16;
|
||||
ver_rev |= board_get_hw_revision();
|
||||
|
||||
for (unsigned i = 0; i < arraySize(mft_lists); i++) {
|
||||
@@ -118,7 +118,7 @@ __EXPORT px4_hw_mft_item board_query_manifest(px4_hw_mft_item_id_t id)
|
||||
}
|
||||
|
||||
if (boards_manifest == px4_hw_mft_list_uninitialized) {
|
||||
syslog(LOG_ERR, "[boot] Board %4" PRIx32 " is not supported!\n", ver_rev);
|
||||
syslog(LOG_ERR, "[boot] Board %08" PRIx32 " is not supported!\n", ver_rev);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -185,9 +185,11 @@
|
||||
#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 {'V','5','x', 'x',0}
|
||||
#define HW_INFO_INIT_VER 2
|
||||
#define HW_INFO_INIT_REV 3
|
||||
#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
|
||||
*
|
||||
* Silent mode control \ ESC Mux select
|
||||
|
||||
@@ -129,8 +129,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)}, // 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
|
||||
};
|
||||
|
||||
/************************************************************************************
|
||||
@@ -153,7 +153,7 @@ __EXPORT px4_hw_mft_item board_query_manifest(px4_hw_mft_item_id_t id)
|
||||
static px4_hw_mft_list_entry boards_manifest = px4_hw_mft_list_uninitialized;
|
||||
|
||||
if (boards_manifest == px4_hw_mft_list_uninitialized) {
|
||||
uint32_t ver_rev = board_get_hw_version() << 8;
|
||||
uint32_t ver_rev = board_get_hw_version() << 16;
|
||||
ver_rev |= board_get_hw_revision();
|
||||
|
||||
for (unsigned i = 0; i < arraySize(mft_lists); i++) {
|
||||
@@ -164,7 +164,7 @@ __EXPORT px4_hw_mft_item board_query_manifest(px4_hw_mft_item_id_t id)
|
||||
}
|
||||
|
||||
if (boards_manifest == px4_hw_mft_list_uninitialized) {
|
||||
syslog(LOG_ERR, "[boot] Board %4" PRIx32 " is not supported!\n", ver_rev);
|
||||
syslog(LOG_ERR, "[boot] Board %08" PRIx32 " is not supported!\n", ver_rev);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -142,9 +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 {'V','1','x', 'x',0}
|
||||
#define HW_INFO_INIT_VER 2 /* Offset in above string of the VER */
|
||||
#define HW_INFO_INIT_REV 3 /* Offset in above string of the REV */
|
||||
#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
|
||||
*/
|
||||
|
||||
@@ -90,8 +90,8 @@ static const px4_hw_mft_item_t hw_mft_list_fc0100[] = {
|
||||
};
|
||||
|
||||
static px4_hw_mft_list_entry_t mft_lists[] = {
|
||||
{0x0006, hw_mft_list_fc0006, arraySize(hw_mft_list_fc0006)},
|
||||
{0x0100, 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)}
|
||||
};
|
||||
|
||||
/************************************************************************************
|
||||
@@ -114,7 +114,7 @@ __EXPORT px4_hw_mft_item board_query_manifest(px4_hw_mft_item_id_t id)
|
||||
static px4_hw_mft_list_entry boards_manifest = px4_hw_mft_list_uninitialized;
|
||||
|
||||
if (boards_manifest == px4_hw_mft_list_uninitialized) {
|
||||
uint32_t ver_rev = board_get_hw_version() << 8;
|
||||
uint32_t ver_rev = board_get_hw_version() << 16;
|
||||
ver_rev |= board_get_hw_revision();
|
||||
|
||||
for (unsigned i = 0; i < arraySize(mft_lists); i++) {
|
||||
@@ -125,7 +125,7 @@ __EXPORT px4_hw_mft_item board_query_manifest(px4_hw_mft_item_id_t id)
|
||||
}
|
||||
|
||||
if (boards_manifest == px4_hw_mft_list_uninitialized) {
|
||||
syslog(LOG_ERR, "[boot] Board %4" PRIx32 " is not supported!\n", ver_rev);
|
||||
syslog(LOG_ERR, "[boot] Board %08" PRIx32 " is not supported!\n", ver_rev);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -182,9 +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 {'V','2','x', 'x',0}
|
||||
#define HW_INFO_INIT_VER 3 /* Offset in above string of the VER */
|
||||
#define HW_INFO_INIT_REV 4 /* Offset in above string of the REV */
|
||||
#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.
|
||||
|
||||
@@ -83,7 +83,7 @@ static const px4_hw_mft_item_t hw_mft_list_fc0200[] = {
|
||||
};
|
||||
|
||||
static px4_hw_mft_list_entry_t mft_lists[] = {
|
||||
{0x0300, hw_mft_list_fc0200, arraySize(hw_mft_list_fc0200)},
|
||||
{V20300, hw_mft_list_fc0200, arraySize(hw_mft_list_fc0200)},
|
||||
};
|
||||
|
||||
/************************************************************************************
|
||||
@@ -106,7 +106,7 @@ __EXPORT px4_hw_mft_item board_query_manifest(px4_hw_mft_item_id_t id)
|
||||
static px4_hw_mft_list_entry boards_manifest = px4_hw_mft_list_uninitialized;
|
||||
|
||||
if (boards_manifest == px4_hw_mft_list_uninitialized) {
|
||||
uint32_t ver_rev = board_get_hw_version() << 8;
|
||||
uint32_t ver_rev = board_get_hw_version() << 16;
|
||||
ver_rev |= board_get_hw_revision();
|
||||
|
||||
for (unsigned i = 0; i < arraySize(mft_lists); i++) {
|
||||
@@ -117,7 +117,7 @@ __EXPORT px4_hw_mft_item board_query_manifest(px4_hw_mft_item_id_t id)
|
||||
}
|
||||
|
||||
if (boards_manifest == px4_hw_mft_list_uninitialized) {
|
||||
syslog(LOG_ERR, "[boot] Board %4" PRIx32 " is not supported!\n", ver_rev);
|
||||
syslog(LOG_ERR, "[boot] Board %08" PRIx32 " is not supported!\n", ver_rev);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,9 @@ static const px4_mft_entry_s mtd_mft = {
|
||||
|
||||
static const px4_mft_s mft = {
|
||||
.nmft = 1,
|
||||
.mfts = &mtd_mft
|
||||
.mfts = {
|
||||
&mtd_mft
|
||||
}
|
||||
};
|
||||
|
||||
const px4_mft_s *board_get_manifest(void)
|
||||
|
||||
@@ -192,9 +192,10 @@
|
||||
#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 {'V','5','x', 'x',0}
|
||||
#define HW_INFO_INIT_VER 2
|
||||
#define HW_INFO_INIT_REV 3
|
||||
#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
|
||||
*
|
||||
* Silent mode control \ ESC Mux select
|
||||
|
||||
@@ -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)},
|
||||
};
|
||||
|
||||
/************************************************************************************
|
||||
|
||||
@@ -66,7 +66,9 @@ static const px4_mft_entry_s mtd_mft = {
|
||||
|
||||
static const px4_mft_s mft = {
|
||||
.nmft = 1,
|
||||
.mfts = &mtd_mft
|
||||
.mfts = {
|
||||
&mtd_mft
|
||||
}
|
||||
};
|
||||
|
||||
const px4_mft_s *board_get_manifest(void)
|
||||
|
||||
@@ -65,7 +65,9 @@ static const px4_mft_entry_s mtd_mft = {
|
||||
|
||||
static const px4_mft_s mft = {
|
||||
.nmft = 1,
|
||||
.mfts = &mtd_mft
|
||||
.mfts = {
|
||||
&mtd_mft
|
||||
}
|
||||
};
|
||||
|
||||
const px4_mft_s *board_get_manifest(void)
|
||||
|
||||
@@ -9,7 +9,7 @@ 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 V550 V552 V560 V562
|
||||
if ver hwtypecmp V5005000 V5005002 V5006000 V5006002
|
||||
then
|
||||
# CUAV V5+ (V550/V552) and V5nano (V560/V562) have 3 IMUs
|
||||
# Multi-EKF (IMUs only)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
board_adc start
|
||||
|
||||
if ver hwtypecmp V552 V562
|
||||
if ver hwtypecmp V5005002 V5006002
|
||||
then
|
||||
# Internal SPI bus ICM-42688-P
|
||||
icm42688p -s -R 2 -q start
|
||||
|
||||
@@ -188,9 +188,8 @@
|
||||
#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 {'V','5','x', 'x',0}
|
||||
#define HW_INFO_INIT_VER 2
|
||||
#define HW_INFO_INIT_REV 3
|
||||
|
||||
#define HW_INFO_INIT_PREFIX "V5"
|
||||
#define BOARD_NUM_SPI_CFG_HW_VERSIONS 3
|
||||
#define V500 HW_VER_REV(0x0,0x0) // FMUV5, Rev 0
|
||||
#define V515 HW_VER_REV(0x1,0x5) // CUAV V5, Rev 5
|
||||
|
||||
@@ -186,7 +186,7 @@ __EXPORT px4_hw_mft_item board_query_manifest(px4_hw_mft_item_id_t id)
|
||||
static px4_hw_mft_list_entry boards_manifest = px4_hw_mft_list_uninitialized;
|
||||
|
||||
if (boards_manifest == px4_hw_mft_list_uninitialized) {
|
||||
uint32_t ver_rev = board_get_hw_version() << 8;
|
||||
uint32_t ver_rev = board_get_hw_version() << 16;
|
||||
ver_rev |= board_get_hw_revision();
|
||||
|
||||
for (unsigned i = 0; i < arraySize(mft_lists); i++) {
|
||||
@@ -197,7 +197,7 @@ __EXPORT px4_hw_mft_item board_query_manifest(px4_hw_mft_item_id_t id)
|
||||
}
|
||||
|
||||
if (boards_manifest == px4_hw_mft_list_uninitialized) {
|
||||
syslog(LOG_ERR, "[boot] Board %4" PRIx32 " is not supported!\n", ver_rev);
|
||||
syslog(LOG_ERR, "[boot] Board %08" PRIx32 " is not supported!\n", ver_rev);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# board specific MAVLink startup script.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
if ver hwtypecmp V5X90 V5X91 V5Xa0 V5Xa1 V5X80 V5X81
|
||||
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
|
||||
|
||||
@@ -32,33 +32,11 @@ then
|
||||
ina238 -X -b 2 -t 2 -k start
|
||||
fi
|
||||
|
||||
if ver hwtypecmp V5X90 V5X91 V5X92 V5Xa0 V5Xa1 V5Xa2
|
||||
if ver hwtypecmp V5X000000 V5X000001 V5X000002 V5X001000
|
||||
then
|
||||
#SKYNODE base fmu board orientation
|
||||
|
||||
if ver hwtypecmp V5X90 V5X91 V5Xa0 V5Xa1
|
||||
then
|
||||
# Internal SPI BMI088
|
||||
bmi088 -A -R 2 -s start
|
||||
bmi088 -G -R 2 -s start
|
||||
else
|
||||
# Internal SPI bus ICM20649
|
||||
icm20649 -s -R 4 start
|
||||
fi
|
||||
|
||||
# Internal SPI bus ICM42688p
|
||||
icm42688p -R 4 -s start
|
||||
|
||||
# Internal SPI bus ICM-20602 (hard-mounted)
|
||||
icm20602 -R 8 -s start
|
||||
|
||||
# Internal magnetometer on I2c
|
||||
bmm150 -I -R 6 start
|
||||
|
||||
else
|
||||
#FMUv5Xbase board orientation
|
||||
|
||||
if ver hwtypecmp V5X00 V5X01
|
||||
if ver hwtypecmp V5X000000 V5X000001
|
||||
then
|
||||
# Internal SPI BMI088
|
||||
bmi088 -A -R 4 -s start
|
||||
@@ -77,6 +55,28 @@ else
|
||||
# Internal magnetometer on I2c
|
||||
bmm150 -I start
|
||||
|
||||
else
|
||||
#SKYNODE base fmu board orientation
|
||||
|
||||
if ver hwtypecmp V5X009000 V5X009001 V5X00a000 V5X00a001 V5X008000 V5X008001 V5X010001
|
||||
then
|
||||
# Internal SPI BMI088
|
||||
bmi088 -A -R 2 -s start
|
||||
bmi088 -G -R 2 -s start
|
||||
else
|
||||
# Internal SPI bus ICM20649
|
||||
icm20649 -s -R 4 start
|
||||
fi
|
||||
|
||||
# Internal SPI bus ICM42688p
|
||||
icm42688p -R 4 -s start
|
||||
|
||||
# Internal SPI bus ICM-20602 (hard-mounted)
|
||||
icm20602 -R 8 -s start
|
||||
|
||||
# Internal magnetometer on I2c
|
||||
bmm150 -I -R 6 start
|
||||
|
||||
fi
|
||||
|
||||
# External compass on GPS1/I2C1 (the 3rd external bus): standard Holybro Pixhawk 4 or CUAV V5 GPS/compass puck (with lights, safety button, and buzzer)
|
||||
@@ -88,7 +88,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 V5X00 V5X90 V5Xa0
|
||||
if ver hwtypecmp V5X000000 V5X001000 V5X008000 V5X009000 V5X00a000
|
||||
then
|
||||
bmp388 -I start
|
||||
else
|
||||
|
||||
@@ -111,6 +111,8 @@
|
||||
*
|
||||
* Note that these are unshifted addresses.
|
||||
*/
|
||||
|
||||
#define BOARD_MTD_NUM_EEPROM 2 /* MTD: base_eeprom, imu_eeprom*/
|
||||
#define PX4_I2C_OBDEV_SE050 0x48
|
||||
|
||||
#define GPIO_I2C4_DRDY1_BMP388 /* PG5 */ (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTG|GPIO_PIN5)
|
||||
@@ -182,21 +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 {'V','5','X','x', 'x',0}
|
||||
#define HW_INFO_INIT_VER 3 /* Offset in above string of the VER */
|
||||
#define HW_INFO_INIT_REV 4 /* Offset in above string of the REV */
|
||||
#define HW_INFO_INIT_PREFIX "V5X"
|
||||
#define BOARD_NUM_SPI_CFG_HW_VERSIONS 3
|
||||
// Base FMUM
|
||||
#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 V5X80 HW_VER_REV(0x8,0x0) // USB (Q), Rev 0
|
||||
#define V5X81 HW_VER_REV(0x8,0x1) // USB (Q) I2C2 BMP388, Rev 1
|
||||
#define V5X82 HW_VER_REV(0x8,0x2) // USB (Q) I2C2 BMP388, 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
|
||||
|
||||
/* HEATER
|
||||
* PWM in future
|
||||
|
||||
@@ -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>
|
||||
@@ -72,6 +70,7 @@ extern "C" {
|
||||
#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>
|
||||
@@ -221,6 +220,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(),
|
||||
@@ -230,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");
|
||||
@@ -266,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) {
|
||||
|
||||
@@ -118,12 +118,16 @@ static px4_hw_mft_list_entry_t mft_lists[] = {
|
||||
{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
|
||||
{V5X80, hw_mft_list_v0500, arraySize(hw_mft_list_v0500)}, // USB (Q), Rev 0
|
||||
{V5X81, hw_mft_list_v0500, arraySize(hw_mft_list_v0500)}, // USB (Q) I2C2 BMP388, Rev 1
|
||||
{V5X82, hw_mft_list_v0500, arraySize(hw_mft_list_v0500)}, // USB (Q) I2C2 BMP388, 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
|
||||
};
|
||||
|
||||
/************************************************************************************
|
||||
@@ -146,7 +150,7 @@ __EXPORT px4_hw_mft_item board_query_manifest(px4_hw_mft_item_id_t id)
|
||||
static px4_hw_mft_list_entry boards_manifest = px4_hw_mft_list_uninitialized;
|
||||
|
||||
if (boards_manifest == px4_hw_mft_list_uninitialized) {
|
||||
uint32_t ver_rev = board_get_hw_version() << 8;
|
||||
uint32_t ver_rev = board_get_hw_version() << 16;
|
||||
ver_rev |= board_get_hw_revision();
|
||||
|
||||
for (unsigned i = 0; i < arraySize(mft_lists); i++) {
|
||||
@@ -157,7 +161,7 @@ __EXPORT px4_hw_mft_item board_query_manifest(px4_hw_mft_item_id_t id)
|
||||
}
|
||||
|
||||
if (boards_manifest == px4_hw_mft_list_uninitialized) {
|
||||
syslog(LOG_ERR, "[boot] Board %4" PRIx32 " is not supported!\n", ver_rev);
|
||||
syslog(LOG_ERR, "[boot] Board %08" PRIx32 " is not supported!\n", ver_rev);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -117,10 +117,12 @@ static const px4_mft_entry_s mtd_mft = {
|
||||
|
||||
static const px4_mft_s mft = {
|
||||
.nmft = 1,
|
||||
.mfts = &mtd_mft
|
||||
.mfts = {
|
||||
&mtd_mft
|
||||
}
|
||||
};
|
||||
|
||||
const px4_mft_s *board_get_manifest(void)
|
||||
{
|
||||
return &mft;
|
||||
}
|
||||
}
|
||||
@@ -173,9 +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 {'V','6','U','x', 'x',0}
|
||||
#define HW_INFO_INIT_VER 3 /* Offset in above string of the VER */
|
||||
#define HW_INFO_INIT_REV 4 /* Offset in above string of the REV */
|
||||
#define HW_INFO_INIT_PREFIX "V6U"
|
||||
#define V6U00 HW_VER_REV(0x0,0x0)
|
||||
|
||||
/* HEATER
|
||||
* PWM in future
|
||||
|
||||
@@ -82,7 +82,7 @@ static const px4_hw_mft_item_t hw_mft_list_v0600[] = {
|
||||
};
|
||||
|
||||
static px4_hw_mft_list_entry_t mft_lists[] = {
|
||||
{0x0000, hw_mft_list_v0600, arraySize(hw_mft_list_v0600)},
|
||||
{V6U00, hw_mft_list_v0600, arraySize(hw_mft_list_v0600)},
|
||||
};
|
||||
|
||||
/************************************************************************************
|
||||
@@ -105,7 +105,7 @@ __EXPORT px4_hw_mft_item board_query_manifest(px4_hw_mft_item_id_t id)
|
||||
static px4_hw_mft_list_entry boards_manifest = px4_hw_mft_list_uninitialized;
|
||||
|
||||
if (boards_manifest == px4_hw_mft_list_uninitialized) {
|
||||
uint32_t ver_rev = board_get_hw_version() << 8;
|
||||
uint32_t ver_rev = board_get_hw_version() << 16;
|
||||
ver_rev |= board_get_hw_revision();
|
||||
|
||||
for (unsigned i = 0; i < arraySize(mft_lists); i++) {
|
||||
@@ -116,7 +116,7 @@ __EXPORT px4_hw_mft_item board_query_manifest(px4_hw_mft_item_id_t id)
|
||||
}
|
||||
|
||||
if (boards_manifest == px4_hw_mft_list_uninitialized) {
|
||||
syslog(LOG_ERR, "[boot] Board %4" PRIx32 " is not supported!\n", ver_rev);
|
||||
syslog(LOG_ERR, "[boot] Board %08" PRIx32 " is not supported!\n", ver_rev);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,9 @@ static const px4_mft_entry_s mtd_mft = {
|
||||
|
||||
static const px4_mft_s mft = {
|
||||
.nmft = 1,
|
||||
.mfts = &mtd_mft
|
||||
.mfts = {
|
||||
&mtd_mft
|
||||
}
|
||||
};
|
||||
|
||||
const px4_mft_s *board_get_manifest(void)
|
||||
|
||||
@@ -32,7 +32,7 @@ bmi088 -G -R 4 -s start
|
||||
# Internal SPI bus ICM42688p
|
||||
icm42688p -R 6 -s start
|
||||
|
||||
if ver hwtypecmp V6X03 V6X13
|
||||
if ver hwtypecmp V6X000003 V6X001003
|
||||
then
|
||||
# Internal SPI bus ICM-42670-P (hard-mounted)
|
||||
icm42670p -R 14 -s start
|
||||
@@ -50,7 +50,7 @@ ist8310 -X -b 1 -R 10 start
|
||||
# Possible internal Baro
|
||||
bmp388 -I -a 0x77 start
|
||||
|
||||
if ver hwtypecmp V6X00 V6X10
|
||||
if ver hwtypecmp V6X000000 V6X001000
|
||||
then
|
||||
bmp388 -I start
|
||||
else
|
||||
|
||||
@@ -211,9 +211,7 @@
|
||||
#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 {'V','6','X','x', 'x',0}
|
||||
#define HW_INFO_INIT_VER 3 /* Offset in above string of the VER */
|
||||
#define HW_INFO_INIT_REV 4 /* Offset in above string of the REV */
|
||||
#define HW_INFO_INIT_PREFIX "V6X"
|
||||
|
||||
#define BOARD_NUM_SPI_CFG_HW_VERSIONS 2 // Rev 0 and Rev 3 Sensor sets
|
||||
// Base/FMUM
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ __EXPORT px4_hw_mft_item board_query_manifest(px4_hw_mft_item_id_t id)
|
||||
static px4_hw_mft_list_entry boards_manifest = px4_hw_mft_list_uninitialized;
|
||||
|
||||
if (boards_manifest == px4_hw_mft_list_uninitialized) {
|
||||
uint32_t ver_rev = board_get_hw_version() << 8;
|
||||
uint32_t ver_rev = board_get_hw_version() << 16;
|
||||
ver_rev |= board_get_hw_revision();
|
||||
|
||||
for (unsigned i = 0; i < arraySize(mft_lists); i++) {
|
||||
@@ -135,7 +135,7 @@ __EXPORT px4_hw_mft_item board_query_manifest(px4_hw_mft_item_id_t id)
|
||||
}
|
||||
|
||||
if (boards_manifest == px4_hw_mft_list_uninitialized) {
|
||||
syslog(LOG_ERR, "[boot] Board %4" PRIx32 " is not supported!\n", ver_rev);
|
||||
syslog(LOG_ERR, "[boot] Board %08" PRIx32 " is not supported!\n", ver_rev);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,9 @@ static const px4_mft_entry_s mtd_mft = {
|
||||
|
||||
static const px4_mft_s mft = {
|
||||
.nmft = 1,
|
||||
.mfts = &mtd_mft
|
||||
.mfts = {
|
||||
&mtd_mft
|
||||
}
|
||||
};
|
||||
|
||||
const px4_mft_s *board_get_manifest(void)
|
||||
|
||||
@@ -173,10 +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 {'V','5','X','x', 'x',0}
|
||||
#define HW_INFO_INIT_VER 3 /* Offset in above string of the VER */
|
||||
#define HW_INFO_INIT_REV 4 /* Offset in above string of the REV */
|
||||
|
||||
#define HW_INFO_INIT_PREFIX "SDSA"
|
||||
#define SDSA0501 HW_VER_REV(0x05,0x01)
|
||||
/* HEATER
|
||||
* PWM in future
|
||||
*/
|
||||
|
||||
@@ -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)},
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -82,6 +82,10 @@
|
||||
#define BOARD_NUM_SPI_CFG_HW_VERSIONS 1
|
||||
#endif
|
||||
|
||||
#ifndef BOARD_MTD_NUM_EEPROM
|
||||
#define BOARD_MTD_NUM_EEPROM 1
|
||||
#endif
|
||||
|
||||
/* ADC defining tools
|
||||
* We want to normalize the V5 Sensing to V = (adc_dn) * ADC_V5_V_FULL_SCALE/(2 ^ ADC_BITS) * ADC_V5_SCALE)
|
||||
*/
|
||||
@@ -258,9 +262,12 @@
|
||||
|
||||
#if defined(BOARD_HAS_HW_VERSIONING)
|
||||
# define BOARD_HAS_VERSIONING 1
|
||||
# define HW_VER_REV(v,r) ((uint32_t)((v) & 0xff) << 8) | ((uint32_t)(r) & 0xff)
|
||||
# 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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -65,7 +65,7 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
const uint32_t nmft;
|
||||
const px4_mft_entry_s *mfts;
|
||||
const px4_mft_entry_s *mfts[];
|
||||
} px4_mft_s;
|
||||
|
||||
#include "px4_platform_common/mtd_manifest.h"
|
||||
@@ -88,6 +88,19 @@ __BEGIN_DECLS
|
||||
|
||||
__EXPORT const px4_mft_s *board_get_manifest(void);
|
||||
|
||||
/************************************************************************************
|
||||
* Name: board_get_base_eeprom_mtd_manifest
|
||||
*
|
||||
* Description:
|
||||
* A board will provide this function to return the mtd with eeprom manifest
|
||||
*
|
||||
* Returned Value:
|
||||
* pointer to mtd manifest
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
__EXPORT const px4_mtd_manifest_t *board_get_base_eeprom_mtd_manifest(void);
|
||||
|
||||
/************************************************************************************
|
||||
* Name: px4_mft_configure
|
||||
*
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define MAX_MTD_INSTANCES 5u
|
||||
|
||||
// The data needed to interface with mtd device's
|
||||
|
||||
typedef struct {
|
||||
@@ -60,7 +62,7 @@ typedef struct {
|
||||
* This can be Null if there are no mtd instances.
|
||||
*
|
||||
*/
|
||||
__EXPORT mtd_instance_s *px4_mtd_get_instances(unsigned int *count);
|
||||
__EXPORT mtd_instance_s **px4_mtd_get_instances(unsigned int *count);
|
||||
|
||||
/*
|
||||
Get device complete geometry or a device
|
||||
@@ -75,7 +77,9 @@ __EXPORT int px4_mtd_get_geometry(const mtd_instance_s *instance, unsigned long
|
||||
*/
|
||||
__EXPORT ssize_t px4_mtd_get_partition_size(const mtd_instance_s *instance, const char *partname);
|
||||
|
||||
FAR struct mtd_dev_s *px4_at24c_initialize(FAR struct i2c_master_s *dev,
|
||||
uint8_t address);
|
||||
int px4_at24c_initialize(FAR struct i2c_master_s *dev,
|
||||
uint8_t address, FAR struct mtd_dev_s **mtd_dev);
|
||||
|
||||
void px4_at24c_deinitialize(void);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
@@ -47,7 +47,7 @@ void px4_set_spi_buses_from_hw_version()
|
||||
#if defined(BOARD_HAS_SIMPLE_HW_VERSIONING)
|
||||
int hw_version_revision = board_get_hw_version();
|
||||
#else
|
||||
int hw_version_revision = (board_get_hw_version() << 8) | board_get_hw_revision();
|
||||
int hw_version_revision = (board_get_hw_version() << 16) | board_get_hw_revision();
|
||||
#endif
|
||||
|
||||
|
||||
@@ -66,12 +66,12 @@ void px4_set_spi_buses_from_hw_version()
|
||||
}
|
||||
}
|
||||
|
||||
const px4_spi_bus_t *px4_spi_buses{};
|
||||
const px4_spi_bus_t *px4_spi_buses{nullptr};
|
||||
#endif
|
||||
|
||||
int px4_find_spi_bus(uint32_t devid)
|
||||
{
|
||||
for (int i = 0; i < SPI_BUS_MAX_BUS_ITEMS; ++i) {
|
||||
for (int i = 0; px4_spi_buses != nullptr && i < SPI_BUS_MAX_BUS_ITEMS; ++i) {
|
||||
const px4_spi_bus_t &bus_data = px4_spi_buses[i];
|
||||
|
||||
if (bus_data.bus == -1) {
|
||||
|
||||
@@ -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
|
||||
*
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2021 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
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#define HW_VERSION_EEPROM 0x7 //!< Get hw_info from EEPROM
|
||||
#define HW_EEPROM_VERSION_MIN 0x10 //!< Minimum supported version
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
typedef struct {
|
||||
uint16_t id;
|
||||
} mtd_mft_t;
|
||||
|
||||
typedef struct {
|
||||
mtd_mft_t version;
|
||||
uint16_t hw_extended_ver;
|
||||
uint16_t crc;
|
||||
} mtd_mft_v0_t;
|
||||
|
||||
typedef struct {
|
||||
mtd_mft_t version;
|
||||
uint16_t hw_extended_ver;
|
||||
//{device tree overlay}
|
||||
uint16_t crc;
|
||||
} mtd_mft_v1_t;
|
||||
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#define MTD_MFT_v0 0U //<! EEPROM MTD MFT structure version 0
|
||||
#define MTD_MFT_v1 1U //<! EEPROM MTD MFT structure version 1
|
||||
|
||||
#define MTD_MFT_OFFSET 0 //<! Offset in EEPROM where mtd_mft data starts
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/************************************************************************************
|
||||
* Name: board_set_eeprom_hw_info
|
||||
*
|
||||
* Description:
|
||||
* 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:
|
||||
* 0 - Successful storing to EEPROM
|
||||
* -1 - Error while storing to EEPROM
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#if !defined(BOARD_HAS_SIMPLE_HW_VERSIONING) && defined(BOARD_HAS_VERSIONING)
|
||||
__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(const char *path, mtd_mft_t *mtd_mft_unk) { return -ENOSYS; }
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Name: board_get_eeprom_hw_info
|
||||
*
|
||||
* Description:
|
||||
* Function for reading hardware info from EEPROM
|
||||
*
|
||||
* Output Parameters:
|
||||
* *mtd_mft - pointer to mtd_mft to read hw_info
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 - Successful reading from EEPROM
|
||||
* -1 - Error while reading from EEPROM
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#if !defined(BOARD_HAS_SIMPLE_HW_VERSIONING) && defined(BOARD_HAS_VERSIONING)
|
||||
__EXPORT int board_get_eeprom_hw_info(const char *path, mtd_mft_t *mtd_mft);
|
||||
#else
|
||||
static inline int board_get_eeprom_hw_info(const char *path, mtd_mft_t *mtd_mft) { return -ENOSYS; }
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
@@ -70,6 +70,7 @@
|
||||
#include <nuttx/mtd/mtd.h>
|
||||
|
||||
#include <perf/perf_counter.h>
|
||||
#include <board_config.h>
|
||||
|
||||
/************************************************************************************
|
||||
* Pre-processor Definitions
|
||||
@@ -195,11 +196,8 @@ int at24c_nuke(void);
|
||||
* Private Data
|
||||
************************************************************************************/
|
||||
|
||||
/* At present, only a single AT24 part is supported. In this case, a statically
|
||||
* allocated state structure may be used.
|
||||
*/
|
||||
|
||||
static struct at24c_dev_s g_at24c;
|
||||
static uint8_t number_of_instances = 0u;
|
||||
static struct at24c_dev_s g_at24c[BOARD_MTD_NUM_EEPROM];
|
||||
|
||||
/************************************************************************************
|
||||
* Private Functions
|
||||
@@ -262,7 +260,7 @@ void at24c_test(void)
|
||||
unsigned errors = 0;
|
||||
|
||||
for (count = 0; count < 10000; count++) {
|
||||
ssize_t result = at24c_bread(&g_at24c.mtd, 0, 1, buf);
|
||||
ssize_t result = at24c_bread(&g_at24c[0].mtd, 0, 1, buf);
|
||||
|
||||
if (result == ERROR) {
|
||||
if (errors++ > 2) {
|
||||
@@ -538,13 +536,17 @@ static int at24c_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
|
||||
* other functions (such as a block or character driver front end).
|
||||
*
|
||||
************************************************************************************/
|
||||
FAR struct mtd_dev_s *px4_at24c_initialize(FAR struct i2c_master_s *dev,
|
||||
uint8_t address)
|
||||
int px4_at24c_initialize(FAR struct i2c_master_s *dev,
|
||||
uint8_t address, FAR struct mtd_dev_s **mtd_dev)
|
||||
|
||||
{
|
||||
if (number_of_instances >= BOARD_MTD_NUM_EEPROM) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
FAR struct at24c_dev_s *priv;
|
||||
|
||||
finfo("dev: %p\n", dev);
|
||||
finfo("dev: %p, mtd_dev %p\n", dev, mtd_dev);
|
||||
|
||||
/* Allocate a state structure (we allocate the structure instead of using
|
||||
* a fixed, static allocation so that we can handle multiple FLASH devices.
|
||||
@@ -553,7 +555,7 @@ FAR struct mtd_dev_s *px4_at24c_initialize(FAR struct i2c_master_s *dev,
|
||||
* to be extended to handle multiple FLASH parts on the same I2C bus.
|
||||
*/
|
||||
|
||||
priv = &g_at24c;
|
||||
priv = &g_at24c[number_of_instances];
|
||||
|
||||
if (priv) {
|
||||
/* Initialize the allocated structure */
|
||||
@@ -608,13 +610,13 @@ FAR struct mtd_dev_s *px4_at24c_initialize(FAR struct i2c_master_s *dev,
|
||||
priv->perf_resets_retries = NULL;
|
||||
priv->perf_errors = NULL;
|
||||
|
||||
return NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Return the implementation-specific state structure as the MTD device */
|
||||
*mtd_dev = (FAR struct mtd_dev_s *)priv;
|
||||
++number_of_instances;
|
||||
|
||||
finfo("Return %p\n", priv);
|
||||
return (FAR struct mtd_dev_s *)priv;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -622,5 +624,5 @@ FAR struct mtd_dev_s *px4_at24c_initialize(FAR struct i2c_master_s *dev,
|
||||
*/
|
||||
int at24c_nuke(void)
|
||||
{
|
||||
return at24c_eraseall(&g_at24c);
|
||||
return at24c_eraseall(&g_at24c[0]);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,9 @@ static const px4_mft_entry_s mtd_mft = {
|
||||
|
||||
static const px4_mft_s default_mft = {
|
||||
.nmft = 1,
|
||||
.mfts = &mtd_mft
|
||||
.mfts = {
|
||||
&mtd_mft
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -73,9 +75,9 @@ __EXPORT int px4_mft_configure(const px4_mft_s *mft)
|
||||
|
||||
if (mft != nullptr) {
|
||||
for (uint32_t m = 0; m < mft->nmft; m++) {
|
||||
switch (mft->mfts[m].type) {
|
||||
switch (mft->mfts[m]->type) {
|
||||
case MTD:
|
||||
px4_mtd_config(static_cast<const px4_mtd_manifest_t *>(mft->mfts[m].pmft));
|
||||
px4_mtd_config(static_cast<const px4_mtd_manifest_t *>(mft->mfts[m]->pmft));
|
||||
break;
|
||||
|
||||
case MFT:
|
||||
@@ -95,10 +97,10 @@ __EXPORT int px4_mft_query(const px4_mft_s *mft, px4_manifest_types_e type,
|
||||
|
||||
if (mft != nullptr) {
|
||||
for (uint32_t m = 0; m < mft->nmft; m++) {
|
||||
if (mft->mfts[m].type == 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:
|
||||
|
||||
@@ -64,7 +64,8 @@ extern "C" {
|
||||
off_t firstblock, off_t nblocks);
|
||||
}
|
||||
static int num_instances = 0;
|
||||
static mtd_instance_s *instances = nullptr;
|
||||
static int total_blocks = 0;
|
||||
static mtd_instance_s *instances[MAX_MTD_INSTANCES] = {};
|
||||
|
||||
|
||||
static int ramtron_attach(mtd_instance_s &instance)
|
||||
@@ -147,15 +148,19 @@ static int at24xxx_attach(mtd_instance_s &instance)
|
||||
|
||||
/* start the MTD driver, attempt 5 times */
|
||||
for (int i = 0; i < 5; i++) {
|
||||
instance.mtd_dev = px4_at24c_initialize(i2c, PX4_I2C_DEVID_ADDR(instance.devid));
|
||||
int ret_val = px4_at24c_initialize(i2c, PX4_I2C_DEVID_ADDR(instance.devid), &(instance.mtd_dev));
|
||||
|
||||
if (instance.mtd_dev) {
|
||||
if (ret_val == 0) {
|
||||
/* abort on first valid result */
|
||||
if (i > 0) {
|
||||
PX4_WARN("EEPROM needed %d attempts to attach", i + 1);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
} else if (ret_val == -ENOMEM) {
|
||||
PX4_ERR("Number of at24c EEPROM instances reached the board limit of %d", BOARD_MTD_NUM_EEPROM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,7 +235,7 @@ ssize_t px4_mtd_get_partition_size(const mtd_instance_s *instance, const char *p
|
||||
return instance->partition_block_counts[partn] * blocksize;
|
||||
}
|
||||
|
||||
mtd_instance_s *px4_mtd_get_instances(unsigned int *count)
|
||||
mtd_instance_s **px4_mtd_get_instances(unsigned int *count)
|
||||
{
|
||||
*count = num_instances;
|
||||
return instances;
|
||||
@@ -292,62 +297,69 @@ int px4_mtd_config(const px4_mtd_manifest_t *mft_mtd)
|
||||
}
|
||||
|
||||
rv = -ENOMEM;
|
||||
int total_blocks = 0;
|
||||
uint8_t total_new_instances = mtd_list->nconfigs + num_instances;
|
||||
|
||||
instances = new mtd_instance_s[mtd_list->nconfigs];
|
||||
|
||||
if (instances == nullptr) {
|
||||
memoryout:
|
||||
PX4_ERR("failed to allocate memory!");
|
||||
if (total_new_instances >= MAX_MTD_INSTANCES) {
|
||||
PX4_ERR("reached limit of max %u mtd instances", MAX_MTD_INSTANCES);
|
||||
return rv;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < mtd_list->nconfigs; i++) {
|
||||
for (uint8_t i = num_instances, num_entry = 0u; i < total_new_instances; ++i, ++num_entry) {
|
||||
|
||||
instances[i] = new mtd_instance_s;
|
||||
|
||||
if (instances == nullptr) {
|
||||
memoryout:
|
||||
PX4_ERR("failed to allocate memory!");
|
||||
return rv;
|
||||
}
|
||||
|
||||
num_instances++;
|
||||
uint32_t nparts = mtd_list->entries[i]->npart;
|
||||
instances[i].devid = mtd_list->entries[i]->device->devid;
|
||||
instances[i].mtd_dev = nullptr;
|
||||
instances[i].n_partitions_current = 0;
|
||||
|
||||
uint32_t nparts = mtd_list->entries[num_entry]->npart;
|
||||
instances[i]->devid = mtd_list->entries[num_entry]->device->devid;
|
||||
instances[i]->mtd_dev = nullptr;
|
||||
instances[i]->n_partitions_current = 0;
|
||||
|
||||
rv = -ENOMEM;
|
||||
instances[i].part_dev = new FAR struct mtd_dev_s *[nparts];
|
||||
instances[i]->part_dev = new FAR struct mtd_dev_s *[nparts];
|
||||
|
||||
if (instances[i].part_dev == nullptr) {
|
||||
if (instances[i]->part_dev == nullptr) {
|
||||
goto memoryout;
|
||||
}
|
||||
|
||||
instances[i].partition_block_counts = new int[nparts];
|
||||
instances[i]->partition_block_counts = new int[nparts];
|
||||
|
||||
if (instances[i].partition_block_counts == nullptr) {
|
||||
if (instances[i]->partition_block_counts == nullptr) {
|
||||
goto memoryout;
|
||||
}
|
||||
|
||||
instances[i].partition_types = new int[nparts];
|
||||
instances[i]->partition_types = new int[nparts];
|
||||
|
||||
if (instances[i].partition_types == nullptr) {
|
||||
if (instances[i]->partition_types == nullptr) {
|
||||
goto memoryout;
|
||||
}
|
||||
|
||||
instances[i].partition_names = new const char *[nparts];
|
||||
instances[i]->partition_names = new const char *[nparts];
|
||||
|
||||
if (instances[i].partition_names == nullptr) {
|
||||
if (instances[i]->partition_names == nullptr) {
|
||||
goto memoryout;
|
||||
}
|
||||
|
||||
for (uint32_t p = 0; p < nparts; p++) {
|
||||
instances[i].partition_block_counts[p] = mtd_list->entries[i]->partd[p].nblocks;
|
||||
instances[i].partition_names[p] = mtd_list->entries[i]->partd[p].path;
|
||||
instances[i].partition_types[p] = mtd_list->entries[i]->partd[p].type;
|
||||
instances[i]->partition_block_counts[p] = mtd_list->entries[num_entry]->partd[p].nblocks;
|
||||
instances[i]->partition_names[p] = mtd_list->entries[num_entry]->partd[p].path;
|
||||
instances[i]->partition_types[p] = mtd_list->entries[num_entry]->partd[p].type;
|
||||
}
|
||||
|
||||
if (mtd_list->entries[i]->device->bus_type == px4_mft_device_t::I2C) {
|
||||
rv = at24xxx_attach(instances[i]);
|
||||
if (mtd_list->entries[num_entry]->device->bus_type == px4_mft_device_t::I2C) {
|
||||
rv = at24xxx_attach(*instances[i]);
|
||||
|
||||
} else if (mtd_list->entries[i]->device->bus_type == px4_mft_device_t::SPI) {
|
||||
rv = ramtron_attach(instances[i]);
|
||||
} else if (mtd_list->entries[num_entry]->device->bus_type == px4_mft_device_t::SPI) {
|
||||
rv = ramtron_attach(*instances[i]);
|
||||
|
||||
} else if (mtd_list->entries[i]->device->bus_type == px4_mft_device_t::ONCHIP) {
|
||||
instances[i].n_partitions_current++;
|
||||
} else if (mtd_list->entries[num_entry]->device->bus_type == px4_mft_device_t::ONCHIP) {
|
||||
instances[i]->n_partitions_current++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -362,7 +374,7 @@ memoryout:
|
||||
unsigned int nblocks;
|
||||
unsigned int partsize;
|
||||
|
||||
rv = px4_mtd_get_geometry(&instances[i], &blocksize, &erasesize, &neraseblocks, &blkpererase, &nblocks, &partsize);
|
||||
rv = px4_mtd_get_geometry(instances[i], &blocksize, &erasesize, &neraseblocks, &blkpererase, &nblocks, &partsize);
|
||||
|
||||
if (rv != 0) {
|
||||
goto errout;
|
||||
@@ -375,13 +387,13 @@ memoryout:
|
||||
unsigned long offset;
|
||||
unsigned part;
|
||||
|
||||
for (offset = 0, part = 0; rv == 0 && part < nparts; offset += instances[i].partition_block_counts[part], part++) {
|
||||
for (offset = 0, part = 0; rv == 0 && part < nparts; offset += instances[i]->partition_block_counts[part], part++) {
|
||||
|
||||
/* Create the partition */
|
||||
|
||||
instances[i].part_dev[part] = mtd_partition(instances[i].mtd_dev, offset, instances[i].partition_block_counts[part]);
|
||||
instances[i]->part_dev[part] = mtd_partition(instances[i]->mtd_dev, offset, instances[i]->partition_block_counts[part]);
|
||||
|
||||
if (instances[i].part_dev[part] == nullptr) {
|
||||
if (instances[i]->part_dev[part] == nullptr) {
|
||||
PX4_ERR("mtd_partition failed. offset=%lu nblocks=%u",
|
||||
offset, nblocks);
|
||||
rv = -ENOSPC;
|
||||
@@ -392,7 +404,7 @@ memoryout:
|
||||
|
||||
snprintf(blockname, sizeof(blockname), "/dev/mtdblock%d", total_blocks);
|
||||
|
||||
rv = ftl_initialize(total_blocks, instances[i].part_dev[part]);
|
||||
rv = ftl_initialize(total_blocks, instances[i]->part_dev[part]);
|
||||
|
||||
if (rv < 0) {
|
||||
PX4_ERR("ftl_initialize %s failed: %d", blockname, rv);
|
||||
@@ -403,14 +415,14 @@ memoryout:
|
||||
|
||||
/* Now create a character device on the block device */
|
||||
|
||||
rv = bchdev_register(blockname, instances[i].partition_names[part], false);
|
||||
rv = bchdev_register(blockname, instances[i]->partition_names[part], false);
|
||||
|
||||
if (rv < 0) {
|
||||
PX4_ERR("bchdev_register %s failed: %d", instances[i].partition_names[part], rv);
|
||||
PX4_ERR("bchdev_register %s failed: %d", instances[i]->partition_names[part], rv);
|
||||
goto errout;
|
||||
}
|
||||
|
||||
instances[i].n_partitions_current++;
|
||||
instances[i]->n_partitions_current++;
|
||||
}
|
||||
|
||||
errout:
|
||||
@@ -418,9 +430,9 @@ errout:
|
||||
if (rv < 0) {
|
||||
PX4_ERR("mtd failure: %d bus %" PRId32 " address %" PRId32 " class %d",
|
||||
rv,
|
||||
PX4_I2C_DEVID_BUS(instances[i].devid),
|
||||
PX4_I2C_DEVID_ADDR(instances[i].devid),
|
||||
mtd_list->entries[i]->partd[instances[i].n_partitions_current].type);
|
||||
PX4_I2C_DEVID_BUS(instances[i]->devid),
|
||||
PX4_I2C_DEVID_ADDR(instances[i]->devid),
|
||||
mtd_list->entries[num_entry]->partd[instances[i]->n_partitions_current].type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -452,14 +464,14 @@ __EXPORT int px4_mtd_query(const char *sub, const char *val, const char **get)
|
||||
rv = -ENOENT;
|
||||
|
||||
for (int i = 0; i < num_instances; i++) {
|
||||
for (unsigned n = 0; n < instances[i].n_partitions_current; n++) {
|
||||
if (instances[i].partition_types[n] == key) {
|
||||
for (unsigned n = 0; n < instances[i]->n_partitions_current; n++) {
|
||||
if (instances[i]->partition_types[n] == key) {
|
||||
if (get != nullptr && val == nullptr) {
|
||||
*get = instances[i].partition_names[n];
|
||||
*get = instances[i]->partition_names[n];
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (val != nullptr && strcmp(instances[i].partition_names[n], val) == 0) {
|
||||
if (val != nullptr && strcmp(instances[i]->partition_names[n], val) == 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
@@ -52,12 +52,16 @@
|
||||
# define GPIO_HW_REV_DRIVE GPIO_HW_VER_REV_DRIVE
|
||||
# define GPIO_HW_VER_DRIVE GPIO_HW_VER_REV_DRIVE
|
||||
# endif
|
||||
|
||||
#define HW_INFO_SIZE (int) arraySize(HW_INFO_INIT_PREFIX) + HW_INFO_VER_DIGITS + HW_INFO_REV_DIGITS
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
static int hw_version = 0;
|
||||
static int hw_revision = 0;
|
||||
static char hw_info[] = HW_INFO_INIT;
|
||||
static char hw_info[HW_INFO_SIZE] = {0};
|
||||
|
||||
/****************************************************************************
|
||||
* Protected Functions
|
||||
@@ -193,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) */
|
||||
@@ -204,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;
|
||||
}
|
||||
@@ -338,8 +342,12 @@ int board_determine_hw_info()
|
||||
int rv = determine_hw_info(&hw_revision, &hw_version);
|
||||
|
||||
if (rv == OK) {
|
||||
hw_info[HW_INFO_INIT_REV] = board_get_hw_revision() + '0';
|
||||
hw_info[HW_INFO_INIT_VER] = board_get_hw_version() + '0';
|
||||
|
||||
if (rv == OK) {
|
||||
|
||||
snprintf(hw_info, sizeof(hw_info), HW_INFO_INIT_PREFIX HW_INFO_SUFFIX, hw_version, hw_revision);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
||||
@@ -34,4 +34,4 @@
|
||||
px4_add_library(arch_board_hw_info
|
||||
board_hw_rev_ver.c
|
||||
)
|
||||
target_link_libraries(arch_board_hw_info PRIVATE arch_adc)
|
||||
target_link_libraries(arch_board_hw_info PRIVATE arch_adc systemlib)
|
||||
|
||||
@@ -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,10 +41,14 @@
|
||||
#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>
|
||||
#include <fcntl.h>
|
||||
#include <board_config.h>
|
||||
|
||||
#include <systemlib/crc.h>
|
||||
#include <systemlib/px4_macros.h>
|
||||
|
||||
#if defined(BOARD_HAS_HW_VERSIONING)
|
||||
@@ -53,12 +57,16 @@
|
||||
# define GPIO_HW_REV_DRIVE GPIO_HW_VER_REV_DRIVE
|
||||
# define GPIO_HW_VER_DRIVE GPIO_HW_VER_REV_DRIVE
|
||||
# endif
|
||||
|
||||
#define HW_INFO_SIZE (int) arraySize(HW_INFO_INIT_PREFIX) + HW_INFO_VER_DIGITS + HW_INFO_REV_DIGITS
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
static int hw_version = 0;
|
||||
static int hw_revision = 0;
|
||||
static char hw_info[] = HW_INFO_INIT;
|
||||
static char hw_info[HW_INFO_SIZE] = {0};
|
||||
|
||||
/****************************************************************************
|
||||
* Protected Functions
|
||||
@@ -437,18 +445,170 @@ __EXPORT int board_get_hw_revision()
|
||||
|
||||
int board_determine_hw_info()
|
||||
{
|
||||
// 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) {
|
||||
|
||||
hw_info[HW_INFO_INIT_REV] = board_get_hw_revision() < 10 ?
|
||||
board_get_hw_revision() + '0' :
|
||||
board_get_hw_revision() + 'a' - 10;
|
||||
hw_info[HW_INFO_INIT_VER] = board_get_hw_version() < 10 ?
|
||||
board_get_hw_version() + '0' :
|
||||
board_get_hw_version() + 'a' - 10;
|
||||
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(path, (mtd_mft_t *)&mtd_mft);
|
||||
|
||||
if (rv == OK) {
|
||||
hw_version = mtd_mft.hw_extended_ver;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rv == OK) {
|
||||
snprintf(hw_info, sizeof(hw_info), HW_INFO_INIT_PREFIX HW_INFO_SUFFIX, hw_version, hw_revision);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
* Name: board_set_eeprom_hw_info
|
||||
*
|
||||
* Description:
|
||||
* Function for writing hardware info to EEPROM
|
||||
*
|
||||
* Input Parameters:
|
||||
* *mtd_mft_unk - pointer to mtd_mft to write hw_info
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 - Successful storing to EEPROM
|
||||
* -1 - Error while storing to EEPROM
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
int board_set_eeprom_hw_info(const char *path, mtd_mft_t *mtd_mft_unk)
|
||||
{
|
||||
if (mtd_mft_unk == NULL || path == NULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
// Later this will be a demux on type
|
||||
if (mtd_mft_unk->id != MTD_MFT_v0) {
|
||||
printf("Verson is: %d, Only mft version %d is supported\n", mtd_mft_unk->id, MTD_MFT_v0);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mtd_mft_v0_t *mtd_mft = (mtd_mft_v0_t *)mtd_mft_unk;
|
||||
|
||||
if (mtd_mft->hw_extended_ver < HW_EEPROM_VERSION_MIN) {
|
||||
printf("hardware version for EEPROM must be greater than %x\n", HW_EEPROM_VERSION_MIN);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
int fd = open(path, O_WRONLY);
|
||||
|
||||
if (fd < 0) {
|
||||
return -errno;
|
||||
}
|
||||
|
||||
int ret_val = OK;
|
||||
|
||||
mtd_mft->crc = crc16_signature(CRC16_INITIAL, sizeof(*mtd_mft) - sizeof(mtd_mft->crc), (uint8_t *) mtd_mft);
|
||||
|
||||
if (
|
||||
(MTD_MFT_OFFSET != lseek(fd, MTD_MFT_OFFSET, SEEK_SET)) ||
|
||||
(sizeof(*mtd_mft) != write(fd, mtd_mft, sizeof(*mtd_mft)))
|
||||
) {
|
||||
ret_val = -errno;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
* Name: board_get_eeprom_hw_info
|
||||
*
|
||||
* Description:
|
||||
* Function for reading hardware info from EEPROM
|
||||
*
|
||||
* Output Parameters:
|
||||
* *mtd_mft - pointer to mtd_mft to read hw_info
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 - Successful reading from EEPROM
|
||||
* -1 - Error while reading from EEPROM
|
||||
*
|
||||
************************************************************************************/
|
||||
__EXPORT int board_get_eeprom_hw_info(const char *path, mtd_mft_t *mtd_mft)
|
||||
{
|
||||
if (mtd_mft == NULL || path == NULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
int fd = open(path, O_RDONLY);
|
||||
|
||||
if (fd < 0) {
|
||||
return -errno;
|
||||
}
|
||||
|
||||
int ret_val = OK;
|
||||
mtd_mft_t format_version = {-1};
|
||||
|
||||
if (
|
||||
(MTD_MFT_OFFSET != lseek(fd, MTD_MFT_OFFSET, SEEK_SET)) ||
|
||||
(sizeof(format_version) != read(fd, &format_version, sizeof(format_version)))
|
||||
) {
|
||||
ret_val = -errno;
|
||||
|
||||
} else if (format_version.id != mtd_mft->id) {
|
||||
ret_val = -EPROTO;
|
||||
|
||||
} else {
|
||||
|
||||
uint16_t mft_size = 0;
|
||||
|
||||
switch (format_version.id) {
|
||||
case MTD_MFT_v0: mft_size = sizeof(mtd_mft_v0_t); break;
|
||||
|
||||
case MTD_MFT_v1: mft_size = sizeof(mtd_mft_v1_t); break;
|
||||
|
||||
default:
|
||||
printf("[boot] Error, unknown version %d of mtd_mft in EEPROM\n", format_version.id);
|
||||
ret_val = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ret_val == OK) {
|
||||
|
||||
if (
|
||||
(MTD_MFT_OFFSET != lseek(fd, MTD_MFT_OFFSET, SEEK_SET)) ||
|
||||
(mft_size != read(fd, mtd_mft, mft_size))
|
||||
) {
|
||||
ret_val = -errno;
|
||||
|
||||
} else {
|
||||
|
||||
union {
|
||||
uint16_t w;
|
||||
uint8_t b[2];
|
||||
} crc;
|
||||
|
||||
uint8_t *bytes = (uint8_t *) mtd_mft;
|
||||
crc.w = crc16_signature(CRC16_INITIAL, mft_size - sizeof(crc), bytes);
|
||||
uint8_t *eeprom_crc = &bytes[mft_size - sizeof(crc)];
|
||||
|
||||
if (!(crc.b[0] == eeprom_crc[0] && crc.b[1] == eeprom_crc[1])) {
|
||||
ret_val = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+11
-11
@@ -80,11 +80,11 @@ static int mtd_status(void)
|
||||
bool running = false;
|
||||
unsigned int num_instances;
|
||||
|
||||
const mtd_instance_s *instances = px4_mtd_get_instances(&num_instances);
|
||||
mtd_instance_s **instances = px4_mtd_get_instances(&num_instances);
|
||||
|
||||
if (instances) {
|
||||
for (unsigned int i = 0; i < num_instances; ++i) {
|
||||
if (instances[i].mtd_dev) {
|
||||
if (instances[i]->mtd_dev) {
|
||||
|
||||
unsigned long blocksize;
|
||||
unsigned long erasesize;
|
||||
@@ -93,7 +93,7 @@ static int mtd_status(void)
|
||||
unsigned int nblocks;
|
||||
unsigned int partsize;
|
||||
|
||||
ret = px4_mtd_get_geometry(&instances[i], &blocksize, &erasesize, &neraseblocks, &blkpererase, &nblocks, &partsize);
|
||||
ret = px4_mtd_get_geometry(instances[i], &blocksize, &erasesize, &neraseblocks, &blkpererase, &nblocks, &partsize);
|
||||
|
||||
if (ret == 0) {
|
||||
|
||||
@@ -102,17 +102,17 @@ static int mtd_status(void)
|
||||
printf(" blocksize: %lu\n", blocksize);
|
||||
printf(" erasesize: %lu\n", erasesize);
|
||||
printf(" neraseblocks: %lu\n", neraseblocks);
|
||||
printf(" No. partitions: %u\n", instances[i].n_partitions_current);
|
||||
printf(" No. partitions: %u\n", instances[i]->n_partitions_current);
|
||||
|
||||
|
||||
unsigned int totalnblocks = 0;
|
||||
unsigned int totalpartsize = 0;
|
||||
|
||||
for (unsigned int p = 0; p < instances[i].n_partitions_current; p++) {
|
||||
for (unsigned int p = 0; p < instances[i]->n_partitions_current; p++) {
|
||||
FAR struct mtd_geometry_s geo;
|
||||
ret = instances[i].part_dev[p]->ioctl(instances[i].part_dev[p], MTDIOC_GEOMETRY, (unsigned long)((uintptr_t)&geo));
|
||||
ret = instances[i]->part_dev[p]->ioctl(instances[i]->part_dev[p], MTDIOC_GEOMETRY, (unsigned long)((uintptr_t)&geo));
|
||||
printf(" partition: %u:\n", p);
|
||||
printf(" name: %s\n", instances[i].partition_names[p]);
|
||||
printf(" name: %s\n", instances[i]->partition_names[p]);
|
||||
printf(" blocks: %" PRIu32 " (%lu bytes)\n", geo.neraseblocks, erasesize * geo.neraseblocks);
|
||||
totalnblocks += geo.neraseblocks;
|
||||
totalpartsize += erasesize * geo.neraseblocks;
|
||||
@@ -323,7 +323,7 @@ int mtd_main(int argc, char *argv[])
|
||||
|
||||
if (myoptind < argc) {
|
||||
unsigned int num_instances;
|
||||
mtd_instance_s *instances = px4_mtd_get_instances(&num_instances);
|
||||
mtd_instance_s **instances = px4_mtd_get_instances(&num_instances);
|
||||
|
||||
if (instances == nullptr) {
|
||||
PX4_ERR("Driver not running");
|
||||
@@ -338,11 +338,11 @@ int mtd_main(int argc, char *argv[])
|
||||
#if !defined(CONSTRAINED_FLASH)
|
||||
|
||||
if (!strcmp(argv[myoptind], "readtest")) {
|
||||
return mtd_readtest(instances[instance]);
|
||||
return mtd_readtest(*instances[instance]);
|
||||
}
|
||||
|
||||
if (!strcmp(argv[myoptind], "rwtest")) {
|
||||
return mtd_rwtest(instances[instance]);
|
||||
return mtd_rwtest(*instances[instance]);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -352,7 +352,7 @@ int mtd_main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
if (!strcmp(argv[myoptind], "erase")) {
|
||||
return mtd_erase(instances[instance]);
|
||||
return mtd_erase(*instances[instance]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user