1 2 Previous Next 15 Replies Latest reply on Jul 19, 2020 6:18 PM by RodolfoG_11

    Elm-Chan FatFs


      Hi all,


      Just wondering if anyone has had any success porting Elm-chan's FatFS SD card file system library (http://elm-chan.org/fsw/ff/00index_e.html) to a PSoC 4. This is my first attempt at porting low level code like this and I'm a little lost, I'd love it if anyone could share any example source code they may have for my reference.



        • 2. Re: Elm-Chan FatFs

          Is there an English version?


          Also, I couldn't be sure but it looks like there isn't a code example for the PSoC port of FatFs itself.

          • 3. Re: Elm-Chan FatFs

            You can look here:




            I have started porting the library two days ago. It needs more changes and testing but i think porting will be a bit slow. It´s dificult for me to stay too much time in front of my computer with a broken ankle.

            • 4. Re: Elm-Chan FatFs

              thanks for the port!

              • 5. Re: Elm-Chan FatFs

                Could someone kindly confirm whether jesusrcc's porting (https://github.com/hackingchips/PSoCFatFs) works for microSD cards >4gb in size?

                • 6. Re: Elm-Chan FatFs

                  I have tested the demos in github with a Sandisk Ultra microSDHC I  16Gb card and with a Qilive microSCHC I 32Gb, and the PSoC4 dev kit, and they work, but there is an issue with f_getfree() function (look issues at github).


                  Actually i am using the 16Gb card on a personal project without problems apart of f_getfree issue.

                  • 7. Re: Elm-Chan FatFs

                    jesusrcc, thank you for the response and for the porting work! 


                    I tried your application (PSoC 5LP version) on the PSoC 5LP prototyping kit with a Sandisk (normal) microSDHC 4Gb card (formatted to both FAT32 and exFAT), but I constantly keep getting the FR_NOT_READY error. I tried to figure out the root of the problem and it seems to be that the STA_NOINIT (drive not initialised) flag is thrown up.


                    I tried a few things:


                    (1) played the following constants, plugging in different values:




                    (2)  played with the bit rate setting of the SPI master component


                    (3) connected SPI master component to an external clock (instead of an internal clock) and ran it off clock speeds from 4 MHz - 20 MHz 


                    None of these worked.


                    What I am wondering is whether I am missing on something that I am supposed to do? For example, in the function you call:


                    resultF = f_mount(&fatFs, "", 1);


                    am I supposed to replace the "" (second parameter) with something (a logical drive number to be mounted/unmounted -- I don't know where I can find this though :/)


                    I am a newbie to working with SD cards so your help would be greatly appreciated! I will try to do some further debugging if you need more information. 

                    • 8. Re: Elm-Chan FatFs

                      How are you connecting the sd card to the prototyping kit? Directly? Any commercial sdcard prototyping kit or shield?


                      What it the 5LP prototyping kit you are using?

                      • 9. Re: Elm-Chan FatFs

                        I am using the CY8CKIT-059  prototpying kit .I am interfacing the microSD card via a 5V breakout board - the board uses a simple voltage divider circuit to reduce voltage from 5V to 3.3V, however I just noticed that the MISO pin is 3.3V output connected directly to the PSoC. I will purchase a new breakout board with integrated logic converter chip and see what happens from there!


                        I will get back to you if I have any problems. Thanks!

                        • 10. Re: Elm-Chan FatFs

                          A few days ago, i helped a person with a similar problem and it was the MISO signal and a PSOC working at 5V.
                           Maximun voltage in MISO for high level voltage is 3.3V while (from datasheet) the minimun voltage at a gpio pin of PSOC working at 5V is 0.7*VDDIO = 3.5

                          • 11. Re: Elm-Chan FatFs

                            Yes that makes sense. Thank you!


                            Also, seeing that you got fatFs working on the CY8CKIT-042 kit, have you tested the library on the PSoC 4 BLE kit (CY8CKIT-042-BLE)? If not, are you aware of its compatibiliy?


                            And as a general question, would you recommend implementing the fatFs file system with a Cortex M0 mcu (CY8CKIT-042 or CY8CKIT-042-BLE?) . Most forums tend to suggest that an M0 is not really capable of implementing a file system? Or does the capability vary from mcu to mcu, depending on the amount of RAM avaiable?

                            • 12. Re: Elm-Chan FatFs

                              I think it have to work with BLE modules too but i have not tested it. I don't have any BLE modules.


                              I friend of me will use it in a BLE module but until now, i don't have news from him.


                              I am not very experienced with the library. I have ported it and i am using it in two personal projects without problems. I have seen the same library working in a lot of other platforms, from tiny 8 bit microcontrollers to embedded systems. I can not figure out why a M0 core will no be able to manage the file system. I supose it depends on what we expect from it.

                              • 13. Re: Elm-Chan FatFs



                                I am quite new to the PSoC community and I am trying to port your project to PSoC 6. I have modified the sdcard.c file as in attachment to use PSoC 6 macros, but I get a "sdcard not ready" error. Any idea what I am doing wrong? In attachment also my main file (still under clean up).




                                • 14. Re: Elm-Chan FatFs

                                  I also try to port the Project to PSoC6. But i get everytime the error: (FR_DISK_ERR) low level error.

                                  Whats the reason for this? I think it's very poor from Cypres not to offer a working filesystem for PSoC6 and PSoC Creator.

                                  1 2 Previous Next