Good morning from Germany,
I would like to know wheter if there is any library / API for SDIO device on Zynq. We are developing a Bare Metal Software which has to log some data on SD card, through SDIO interface.
Thank you in advance,
Michel
Good morning from Germany,
I would like to know wheter if there is any library / API for SDIO device on Zynq. We are developing a Bare Metal Software which has to log some data on SD card, through SDIO interface.
Thank you in advance,
Michel
Hi
I have not done anything with SDIO, but have made a fully working bare metal Vivado project that allows you to work with an SD card in SPI mode. It uses the 'FatFs' libraries available here -
http://elm-chan.org/fsw/ff/00index_e.html
Enabling GPIO in the PS block, you can then communicate through MIO pins 40-47, which are the pins in the SD slot on the Zedboard. (I am sure this is not the best way to do this, but it works!)
I made the modifications to the 'generic' version of the FatFs library and have stuck the C files here so you can have a look
http://personal.strath.ac.uk/kenneth.barlee/zed_posts/fatfs_sd.zip
Kenny
Hi, Kenny.
It's great!!
Does "Enabling GPIO" means that pin40-47 should be GPIO not SD0?
I will try.
Thank you.
Sam
Hi, Kenny.
It's working!!
Thank you for your idea!!
sam
...haha - glad I could help!
For anyone else reading this - yes, set the MIO pins 40-47 to be GPIO
K
HI, Kenny.
Could this library create a binary file and write in binary format?
Sean
Hi Sean,
Yes I am sure it probably could. If you look at the main.c file though, you will see that functions have been created that allow for files + folders to be created, and char strings to be written to them.
If you are wanting to log binary values to a file I would suggest something along the lines of
//stackoverflow.com/questions/111928/is-there-a-printf-converter-to-print-in-binary-format
const char *byte_to_binary(unsigned long x)
{
tstatic char binary[32];
tbinary[0]='0';
tint z;
tfor (z = 134217728; z > 0; z >>= 1)
t{
ttstrcat(binary,((x & z) == z)?"1":"0");
t}
treturn binary;
}
void main(void)
{
....
t//BINARY VALUE
tint bin = 0b010101010101;
t//CREATE NEW FILE
tprintf("
create a new file (binary.txt)");
trc = f_open(&Fil, "BINARY.TXT", FA_WRITE | FA_CREATE_ALWAYS);
tif (rc) die(rc);
t//WRITE TO NEW FILE
tprintf("
write binary data");
tchar buffer[33];
tsprintf(buffer,"%s
",byte_to_binary(bin));
trc = f_write(&Fil, *buffer, strlen(buffer), &bw);
tif (rc) die(rc);
t//CLOSE NEW FILE
tprintf("
close the file");
trc = f_close(&Fil);
tif (rc) die(rc);
t...
}
(note - not tested!)
...rather than writing binary commands. If you want to do that though, I guess you would have to manipulate some of the files in the background. Have not done it myself so could not comment!
Kenny
HI, Kenny.
It does work! Thank you for answering!
Sean
Hi
I am getting this error 10 = FR_WRITE_PROTECTED = The physical drive is write when everytime I run the application.
I used diskpart to to disable write protection, but I still get the same error.