Skip to content

USB host/device boot - various improvements #1126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 47 commits into from Jul 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
2efd3c0
Mention in bold that USB host boot only available on Pi 3 and 2v1.2
Apr 25, 2019
3af4ee0
Mention in bold that USB host boot only available on Pi 3 and 2v1.2
Apr 25, 2019
d20a997
Fix: USB *mass storage* boot only on 3 and 2v1.2
Apr 25, 2019
683406b
Mention only Pi 3 and 2v1.2 can do net boot, correct a sub-heading
Apr 25, 2019
e5b632d
Make mention of which Pi models can do USB host boot consistent with …
Apr 25, 2019
a0754d6
Fix capitalisation in page heading
Apr 25, 2019
44ecfbf
Make page title consistent with link from hardware/raspberrypi/README.md
Apr 27, 2019
666f428
Revert "Make page title consistent with link from hardware/raspberryp…
Apr 27, 2019
bff4b0f
Make page title consistent with link from hardware/raspberrypi/bootmo…
Apr 27, 2019
6fa06a1
bootmodes/device.md - improve page heading, improve wording
Apr 27, 2019
06b8aa8
Change warning about which Pi's can do USB boot
Apr 27, 2019
b276448
Add Pi A and 3A+ to USB device mode boot docs
Apr 27, 2019
7c114aa
3A+ cannot net boot (no NIC)
Apr 28, 2019
7b8c133
bootmodes/host.md: explain 3A+ can do MSD, not netboot
Apr 28, 2019
3b1e3be
3A+ cannot net boot (no NIC) (take 2)
Apr 28, 2019
c1aedf5
bootmodes/README.md - fix up some wording around USB host boot
Apr 28, 2019
c17ccdb
use lurch's wording
Apr 29, 2019
fe57a63
capitalise Ethernet to match other instances
Apr 29, 2019
d27a19d
clarify / simplify wording
Apr 29, 2019
a3491d3
Improve accuracy
Apr 29, 2019
18d0680
Combine BCM2837A0 and B0 variants into single page
Apr 29, 2019
65eb7e5
add B0 variant Pi models
Apr 29, 2019
b5d2626
Revert "add B0 variant Pi models"
Apr 30, 2019
3781df9
Revert "Combine BCM2837A0 and B0 variants into single page"
Apr 30, 2019
5295414
bootflow.md - this page only applies to 2837-based Pi's add relevant …
Apr 30, 2019
de81ff4
tweak: move period outside link
Apr 30, 2019
96e3545
fix markup
Apr 30, 2019
e2e0216
MSD -> mass storage device
Apr 30, 2019
94abcf0
MSD -> mass storage device (take 2)
Apr 30, 2019
37d158f
tweak wording
Apr 30, 2019
284db1c
msd.md - standardise heading
Apr 30, 2019
b8c4a06
fix typo
Apr 30, 2019
dfa90f1
Don't say that USB device boot is enabled on all Pi's, since it doesn…
Apr 30, 2019
d5a3de9
fix wording
Apr 30, 2019
09f624a
fix wording
Apr 30, 2019
6e99f70
mention OTP bit for USB device mode is enabled by default, but don't …
Apr 30, 2019
f1f4f8d
fix wording
Apr 30, 2019
55b5561
Update device.md
May 10, 2019
3213e1e
some models -> above models of Pi
Jun 8, 2019
9eeedfd
fix wording "the required built in net iface" -> "a built in..."
Jun 12, 2019
dfbad1f
Minor changes in copy-edit
Jul 17, 2019
01806cb
Minor changes in copy-edit
Jul 17, 2019
dbeda0d
Minor changes in copy-edit
Jul 17, 2019
9e94f62
Minor changes in copy-edit
Jul 17, 2019
bf7dd70
Minor changes in copy-edit
Jul 17, 2019
eeb057b
V minor change in copy-edit
Jul 17, 2019
adc0a50
Merge branch 'master' into patch-2
JamesH65 Jul 18, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions hardware/raspberrypi/bootmodes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ The Raspberry Pi has a number of different stages of booting. This document expl
[GPIO boot mode](gpio.md)

## Special bootcode.bin-only boot mode
USB host and Ethernet boot can be performed by BCM2837-based Raspberry Pis (these are all Pi 3 models, and some Pi 2Bs). In addition, all Raspberry Pi models can use a new bootcode.bin-only method to enable USB host and Ethernet booting.
USB host and Ethernet boot can be performed by BCM2837-based Raspberry Pis - that is, Pi 2B version 1.2, Pi 3B, and Pi 3B+ (Raspberry Pi 3A+ cannot net boot since it does not have a built-in Ethernet interface). In addition, all Raspberry Pi models can use a new bootcode.bin-only method to enable USB host boot.

