Hello community,
I am seeking assistance with integrating littlefs with the LPCxpresso55S16. I have encountered several difficulties due to the lack of documentation regarding the flash memory characteristics of the LPCXpresso55S16.
I have created the following functions and attempted to assign them to the lfs_config struct for initialization. However, I suspect that the other struct members I defined might be incorrect.
Currently, when executing the lfs_mount function, it calls the lfs_rawmount, and I receive LFS_ERR_CORRUPT during the execution of lfs_dir_fetchmatch. Upon investigation, I believe this error is related to corruption in the directory pair, as the pair[0] and pair[1] values of the dir variable are both 0 before executing this function.
Could someone assist me in mounting littlefs on the LPCXpresso55S16?
Here is the code:
********Created function *********
*************** lfs_config initialization *******
************** Main program ********
int main(void) {
/* Init board hardware. */
/* set BOD VBAT level to 1.65V */
POWER_SetBodVbatLevel(kPOWER_BodVbatLevel1650mv, kPOWER_BodHystLevel50mv, false);
/* attach 12 MHz clock to FLEXCOMM0 (debug console) */
CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH);
/* enable clock for GPIO*/
CLOCK_EnableClock(kCLOCK_Gpio0);
CLOCK_EnableClock(kCLOCK_Gpio1);
BOARD_InitBootPins();
BOARD_BootClockFROHF96M();
BOARD_InitDebugConsole();
flash_config_t flashInstance;
InitilizeFlashInstance(&flashInstance);
// mount the filesystem
int err =lfs_mount(&lfs, &cfg);
}
Something worth mentioning is that I have created the functions based on the IAP API to program the flash of the LPCXpresso55S16. These functions are used in the integration with littlefs to handle reading, writing, erasing, and synchronizing data in the flash memory.
Please let me know if you need any further information.
Ahmed.
Hello @ahmed007
How about refer to threads Erich share to you?
https://community.nxp.com/t5/LPC-Microcontrollers/Littlefs-LPCXpresso55S16/m-p/1667540
BR
Alice
Hello,
Thank you, Alice, for your response. I have some inquiries regarding the definition of certain variables for the LPCXpresso55S16, as it has a specific flash memory configuration.
Here are the variables I am unsure about:
lfs_config cfg = {
.read_size =
.prog_size =
.block_size =
.block_count =
.cache_size =
.lookahead_size =
.read_buffer =
.prog_buffer =
.lookahead_buffer =
}
Additionally, I would like to determine the appropriate starting address for programming the flash. In my case, I have selected the address 0x38000 and defined it as follows:
#define FS_FLASH_OFFSET 0x38000
Lastly, I have utilized the IAP API to create the read, write, and erase functions, which will be assigned to the cfg struct instance. Could you please confirm if this approach is correct?
Thank you.
Best regards,
ahmed
Hello @ahmed007
Sorry I'm not very familiar with LittleFS, what about the definition meaning?
#define FS_FLASH_OFFSET 0x38000
For LPC55S1x 256 KB part, the total flash size can be used by customer is 244 KB.
BR
Alice