0
\$\begingroup\$

I want to boot an ARM Linux board (Allwinner H3 for example) from a generic (micro) SD card through an SPI interface. Can an SD card accept SPI communication right away or is there any "SPI mode initialization" needed on the card?

I must admit I have not gone through all the SD documentation and examples available (like linked in this answer) as I am not on such a low level like Arduino but on a Linux system instead.

This post says an SD card needs to be "switched" to SPI mode first and I am not sure how this is compatible with the SPI boot process in Linux. Can someone explain please?

Edit: The reason for booting from SPI on a Linux board that has a micro SD card slot is that I want to use this slot as a secondary removable storage only (for saving photos etc.) and want to have a system on different SD card that will be directly soldered to the SPI interface (possibly without intermediate board/controller).

\$\endgroup\$
  • \$\begingroup\$ I don't understand the question. If you have an SD card, connect it to the SD interface on the board. If you want to boot over SPI, use a SPI flash. Why would you deliberately connect a device to the wrong interface? \$\endgroup\$ – Dave Tweed Sep 21 '18 at 12:18
  • \$\begingroup\$ Sorry I just added the explanation - please see the edit. \$\endgroup\$ – Kozuch Sep 21 '18 at 12:19
  • \$\begingroup\$ That doesn't answer my question. If you want to use the SPI interface, use a SPI flash chip, not an SD card. \$\endgroup\$ – Dave Tweed Sep 21 '18 at 12:20
  • \$\begingroup\$ The reason is cost - SPI flash is expensive, SD card is cheap for same amount of storage. Edit: To be more exact, those two do not really match in storage size, my requirement exceeds SPI flash capacity - I need few GBytes. \$\endgroup\$ – Kozuch Sep 21 '18 at 12:21
  • \$\begingroup\$ Why do you need the same amount of storage? The boot device only needs to contain the OS kernel and a compressed initial filesystem image. \$\endgroup\$ – Dave Tweed Sep 21 '18 at 12:37
1
\$\begingroup\$

I'm not intimately familiar with the details of booting Linux on ARM, but I once had to boot a DSP chip from a device that the on-chip boot ROM didn't understand. I ended up writing a second-stage bootloader that the on-chip loader could read, after which my loader reconfigured the chip and booted the actual application.

You might need to do something similar, using a small SPI flash for the second-stage bootloader, and wiring your SD card to the same SPI inteface using a second chip-select line.

\$\endgroup\$
1
\$\begingroup\$

Can an SD card accept SPI communication right away or is there any "SPI mode initialization" needed on the card?

Yes. I have written SD-card read/write code for a micro controller and it is only using the SPI interface. But beware that the SD interface has some 'nasty' requirements which means you can't do it all in 'byte' mode. At some point you have to wait for a '0' to arrive (which can be after e.g. 6 clocks) and start processing bytes from there.

I found a lot of SD-cards play 'nice' in that they set the 8'th bit (last bit of a byte) low so you can use 'byte' mode for those. But not all manufactures are so kind.

Also to reset (CMD0) you have to send clocks with NO chip select.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.