Richard_H
Posts: 12
Joined: Mon Apr 04, 2016 1:48 am

Booting Pi from SPI or NAND

Thu Sep 29, 2016 4:50 pm

I understand the Pi can boot from SPI or NAND, but I'm not finding any documentation around these options. Are they actually implemented? (e.g., it looks like booting from mass storage has only just been implemented.)
https://github.com/raspberrypi/document ... ootflow.md

I have a project that needs to be reliable long-term, and SD card seems to be a frequent failure point. I'm not sure I'd have any greater faith in a USB flash card. Network booting isn't an option here. I've got to develop a hat for other reasons anyway, and would like to add a more reliable boot source there.

Any pointers to using SPI or NAND boot sources?

User avatar
joan
Posts: 13929
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Booting Pi from SPI or NAND

Thu Sep 29, 2016 4:51 pm

News to me. Where did you hear that the Pi can boot from SPI or NAND?

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 11762
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Booting Pi from SPI or NAND

Thu Sep 29, 2016 5:10 pm

any SD-card initially starts up in single bit SPI mode, and its possible to access any FAT32 partition that way, so yes, in theory the PI should be able to boot from an SPI device, like a serial EEPROM, a couple years back I suggested to do exactly that to expand the simple boot system of the PI, but nothing came of that.
Staying in SPI mode will however affect performance negatively as the regular (nibble) mode is much faster.
Note that the Compute Module boots and runs from a similar connected device that isn't a simple SD-card.

Richard_H
Posts: 12
Joined: Mon Apr 04, 2016 1:48 am

Re: Booting Pi from SPI or NAND

Thu Sep 29, 2016 9:41 pm

joan wrote:News to me. Where did you hear that the Pi can boot from SPI or NAND?
Hi, Joan.

The link in my post shows the boot sequence, which includes SPI and NAND options. Presuming it's like what I've read about MSD boot, you would apparently have to enable it in the OTP first, and then strap a GPIO pin at boot-up to activate it to try.

Richard_H
Posts: 12
Joined: Mon Apr 04, 2016 1:48 am

Re: Booting Pi from SPI or NAND

Thu Sep 29, 2016 9:51 pm

mahjongg wrote:any SD-card initially starts up in single bit SPI mode, and its possible to access any FAT32 partition that way, so yes, in theory the PI should be able to boot from an SPI device, like a serial EEPROM, a couple years back I suggested to do exactly that to expand the simple boot system of the PI, but nothing came of that.
Staying in SPI mode will however affect performance negatively as the regular (nibble) mode is much faster.
Note that the Compute Module boots and runs from a similar connected device that isn't a simple SD-card.
Hi, Mahjongg.

This is similar to what I'm exploring. I'm not too concerned about the speed at the moment. I'll explore the compute module's approach - are you referring to eMMC?

If one were to tap the SD boot behavior you describe, are the SPI pins on the header on a shared bus with the SD slot? i.e., if there's no SD card in the slot, could the SD card boot process be hijacked via the header pins? Or would I be looking at soldering on the SD pins? (Easily done for prototyping, but hoping I can implement this in a turnkey hat.)

More broadly, do you know if they've implemented / documented these options yet?

Thanks!

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 11762
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Booting Pi from SPI or NAND

Sun Oct 02, 2016 4:45 pm

yes eMMC.

No the PI's card interface has its own hardware block in the SoC not part of the regular GPIO, and SPI is just a subpart of it, the pins cannot (IMHO) be relocated to a GPIO pin.

Also my thought about the Boot code using SPI mode, is just an assumption based on the fact that the boot code must be as small/simple as possible, and switching from the initial SPI mode to any of the faster modes is a tricky process, code that works on all SD-cards is hard to create and extensive. Thats why I assume it (the boot code) simply defaults to SPI mode.

I've never seen an implementation of booting from an EEPROM, and yes, you need to modify the PCB, or solder wires directly to the SD-card holder.

IMHO ALL forms of Flash memory can be "flimsy", in fact the more you study how it all works, the more improbable it seems it does.... :mrgreen: But the mayor culprit for failure to me seems to be a power shutdown while the card controller is doing "household management tasks".

Olma
Posts: 3
Joined: Tue Sep 12, 2017 8:05 pm

Re: Booting Pi from SPI or NAND

Tue Sep 12, 2017 8:43 pm

Other boards can be booted from SPI through the GPIO pins : https://linux-sunxi.org/Bootable_SPI_flash
Is it possible to do the same for the rpi 3 and just connect a SPI flash chip to the right pins?

Richard_H
Posts: 12
Joined: Mon Apr 04, 2016 1:48 am

Re: Booting Pi from SPI or NAND

Wed Sep 13, 2017 7:06 am

Olma,

I ran into a dead end with this last year, but perhaps times change.

I recall the obstacles were that the Pi3 does not expose any boot methods though the headers (SPI boot was limited to the SPI wired to the SD slot, but not the one exposed on the header). I was also looking at using SPI as a kind of network bus between 2 Pis (say, with one of them emulating a storage device, or a remote NIC), but the Broadcom chip doesn't have a published way to put the SPI interface into slave mode. Sad, because that's such a simple thing.

My goal was to provide a non-network boot option through the header pins to be more reliable than USB or SD, but it doesn't appear that the firmware (at that time) had the capability. I recall there is a technique (developed for flashless Pi Zero projects) where the boot code can be pushed through USB keyboard or serial method, but again it was more of a hack than I was trying to achieve.

If anyone knows more (perhaps a bootstrap update?) about how to boot the Pi via header pins, I'd love to hear about it here.

Olma
Posts: 3
Joined: Tue Sep 12, 2017 8:05 pm

Re: Booting Pi from SPI or NAND

Wed Sep 13, 2017 10:25 am

The boot through USB keyboard or serial sounds interesting. Any links for that?
I would be ok with using the normal SD card pins for SPI booting. There are also SD card extender cables so maybe one would not need to solder something on the board.
It may also be possible to boot via a SPI EEPROM attached to the GPIO pins.
The primary SD card boot mode is, as standard, set to be GPIOs 49-53. It is possible to boot from the secondary SD card on a second set of pins, i.e. to add a secondary SD card to the GPIO pins. However, we have not yet enabled this ability
https://github.com/raspberrypi/document ... ootflow.md

I opened a issue on github to see if we can enable this boot mode: https://github.com/raspberrypi/firmware/issues/874

Richard_H
Posts: 12
Joined: Mon Apr 04, 2016 1:48 am

Re: Booting Pi from SPI or NAND

Wed Sep 13, 2017 2:55 pm

Hi, Olma.

No links, sorry. It didn't fit with my goal of using only the headers, so I didn't archive it. I seem to recall it's been done for a Pi Zero in an attempt to keep the hardware cost very low.

Yes, the option to boot from the secondary SPI would allow doing it via the headers if they added that support. I imagine a fake SD card on a cable could also achieve the same today.

Please do update this thread if you find anything new.

Cheers,
Richard
Last edited by Richard_H on Sat Sep 16, 2017 11:52 pm, edited 1 time in total.

jimmypopali96
Posts: 6
Joined: Wed Apr 17, 2013 7:49 am

Re: Booting Pi from SPI or NAND

Sat Sep 16, 2017 8:31 pm

Has anyone had any success with this?
I'm working on a project that spi boot would be invaluable !

phychris
Posts: 3
Joined: Thu Nov 12, 2015 8:57 pm

Re: Booting Pi from SPI or NAND

Thu Apr 18, 2019 4:49 pm

This is my only hope to save my pi2 from its brick existence. Bad SD trace, pin 8 (DAT1)

Return to “Advanced users”