This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Porting Flash FS on SPI Flash on Tiva

Other Parts Discussed in Thread: TM4C1299KCZAD

Hi All,

I have downloaded Adesto SPI flash Driver example code from below link for AT45DB161E flash.

I made changes to the driver to make it work for AT45DB641E with sector size and page sizes and read write address modifcation.

Raw read and writes are working but am unable to mount FAT FS on this flash.

Can anyone help me out in this or point me to any reference code?

processors.wiki.ti.com/.../TI-RTOS_Examples_SerialFlash

  • What version of TI-RTOS are you using?
    What device are you on?
    Can you be more explicit on what API is failing?
    You said the raw one works after you made changes to the AT45DB files...did you make the same changes to the FatFS project? They do not share the same AT45DB files.

    Todd
  • Am using Ti -RTOS V6 on Tiva TM4C1299KCZAD Micro controller.
    In Formating the flash call to Mk_fs() it failing. While Disk read is failing.
    I have made same changes to AT45DB files in FatFS project.
  • Hi Todd,
    PFA below changes i have made for driver Read and write functions. Commented part are the original code for 161E flash.
    f_mkfs() is success, but failing to open file through f_open(), File signature not matching with default value @ location 510 bytes.
    Read:-
    txBuffer[0] = 0xD2;
    //txBuffer[1] = (unsigned char)(page >> 6);
    //txBuffer[2] = (unsigned char)((page << 2) | (0x3 & (transaction->byte >> 8)));
    txBuffer[1] = (unsigned char)(page >> 7); // Page size is 15 bits 8 in tx1 and 7 in tx2.
    txBuffer[2] = (unsigned char)((page << 1) | (0x1 & (transaction->byte >> 8)));
    txBuffer[3] = (unsigned char)(0xFF & (transaction->byte));

    Write:-
    txBuffer[0] = 0x87; //write to buffer 2
    txBuffer[1] = 0x00;
    //txBuffer[2] = (unsigned char)(0x3 & (transaction->byte >> 8));
    txBuffer[2] = (unsigned char)(0x1 & (transaction->byte >> 8)); //( 9 bit buffer address.
    txBuffer[3] = (unsigned char)(0xFF & transaction->byte);
  • 3704.AT45DB.cHi Todd,

                    Attached is the modified AT45DB.c file. Please confirm the changes are correct.

    Regards,

    Rudresh

  • Thanks. Did the out of the box code work for both the raw and FatFS examples when you used the 528 byte page size?
  • I was able to reproduce the problem and I'm not sure what is causing the problem. Please note the readme.txt states that 512 byte page size has not been validated. There appears to be a problem. I'll open a bug report and recommend you use 528 byte page size mode instead (as the out of the box code has it) until the issue has been looked into more.

    Todd
  • Hi Todd,

    But I am using AT45DB641E flash where according to Data Sheet page size is limited to either 256/264 bytes(Page number 5). 

    File :- AT45DB.h

    /*!
     *  @brief AT45DB Number of Pages constant
     */
    #define AT45DB161_NUMBER_OF_PAGES  32768
    /*!
     *  @brief AT45DB Page size constant
     */
    #define AT45DB161_PAGE_SIZE        264

    File :- AT45DBFatFs.h

    #define AT45DBFatFs_FLASH_SECTOR_SIZE           32
    #define AT45DBFatFs_DRIVE_NOT_MOUNTED           ~0

    We Suspect code will not work for Page size of 528 as per 641E data sheet its limited to 256/264 bytes.

    Please Conform the changes.

  • I figured out why the 512 operations did not work for me. The device was in 528 mode. You have to explicitly put the device into 512 mode (also called "Power of 2" mode). Did you do that? Bit 0 of the status register tells you what mode you are in (0 = 528 mode, 1 = 512 mode). If you are in 528 mode, the 512 operations do not work (and vice versa). Please refer to the datasheet for more details.

    It works the same for the AT45DB641E except the modes are 256 vs 264.

    Todd
  • Hi Todd,

    I have verified the with with both page sizes and still same issue with fopen. Am attaching modified driver source files for your review. Please review it once

    and conform if everything fine?2063.AT45DB.h

    0871.AT45DB.c

  • The FatFS module requires a 512, 1024, 2048 or 4096 sector size. You need to use a 512 sector size in your diskIOctrl function.

    DRESULT AT45DBFatFs_diskIOctrl(UChar drv, UChar ctrl, Void *buf)

    {

      ...

       switch (ctrl) {

           ...

           case GET_SECTOR_SIZE:

               /* Get sectors on the disk (WORD) */

               *(WORD*)buf = AT45DBFatFs_FLASH_SECTOR_SIZE; // this is 512 define in the AT45DBFatFs.h file

    However, in your driver, you need to map each sector to two flash pages.

    Todd

  • Hi Todd,
    Thanks for your replay.
    The driver code which we downloaded has been working on AT45DB161E(2MB) flash. We can able to do all file operations.
    The same code modified for new flash AT45DB321E(4MB), where unable to do file operations,
    f_mkfs() is mounting FS but unable to do file operations like f_open will return NO_FILE_SYSTEM error. I have given the Sector size and Page size according to its datasheet.
    While f_open() call is failing @check_fs() function is unable to find "FAT" string written BOOT sector.

    #define AT45DB161_NUMBER_OF_PAGES 8192
    #define AT45DB161_PAGE_SIZE 528

    #define AT45DBFatFs_FLASH_SECTOR_SIZE 1024

    One more observation is that on same 4MB flash if use 161E code without changing any configuration in page size and sector size, FS is porting but only 2 MB memory is available.

    Please suggest any ideas to find the issue.
  • Why are you using 1024 for AT45DBFatFs_FLASH_SECTOR_SIZE? I'd use 512 and then 512 or 528 for the AT45DB161_PAGE_SIZE (depending on how the device is setup).

    What happened to the AT45DB321E device?
  • For AT45DB321E i can able to see only 2MB out of 4MB of flash size.

    So i was trying to use with different configuration of sector and page sizes.

  • This has been resolved. The AT45DB161_NUMBER_OF_PAGES was incorrect.