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

Problem about fatfs and QSPI on nRF52840

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

Parents Reply
  • I had a similar issue yesterday,  on a 16MB QSPI Winbond W25Q128JVSIQ, there was one block on the whole flash that would corrupt, it was repeatable and happened at the same location across devices.   It would also cause large block writes to fail too.

    I changed NRF_BLOCK_DEV_QSPI_FLAG_CACHE_WRITEBACK to 0, and it now works fine.  Seems to be a bug in the CACHE_WRITEBACK code.

Children
No Data
Related