Page 1 of 1

[STM32F4DISC] and Adafruit SDIO breakout

Posted: Fri Sep 04, 2020 6:30 pm
by scsibuzz
Hi all,

Thanks for your support.

New to MicroPython and building the software in general, so please excuse my ignorance.

I'm trying to build MicroPython to add support on my STM32F4DISC (new blue version) for Adafruit's newer SDIO breakout ( https://www.adafruit.com/product/4682 ).

I'm following this gentlemen's blog on how to add the definitions to enable SDcard support for the discovery board.

http://www.kaltpost.de/?p=2199

Specifically, he calls for making the following definitions:

#define MICROPY_HW_HAS_SDCARD (1)
// SD card detect switch
#define MICROPY_HW_SDCARD_DETECT_PIN (pin_A8)
#define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLUP)
#define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_RESET)

And then with respect to wiring, the following:

SD-Card STM32F4-Discovery
-------------------------------
1 SDIO_D3 PC11
2 SDIO_CMD PD2
3 VSS GND
4 VDD 3V
5 SDIO_CLK PC12
6 SDIO_SW PA8
7 SDIO_D0 PC8
8 SDIO_D1 PC9
9 SDIO_D2 PC10

Unfortunately, after defining the changes, building and flashing the .DFU, I'm unable to perform any I/O to the SDCARD. Getting:

Code: Select all

>>> f = open("/sd/tryagain.txt", "w")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 19] ENODEV
I've triple checked my wiring - the only thing I could not precisely match is the definition for SDIO_SW. I think this is the DETECT pin on the breakout:

https://learn.adafruit.com/adafruit-mic ... io/pinouts

The other thing that caught my attention is the following taken from the pinout page:
Common Logic Pins
DET - Detect whether a microSD card is inserted. This pin is connected to GND internally when there's no card, but when one is inserted it is pulled up to 3V with a 4.7kΩ resistor. That means that when the pin's logic level is False there's no card and when it's True there is.
Based on the above, I wondered if the following was causing me issues:

#define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLUP)

So I changed it to:

#define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_NOPULL)

However, that didn't seem to help.

Does anyone have any ideas on what might be the problem?

Also, can someone tell me how I can confirm the following pin out definitions that I wired are the expected MicroPython PINs for SDIO?

SD-Card STM32F4-Discovery
-------------------------------
1 SDIO_D3 PC11
2 SDIO_CMD PD2
3 VSS GND
4 VDD 3V
5 SDIO_CLK PC12
6 SDIO_SW PA8
7 SDIO_D0 PC8
8 SDIO_D1 PC9
9 SDIO_D2 PC10

Thank you so much for reading!

Re: [STM32F4DISC] and Adafruit SDIO breakout

Posted: Sun Sep 06, 2020 5:02 am
by scsibuzz
So, a bit of progress. I found that in order for the pyb.SDCard to become available, I also needed to define the following in STM32F4DISC mpconfigboard.h:

#define MICROPY_HW_ENABLE_SDCARD (1)

I took a look at the pyboardv1.1 schematic, and it looks like the pinouts for SDIO are configured reciprocally for the discovery board:

PC10 - SDIO_D2
PC11 - SDIO_D3
PD2 - SDIO_CMD
PC12 - SDIO_CK
PC8 - SDIO_D0
PC9 - SDIO_D1
PA8 - SDIO_SW

Unfortunately, even though the SDCard is now available, trying to mount the sdcard fails with OS error 16:

Code: Select all

>>> os.mount(pyb.SDCard(),'/sd')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: 16
All out ammo on this one. Thanks in advance for any suggestions.