Hi. I got a HardFault_Handler when I try to write data on flash memory using the fds_record_update function in a RTOS environment (RTX5). My program has three tasks: one for managing the flash memory (read and write data), one to make blinking the LED 1 and another one to make blinking the LED 2. The program doesn't have problem for reading (fds_record_open), but it always falls in hard fault when I want to write, even if I comment the LED tasks (only the flash task is active). I also tried the code without RTOS and it worked fine, so I guess it should be a problem of compatibility with RTX5. Here's is a part of the flash task code I'm using in the program where I perform a fds_record_update:
my_struct params =
{
.param1 = rand() % (10+1),
.param2 = rand() % (20+1 - 10) + 10,
.param3 = rand() % (30+1 - 20) + 20,
.param4 = rand() % (40+1 - 30) + 30,
.param5 = rand() % (50+1 - 40) + 40,
};
fds_record_t const record =
{
.file_id = VC_FILE,
.key = VC_KEY,
.data.p_data = ¶ms,
.data.length_words = (sizeof(params) + 3) / sizeof(uint32_t),
};
fds_record_find(VC_FILE, VC_KEY, &desc, &tok); // To recover the descriptor
ret_code_t ret = fds_record_update(&desc, &vc_record); // Update the record value found on file VC_FILE with VC_KEY
if( ret != NRF_SUCCESS && (ret == FDS_ERR_NO_SPACE_IN_FLASH))
m_error_FDS = FDS_FLASH_FULL;
I'm using a DK nRF52840 and SDK 17.1.0. Any help would be appreciated!