2023-07-04 01:37 PM
Hi all,
I'm currently working on a project that involves reading data from an audio codec using I2S and storing it on flash memory. For this task, my setup includes an STM32L083, CS4265, and a MT29F1G01 flash.
In my initial approach, I attempted to mount the flash as a filesystem using LittleFS (LFS). However, each time I try to mount the flash, I'm directed to the HardFault_Handler error.
As someone new to programming the STM32, I have managed to set up my environment in VSCode with the necessary extensions, and I'm able to compile, flash, and debug my code. Moreover, I've successfully written an interface driver for the flash, which lets me read and write data to it without issues.
I'm under the impression that I've correctly configured LFS with the following:
const struct lfs_config cfg = {
.read = mt29f1g01_lfs_read,
.prog = mt29f1g01_lfs_prog,
.erase = mt29f1g01_lfs_erase,
.sync = mt29f1g01_lfs_sync,
.read_size = 2048,
.prog_size = 2048,
.block_size = 64 * 2048,
.block_count = 1024,
.lookahead_size = 2048,
.cache_size = 2048,
.block_cycles = -1
};
I've attempted to mount the LittleFS with this code:
int err = lfs_mount(&lfs, &cfg);
if (err)
{
err = lfs_format(&lfs, &cfg);
if (err)
{
SEGGER_RTT_printf(0, "Error formatting the filesystem\r\n");
return -1;
}
err = lfs_mount(&lfs, &cfg);
if (err)
{
SEGGER_RTT_printf(0, "Error mounting the filesystem\r\n");
return -1;
}
}
Upon observing the call stack, it seems to originate from bl __libc_init_array in startup_stm32l083xx.s. I'm unsure if I'm interpreting this correctly.
I'm left wondering whether something in the LFS libraries could be causing the hard fault. How can I trace the root cause of this problem? Any help would be appreciated.
Thank you!
2023-07-04 01:57 PM
LittleFS - on which operating system you create the files ?
why not fatFS ?
2023-07-04 02:55 PM
Hi,
The files in question are generated by reading the serial audio data from the I2S interface of the codec. The same system will be used to read the data back for offboard streaming. Our setup does not include any SD cards or similar external storage mediums.
I've chosen LittleFS over FatFS because of its wear leveling feature, which we believe could prolong the lifespan of our onboard flash.
Thanks for your time!
2023-07-05 12:46 AM - edited 2023-07-05 12:47 AM
try to find reason for hard fault and find in source position , where it happens - to see, whats wrong there.
read here similar ...problem i had:
in debug -> right window , see SFR , cpu registers etc.