Skip to content

Commit a30e7c7

Browse files
mathewb64pelwell
authored andcommitted
rpieepromab: docs: Add details to README
1 parent 61371fa commit a30e7c7

1 file changed

Lines changed: 192 additions & 8 deletions

File tree

rpieepromab/README.md

Lines changed: 192 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,200 @@
1-
21
# rpi-eeprom-ab
32

4-
The Raspberry Pi EEPROM AB service is a mailbox based API
3+
The Raspberry Pi EEPROM AB service is a mailbox-based API
54
that allows you to update and manage the AB EEPROM partitions.
65

76
Although this service can be used via raw vcmailbox commands the
8-
recommended API is the command line rpi-eeprom-ab application.
7+
recommended API is the command line `rpi-eeprom-ab` application.
8+
9+
This service currently only exists on the Raspberry Pi 5 family of
10+
devices running AB-capable firmware.
911

1012
## Build Instructions
1113

12-
- *mkdir build*
13-
- *cd build*
14-
- *cmake ..*
15-
- *make*
16-
- *sudo make install*
14+
```
15+
mkdir build
16+
cd build
17+
cmake ..
18+
make
19+
sudo make install
20+
```
21+
22+
If overwriting the system (APT) installed `rpi-eeprom-ab`, set the CMake
23+
install prefix to `/usr`. Otherwise, there will be a library mismatch because
24+
the default install prefix is `/usr/local`:
25+
26+
```
27+
cmake -DCMAKE_INSTALL_PREFIX=/usr ..
28+
```
29+
30+
## Usage
31+
32+
Display usage instructions for all operations:
33+
34+
```
35+
rpi-eeprom-ab help
36+
```
37+
38+
Show the application and library version:
39+
40+
```
41+
rpi-eeprom-ab version
42+
```
43+
44+
### EEPROM read and write
45+
46+
Update the opposite AB partition with a new bootloader image. The update file
47+
must be a valid partition image and must meet the board's minimum bootloader
48+
version. An update can only be performed when the current partition
49+
is committed.
50+
51+
```
52+
rpi-eeprom-ab update pieeprom-ab.bin
53+
```
54+
55+
Extract a partition image from an AB-capable full pieeprom image:
56+
57+
```
58+
dd if=pieeprom.bin bs=1K skip=64 count=988 of=pieeprom-ab.bin
59+
```
60+
61+
Read the currently selected AB partition to a file:
62+
63+
```
64+
rpi-eeprom-ab read current-partition.bin
65+
```
66+
67+
Read the entire 2 MiB EEPROM to a file:
68+
69+
```
70+
rpi-eeprom-ab dump eeprom-full.bin
71+
```
72+
73+
Get the current status of an EEPROM update:
74+
75+
```
76+
rpi-eeprom-ab update-status
77+
```
78+
79+
### Partition info
80+
81+
Get the currently selected AB partition (`A` or `B`):
82+
83+
```
84+
rpi-eeprom-ab partition
85+
```
86+
87+
Get whether the current partition is committed (`0` or `1`):
88+
89+
```
90+
rpi-eeprom-ab committed
91+
```
92+
93+
Get the committed and valid partition selections and their SHA-256 hashes:
94+
95+
```
96+
rpi-eeprom-ab partition-status
97+
```
98+
99+
Get the partition used at boot and whether it was committed at time of boot:
100+
101+
```
102+
rpi-eeprom-ab status-at-boot
103+
```
104+
105+
### Partition validation and commit
106+
107+
Mark the uncommitted partition as valid.
108+
The hash (a 64-character hex string) must match the SHA-256 hash of the update image.
109+
110+
```
111+
rpi-eeprom-ab mark-partition-valid <hash>
112+
```
113+
114+
Revert to the committed partition as the valid selection, overwriting a
115+
previous `mark-partition-valid`. The hash must match the SHA-256 hash of the
116+
committed partition:
117+
118+
```
119+
rpi-eeprom-ab revert-to-committed <hash>
120+
```
121+
122+
Commit the current AB partition:
123+
124+
```
125+
rpi-eeprom-ab commit
126+
```
127+
128+
Force commit the opposite partition. When this is used, the partition will not
129+
automatically be rolled back if there is a failure.
130+
131+
```
132+
rpi-eeprom-ab force-commit-opposite
133+
```
134+
135+
### Tryboot
136+
137+
When tryboot is enabled (`1`), the bootloader will attempt to boot from the
138+
valid but uncommitted partition on the next reboot. When disabled (`0`), only
139+
the committed partition is used.
140+
141+
Get the current tryboot value:
142+
143+
```
144+
rpi-eeprom-ab tryboot
145+
```
146+
147+
Enable or disable tryboot:
148+
149+
```
150+
rpi-eeprom-ab tryboot 1
151+
rpi-eeprom-ab tryboot 0
152+
```
153+
154+
### Typical update workflow
155+
156+
1. Write the new image to the opposite partition:
157+
```
158+
rpi-eeprom-ab update pieeprom-ab.bin
159+
```
160+
2. Mark the updated partition as valid. The hash must match the SHA-256 hash of
161+
the image written in step 1:
162+
```
163+
export UPDATE_HASH="$(sha256sum pieeprom-ab.bin | awk '{print $1}')"
164+
rpi-eeprom-ab mark-partition-valid "$UPDATE_HASH"
165+
```
166+
3. Enable tryboot and reboot. The tryboot flag is a one-shot flag that is
167+
cleared during boot, so a failed boot falls back to the committed
168+
partition next time:
169+
```
170+
rpi-eeprom-ab tryboot 1
171+
sudo reboot
172+
```
173+
4. After rebooting, verify that the system booted from the new (uncommitted)
174+
partition. `committed` returns `0` when running from the uncommitted
175+
partition, confirming tryboot succeeded:
176+
```
177+
rpi-eeprom-ab committed
178+
```
179+
5. Commit the partition so it is used for all future boots:
180+
```
181+
rpi-eeprom-ab commit
182+
```
183+
184+
#### Forced update alternative
185+
186+
Steps 1 and 2 are the same as above. Then, instead of using tryboot, force
187+
commit the newly written (opposite) partition so it becomes the partition used
188+
for all future boots. This skips the tryboot rollback mechanism, so only use it
189+
when the new image is known to be good:
190+
191+
```
192+
rpi-eeprom-ab force-commit-opposite
193+
```
194+
195+
## Error handling and debug
196+
197+
If the firmware reports an error then `rpi-eeprom-ab` prints a descriptive
198+
message and returns a non-zero exit code.
199+
200+
The firmware logs can be viewed with `sudo vclog -m` for additional debug.

0 commit comments

Comments
 (0)