This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

NRF52 SDk 15.0 with sd-card detect/remove with fatfs

Dear all,

I'd like to re-init sd-card when detect it plug/un-plug. But i face a issue when i re-mount sd-card it can not open file....My flow as below

 

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
bool init_sd_card(void)
{
static DIR dir;
static FILINFO fno;
static FIL file;
static FATFS fs;
uint32_t bytes_written;
FRESULT ff_result;
DSTATUS disk_state = STA_NOINIT;
char filename[50] = "new_testing_file.txt";
// Initialize FATFS disk I/O interface by providing the block device.
static diskio_blkdev_t drives[] =
{
DISKIO_BLOCKDEV_CONFIG(NRF_BLOCKDEV_BASE_ADDR(m_block_dev_sdc, block_dev), NULL)
};
diskio_blockdev_register(drives, ARRAY_SIZE(drives));
printf("Initializing disk 0 (SDC)...\r\n");
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

what is the best re-init sd-card?

regards,

Tuyen

Parents
  • when i re-mount sd-card it can not open file

    Any file, or just one particular file?

    Is that because the file was not not closed properly before you pulled the card out?

    Does everything else work OK after the re-init?

    If you check the card on a PC (or similar), is it corrupted?

    Note that FatFs is a 3rd-party thing - nothing specifically to do with Nordic. For questions specific to FatFs, check the FatFs documentation & forum:

    http://elm-chan.org/fsw/ff/00index_e.html - especially the 'Resources' section at the bottom of the page...

Reply
  • when i re-mount sd-card it can not open file

    Any file, or just one particular file?

    Is that because the file was not not closed properly before you pulled the card out?

    Does everything else work OK after the re-init?

    If you check the card on a PC (or similar), is it corrupted?

    Note that FatFs is a 3rd-party thing - nothing specifically to do with Nordic. For questions specific to FatFs, check the FatFs documentation & forum:

    http://elm-chan.org/fsw/ff/00index_e.html - especially the 'Resources' section at the bottom of the page...

Children
No Data