Skip to content

Commit

Permalink
fmu-v6x-rt Switch FRAM driver to use LittleFS
Browse files Browse the repository at this point in the history
  • Loading branch information
PetervdPerk-NXP committed Feb 13, 2024
1 parent c78389a commit 40b6a3e
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 25 deletions.
1 change: 1 addition & 0 deletions boards/px4/fmu-v6xrt/default.px4board
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ CONFIG_BOARD_SERIAL_GPS2="/dev/ttyS3"
CONFIG_BOARD_SERIAL_TEL1="/dev/ttyS2"
CONFIG_BOARD_SERIAL_TEL2="/dev/ttyS5"
CONFIG_BOARD_SERIAL_TEL3="/dev/ttyS6"
CONFIG_BOARD_PARAM_FILE="/fs/fram/mtd_params"
CONFIG_DRIVERS_ADC_BOARD_ADC=y
CONFIG_DRIVERS_BAROMETER_BMP388=y
CONFIG_DRIVERS_BAROMETER_MS5611=y
Expand Down
4 changes: 4 additions & 0 deletions boards/px4/fmu-v6xrt/nuttx-config/nsh/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ CONFIG_FS_BINFS=y
CONFIG_FS_CROMFS=y
CONFIG_FS_FAT=y
CONFIG_FS_FATTIME=y
CONFIG_FS_LITTLEFS=y
CONFIG_FS_LITTLEFS_LOOKAHEAD_SIZE=8
CONFIG_FS_LITTLEFS_PROGRAM_SIZE_FACTOR=1
CONFIG_FS_LITTLEFS_READ_SIZE_FACTOR=4
CONFIG_FS_PROCFS=y
CONFIG_FS_PROCFS_MAX_TASKS=64
CONFIG_FS_PROCFS_REGISTER=y
Expand Down
29 changes: 29 additions & 0 deletions boards/px4/fmu-v6xrt/src/imxrt_flexspi_fram.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,7 @@ int flexspi_attach(mtd_instance_s *instance)
int imxrt_flexspi_fram_initialize(void)
{
uint8_t vendor_id;
struct mtd_dev_s *mtd_dev = &g_flexspi_nor.mtd;
int ret = -ENODEV;

/* Configure multiplexed pins as connected on the board */
Expand Down Expand Up @@ -690,6 +691,34 @@ int imxrt_flexspi_fram_initialize(void)
}
}

/* Register the MTD driver so that it can be accessed from the
* VFS.
*/

ret = register_mtddriver("/dev/fram", mtd_dev, 0755, NULL);

if (ret < 0) {
syslog(LOG_ERR, "ERROR: Failed to register MTD driver: %d\n",
ret);
}

/* mtd_dev->ioctl(mtd_dev, MTDIOC_BULKERASE, 0); */

#ifdef CONFIG_FS_LITTLEFS

/* Mount the LittleFS file system */

ret = nx_mount("/dev/fram", "/mnt/lfs", "littlefs", 0,
"autoformat");

if (ret < 0) {
syslog(LOG_ERR,
"ERROR: Failed to mount LittleFS at /mnt/lfs: %d\n",
ret);
}

#endif

return ret;
}
#endif /* CONFIG_IMXRT_FLEXSPI */
4 changes: 4 additions & 0 deletions boards/px4/fmu-v6xrt/src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,10 @@ __EXPORT int board_app_initialize(uintptr_t arg)

#endif

#ifdef CONFIG_IMXRT_FLEXSPI
imxrt_flexspi_fram_initialize();
#endif

#ifdef CONFIG_IMXRT_ENET
imxrt_netinitialize(0);
#endif
Expand Down
20 changes: 0 additions & 20 deletions boards/px4/fmu-v6xrt/src/mtd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,6 @@ static const px4_mft_device_t i2c6 = { // 24LC64T on BASE 8K 32 X 2
.devid = PX4_MK_I2C_DEVID(6, 0x51)
};


static const px4_mtd_entry_t fmum_fram = {
.device = &qspi_flash,
.npart = 2,
.partd = {
{
.type = MTD_PARAMETERS,
.path = "/fs/mtd_params",
.nblocks = 32
},
{
.type = MTD_WAYPOINTS,
.path = "/fs/mtd_waypoints",
.nblocks = 32

}
},
};

static const px4_mtd_entry_t base_eeprom = {
.device = &i2c6,
.npart = 2,
Expand Down Expand Up @@ -112,7 +93,6 @@ static const px4_mtd_entry_t imu_eeprom = {
static const px4_mtd_manifest_t board_mtd_config = {
.nconfigs = 3,
.entries = {
&fmum_fram,
&base_eeprom,
&imu_eeprom
}
Expand Down
5 changes: 0 additions & 5 deletions platforms/nuttx/src/px4/common/px4_mtd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,6 @@ int px4_mtd_config(const px4_mtd_manifest_t *mft_mtd)

} else if (mtd_list->entries[num_entry]->device->bus_type == px4_mft_device_t::SPI) {
rv = ramtron_attach(*instances[i]);
#if defined(HAS_FLEXSPI)

} else if (mtd_list->entries[num_entry]->device->bus_type == px4_mft_device_t::FLEXSPI) {
rv = flexspi_attach(instances[i]);
#endif

} else if (mtd_list->entries[num_entry]->device->bus_type == px4_mft_device_t::ONCHIP) {
instances[i]->n_partitions_current++;
Expand Down

0 comments on commit 40b6a3e

Please sign in to comment.