Just format an SD card as FAT32 and copy on the latest [bootcode.bin](https://github.com/raspberrypi/firmware/raw/master/boot/bootcode.bin).
Format an SD card as FAT32 and copy on the latest [bootcode.bin](https://github.com/raspberrypi/firmware/raw/master/boot/bootcode.bin). The SD card must be present in the Pi for it to boot. Once bootcode.bin is loaded from the SD card, the Pi continues booting using USB host mode.

This is useful for the Raspberry Pi 1, 2, and Zero models, which are based on the BCM2835 and BCM2836 devices, and in situations where a Pi 3 fails to boot (the latest bootcode.bin includes additional bugfixes for the Pi 3, compared to the boot code burned into the BCM2837).
This is useful for the Raspberry Pi 1, 2, and Zero models, which are based on the BCM2835 and BCM2836 chips, and in situations where a Pi 3 fails to boot (the latest bootcode.bin includes additional bugfixes for the Pi 3B, compared to the boot code burned into the BCM2837A0).

If you have a problem with a mass storage device still not working even with this bootcode.bin, then please add a new file 'timeout' to the SD card. This should extend the time it waits for the mass storage device to initialise to six seconds.
If you have a problem with a mass storage device still not working, even with this bootcode.bin, then please add a new file 'timeout' to the SD card. This will extend to six seconds the time for which it waits for the mass storage device to initialise.

## bootcode.bin UART enable

Expand Down
6 changes: 4 additions & 2 deletions hardware/raspberrypi/bootmodes/bootflow.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Boot flow for models prior to the Raspberry Pi 4
# Boot sequence

The flow of boot begins with reading the OTP to decide on the valid boot modes enabled. By default, this is SD card boot followed by USB device boot. Subsequently, the boot ROM checks to see if the GPIO boot mode OTP bits have been programmed — one to enable GPIO boot mode and one to select the bank of GPIOs it uses to disable boot modes (low = GPIOs 22-26, high = GPIOs 39-43). This makes it possible to use a hardware switch to choose between different boot modes if there is more than one available.
**The following boot sequence applies to the BCM2837-based models of Raspberry Pi only. On all other models, the Pi will try [SD card boot](sdcard.md), followed by [USB device mode boot](device.md).**

The boot sequence begins with reading the OTP to determine which boot modes are enabled. By default, this is SD card boot followed by USB device boot. Subsequently, the boot ROM checks to see whether the GPIO boot mode OTP bits have been programmed — one to enable GPIO boot mode, and one to select the bank of GPIOs it uses to disable boot modes (low = GPIOs 22-26, high = GPIOs 39-43). This makes it possible to use hardware attached to the GPIO connector to choose between different boot modes.

The GPIO boot mode OTP bits can be programmed by adding `program_gpio_bootmode=n` to `config.txt`, where n is `1` to select the low bank (22-26) or `2` to select the high bank (39-43). Once added, boot the device, then power-cycle it (rebooting is not sufficient). You should expect it to no longer boot (all boot modes will be disabled by default). Apply a pull-up to the required pin to enable the required boot mode. After programming, the `config.txt` setting can be removed.

Expand Down
13 changes: 8 additions & 5 deletions hardware/raspberrypi/bootmodes/device.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
# Device boot
# USB device boot mode

The following devices can boot through the special device boot mode:
The following devices can boot using USB device boot mode:

* Pi CM
* Pi CM3
* Pi Compute Module
* Pi Compute Module 3
* Pi Zero
* Pi Zero W
* Pi A
* Pi A+
* Pi 3A+

When this boot mode is activated (usually after a failure to boot from the SD card), it switches to a USB device and awaits a USB reset from the host. Example code showing how the host needs to talk to the Pi can be found [here](https://github.com/raspberrypi/usbboot).
When this boot mode is activated (usually after a failure to boot from the SD card), the Raspberry Pi puts its USB port into device mode and awaits a USB reset from the host. Example code showing how the host needs to talk to the Pi can be found [here](https://github.com/raspberrypi/usbboot).

The host first sends a structure to the device down control endpoint 0. This contains the size and signature for the boot (security is not enabled so no signature is required). Secondly, code is transmitted down endpoint 1 (bootcode.bin). Finally, the device will reply with a success code of:

Expand Down
10 changes: 6 additions & 4 deletions hardware/raspberrypi/bootmodes/host.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# USB Host boot mode
# USB host boot mode

**USB host boot is available on Raspberry Pi 3B, 3B+, 3A+, and 2B v1.2 only. Raspberry Pi 3A+ only supports mass storage boot, not network boot.**

The USB host boot mode follows this sequence:

Expand All @@ -12,11 +14,11 @@ The USB host boot mode follows this sequence:
* If VID == SMSC && PID == 9500
* Add device to Ethernet device list
* If class interface == mass storage class
* Add device to MSD device list
* Add device to mass storage device list
* Else
* Enumerate single device
* Go through MSD device list
* [Boot from MSD](msd.md)
* Go through mass storage device list
* [Boot from mass storage device](msd.md)
* Go through Ethernet device list
* [Boot from Ethernet](net.md)

4 changes: 2 additions & 2 deletions hardware/raspberrypi/bootmodes/msd.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# How to boot from a USB mass storage device on a Raspberry Pi
# USB mass storage device boot

**USB boot is available on the Raspberry Pi 3B, 3B+, 3A+ and Raspberry Pi 2B v1.2 models only.**
**USB mass storage boot is available on Raspberry Pi 3B, 3B+, 3A+, and 2B v1.2 only.**

This tutorial explains how to boot your Raspberry Pi from a USB mass storage device such as a flash drive or USB hard disk. Be warned that this feature is experimental and does not work with all USB mass storage devices. See [this blog post](https://www.raspberrypi.org/blog/pi-3-booting-part-i-usb-mass-storage-boot/) from Gordon Hollingworth for an explanation of why some USB mass storage devices don't work, as well as for some background information.

Expand Down
6 changes: 4 additions & 2 deletions hardware/raspberrypi/bootmodes/net.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Network booting

This section describes how network booting works. We also have a [tutorial about setting up a working bootable system](net_tutorial.md). Network booting works only for the wired adapter built into certain models of Raspberry Pi. Booting over wireless LAN is not supported, nor is booting from any other wired network device.
**Network booting is available on Raspberry Pi 3B, 3B+, and 2B v1.2 only.**

This section describes how network booting works. We also have a [tutorial about setting up a working bootable system](net_tutorial.md). Network booting works only for the wired adapter built into the above models of Raspberry Pi. Booting over wireless LAN is not supported, nor is booting from any other wired network device.

To network boot, the boot ROM does the following:

Expand All @@ -22,7 +24,7 @@ To get the serial number for the device you can either try this boot mode and se

If you put all your files into the root of your tftp directory then all following files will be accessed from there.

## Debugging the NFS boot mode
## Debugging the network boot mode

The first thing to check is that the OTP bit is correctly programmed. To do this, you need to add `program_usb_boot_mode=1` to config.txt and reboot (with a standard SD card that boots correctly into Raspbian). Once you've done this, you should be able to do:

Expand Down
6 changes: 2 additions & 4 deletions hardware/raspberrypi/bootmodes/usb.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# USB boot modes

There are two separate boot modes for USB:
There are two separate boot modes for USB (available only on certain models):

* [USB device boot](device.md)
* [USB host boot](host.md) with boot options:
* [USB mass storage boot](msd.md)
* [Network boot](net.md)

Note that network boot is only possible on Raspberry Pi models that have a built-in wired Ethernet interface.

The choice between the two boot modes is made by the firmware at boot time when it reads the OTP bits. There are two bits to control USB boot: the first enables device boot and is enabled by default on all Raspberry Pi computers. The second bit enables USB host boot; if this bit is also set, then the processor reads the OTGID pin to decide whether to boot as a host (driven to zero as on the Raspberry Pi Model B) or as a device (left floating). The Pi Zero has access to this pin through the OTGID pin on the USB connector, and the Compute Module has access to this pin on the edge connector.
The choice between the two boot modes is made by the firmware at boot time when it reads the OTP bits. There are two bits to control USB boot: the first enables USB device boot and is enabled by default. The second enables USB host boot; if the USB host boot mode bit is set, then the processor reads the OTGID pin to decide whether to boot as a host (driven to zero as on the Raspberry Pi Model B) or as a device (left floating). The Pi Zero has access to this pin through the OTGID pin on the USB connector, and the Compute Module has access to this pin on the edge connector.

There are also OTP bits that allow certain GPIO pins to be used for selecting which boot modes the Pi should attempt to use.