From 815eed2c6db04e21a85cfe1153320dc5829041fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Mi=C5=A1i=C4=87?= Date: Mon, 7 Nov 2022 17:26:14 +0100 Subject: [PATCH] mtd: add support for extended HW revision --- boards/ark/fmu-v6x/src/mtd.cpp | 13 +++++--- boards/px4/fmu-v5x/src/mtd.cpp | 13 +++++--- boards/px4/fmu-v6c/src/mtd.cpp | 9 ++++-- boards/px4/fmu-v6x/src/mtd.cpp | 13 +++++--- boards/sky-drones/smartap-airlink/src/mtd.cpp | 4 +-- .../px4_platform_common/mtd_manifest.h | 11 +++---- .../px4_platform/board_hw_eeprom_rev_ver.h | 12 ++++---- .../board_hw_info/board_hw_rev_ver.c | 30 ++++++++++++++----- 8 files changed, 71 insertions(+), 34 deletions(-) diff --git a/boards/ark/fmu-v6x/src/mtd.cpp b/boards/ark/fmu-v6x/src/mtd.cpp index e697ddc9d9..bc4aa33c80 100644 --- a/boards/ark/fmu-v6x/src/mtd.cpp +++ b/boards/ark/fmu-v6x/src/mtd.cpp @@ -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, diff --git a/boards/px4/fmu-v5x/src/mtd.cpp b/boards/px4/fmu-v5x/src/mtd.cpp index 4feb42baec..fc1e97d2c8 100644 --- a/boards/px4/fmu-v5x/src/mtd.cpp +++ b/boards/px4/fmu-v5x/src/mtd.cpp @@ -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, diff --git a/boards/px4/fmu-v6c/src/mtd.cpp b/boards/px4/fmu-v6c/src/mtd.cpp index a56daa90c7..b315ff399d 100644 --- a/boards/px4/fmu-v6c/src/mtd.cpp +++ b/boards/px4/fmu-v6c/src/mtd.cpp @@ -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, diff --git a/boards/px4/fmu-v6x/src/mtd.cpp b/boards/px4/fmu-v6x/src/mtd.cpp index 4feb42baec..fc1e97d2c8 100644 --- a/boards/px4/fmu-v6x/src/mtd.cpp +++ b/boards/px4/fmu-v6x/src/mtd.cpp @@ -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, diff --git a/boards/sky-drones/smartap-airlink/src/mtd.cpp b/boards/sky-drones/smartap-airlink/src/mtd.cpp index f8f553b8c6..8b74a4617c 100644 --- a/boards/sky-drones/smartap-airlink/src/mtd.cpp +++ b/boards/sky-drones/smartap-airlink/src/mtd.cpp @@ -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 }, { diff --git a/platforms/common/include/px4_platform_common/mtd_manifest.h b/platforms/common/include/px4_platform_common/mtd_manifest.h index 52fe71e6b0..0bf8b52619 100644 --- a/platforms/common/include/px4_platform_common/mtd_manifest.h +++ b/platforms/common/include/px4_platform_common/mtd_manifest.h @@ -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; diff --git a/platforms/nuttx/src/px4/common/include/px4_platform/board_hw_eeprom_rev_ver.h b/platforms/nuttx/src/px4/common/include/px4_platform/board_hw_eeprom_rev_ver.h index 93672affce..8f4f671403 100644 --- a/platforms/nuttx/src/px4/common/include/px4_platform/board_hw_eeprom_rev_ver.h +++ b/platforms/nuttx/src/px4/common/include/px4_platform/board_hw_eeprom_rev_ver.h @@ -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 + +#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; //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; }