mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
mtd: add support for extended HW revision
This commit is contained in:
parent
855eb42c59
commit
815eed2c6d
@ -71,8 +71,8 @@ static const px4_mtd_entry_t base_eeprom = {
|
||||
.npart = 2,
|
||||
.partd = {
|
||||
{
|
||||
.type = MTD_MFT,
|
||||
.path = "/fs/mtd_mft",
|
||||
.type = MTD_MFT_VER,
|
||||
.path = "/fs/mtd_mft_ver",
|
||||
.nblocks = 248
|
||||
},
|
||||
{
|
||||
@ -86,12 +86,17 @@ static const px4_mtd_entry_t base_eeprom = {
|
||||
|
||||
static const px4_mtd_entry_t imu_eeprom = {
|
||||
.device = &i2c4,
|
||||
.npart = 2,
|
||||
.npart = 3,
|
||||
.partd = {
|
||||
{
|
||||
.type = MTD_CALDATA,
|
||||
.path = "/fs/mtd_caldata",
|
||||
.nblocks = 248
|
||||
.nblocks = 240
|
||||
},
|
||||
{
|
||||
.type = MTD_MFT_REV,
|
||||
.path = "/fs/mtd_mft_rev",
|
||||
.nblocks = 8
|
||||
},
|
||||
{
|
||||
.type = MTD_ID,
|
||||
|
||||
@ -71,8 +71,8 @@ static const px4_mtd_entry_t base_eeprom = {
|
||||
.npart = 2,
|
||||
.partd = {
|
||||
{
|
||||
.type = MTD_MFT,
|
||||
.path = "/fs/mtd_mft",
|
||||
.type = MTD_MFT_VER,
|
||||
.path = "/fs/mtd_mft_ver",
|
||||
.nblocks = 248
|
||||
},
|
||||
{
|
||||
@ -86,12 +86,17 @@ static const px4_mtd_entry_t base_eeprom = {
|
||||
|
||||
static const px4_mtd_entry_t imu_eeprom = {
|
||||
.device = &i2c4,
|
||||
.npart = 2,
|
||||
.npart = 3,
|
||||
.partd = {
|
||||
{
|
||||
.type = MTD_CALDATA,
|
||||
.path = "/fs/mtd_caldata",
|
||||
.nblocks = 248
|
||||
.nblocks = 240
|
||||
},
|
||||
{
|
||||
.type = MTD_MFT_REV,
|
||||
.path = "/fs/mtd_mft_rev",
|
||||
.nblocks = 8
|
||||
},
|
||||
{
|
||||
.type = MTD_ID,
|
||||
|
||||
@ -65,12 +65,17 @@ static const px4_mtd_entry_t fmum_fram = {
|
||||
|
||||
static const px4_mtd_entry_t imu_eeprom = {
|
||||
.device = &i2c4,
|
||||
.npart = 2,
|
||||
.npart = 3,
|
||||
.partd = {
|
||||
{
|
||||
.type = MTD_CALDATA,
|
||||
.path = "/fs/mtd_caldata",
|
||||
.nblocks = 248
|
||||
.nblocks = 240
|
||||
},
|
||||
{
|
||||
.type = MTD_MFT_REV,
|
||||
.path = "/fs/mtd_mft_rev",
|
||||
.nblocks = 8
|
||||
},
|
||||
{
|
||||
.type = MTD_ID,
|
||||
|
||||
@ -71,8 +71,8 @@ static const px4_mtd_entry_t base_eeprom = {
|
||||
.npart = 2,
|
||||
.partd = {
|
||||
{
|
||||
.type = MTD_MFT,
|
||||
.path = "/fs/mtd_mft",
|
||||
.type = MTD_MFT_VER,
|
||||
.path = "/fs/mtd_mft_ver",
|
||||
.nblocks = 248
|
||||
},
|
||||
{
|
||||
@ -86,12 +86,17 @@ static const px4_mtd_entry_t base_eeprom = {
|
||||
|
||||
static const px4_mtd_entry_t imu_eeprom = {
|
||||
.device = &i2c4,
|
||||
.npart = 2,
|
||||
.npart = 3,
|
||||
.partd = {
|
||||
{
|
||||
.type = MTD_CALDATA,
|
||||
.path = "/fs/mtd_caldata",
|
||||
.nblocks = 248
|
||||
.nblocks = 240
|
||||
},
|
||||
{
|
||||
.type = MTD_MFT_REV,
|
||||
.path = "/fs/mtd_mft_rev",
|
||||
.nblocks = 8
|
||||
},
|
||||
{
|
||||
.type = MTD_ID,
|
||||
|
||||
@ -66,8 +66,8 @@ static const px4_mtd_entry_t base_eeprom = {
|
||||
.npart = 2,
|
||||
.partd = {
|
||||
{
|
||||
.type = MTD_MFT,
|
||||
.path = "/fs/mtd_mft",
|
||||
.type = MTD_MFT_VER,
|
||||
.path = "/fs/mtd_mft_ver",
|
||||
.nblocks = 248
|
||||
},
|
||||
{
|
||||
|
||||
@ -37,12 +37,13 @@ typedef enum {
|
||||
MTD_PARAMETERS = 1,
|
||||
MTD_WAYPOINTS = 2,
|
||||
MTD_CALDATA = 3,
|
||||
MTD_MFT = 4,
|
||||
MTD_ID = 5,
|
||||
MTD_NET = 6,
|
||||
MTD_MFT_VER = 4,
|
||||
MTD_MFT_REV = 5,
|
||||
MTD_ID = 6,
|
||||
MTD_NET = 7
|
||||
} px4_mtd_types_t;
|
||||
#define PX4_MFT_MTD_TYPES {MTD_PARAMETERS, MTD_WAYPOINTS, MTD_CALDATA, MTD_MFT, MTD_ID, MTD_NET}
|
||||
#define PX4_MFT_MTD_STR_TYPES {"MTD_PARAMETERS", "MTD_WAYPOINTS", "MTD_CALDATA", "MTD_MFT", "MTD_ID", "MTD_NET"}
|
||||
#define PX4_MFT_MTD_TYPES {MTD_PARAMETERS, MTD_WAYPOINTS, MTD_CALDATA, MTD_MFT_VER, MTD_MFT_REV, MTD_ID, MTD_NET}
|
||||
#define PX4_MFT_MTD_STR_TYPES {"MTD_PARAMETERS", "MTD_WAYPOINTS", "MTD_CALDATA", "MTD_MFT_VER", "MTD_MFT_REV", "MTD_ID", "MTD_NET"}
|
||||
|
||||
typedef struct {
|
||||
const px4_mtd_types_t type;
|
||||
|
||||
@ -32,8 +32,10 @@
|
||||
****************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#define HW_VERSION_EEPROM 0x7 //!< Get hw_info from EEPROM
|
||||
#define HW_EEPROM_VERSION_MIN 0x10 //!< Minimum supported version
|
||||
#include <errno.h>
|
||||
|
||||
#define HW_ID_EEPROM 0x7 //!< Get hw_info from EEPROM
|
||||
#define HW_EEPROM_ID_MIN 0x10 //!< Minimum supported id (version/revision)
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
@ -43,13 +45,13 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
mtd_mft_t version;
|
||||
uint16_t hw_extended_ver;
|
||||
uint16_t hw_extended_id; //<! HW version for MTD_MFT_VER, HW revision for MTD_MFT_REV
|
||||
uint16_t crc;
|
||||
} mtd_mft_v0_t;
|
||||
|
||||
typedef struct {
|
||||
mtd_mft_t version;
|
||||
uint16_t hw_extended_ver;
|
||||
mtd_mft_t version;
|
||||
uint16_t hw_extended_id;
|
||||
//{device tree overlay}
|
||||
uint16_t crc;
|
||||
} mtd_mft_v1_t;
|
||||
|
||||
@ -445,22 +445,36 @@ __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) {
|
||||
|
||||
if (rvmft == OK && path != NULL && hw_version == HW_VERSION_EEPROM) {
|
||||
// MFT supported?
|
||||
const char *path;
|
||||
int rvmft = px4_mtd_query("MTD_MFT_VER", NULL, &path);
|
||||
|
||||
if (rvmft == OK && path != NULL && hw_version == HW_ID_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;
|
||||
hw_version = mtd_mft.hw_extended_id;
|
||||
}
|
||||
}
|
||||
|
||||
path = NULL;
|
||||
rvmft = px4_mtd_query("MTD_MFT_REV", NULL, &path);
|
||||
|
||||
if (rvmft == OK && path != NULL && hw_revision == HW_ID_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_revision = mtd_mft.hw_extended_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -495,14 +509,14 @@ int board_set_eeprom_hw_info(const char *path, mtd_mft_t *mtd_mft_unk)
|
||||
|
||||
// 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);
|
||||
printf("Version 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);
|
||||
if (mtd_mft->hw_extended_id < HW_EEPROM_ID_MIN) {
|
||||
printf("hardware version for EEPROM must be greater than %x\n", HW_EEPROM_ID_MIN);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user