Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PACKAGE_INSTALL:remove:revpi = "initramfs-module-migrate"

PACKAGE_INSTALL:append:raspberrypicm4-ioboard-sb = " initramfs-module-kexec-pi4-fwgpio"
IMAGE_ROOTFS_MAXSIZE:raspberrypicm4-ioboard-sb = "51200"
IMAGE_ROOTFS_MAXSIZE:raspberrypicm4-ioboard-sb = "65536"

# increase initramfs maxsize to 40 MiB
IMAGE_ROOTFS_MAXSIZE:raspberrypi5 = "40960"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ IMAGE_ROOTFS_SIZE:raspberrypi5="655360"
BALENA_BOOT_SIZE:raspberrypi5="81920"

# Increase boot partition size
BALENA_BOOT_SIZE:raspberrypicm4-ioboard-sb = "131072"
BALENA_BOOT_SIZE:raspberrypicm4-ioboard-sb = "174080"

# Increase Root File system size
IMAGE_ROOTFS_SIZE:revpi-connect-s ?= "319488"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,35 @@ kexec_pi4_fwgpio_run() {
WIFI_DRIVER_DIR="$(readlink -f "${WIFI_SYSFS_PATH}/driver")"
WIFI_DEV="$(basename "${WIFI_SYSFS_PATH}")"

GPIO_SYSFS_DIR="/sys/class/gpio"
GPIOCHIP="gpiochip1"

FW_GPIO_BASE="504"
# gpiochip1 - 8 lines:
# line 0: "BT_ON" "shutdown" output active-high [used]
# line 1: "WL_ON" unused output active-high
# line 2: "PWR_LED_OFF" "PWR" output active-low [used]
# line 3: "GLOBAL_RESET" unused output active-high
# line 4: "VDD_SD_IO_SEL" "vdd-sd-io" output active-high [used]
# line 5: "CAM_GPIO" "regulator-cam1" output active-high [used]
# line 6: "SD_PWR_ON" "regulator-sd-vcc" output active-high [used]
# line 7: "SD_OC_N" unused input active-high
BT_ON="0"
WL_ON="1"

NEED_RESET="0"
CURRENT_STATE="0"
for PIN in "${BT_ON}" "${WL_ON}"; do
GPIO=$["${FW_GPIO_BASE}" + "${PIN}"]
echo "${GPIO}" > "${GPIO_SYSFS_DIR}/export"
PIN_VALUE="$(cat "${GPIO_SYSFS_DIR}/gpio${GPIO}/value")"
for GPIO in "${BT_ON}" "${WL_ON}"; do
PIN_VALUE="$(gpioget "${GPIOCHIP}" "${GPIO}")"

if [ "$bootparam_balena_stage2" = "true" ]; then
CURRENT_STATE=$["${CURRENT_STATE}" | ("${PIN_VALUE}" << "${PIN}")]
CURRENT_STATE=$(("${CURRENT_STATE}" | ("${PIN_VALUE}" << "${GPIO}")))
elif [ -n "$bootparam_balena_pi4_fwgpio" ]; then
NEW_VALUE=$[("$bootparam_balena_pi4_fwgpio" >> "${PIN}") & 1]
echo "${NEW_VALUE}" > "${GPIO_SYSFS_DIR}/gpio${GPIO}/value"
NEW_VALUE=$((("$bootparam_balena_pi4_fwgpio" >> "${GPIO}") & 1))
gpioset "${GPIOCHIP}" "${GPIO}=${NEW_VALUE}"

if [ "${PIN_VALUE}" != "${NEW_VALUE}" ]; then
NEED_RESET="1"
fi
fi

echo "${GPIO}" > "${GPIO_SYSFS_DIR}/unexport"
done

if [ "${NEED_RESET}" = "1" ]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SRC_URI:append = " \

PACKAGES:append = " initramfs-module-kexec-pi4-fwgpio"
SUMMARY:initramfs-module-kexec-pi4-fwgpio = "Hook necessary to persist the value of Pi4/CM4 firmware GPIOs after kexec"
RDEPENDS:initramfs-module-kexec-pi4-fwgpio = "initramfs-module-kexec"
RDEPENDS:initramfs-module-kexec-pi4-fwgpio = "initramfs-module-kexec libgpiod-tools"
FILES:initramfs-module-kexec-pi4-fwgpio = "/init.d/73-kexec_pi4_fwgpio"

PACKAGES:remove:revpi = "initramfs-module-migrate"
Expand Down
Loading