summaryrefslogtreecommitdiff
path: root/custom-scripts/modify-raspi.sh
blob: 9340f04d8ad1d92c45f86255a4a39e7029a6cee3 (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
#!/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 -q 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 -q 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 -q nohdmi "$cfgfile" || sed -i -e '/dtoverlay/ s/$/,nohdmi/' "$cfgfile"
grep -q disable_fw_kms_setup "$cfgfile" || echo "disable_fw_kms_setup=1" >> "$cfgfile"
grep -q enable_tvout "$cfgfile" || echo "enable_tvout=0" >> "$cfgfile"
grep -q force_turbo "$cfgfile" || echo "force_turbo=0" >> "$cfgfile"
grep -q initial_turbo "$cfgfile" || echo "initial_turbo=10" >> "$cfgfile"
grep -q hdmi_blanking "$cfgfile" || echo "hdmi_blanking=1" >> "$cfgfile"
grep -q hdmi_ignore_edid "$cfgfile" || echo "hdmi_ignore_edid=0xa5000080" >> "$cfgfile"
grep -q hdmi_ignore_cec_init "$cfgfile" || echo "hdmi_ignore_cec_init=1" >> "$cfgfile"
grep -q hdmi_ignore_cec "$cfgfile" || echo "hdmi_ignore_cec=1" >> "$cfgfile"
grep -q force_eeprom_read "$cfgfile" || echo "force_eeprom_read=0" >> "$cfgfile"
grep -q disable_poe_fan "$cfgfile" || echo "disable_poe_fan=1" >> "$cfgfile"
grep -q ignore_lcd "$cfgfile" || echo "ignore_lcd=1" >> "$cfgfile"
grep -q disable_touchscreen "$cfgfile" || echo "disable_touchscreen=1" >> "$cfgfile"
grep -q camera_auto_detect "$cfgfile" || echo "camera_auto_detect=0" >> "$cfgfile"
grep -q display_auto_detect "$cfgfile" || echo "display_auto_detect=0" >> "$cfgfile"

exit 0