Skip to content

Commit f211851

Browse files
Merge pull request #4037 from timg236/bootloader-reliability
Document new bootloader options
2 parents eeb29da + c1fcba4 commit f211851

File tree

4 files changed

+80
-1
lines changed

4 files changed

+80
-1
lines changed

documentation/asciidoc/computers/config_txt/conditional.adoc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,34 @@ Some models of Raspberry Pi, including Zero, Compute Module, and Keyboard models
9696

9797
The `[none]` filter prevents any settings that follow from being applied to any hardware. Although there is nothing that you can't do without `[none]`, it can be a useful way to keep groups of unused settings in config.txt without having to comment out every line.
9898

99+
=== The `[partition=N]` filter
100+
This `partition` filter can be be used to select alternate boot flows according to the requested partition number (`sudo reboot N`) or via direct usage of the `PM_RSTS` watchdog register.
101+
102+
[source,ini]
103+
----
104+
# Bootloader EEPROM config.
105+
# If PM_RSTS is partition 62 then set bootloader properties to disable
106+
# SD high speed and show HDMI diagnostics
107+
# Boot from partition 2 with debug option.
108+
[partition=62]
109+
# Only high (>31) partition can be remapped.
110+
PARTITION=2
111+
SD_QUIRKS=0x1
112+
HDMI_DELAY=0
113+
----
114+
115+
Example `config.txt` - (Currently Raspberry Pi 5 onwards)
116+
[source,ini]
117+
----
118+
# config.txt - If the original requested partition number in PM_RSTS was a
119+
# special number then use an alternate cmdline.txt
120+
[partition=62]
121+
cmdline=cmdline-recovery.txt
122+
----
123+
124+
The raw value of the `PM_RSTS` register at bootup is available via `/proc/device-tree/chosen/bootloader/rsts` and the final partition number used for booting is available via `/proc/device-tree/chosen/bootloader/partition`. These are big-endian binary values.
125+
126+
99127
=== The `[tryboot]` filter
100128

101129
This filter succeeds if the `tryboot` reboot flag was set.

documentation/asciidoc/computers/configuration/device-tree.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,8 @@ The firmware uses the special https://www.kernel.org/doc/html/latest/devicetree/
845845

846846
`rpi-duid`:: _(string)_ Raspberry Pi 5 only. A string representation of the QR code on the PCB.
847847

848+
`rpi-serial64`:: _(string)_ A string representation of the 64-bit serial number. On flagship models since Raspberry Pi 5 this is same as the normal serial number (`/proc/device-tree/serial-number`). On earlier models the default serial number is still 32-bit but with newer firmware a 64-bit serial number is now available and is visible through this node.
849+
848850
==== Common bootloader properties `/chosen/bootloader`
849851

850852
Each property is stored as a 32-bit integer unless indicated otherwise.

documentation/asciidoc/computers/raspberry-pi/eeprom-bootloader.adoc

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Default: `0`
3434
[[UART_BAUD]]
3535
==== `UART_BAUD`
3636

37-
Raspberry Pi 5 only.
37+
Flagship models since Raspberry Pi 5 only.
3838

3939
Changes the baud rate for the bootloader UART.
4040

@@ -62,6 +62,15 @@ On Flagship models since Raspberry Pi 5 and Keyboard models since Pi 500, this p
6262

6363
Default: `1` on Compute Modules since CM5 and Keyboard models; otherwise `0`
6464

65+
[[WAIT_FOR_POWER_BUTTON]]
66+
==== `WAIT_FOR_POWER_BUTTON`
67+
68+
Flagship models since Raspberry Pi 5 only.
69+
70+
If this property and `POWER_OFF_ON_HALT` are both set to `1` then the bootloader will immediately power-off and wait for the power to be pressed on the first boot after the power supply has been removed. This means that instead of booting immediately after power-loss the system will wait for the power button to be pressed.
71+
72+
Default: `0`
73+
6574
[[BOOT_ORDER]]
6675
==== `BOOT_ORDER`
6776

@@ -151,6 +160,24 @@ The number of times that SD boot will be retried after failure before moving to
151160

152161
`-1` means infinite retries.
153162

163+
Default: `0`
164+
165+
[[SD_QUIRKS]]
166+
==== `SD_QURIKS`
167+
168+
The `SD_QUIRKS` property provides a set of options to support device bringup and workaround interoperability issues.
169+
170+
The flags are implemented as a bit-field. Undefined bits are reserved for future use and should be set to zero.
171+
172+
[cols="1m,3"]
173+
|===
174+
| Value | Behaviour
175+
176+
| 0x1
177+
| Disable SD High Speed modes. The card clock is limited to 12.5 MHz
178+
|===
179+
180+
154181
Default: `0`
155182

156183
[[NET_BOOT_MAX_RETRIES]]
@@ -472,6 +499,19 @@ Max length: 32 characters
472499
The `PARTITION` option may be used to specify the boot partition number, if it has not explicitly been set by the `reboot` command (e.g. `sudo reboot N`) or by `boot_partition=N` in `autoboot.txt`.
473500
This could be used to boot from a rescue partition if the user presses a button.
474501

502+
The latest firmware also allows high partition numbers (> 31) to be overriden. This allows a custom setup of the system hardware watchdog to trigger a reboot with a special high partition number (e.g. 62) which can be detected by the bootloader (using a conditional filter) and remapped to a recovery partition.
503+
504+
Example:
505+
[source,ini]
506+
----
507+
# System watchdog fired - boot the rescue partition with additional options
508+
# Disable SD high speed mode and enable HDMI diagnostics immediately.
509+
[partition=62]
510+
PARTITION=2
511+
HDMI_DELAY=0
512+
SD_QUIRKS=1
513+
----
514+
475515
[source,ini]
476516
----
477517
# Boot from partition 2 if GPIO 7 is pulled low
@@ -481,6 +521,14 @@ PARTITION=2
481521

482522
Default: 0
483523

524+
[[PARTITION_WALK]]
525+
==== `PARTITION_WALK`
526+
This property is designed to improve the reliability of `A/B` boot schemes using `autoboot.txt` by searching for bootable partitions if the specified partition does not appear to be bootable. If `PARTITION_WALK=1` and the requested partition is not bootable and does not have a valid `autoboot.txt` then the bootloader will check each partition in turn (up to 8 and wrapping to 0) to see if it is bootable (contains `start4.elf` on a Pi4, or `config.txt` and a suitable device-tree on Pi 5 or newer).
527+
528+
During the "partition walk" `autoboot.txt` files are not processed to avoid cycling dependencies. It is assumed that the requested boot partition has failed and the system is attempting recovery.
529+
530+
Default: `0`
531+
484532
[[PSU_MAX_CURRENT]]
485533
==== `PSU_MAX_CURRENT`
486534

documentation/asciidoc/computers/raspberry-pi/otp-bits.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ This is available via device-tree in `/proc/device-tree/chosen/rpi-boardrev-ext`
5454
* Raspberry Pi 400
5555
** Bits 0-7: The default keyboard country code used by https://github.com/raspberrypi-ui/piwiz[piwiz]
5656

57+
`35` :: High 32 bits of 64-bit serial number
5758
`36-43`:: xref:raspberry-pi.adoc#industrial-use-of-the-raspberry-pi[customer OTP values]
5859
`45`:: MPG2 decode key
5960
`46`:: WVC1 decode key

0 commit comments

Comments
 (0)