Merge branch 'main' into wip_new_uart_api

This commit is contained in:
Eric Katzfey
2024-03-05 08:56:53 -08:00
526 changed files with 20747 additions and 8647 deletions
+1
View File
@@ -51,6 +51,7 @@ add_library(px4_platform STATIC
px4_cli.cpp
shutdown.cpp
spi.cpp
pab_manifest.c
${SRCS}
)
target_link_libraries(px4_platform prebuild_targets px4_work_queue)
@@ -269,6 +269,18 @@
# define HW_VER_REV(v,r) ((uint32_t)((v) & 0xffff) << 16) | ((uint32_t)(r) & 0xffff)
#endif
#if defined(BOARD_HAS_HW_SPLIT_VERSIONING)
typedef uint16_t hw_fmun_id_t;
typedef uint16_t hw_base_id_t;
// Original Signals GPIO_HW_REV_SENSE/GPIO_HW_VER_REV_DRIVE is used to ID the FMUM
// Original Signals GPIO_HW_VER_SENSE/GPIO_HW_VER_REV_DRIVE is used to ID the BASE
# define BOARD_HAS_VERSIONING 1
# define HW_FMUM_ID(rev) ((hw_fmun_id_t)(rev) & 0xffff)
# define HW_BASE_ID(ver) ((hw_base_id_t)(ver) & 0xffff)
# define GET_HW_FMUM_ID() (HW_FMUM_ID(board_get_hw_revision()))
# define GET_HW_BASE_ID() (HW_BASE_ID(board_get_hw_version()))
#endif
#define HW_INFO_REV_DIGITS 3
#define HW_INFO_VER_DIGITS 3
@@ -458,6 +470,15 @@ static inline bool board_rc_singlewire(const char *device) { return false; }
* A board may define RC_SERIAL_SWAP_RXTX, so that RC_SERIAL_PORT is configured
* as UART with RX/TX swapped.
*
* It can optionaly define RC_SERIAL_SWAP_USING_SINGLEWIRE If the board is wired
* with TX to the input (Swapped) and the SoC does not support U[S]ART level
* HW swapping, then use onewire to do the swap if and only if:
*
* RC_SERIAL_SWAP_USING_SINGLEWIRE is defined
* RC_SERIAL_SWAP_RXTX is defined
* TIOCSSWAP is defined and retuns !OK
* TIOCSSINGLEWIRE is defined
*
* Input Parameters:
* device: serial device, e.g. "/dev/ttyS0"
*
@@ -659,20 +680,51 @@ bool board_booted_by_px4(void);
************************************************************************************/
typedef enum {
PX4_MFT_PX4IO = 0,
PX4_MFT_USB = 1,
PX4_MFT_CAN2 = 2,
PX4_MFT_CAN3 = 3,
PX4_MFT_PX4IO = 0,
PX4_MFT_USB = 1,
PX4_MFT_CAN2 = 2,
PX4_MFT_CAN3 = 3,
PX4_MFT_PM2 = 4,
PX4_MFT_ETHERNET = 5,
PX4_MFT_T1_ETH = 6,
PX4_MFT_T100_ETH = 7,
PX4_MFT_T1000_ETH = 8,
} px4_hw_mft_item_id_t;
typedef int (*system_query_func_t)(const char *sub, const char *val, void *out);
#define PX4_MFT_MFT_TYPES { \
PX4_MFT_PX4IO, \
PX4_MFT_USB, \
PX4_MFT_CAN2, \
PX4_MFT_CAN3, \
PX4_MFT_PM2, \
PX4_MFT_ETHERNET, \
PX4_MFT_T1_ETH, \
PX4_MFT_T100_ETH, \
PX4_MFT_T1000_ETH }
#define PX4_MFT_MFT_STR_TYPES { \
"MFT_PX4IO", \
"MFT_USB", \
"MFT_CAN2", \
"MFT_CAN3", \
"MFT_PM2", \
"MFT_ETHERNET", \
"MFT_T1_ETH", \
"MFT_T100_ETH", \
"MFT_T1000_ETH", \
"MFT_T1000_ETH"}
typedef enum {
px4_hw_con_unknown = 0,
px4_hw_con_onboard = 1,
px4_hw_con_unknown = 0,
px4_hw_con_onboard = 1,
px4_hw_con_connector = 3,
} px4_hw_connection_t;
typedef struct {
unsigned int id: 16; /* The id px4_hw_mft_item_id_t */
unsigned int present: 1; /* 1 if this board have this item */
unsigned int mandatory: 1; /* 1 if this item has to be present and working */
unsigned int connection: 2; /* See px4_hw_connection_t */
@@ -684,7 +736,7 @@ typedef const px4_hw_mft_item_t *px4_hw_mft_item;
#if defined(BOARD_HAS_VERSIONING)
__EXPORT px4_hw_mft_item board_query_manifest(px4_hw_mft_item_id_t id);
__EXPORT int system_query_manifest(const char *sub, const char *val, void *out);
# define PX4_MFT_HW_SUPPORTED(ID) (board_query_manifest((ID))->present)
# define PX4_MFT_HW_REQUIRED(ID) (board_query_manifest((ID))->mandatory)
# define PX4_MFT_HW_IS_ONBOARD(ID) (board_query_manifest((ID))->connection == px4_hw_con_onboard)
@@ -757,6 +809,26 @@ __EXPORT const char *board_get_hw_type_name(void);
#define board_get_hw_type_name() ""
#endif
/************************************************************************************
* Name: board_get_hw_base_type_name
*
* Description:
* Optional returns a 0 terminated string defining the HW type.
*
* Input Parameters:
* None
*
* Returned Value:
* a 0 terminated string defining the HW type. This may be a 0 length string ""
*
************************************************************************************/
#if defined(BOARD_HAS_HW_SPLIT_VERSIONING)
__EXPORT const char *board_get_hw_base_type_name(void);
#else
#define board_get_hw_base_type_name() ""
#endif
/************************************************************************************
* Name: board_get_hw_version
*
@@ -73,7 +73,11 @@ struct px4_spi_bus_t {
struct px4_spi_bus_all_hw_t {
px4_spi_bus_t buses[SPI_BUS_MAX_BUS_ITEMS];
int board_hw_version_revision{-1}; ///< 0=default, >0 for a specific revision (see board_get_hw_version & board_get_hw_revision), -1=unused
#if defined(BOARD_HAS_HW_SPLIT_VERSIONING)
hw_fmun_id_t board_hw_fmun_id {USHRT_MAX};
#else
int board_hw_version_revision {-1}; ///< 0=default, >0 for a specific revision (see board_get_hw_version & board_get_hw_revision), -1=unused
#endif
};
#if BOARD_NUM_SPI_CFG_HW_VERSIONS > 1
+446
View File
@@ -0,0 +1,446 @@
/****************************************************************************
*
* Copyright (c) 2024 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.
*
****************************************************************************/
/**
* @file pab_manifest.c
*
* This module supplies the interface to the manifest of hardware that is
* optional and dependent on the HW_BASE_ID
*
* The manifest allows the system to know whether a hardware option
* say for example the PX4IO is an no-pop option vs it is broken.
*
*/
/****************************************************************************
* Included Files
****************************************************************************/
#include <board_config.h>
#if defined(BOARD_HAS_HW_SPLIT_VERSIONING)
#include <inttypes.h>
#include <stdbool.h>
#include <syslog.h>
#include "systemlib/px4_macros.h"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
typedef struct {
hw_base_id_t hw_base_id; /* The ID of the Base */
const px4_hw_mft_item_t *mft; /* The first entry */
uint32_t entries; /* the lenght of the list */
} px4_hw_mft_list_entry_t;
typedef px4_hw_mft_list_entry_t *px4_hw_mft_list_entry;
#define px4_hw_mft_list_uninitialized (px4_hw_mft_list_entry) -1
static const px4_hw_mft_item_t device_unsupported = {0, 0, 0};
// List of components on a specific base board configuration
// The ids of those components is given by the enum (px4_hw_mft_item_id_t)
// declared in board_common.h
// BASE ID 0 Auterion vXx base board
static const px4_hw_mft_item_t base_configuration_0[] = {
{
.id = PX4_MFT_PX4IO,
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_onboard,
},
{
.id = PX4_MFT_USB,
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_onboard,
},
{
.id = PX4_MFT_CAN2,
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_onboard,
},
{
.id = PX4_MFT_CAN3,
.present = 0,
.mandatory = 0,
.connection = px4_hw_con_unknown,
},
{
.id = PX4_MFT_PM2,
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_onboard,
},
{
.id = PX4_MFT_ETHERNET,
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_connector,
},
{
.id = PX4_MFT_T100_ETH,
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_connector,
},
};
// BASE ID 1 vXx base without px4io
static const px4_hw_mft_item_t base_configuration_1[] = {
{
.id = PX4_MFT_PX4IO,
.present = 0,
.mandatory = 0,
.connection = px4_hw_con_unknown,
},
{
.id = PX4_MFT_USB,
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_onboard,
},
{
.id = PX4_MFT_CAN2,
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_onboard,
},
{
.id = PX4_MFT_CAN3,
.present = 0,
.mandatory = 0,
.connection = px4_hw_con_unknown,
},
{
.id = PX4_MFT_PM2,
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_onboard,
},
{
.id = PX4_MFT_ETHERNET,
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_connector,
},
{
.id = PX4_MFT_T100_ETH,
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_connector,
},
};
// BASE ID 2 Modal AI Alaised to ID 0
// BASE ID 3 NXP T1 PHY
static const px4_hw_mft_item_t base_configuration_3[] = {
{
.id = PX4_MFT_PX4IO,
.present = 0,
.mandatory = 0,
.connection = px4_hw_con_unknown,
},
{
.id = PX4_MFT_USB,
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_onboard,
},
{
.id = PX4_MFT_CAN2,
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_onboard,
},
{
.id = PX4_MFT_CAN3,
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_onboard,
},
{
.id = PX4_MFT_PM2,
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_onboard,
},
{
.id = PX4_MFT_ETHERNET,
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_connector,
},
{
.id = PX4_MFT_T1_ETH,
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_connector,
},
};
// BASE ID 4 HB CM4 Alaised to ID 0
// BASE ID 5 HB min
static const px4_hw_mft_item_t base_configuration_5[] = {
{
.id = PX4_MFT_PX4IO,
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_onboard,
},
{
.id = PX4_MFT_USB,
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_onboard,
},
{
.id = PX4_MFT_CAN2,
.present = 0,
.mandatory = 0,
.connection = px4_hw_con_unknown,
},
{
.id = PX4_MFT_CAN3,
.present = 0,
.mandatory = 0,
.connection = px4_hw_con_unknown,
},
{
.id = PX4_MFT_ETHERNET,
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_connector,
},
{
.id = PX4_MFT_T100_ETH,
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_connector,
},
};
// BASE ID 6 Not allocated
// BASE ID 7 Read from EEPROM
// BASE ID 8 Skynode QS with USB - Alaised to ID 0
// BASE ID 9 Auterion Skynode base RC9 & older (no usb
static const px4_hw_mft_item_t base_configuration_9[] = {
{
.id = PX4_MFT_PX4IO,
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_onboard,
},
{
.id = PX4_MFT_USB,
.present = 0,
.mandatory = 0,
.connection = px4_hw_con_unknown,
},
{
.id = PX4_MFT_CAN2,
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_onboard,
},
{
.id = PX4_MFT_CAN3,
.present = 0,
.mandatory = 0,
.connection = px4_hw_con_unknown,
},
{
.id = PX4_MFT_PM2,
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_onboard,
},
{
.id = PX4_MFT_ETHERNET,
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_connector,
},
{
.id = PX4_MFT_T100_ETH,
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_onboard,
},
};
// BASE ID 10 Skynode QS no USB Alaised to ID 9
// BASE ID 16 Auterion Skynode RC10, RC11, RC12, RC13 Alaised to ID 0
// BASE ID 17 Auterion Skynode RC13 with many parts removed
static const px4_hw_mft_item_t base_configuration_17[] = {
{
.id = PX4_MFT_PX4IO,
.present = 0,
.mandatory = 0,
.connection = px4_hw_con_onboard,
},
{
.id = PX4_MFT_USB,
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_unknown,
},
{
.id = PX4_MFT_CAN2,
.present = 0,
.mandatory = 0,
.connection = px4_hw_con_onboard,
},
{
.id = PX4_MFT_CAN3,
.present = 0,
.mandatory = 0,
.connection = px4_hw_con_unknown,
},
{
.id = PX4_MFT_PM2,
.present = 0,
.mandatory = 0,
.connection = px4_hw_con_onboard,
},
{
.id = PX4_MFT_ETHERNET,
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_connector,
},
{
.id = PX4_MFT_T100_ETH,
.present = 1,
.mandatory = 1,
.connection = px4_hw_con_onboard,
},
};
static px4_hw_mft_list_entry_t mft_lists[] = {
// ver_rev
{HW_BASE_ID(0), base_configuration_0, arraySize(base_configuration_0)}, // std Base with PX4IO
{HW_BASE_ID(1), base_configuration_1, arraySize(base_configuration_1)}, // std Base No PX4IO
{HW_BASE_ID(2), base_configuration_0, arraySize(base_configuration_0)}, // CUAV Base
{HW_BASE_ID(3), base_configuration_3, arraySize(base_configuration_3)}, // NXP T1 PHY
{HW_BASE_ID(4), base_configuration_0, arraySize(base_configuration_0)}, // HB CM4 base
{HW_BASE_ID(5), base_configuration_5, arraySize(base_configuration_5)}, // HB Mini
{HW_BASE_ID(8), base_configuration_0, arraySize(base_configuration_0)}, // Auterion Skynode ver 8 Aliased to 0
{HW_BASE_ID(9), base_configuration_9, arraySize(base_configuration_9)}, // Auterion Skynode ver 9
{HW_BASE_ID(10), base_configuration_9, arraySize(base_configuration_9)}, // Auterion Skynode ver 10
{HW_BASE_ID(16), base_configuration_0, arraySize(base_configuration_0)}, // Auterion Skynode ver 16
{HW_BASE_ID(17), base_configuration_17, arraySize(base_configuration_17)}, // Auterion Skynode ver 17
};
/************************************************************************************
* Name: base_query_manifest
*
* Description:
* Optional returns manifest item.
*
* Input Parameters:
* manifest_id - the ID for the manifest item to retrieve
*
* Returned Value:
* 0 - item is not in manifest => assume legacy operations
* pointer to a manifest item
*
************************************************************************************/
__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) {
hw_base_id_t hw_base_id = GET_HW_BASE_ID();
for (unsigned i = 0; i < arraySize(mft_lists); i++) {
if (mft_lists[i].hw_base_id == hw_base_id) {
boards_manifest = &mft_lists[i];
break;
}
}
if (boards_manifest == px4_hw_mft_list_uninitialized) {
syslog(LOG_ERR, "[boot] Board %04" PRIx16 " is not supported!\n", hw_base_id);
}
}
px4_hw_mft_item rv = &device_unsupported;
if (boards_manifest != px4_hw_mft_list_uninitialized)
for (unsigned int ndx = 0; ndx < boards_manifest->entries; ndx++) {
if (boards_manifest->mft[ndx].id == id) {
rv = &boards_manifest->mft[id];
break;
}
}
return rv;
}
__EXPORT int system_query_manifest(const char *sub, const char *val, void *out)
{
static const char *keys[] = PX4_MFT_MFT_STR_TYPES;
static const px4_hw_mft_item_id_t item_ids[] = PX4_MFT_MFT_TYPES;
px4_hw_mft_item rv = &device_unsupported;
int id = -1;
int intval = atoi(val);
for (unsigned int k = 0; k < arraySize(keys); k++) {
if (!strcmp(keys[k], sub)) {
id = item_ids[k];
break;
}
}
if (id != -1) {
// In case we have to filter when a FMUM is mounted to a BASE
// For now just use the board
rv = board_query_manifest(id);
return rv->present == intval ? OK : -ENXIO;
}
return -ENOENT;
}
#endif
+21 -5
View File
@@ -44,12 +44,26 @@
#if BOARD_NUM_SPI_CFG_HW_VERSIONS > 1
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 = HW_VER_REV(board_get_hw_version(), board_get_hw_revision());
#endif
# if defined(BOARD_HAS_HW_SPLIT_VERSIONING)
int hw_fmun_id = GET_HW_FMUM_ID();
for (int i = 0; i < BOARD_NUM_SPI_CFG_HW_VERSIONS; ++i) {
if (!px4_spi_buses && px4_spi_buses_all_hw[i].board_hw_fmun_id == 0) {
px4_spi_buses = px4_spi_buses_all_hw[i].buses;
}
if (px4_spi_buses_all_hw[i].board_hw_fmun_id == hw_fmun_id) {
px4_spi_buses = px4_spi_buses_all_hw[i].buses;
}
}
# else
# if defined(BOARD_HAS_SIMPLE_HW_VERSIONING)
int hw_version_revision = board_get_hw_version();
# else
int hw_version_revision = HW_VER_REV(board_get_hw_version(), board_get_hw_revision());
# endif
for (int i = 0; i < BOARD_NUM_SPI_CFG_HW_VERSIONS; ++i) {
if (!px4_spi_buses && px4_spi_buses_all_hw[i].board_hw_version_revision == 0) {
@@ -61,6 +75,8 @@ void px4_set_spi_buses_from_hw_version()
}
}
# endif
if (!px4_spi_buses) { // fallback
px4_spi_buses = px4_spi_buses_all_hw[0].buses;
}