Hi,
I managed to have the fat_fs sample to work.
Now i would like to be able to write and read files, onto the SD-CARD, that a PC will understand, it seems to needs some more then
Hi,
I managed to have the fat_fs sample to work.
Now i would like to be able to write and read files, onto the SD-CARD, that a PC will understand, it seems to needs some more then
Hi,
You should be able to use a similar approach as the FatFS example in nRF5 SDK uses to write a text file to the SD-card:
#define FILE_NAME "NORDIC.TXT"
#define TEST_STRING "SD card example."
...
ff_result = f_open(&file, FILE_NAME, FA_READ | FA_WRITE | FA_OPEN_APPEND);
if (ff_result != FR_OK)
{
NRF_LOG_INFO("Unable to open or create file: " FILE_NAME ".");
return;
}
ff_result = f_write(&file, TEST_STRING, sizeof(TEST_STRING) - 1, (UINT *) &bytes_written);
if (ff_result != FR_OK)
{
NRF_LOG_INFO("Write failed\r\n.");
}
else
{
NRF_LOG_INFO("%d bytes written.", bytes_written);
}
(void) f_close(&file);
Note that Zephyr provides a common FS API for the different file systems, so you should replace "f_" with "fs_", and replace the return code checks with the corresponding Zephyr error codes.
Best regards,
Jørgen
Hi,
You should be able to use a similar approach as the FatFS example in nRF5 SDK uses to write a text file to the SD-card:
#define FILE_NAME "NORDIC.TXT"
#define TEST_STRING "SD card example."
...
ff_result = f_open(&file, FILE_NAME, FA_READ | FA_WRITE | FA_OPEN_APPEND);
if (ff_result != FR_OK)
{
NRF_LOG_INFO("Unable to open or create file: " FILE_NAME ".");
return;
}
ff_result = f_write(&file, TEST_STRING, sizeof(TEST_STRING) - 1, (UINT *) &bytes_written);
if (ff_result != FR_OK)
{
NRF_LOG_INFO("Write failed\r\n.");
}
else
{
NRF_LOG_INFO("%d bytes written.", bytes_written);
}
(void) f_close(&file);
Note that Zephyr provides a common FS API for the different file systems, so you should replace "f_" with "fs_", and replace the return code checks with the corresponding Zephyr error codes.
Best regards,
Jørgen
Hi Jorgen,
Thanks for the pointers.
I indeed have it working now :-)
Best Regards,
Theo