carlk3 / no-OS-FatFS-SD-SDIO-SPI-RPi-Pico

A FAT filesystem with SDIO and SPI drivers for SD card on Raspberry Pi Pico
Apache License 2.0
105 stars 18 forks source link

ss_gpio should be optional #16

Closed bog-dan-ro closed 10 months ago

bog-dan-ro commented 10 months ago

It's very useful for projects that are using a single SPI sdcard and the CS is hardwired, this way we save a pin ;-) .

carlk3 commented 10 months ago

Do you have any evidence that off the shelf SD cards can work with CS hardwired?

Physical Layer Specification Version 3.01 says:

Every command or data block is built of 8-bit bytes and is byte aligned to the CS signal (i.e. the length is a multiple of 8 clock cycles). The card starts to count SPI bus clock cycle at the assertion of the CS signal. Every command or data token shall be aligned to 8-clock cycle boundary... The host starts every bus transaction by asserting the CS signal low.

I think I have encountered SD cards that insist on having CS raised between transactions. That's not to say that there are not SD cards that will work with CS tied low; I just don't know.

bog-dan-ro commented 10 months ago

Ah, you're right

carlk3 commented 10 months ago

If you want to save pins, I think a better approach is to use 1-bit SDIO.

For SPI, you need:

For 1-bit SDIO you need:

There is an implementation in pico_sd_card. I am considering adding that functionality to this library.