Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
11 years ago

SD card HAL driver cannot write large files correctly

Hi

I'm using UP sd card interface and it is worked perfect till I write small files - I can open it on my PC and read. But if file size is more than about 4K I get Windows error when I try to open it - "The file or directory .... is corrupted and unreadable. Please run the Chkdsk utility". Grateful for any help!

Thanks!

Sergey Burenkov

6 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Just FYI, may be it help someone)

    I could not fix UP SD_card interface, I tried this solution http://www.alteraforum.com/forum/showthread.php?t=28162&p=134801#post134801 , but not successful.

    So I refused to use UP_SD_card and replaced it by the FatFS library http://elm-chan.org/fsw/ff/00index_e.html. I have found Nios II example for Altera DE-1 board in here http://www.emb4fun.de/fpga/fatfs/index.html. There is no problems to port in on my custom board. Works perfect!

    Best Regards

    Sergey Burenkov
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi, I recently work on FPGA of DE2-115.

    I tried to modify the demonstration, DE2_115_SD_CARD, provided by Terasic to write the data into SD card.

    However, none of my method succeeded.....

    Can you share with me how to use the "University Program SD Card IP Core" to write data into SD card?

    Or just create a text file in SD card?

    Any of your help is highly appreciated.

    Thank you very much!!
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi,

    As I mentioned above, "University Program SD Card IP Core" is not working correctly with files size more than 5 sectors. Also it have issues with big sectors size and big drive size. So I recommend to use FatFS. You can find Nios II example for Altera DE-1 board in here http://www.emb4fun.de/fpga/fatfs/index.html.

    Best Regards

    Sergey Burenkov
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    Hi,

    As I mentioned above, "University Program SD Card IP Core" is not working correctly with files size more than 5 sectors. Also it have issues with big sectors size and big drive size. So I recommend to use FatFS. You can find Nios II example for Altera DE-1 board in here http://www.emb4fun.de/fpga/fatfs/index.html.

    Best Regards

    Sergey Burenkov

    --- Quote End ---

    Thanks for your help!

    But how can I modify the project for my DE2-115 board?

    Or is there any other less complicated method I can try?

    Thank you very much!
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thanks for your help!

    But can you provide some tips for me to modify the project to apply to DE2-115 board?

    I am a beginner with FPGA....couldn't come up with the first step to modify it...
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi,

    If you already have some project for DE2-115, just dowload this project for DE-1 http://www.emb4fun.de/fpga/fatfs/download/fatfs_de1_sw_spi_20130811.zip , then copy hw\ip\pio_spi folder in your IP Cores directory, then copy sources from \sw\de1_fatfs_sw_spi to your software project. You may to open project for DE-1 to learn how make IP core instance in QSYS and software organization.

    Or the other way, just open project for DE-1, replace top level file and pins assigment, change target device, recompile QSYS and Quartus project, and try to run it.

    Best Regards

    Sergey Burenkov