WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Using a SPI connected SD Card breakout with Pi Zero 2 W  (Read 1225 times)

Offline eddible

  • Newbie
  • *
  • Posts: 3
Using a SPI connected SD Card breakout with Pi Zero 2 W
« on: May 13, 2024, 06:13:30 AM »
Hey all,
I've been battling for the last day or so with trying to get a SPI SD card reader to work with a Pi Zero 2 W running PiCore 14.1 64bit. This is what I bought: https://www.ebay.co.uk/itm/256284946662

I have it hooked up to SPI1 on my Pi zero using GPIO 18 as the CS pin (I already tried SPI0, same results unless I was missing something), I've enabled SPI in the config.txt file, and I've added this line at the bottom of config.txt:
 
dtoverlay=spi1-1cs,cs0_pin=18

If I run dmesg | grep mmc I get this:

Code: [Select]
[    2.936327] mmc-bcm2835 3f300000.mmcnr: mmc_debug:0 mmc_debug2:0
[    2.936359] mmc-bcm2835 3f300000.mmcnr: DMA channel allocated
[    3.013529] mmc0: sdhost-bcm2835 loaded - DMA enabled (>1)
[    3.077733] mmc0: host does not support reading read-only switch, assuming write-enable
[    3.082110] mmc0: new high speed SDXC card at address aaaa
[    3.083910] mmcblk0: mmc0:aaaa SD64G 59.5 GiB
[    3.089950]  mmcblk0: p1 p2
[    3.091039] mmcblk0: mmc0:aaaa SD64G 59.5 GiB (quirks 0x00004000)
[    3.099315] mmc1: new high speed SDIO card at address 0001
[    4.776725] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Quota mode: none.
[    4.782968] EXT4-fs (mmcblk0p2): unmounting filesystem.
[    4.828737] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Quota mode: none.

As far as I can tell, mmc1 is my SD card, so it's seeing it. But if I ls /dev/ I only see mmcblk0 which is the built in SD card rather than my external one.

I've searched high and low to try and figure out what I'm missing but I'm not getting anywhere. Can anyone try point me in the right direction? What I ultimately want is to mount the external SD card so I can copy files from it (I only need it to be read only)
« Last Edit: May 13, 2024, 06:40:44 AM by eddible »

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1240
Re: Using a SPI connected SD Card breakout with Pi Zero 2 W
« Reply #1 on: May 13, 2024, 06:48:35 AM »
We probably don’t have the kernel drivers for that loaded, or in an extension.  Do you know what is needed for sdio?

Offline eddible

  • Newbie
  • *
  • Posts: 3
Re: Using a SPI connected SD Card breakout with Pi Zero 2 W
« Reply #2 on: May 13, 2024, 06:51:34 AM »
Afraid not, it didn't come with any documentation either. I did try enabling the sdio overlay when testing, but it seemed worse as the wifi stopped working, bizarrely.

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11576
Re: Using a SPI connected SD Card breakout with Pi Zero 2 W
« Reply #3 on: May 13, 2024, 11:33:18 AM »
Hi eddible
Welcome to the forum.

This fellow claims his solution got it working:
https://forums.raspberrypi.com/viewtopic.php?t=335338#p2102992
Another member on that forum tried that solution and failed.

... but it seemed worse as the wifi stopped working, bizarrely.
Confirmed here:
https://forums.raspberrypi.com/viewtopic.php?t=335338#p2007203

Offline eddible

  • Newbie
  • *
  • Posts: 3
Re: Using a SPI connected SD Card breakout with Pi Zero 2 W
« Reply #4 on: May 14, 2024, 08:29:09 AM »
Thank you!

Okay I tried to generate the dtbo file, which was successful, added it to my config.txt but I get the same result. What I'm confused by is that I see the exact same output from dmesg as above, so it's almost like my changes to the config file aren't being processed perhaps? Is there a way to see errors, or otherwise confirm the dtoverlays are being loaded as expected?

Offline patrikg

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 708
Re: Using a SPI connected SD Card breakout with Pi Zero 2 W
« Reply #5 on: May 14, 2024, 09:44:10 AM »
If you have uart connected you can debug the bootcode.bin you have to change the file with this line

Code: [Select]
sed -i -e "s/BOOT_UART=0/BOOT_UART=1/" bootcode.bin

https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#bootcode-bin-uart-enable