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

FatFs question

I used nRF5_SDK_14.1.0_1dda907.

I used fatfs example.

Wirted data in the same file to sd card.

I discoverd that Max size of the file is 16KB.

Over the max size of file, when i write data to sd card, will be failure.

Can i change the max size to one file, or no limit size ?

  • Hey Woody,

    Over the max size of file, when i write data to sd card, will be failure.

    I need the trace info. 

    Cheers,

    Håkon.

  • Unusual, as the common cluster size of multi-GB-sized SD(HC) cards is 32KB. Did you try different cards?

  • I used 8GB sd card.

    If there are two file in the sd card.

    The one is 16KB.

    Another is 14 KB.

    If i write data to 14KB file, will be successful.

    If i write data to 16KB file, will be failure.

  • I need to know how you have initialized the file system, do you have any code, tracelogs, or logs that you can share?

  • I used the code init the fill system.

    void fatfs_init(void)
    {
        static FATFS fs;
        static DIR dir;
        static FILINFO fno;
        static FIL file;
    
        FRESULT ff_result;
        DSTATUS disk_state = STA_NOINIT;
    		
    		uint8_t string_start_init[] = "\r\nSD card init\r\n";
    		uint8_t file_name1[] = "Ant00000.TXT";
    		size_t	string_size;
    
        // 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));
    
        NRF_LOG_INFO("Initializing disk 0 (SDC)...");
        for (uint32_t retries = 3; retries && disk_state; --retries)
        {
            disk_state = disk_initialize(0);
        }
        if (disk_state)
        {
            NRF_LOG_INFO("Disk initialization failed.");
            return;
        }
    
        uint32_t blocks_per_mb = (1024uL * 1024uL) / m_block_dev_sdc.block_dev.p_ops->geometry(&m_block_dev_sdc.block_dev)->blk_size;
        uint32_t capacity = m_block_dev_sdc.block_dev.p_ops->geometry(&m_block_dev_sdc.block_dev)->blk_count / blocks_per_mb;
        NRF_LOG_INFO("Capacity: %d MB", capacity);
    
        NRF_LOG_INFO("Mounting volume...");
        ff_result = f_mount(&fs, "", 1);
        if (ff_result)
        {
            NRF_LOG_INFO("Mount failed.");
            return;
        }
    
    	NRF_LOG_RAW_INFO("");
    
    	string_size = sizeof(string_start_init) - 1;
    	SD_card_write_string_in_file(string_start_init, string_size,  file_name1);
        return;
    }

Related