summaryrefslogtreecommitdiff
path: root/custom-scripts/modify-raspi.sh
blob: 695c6e7ca62eb07b130495f8b1710b8c2916d654 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh

# post-build, pre-image script
# fail-fast
set -eu

# make /etc/dropbear a directory instead of a symlink to /var...
# (need to persist keys somehow)
TARGET_DIR="$1"
(rm "$TARGET_DIR/etc/dropbear" && mkdir "$TARGET_DIR/etc/dropbear") || true

# add a data partition mount
if ! grep -ql LABEL "$TARGET_DIR/etc/fstab"; then
	printf "LABEL=data\t/data/\text4\trw,noatime,noauto\t0\t0\n" >> "$TARGET_DIR/etc/fstab"
fi

# Enable bootcode UART
sed -i -e "s/BOOT_UART=0/BOOT_UART=1/" "${BINARIES_DIR}/rpi-firmware/bootcode.bin"

# Use "faster" start
#$ grep start rpi-firmware/config.txt
#start_file=start.elf

# https://kittenlabs.de/blog/2024/09/01/extreme-pi-boot-optimization/

cfgfile="${BINARIES_DIR}/rpi-firmware/cmdline.txt"
grep -ql earlycon "$cfgfile" || sed -i -e '1 s/$/ earlycon=pl011,mmio32,0x3f201000/' "$cfgfile"

cfgfile="${BINARIES_DIR}/rpi-firmware/config.txt"
sed -i -e "/start_file/ s/^.*$/start_file=start_cd.elf/" "$cfgfile"
grep -ql miniuart-bt "$cfgfile" && sed -i -e '/dtoverlay/ s/miniuart-bt/disable-bt/' "$cfgfile"
grep -ql krnbt=on "$cfgfile" && sed -i -e '/krnbt=on/ d' "$cfgfile"
grep -ql nohdmi "$cfgfile" || sed -i -e '/dtoverlay/ a dtoverlay=vc4-kms-v3d,nohdmi' "$cfgfile"
grep -ql disable_fw_kms_setup "$cfgfile" || echo "disable_fw_kms_setup=1" >> "$cfgfile"
grep -ql enable_tvout "$cfgfile" || echo "enable_tvout=0" >> "$cfgfile"
grep -ql force_turbo "$cfgfile" || echo "force_turbo=0" >> "$cfgfile"
grep -ql initial_turbo "$cfgfile" || echo "initial_turbo=10" >> "$cfgfile"
grep -ql hdmi_blanking "$cfgfile" || echo "hdmi_blanking=1" >> "$cfgfile"
grep -ql hdmi_ignore_edid "$cfgfile" || echo "hdmi_ignore_edid=0xa5000080" >> "$cfgfile"
grep -ql hdmi_ignore_cec_init "$cfgfile" || echo "hdmi_ignore_cec_init=1" >> "$cfgfile"
grep -ql hdmi_ignore_cec "$cfgfile" || echo "hdmi_ignore_cec=1" >> "$cfgfile"
grep -ql force_eeprom_read "$cfgfile" || echo "force_eeprom_read=0" >> "$cfgfile"
grep -ql disable_poe_fan "$cfgfile" || echo "disable_poe_fan=1" >> "$cfgfile"
grep -ql ignore_lcd "$cfgfile" || echo "ignore_lcd=1" >> "$cfgfile"
grep -ql disable_touchscreen "$cfgfile" || echo "disable_touchscreen=1" >> "$cfgfile"
grep -ql camera_auto_detect "$cfgfile" || echo "camera_auto_detect=0" >> "$cfgfile"
grep -ql display_auto_detect "$cfgfile" || echo "display_auto_detect=0" >> "$cfgfile"

exit 0