Skip to content

Commit

Permalink
added handling of /boot/firmware/ path
Browse files Browse the repository at this point in the history
  • Loading branch information
JavanXD committed May 25, 2024
1 parent 2952015 commit 6b42721
Showing 1 changed file with 32 additions and 16 deletions.
48 changes: 32 additions & 16 deletions stage-honeypi/01-install-honeypi/00-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,22 @@ EOF
# default gpio for Ds18b20, per default raspbian would use gpio 4
w1gpio=11

# Define the default path
CONFIG_PATH="${ROOTFS_DIR}/boot/config.txt"
CMDLINE_PATH="${ROOTFS_DIR}/boot/cmdline.txt"

# Check if the file contains "DO NOT EDIT THIS FILE"
if grep -q 'DO NOT EDIT THIS FILE' ${ROOTFS_DIR}/boot/config.txt; then
# Update the path if the content is found
CONFIG_PATH="${ROOTFS_DIR}/boot/firmware/config.txt"
fi

# Check if cmdline.txt contains "DO NOT EDIT THIS FILE"
if grep -q 'DO NOT EDIT THIS FILE' "${ROOTFS_DIR}/boot/cmdline.txt"; then
CMDLINE_PATH="${ROOTFS_DIR}/boot/firmware/cmdline.txt"
fi


echo '>>> Enable I2C'
if grep -q 'i2c-bcm2708' ${ROOTFS_DIR}/etc/modules; then
echo 'Seems i2c-bcm2708 module already exists, skip this step.'
Expand All @@ -31,15 +47,15 @@ if grep -q '^i2c-dev' ${ROOTFS_DIR}/etc/modules; then
else
echo 'i2c-dev' >> ${ROOTFS_DIR}/etc/modules
fi
if grep -q 'dtparam=i2c1=on' ${ROOTFS_DIR}/boot/config.txt; then
if grep -q 'dtparam=i2c1=on' "$CONFIG_PATH"; then
echo 'Seems i2c1 parameter already set, skip this step.'
else
echo 'dtparam=i2c1=on' >> ${ROOTFS_DIR}/boot/config.txt
echo 'dtparam=i2c1=on' >> "$CONFIG_PATH"
fi
if grep -q '^dtparam=i2c_arm=on' ${ROOTFS_DIR}/boot/config.txt; then
if grep -q '^dtparam=i2c_arm=on' "$CONFIG_PATH"; then
echo 'Seems i2c_arm parameter already set, skip this step.'
else
echo 'dtparam=i2c_arm=on' >> ${ROOTFS_DIR}/boot/config.txt
echo 'dtparam=i2c_arm=on' >> "$CONFIG_PATH"
fi

echo '>>> Enable 1-Wire'
Expand All @@ -53,42 +69,42 @@ if grep -q '^w1_therm' ${ROOTFS_DIR}/etc/modules; then
else
echo 'w1_therm' >> ${ROOTFS_DIR}/etc/modules
fi
if grep -q '^dtoverlay=w1-gpio' ${ROOTFS_DIR}/boot/config.txt; then
if grep -q '^dtoverlay=w1-gpio' "$CONFIG_PATH"; then
echo 'Seems w1-gpio parameter already set, skip this step.'
else
echo 'dtoverlay=w1-gpio,gpiopin='$w1gpio >> ${ROOTFS_DIR}/boot/config.txt
echo 'dtoverlay=w1-gpio,gpiopin='$w1gpio >> "$CONFIG_PATH"
fi
if grep -q '^dtparam=i2c_arm=on' ${ROOTFS_DIR}/boot/config.txt; then
if grep -q '^dtparam=i2c_arm=on' "$CONFIG_PATH"; then
echo 'Seems i2c_arm parameter already set, skip this step.'
else
echo 'dtparam=i2c_arm=on' >> ${ROOTFS_DIR}/boot/config.txt
echo 'dtparam=i2c_arm=on' >> "$CONFIG_PATH"
fi

# Enable Wifi-Stick on Raspberry Pi 1 & 2
if grep -q '^net.ifnames=0' ${ROOTFS_DIR}/boot/cmdline.txt; then
if grep -q '^net.ifnames=0' "$CMDLINE_PATH"; then
echo 'Seems net.ifnames=0 parameter already set, skip this step.'
else
echo 'net.ifnames=0' >> ${ROOTFS_DIR}/boot/cmdline.txt
echo 'net.ifnames=0' >> "$CMDLINE_PATH"
fi

# enable miniuart-bt on Raspberry Pi and set core frequency, for stable miniUART and bluetooth (see https://www.raspberrypi.org/documentation/configuration/uart.md)
echo ">>> Install required miniuart-bt modules for rak811 & Witty Pi"
if grep -q 'dtoverlay=pi3-miniuart-bt' ${ROOTFS_DIR}/boot/config.txt; then
if grep -q 'dtoverlay=pi3-miniuart-bt' "$CONFIG_PATH"; then
echo 'Seems setting Pi3/4 Bluetooth to use mini-UART is done already, skip this step.'
else
echo 'dtoverlay=pi3-miniuart-bt' >> ${ROOTFS_DIR}/boot/config.txt
echo 'dtoverlay=pi3-miniuart-bt' >> "$CONFIG_PATH"
fi
if grep -q 'core_freq=250' ${ROOTFS_DIR}/boot/config.txt; then
if grep -q 'core_freq=250' "$CONFIG_PATH"; then
echo 'Seems the frequency of GPU processor core is set to 250MHz already, skip this step.'
else
echo 'core_freq=250' >> ${ROOTFS_DIR}/boot/config.txt
echo 'core_freq=250' >> "$CONFIG_PATH"
fi

# Enable HDMI for a default "safe" mode to work on all screens
if grep -q '^hdmi_safe=1' ${ROOTFS_DIR}/boot/config.txt; then
if grep -q '^hdmi_safe=1' "$CONFIG_PATH"; then
echo 'Seems the hdmi is set to safe mode already, skip this step.'
else
echo 'hdmi_safe=1' >> ${ROOTFS_DIR}/boot/config.txt
echo 'hdmi_safe=1' >> "$CONFIG_PATH"
fi

echo '>>> Create www-data user'
Expand Down

0 comments on commit 6b42721

Please sign in to comment.