static bool fatfs_init(void) { FRESULT ff_result; bool init_result = true; DSTATUS disk_state = STA_NOINIT; bool flag = false; memset(&m_filesystem, 0, sizeof(FATFS)); // Initialize FATFS disk I/O interface by providing the block device. static diskio_blkdev_t drives[] = { #if USE_SD_CARD DISKIO_BLOCKDEV_CONFIG(NRF_BLOCKDEV_BASE_ADDR(m_block_dev_sdc, block_dev), NULL) #else DISKIO_BLOCKDEV_CONFIG(NRF_BLOCKDEV_BASE_ADDR(m_block_dev_qspi, block_dev), NULL) #endif }; diskio_blockdev_register(drives, ARRAY_SIZE(drives)); NRF_LOG_INFO("Initializing disk 0 (QSPI)..."); disk_state = disk_initialize(0); if (disk_state) { NRF_LOG_ERROR("Disk initialization failed."); return false; } NRF_LOG_INFO("Mounting volume..."); ff_result = f_mount(&m_filesystem, "", 1); if (ff_result != FR_OK) { if (ff_result == FR_NO_FILESYSTEM) { NRF_LOG_ERROR("Mount failed. Filesystem not found. Please format device."); } else { NRF_LOG_ERROR("Mount failed: %u", ff_result); } ff_result = fatfs_mkfs(); if (ff_result != FR_OK) { init_result = false; } else { #ifdef RECORD_ERR m_log_buf_len = sprintf((char *)m_log_buf, "f_mount failed,then fatfs_mkfs sucessfully, fatfs_mkfs result %d\r\n", ff_result); record_stat_data(0); #endif flag = true; } } else { flag = true; #ifdef RECORD_ERR m_log_buf_len = sprintf((char *)m_log_buf, "Initializing disk 0 (QSPI) completed,ff_result %d\r\n",ff_result); record_stat_data(1); #endif } return init_result; }
Hi, I was using nRF52840 , flash is mx25L25645GM2, I used fatfs with QSPI ,but I found fatfs was unstable,After some time, the stored file would dispear.Sometime there were scrambling symbols in my files