Skip to content

Commit cd18641

Browse files
authored
os: Bootloader configuration (#589)
* `BOOT_ORDER=0xf461`: sdcard, nvme, then usb * `POWER_OFF_ON_HALT`: enter low power state when powered off (1W -> 0.1W) * `WAIT_FOR_POWER_BUTTON`: do not automatically power on after plugging power cable See * https://www.raspberrypi.com/documentation/computers/config_txt.html * https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#configuration-properties * #589
1 parent e8d16f2 commit cd18641

File tree

10 files changed

+81
-21
lines changed

10 files changed

+81
-21
lines changed

documentation/docs/community/contribute/tips-and-tricks.md

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,7 @@ The default behavior of the PlanktoScope is to act as a router to connect your c
106106
If you have a LAN it may be more convenient to connect the PlanktoScope to it and act as a simple client.
107107

108108
```sh
109-
# Ethernet
110-
nmcli connection down eth0-static
111109
nmcli connection up eth0-default
112-
113-
# Wifi
114-
nmcli connection down wlan0-hotspot
115110
```
116111

117112
<details>
@@ -120,10 +115,6 @@ nmcli connection down wlan0-hotspot
120115
```sh
121116
# Ethernet
122117
nmcli connection down eth0-default
123-
nmcli connection up eth0-static
124-
125-
# Wifi
126-
nmcli connection up wlan0-hotspot
127118
```
128119
</details>
129120

@@ -137,15 +128,6 @@ If that doesn't work, type `nmap -sn 192.168.1.0/24` from your computer to find
137128

138129
See also the operating guide [Networking](https://docs-edge.planktoscope.community/operation/networking/)
139130

140-
## Disable splash screen
141-
142-
We recommend disabling the splash screen to get better boot logs
143-
144-
```sh
145-
sudo nano /boot/firmware/cmdline.txt
146-
# remove "quiet splash plymouth.ignore-serial-consoles"
147-
```
148-
149131
## Backup and Restore SD Card
150132

151133
You will need to plug the SD card into your computer.
@@ -155,7 +137,7 @@ You will need to plug the SD card into your computer.
155137

156138
```sh
157139
# backup whole SD card onto an image file on your computer
158-
sudo dd bs=1M if=/dev/device status=progress | xz > sdcard.img.xz
140+
sudo dd bs=1M if=/dev/device status=progress conv=fdatasync | xz > sdcard.img.xz
159141
```
160142

161143
```sh

documentation/docs/reference/hardware/changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ Easier access to the SD Card, no need for tweezers anymore
3030
3131
The Raspberry micro HDMI ports are now accessible
3232
33+
Reduce power usage when powered off
34+
35+
Does not automatically power on when connected anymore
36+
3337
-->
3438

3539
## v2.6
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
[all]
2+
bootloader_update=0
3+
disable_poe_fan=1
14

5+
[pi5]
26
# Enable battery charging
37
# https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#enable-battery-charging
4-
[pi5]
58
dtparam=rtc_bbat_vchg=3000000
9+
# Enable self update for RPI 5 only
10+
bootloader_update=1
611

712
[all]

software/distro/setup/planktoscope-app-env/PlanktoScope/install.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ sudo chown -R pi:pi "$HOME/PlanktoScope"
1313
# Configure firmware
1414
# https://www.raspberrypi.com/documentation/computers/config_txt.html
1515
sudo bash -c "cat \"$config_files_root/config.txt.snippet\" >> \"/boot/config.txt\""
16+
17+
# Disable the 4 Raspberry logo in the top left corner
18+
# more space for kernel and system logs
19+
sudo sed -i -e 's/$/ logo.nologo/' /boot/cmdline.txt
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[all]
2+
BOOT_ORDER=0xf461
3+
HDMI_DELAY=0
4+
5+
[pi5]
6+
POWER_OFF_ON_HALT=1
7+
WAIT_FOR_POWER_BUTTON=1
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash -eux
2+
3+
rm -f /boot/firmware/pieeprom.sig
4+
rm -f /boot/firmware/pieeprom.upd
5+
rm -f /boot/firmware/RECOVERY.000
6+
rm -f /boot/firmware/recovery.bin
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash -eux
2+
# Update and configure the bootloader
3+
# https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#update-the-bootloader-configuration
4+
# Please note that we disable self update on anything but Raspberry Pi 5; see config.txt.snippet
5+
6+
# Determine the base path for copied files
7+
config_files_root="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
8+
distro_setup_files_root="$(dirname "$(dirname "$config_files_root")")"
9+
repo_root="$(dirname "$(dirname "$(dirname "$distro_setup_files_root")")")"
10+
11+
sudo -E apt-get install -y -o Dpkg::Progress-Fancy=0 \
12+
rpi-eeprom
13+
14+
cp /usr/lib/firmware/raspberrypi/bootloader-2712/latest/pieeprom-2025-03-19.bin /tmp
15+
cp /usr/lib/firmware/raspberrypi/bootloader-2712/latest/recovery.bin /tmp
16+
17+
rpi-eeprom-config /tmp/pieeprom-2025-03-19.bin --config "$config_files_root/boot.conf" --out /tmp/pieeprom.upd
18+
rpi-eeprom-digest -i /tmp/pieeprom.upd -o /tmp/pieeprom.sig
19+
20+
# /boot and not /boot/firmware
21+
# see https://github.com/ethanjli/pinspawn-action/issues/5
22+
sudo cp /tmp/pieeprom.upd /tmp/pieeprom.sig /tmp/recovery.bin /boot/
23+
24+
# The bootloader will be installed on first boot and the files removed
25+
# see https://github.com/PlanktoScope/PlanktoScope/pull/589
26+
27+
# https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#automaticupdates
28+
sudo systemctl mask rpi-eeprom-update
29+
30+
# "The temporary EEPROM update files are automatically deleted by the rpi-eeprom-update service at startup."
31+
# from https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#bootloader-update-files
32+
# But we mask it to avoid auto updates so we have a custom unit file instead
33+
sudo cp $config_files_root/planktoscope-org.firstboot.service /etc/systemd/system/
34+
sudo systemctl enable planktoscope-org.firstboot.service
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[Unit]
2+
Description=PlanktoScope first boot service
3+
ConditionFirstBoot=yes
4+
5+
[Service]
6+
Type=oneshot
7+
ExecStart=/home/pi/PlanktoScope/software/distro/setup/planktoscope-app-env/bootloader/firstboot.sh
8+
9+
[Install]
10+
WantedBy=sysinit.target

software/distro/setup/planktoscope-app-env/python-hardware-controller/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PATH="$PATH:/home/pi/.local/bin"
3838
# Raspberry Pi OS has been updated. In which case this can be removed.
3939
echo "If the next command fails, see comment in install.sh"
4040
sudo -E apt-get install -y -o Dpkg::Progress-Fancy=0 --only-upgrade \
41-
python3-libcamera=0.4.0+rpt20250213-1 python3-av=12.3.0-2+rpt1
41+
python3-libcamera=0.5.0+rpt20250429-1 python3-av=12.3.0-2+rpt1
4242
sudo -E apt-get install -y --no-install-recommends -o Dpkg::Progress-Fancy=0 \
4343
i2c-tools libopenjp2-7 python3-picamera2
4444
poetry --directory "$HOME/PlanktoScope/device-backend/control" install \

software/distro/setup/planktoscope-app-env/setup.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,11 @@ if "$build_scripts_root/overclocking/config.sh"; then
8383
else
8484
panic "$description"
8585
fi
86+
87+
description="update and configure bootloader"
88+
report_starting "$description"
89+
if "$build_scripts_root/bootloader/install.sh"; then
90+
report_finished "$description"
91+
else
92+
panic "$description"
93+
fi

0 commit comments

Comments
 (0)