Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

f_mount error (3) when not setting internal pullups on SPI pins #2

Closed
midasgossye opened this issue Apr 7, 2021 · 9 comments
Closed

Comments

@midasgossye
Copy link

First of all, thanks for the well written how-to guide and blog post!
Thanks to your explanation and code I managed to read and write to a MicroSD card using a custom STM32F4 dev board 😃
However, it didn't work first-go and I had to spend a couple of hours to figure out what the issue was...

I have the microSD card directly connected to the SPI2 interface pins on a STM32F405RGT6, like so:
microSD_card_connections

I altered and uploaded the code and it refused to work, it always gave me a f_mount error (3) error...
I hooked up an SD card interface module (like the one you used in your blogpost) to the same SPI pins, and it started working!
After some probing I noticed that the SD card interface module has pullup resistors on all of the data lines.
After enabling the internal pullups of the SPI interface using the STM32CubeIDE configurator it suddenly started to work!
pullups_cubeIDE

This was definitely a goof up on my part, but it would be nice to add a note on your blogpost or code to enable the internal pullups if someone is directly connecting the SD card pins to the STM32. Hopefully, it can save some other people some time so they don't have to go troubleshooting like I did 😅

@kiwih
Copy link
Owner

kiwih commented Apr 8, 2021

This is great to know. I have added a note to the blog and README.

@kiwih kiwih closed this as completed Apr 8, 2021
@zharfanw
Copy link

I had the same problem too, but it was solved. I was using NUCLEO-64 STM32F446RE, with the same sd card module, and using SD Card Sandisk 16GB.

I did the same thing with blog instruction and I got error (3). And I solved it with all the SPI2 pins(MOSI, MISO, SCK, and CS) are switched to Pull-Down. Actually, I don't know why? but it's work for me.

Thanks for your code and blog post. it's helpful. I leave a comment here to share my experience with the troubles, but the code it's fine for this far.

@zharfanw
Copy link

I had the same problem too, but it was solved. I was using NUCLEO-64 STM32F446RE, with the same sd card module, and using SD Card Sandisk 16GB.

I did the same thing with blog instruction and I got error (3). And I solved it with all the SPI2 pins(MOSI, MISO, SCK, and CS) are switched to Pull-Down. Actually, I don't know why? but it's work for me.

Thanks for your code and blog post. it's helpful. I leave a comment here to share my experience with the troubles, but the code it's fine for this far.

Screenshot 2021-04-16 165444
Screenshot 2021-04-16 165606

@lakshminarayanaks79
Copy link

Hi this lakshminarayana KS
i am trying to integrate SD card with SPI over STM32f469I discovery board but i always get the same problem that f_mount error (3) i followed to blog and also made changed specified here but nothing has worked for me till now.
could be able to help with latest STM32Cube id

Thanks in advance

With Regards
Lakshminarayana KS

@kiwih
Copy link
Owner

kiwih commented Sep 9, 2021

Also try changing your SD card @lakshminarayanaks79 , as noted in the blog, not every SD card likes talking SPI.

@thibeaux
Copy link

thibeaux commented Sep 12, 2021

I fixed this problem by following the steps in this tutorial by Kiwih, https://01001000.xyz/2020-08-09-Tutorial-STM32CubeIDE-SD-card/

You have to make sure you edit the user_diskio.c file adding in the appropriate user code that returns the SPI commands that is used in user_disk_spi.h. This returned the size of my drive being printed into my UART terminal.

I'm using a SANDISK ULTRA 32GB Micro SD Card, HW-125 SD card SPI adapter for my Nucleo-F446RE.

Thanks to you guys! Also I'm using pull-ups on all 4 of my SPI1 pins including the CS. Also I am setting my prescaler to 256.

@MAXH20
Copy link

MAXH20 commented Apr 18, 2022

Set FS_TINY Enabled will make the trick

@nelsonifechukwu
Copy link

Thank you, kiwi. I got mine working.
I'll take insights about pulling these communication lines high to communicate with a flash memory. It's been a sweat shop fr months now.

@pclinh2001
Copy link

I followed the instructions and it works fine with STM32F1, but when I try with STM32G4 "free_sectors" is always 0 causing "fr_invalid_object" error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants