Pico demo sd-card

Can anyone tell me what the correct values for using the sd-card on the pico demo board are?
I have a FAT32 formatted sd-card, that has been tested and works in 2 other LCD screen sd-cards (using different GPIO values) and I can read/write and list the files/folders.

Using the same code with the pico demo board, all I get now is ‘bad SCK pin’.
I’m looking for something that maps:
SD_DAT3 : (GPIO 22)
DAT2 : (GPIO 21)
DAT1 : (GPIO 20)
DAT0 : (GPIO 19)
CMD : (GPIO 18)

to the required values for CS, SCK, MOSI and MISO. The Hardware PDF does give me values - but they do not seem to work - did I mis-interpret them? https://datasheets.raspberrypi.com/rp2040/hardware-design-with-rp2040.pdf PAGE 21

This does not work as I expected it to in MicroPython code:

cs = machine.Pin(18, machine.Pin.OUT, value=1)
spi = machine.SPI(0,

sd = sdcard.SDCard(spi, cs)

any assistance / guidance really appreciated!

‘bad SCK pin’ is the key to your problem: GPIO5 is not a valid SPI-SCK pin. See https://pico.pinout.xyz/

Hi, yes, I did a bit more logical deduction last night using that layout and determined that it should be:
CS = GPIO5 or GPIO22 - get same response
(If I set the following two to any other value the MicroPython library quite nicely tells me I am wrong)

and now I get an error: OSError: no SD card

I even set this up: GitHub - carlk3/no-OS-FatFS-SD-SPI-RPi-Pico: A FAT filesystem with SPI driver for SD card on Raspberry Pi Pico
and built my own uf2 so I could test doing the “mount 0:” and debugging the errors from there.
As I say, I can make this work repeatedly on other breadboard setups, just not on the pico demo and I cannot figure out why?

I really don’t want to have wasted £20 on a pico demo just so I can have VGA - pretty pointless if I cannot get the sd-card working with it. There must be something “simple” I am missing here?

I checked the wiring and I’m sure now that the SD-card is wired not for the SPI interface, but the SDIO interface. I have no experience with that, until now I only used SPI (including carlk3’s implementation). I found this link Pico w/4-bit SDIO interface example? - Raspberry Pi Forums, but I’m not sure if this helps.

Just a small update:
I was doing some random digging & I can confirm that the actual values are:

However, I still get the “SD Card not found” error… I was doing this as a “quick test” using MicroPython - just to make sure that I could read the sdcard from the device.

I found the above values within some C/C++ code here: pico-infonesPlus/sdcard.h at main · fhoedemakers/pico-infonesPlus · GitHub

…and that is when the realisation dawned on me…what if this doesn’t work from MicroPython!

I then checked on the main product page…and, there it is at the top:

Please note that VGA Demo Base only currently works with the C/C++ Pico SDK!

Maybe it needs to be in a BIGGER font - I hang my head in shame…

unfortunately, I still cannot get it to access the SDCard from C-code. Following the simple instructions from here: Pico supports SD cards and FatFS - Hackster.io

I still get

mount 0:
sd_spi_go_low_frequency: Actual frequency: 398089
sd_wait_ready failed
/home/tony/dev/pico/c-code/v2/no-OS-FatFS/FatFs_SPI/sd_driver/sd_card.c:462: Card not ready yet
sd_wait_ready failed
/home/tony/dev/pico/c-code/v2/no-OS-FatFS/FatFs_SPI/sd_driver/sd_card.c:462: Card not ready yet
sd_wait_ready failed

I have tried several different sdcards, proven to work on other devices. am a bit stumped now.

How are the SD Cards formatted? I think they need to be Fat formatted.

yep, all FAT formatted. I have a 2Gb, 16GB and 32GB for variance

Ok, was just a stab in the dark.

no worries! I’ve been doing a lot of that recently with this. Am open to all / any suggestions.

I’ve just hacked up some waveshare C code that accesses the sdcard on their 2.8" touchscreen - am basically removing all references to the LCD display… am nearly there. I have that code successfully accessing the sdcard on that device (the previous mentioned code ‘no-OS-FatFS’ was failing to access this sdcard too).
However, I now have a list of files being output and I can navigate into sub-folders and list them too, so some success on the waveshield device!
I’ll look to clean this code up and then see if I can move it over to then try it on the pico demo board… just have to change the config PINS… in theory…

I still don’t think that you will be able to access the SD-card on the pico-demo with SPI. According to the pinout on the product page, SD-CLK is wired to pin7, i.e. GP5, which is not a SPI clock-pin on the pico.

You are claiming that GPIO18 is SPI-SCK, but that pin is wired to SD-CMD (where you expect MOSI in SPI-mode).

I dug a bit deeper and whilst doing cmake I pass it the board type:
cmake -D"PICO_BOARD=vgaboard" …
(not sure why that shows as 3 dots - should be 2)

which led me to find this file:

that defined these values:
// Note DAT1/2 are shared with UART TX/RX (pull jumpers off header to access
// UART pins and disconnect SD DAT1/2)

and I was using SD_CS PIN 22 in my C code and spi1.

Using these values I still cannot get it to initialise from C/C++,

SD card mount file system failed ,error code :(3)

so maybe you are right… it might not be SPI?

In which case, are there any c/c++ examples out there that access the sd-card on the pico demo board? I cannot seem to find anything.
I did find an example of someone using the pico dvi board (hdmi version) and their code doesn’t seem to do anything smart with the sdcard, so I’m a bit baffled - did I just get a broken board and I’ve been chasing my tail all along?

I think you found the correct link (I failed). If you look at the source code, they implement SPI using PIO, i.e. they don’t use the hardware-spi function-blocks of the pico, but implement their own PIO-version. That’s why it is not relevant that the SD-CLK is not connected to a pico-spi-clk pin. You will find the code in the drivers/sdcard subdirectory.

So the next step for you would be to try to integrate that code into your project. Would be great if this works.

okay… I need bigger brains than I’ve got to figure this one out.

I’ve uploaded the code to here:

It contains the libraries grafted into a super-simple app that attempts to initialise and mount the sdcard for the Pico demo VGA board.

I’ve pasted my debug output into the sdcard_test.c file, but will reproduce it here:
SDCARD_TEST.C: system init response=0
SDCARD_TEST.C: Let’s try to mount the SDcard
FF.C: inside f_mount about to call mount_volume
FF.C: about to call disk_initialize from within mount_volume
SDCARD.C: about to call init_spi() here, I think I was called by FF.C: mount_volume
SDCARD.C: we should be executing the PIO code here
SDCARD_TEST.C: SD card mount error: 3
SDCARD_TEST.C: sdcard_success=0
SDCARD_TEST.C: Bugger an error happened…again…

I put the filename on the front of the printf’s so I could trace through the logic of the code and make sure it was working as I thought it was. From what I can tell, it is indeed going through the correct steps… but still failing anyway.

I’ve tried with:
cmake …
and with the board specified:
cmake -D"PICO_BOARD=vgaboard" …
that doesn’t seem to make a difference.
I’ve tried changing from sp1 to sp0, just incase it is on the first device, done the same with pio1 and pio0 - same result.
Maybe I have a typo / assumption somewhere that is blazing obvious to someone else? but I think I’ve now tried everything I can to read an SDCard using the Pico demo VGA board, without success :-(

The good news is… I don’t think the GPIO PIN settings is the problem :-D That appears to be okay.

I think your pins don’t match the wiring of the board:



I still have to figure out the other pins, they are labeled SD_DAT0-SD_DAT3 in the shop. But I somewhere have a SD-pinout which labels all the pins in both ways, so give me some time.

You genius!

SDCARD_TEST.C: system init response=0
SDCARD_TEST.C: Let’s try to mount the SDcard
FF.C: inside f_mount about to call mount_volume
FF.C: about to call disk_initialize from within mount_volume
SDCARD.C: about to call init_spi() here, I think I was called by FF.C: mount_volume
SDCARD.C: we should be executing the PIO code here
SDCARD.C: pio_spi_init executed
SDCARD_TEST.C: Current directory is: /
SDCARD_TEST.C: sdcard_success=1
SDCARD_TEST.C: Woo!hoo! party time

Glad it works! The real genius are the people that implemented that SPI-PIO stuff. I really have to spend some time with that technology one day.