Skip to content

Commit 0b13983

Browse files
committed
Reduce fwup redundancy by using an EEx template
The final fwup.conf file is still being committed to allow time to grow trust in using a template language to generate the fwup.conf. This refactor is really needed for TRYBOOT support due to significantly more fwup.conf redundancy to migrate pre-TRYBOOT devices.
1 parent 4f7ccaf commit 0b13983

File tree

4 files changed

+306
-28
lines changed

4 files changed

+306
-28
lines changed

REUSE.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ SPDX-License-Identifier = "GPL-2.0-only"
5454
path = [
5555
"fwup-ops.conf",
5656
"fwup.conf",
57+
"fwup.conf.eex",
5758
"fwup_include/*"
5859
]
5960
precedence = "aggregate"

fwup.conf

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Firmware configuration file for the Raspberry Pi 4
2-
2+
#
3+
# IMPORTANT:
4+
# Edit `fwup.conf.eex` and run `mix generate_fwup_conf` to generate fwup.conf.
5+
#
36
require-fwup-version="0.15.0" # For the trim() call
47

58
include("${NERVES_SDK_IMAGES:-.}/fwup_include/fwup-common.conf")
@@ -12,9 +15,7 @@ file-resource start4.elf { host-path = "${NERVES_SYSTEM}/images/rpi-firmware/sta
1215
file-resource config.txt { host-path = "${NERVES_SYSTEM}/images/config.txt" }
1316
file-resource cmdline.txt { host-path = "${NERVES_SYSTEM}/images/cmdline.txt" }
1417
file-resource kernel8.img { host-path = "${NERVES_SYSTEM}/images/Image" }
15-
file-resource bcm2711-rpi-4-b.dtb { host-path = "${NERVES_SYSTEM}/images/bcm2711-rpi-4-b.dtb" }
16-
file-resource bcm2711-rpi-cm4.dtb { host-path = "${NERVES_SYSTEM}/images/bcm2711-rpi-cm4.dtb" }
17-
file-resource bcm2711-rpi-400.dtb { host-path = "${NERVES_SYSTEM}/images/bcm2711-rpi-400.dtb" }
18+
file-resource bcm2708-rpi-b.dtb { host-path = "${NERVES_SYSTEM}/images/bcm2708-rpi-b.dtb" }
1819
file-resource overlays/dwc2.dtbo { host-path = "${NERVES_SYSTEM}/images/rpi-firmware/overlays/dwc2.dtbo" }
1920
file-resource overlays/i2c-mux.dtbo { host-path = "${NERVES_SYSTEM}/images/rpi-firmware/overlays/i2c-mux.dtbo" }
2021
file-resource overlays/imx219.dtbo { host-path = "${NERVES_SYSTEM}/images/rpi-firmware/overlays/imx219.dtbo" }
@@ -77,14 +78,12 @@ task complete {
7778
uboot_setenv(uboot-env, "a.nerves_fw_uuid", "\${FWUP_META_UUID}")
7879
}
7980

81+
on-resource fixup4.dat { fat_write(${BOOT_A_PART_OFFSET}, "fixup4.dat") }
82+
on-resource start4.elf { fat_write(${BOOT_A_PART_OFFSET}, "start4.elf") }
8083
on-resource config.txt { fat_write(${BOOT_A_PART_OFFSET}, "config.txt") }
8184
on-resource cmdline.txt { fat_write(${BOOT_A_PART_OFFSET}, "cmdline.txt") }
82-
on-resource start4.elf { fat_write(${BOOT_A_PART_OFFSET}, "start4.elf") }
83-
on-resource fixup4.dat { fat_write(${BOOT_A_PART_OFFSET}, "fixup4.dat") }
8485
on-resource kernel8.img { fat_write(${BOOT_A_PART_OFFSET}, "kernel8.img") }
85-
on-resource bcm2711-rpi-4-b.dtb { fat_write(${BOOT_A_PART_OFFSET}, "bcm2711-rpi-4-b.dtb") }
86-
on-resource bcm2711-rpi-cm4.dtb { fat_write(${BOOT_A_PART_OFFSET}, "bcm2711-rpi-cm4.dtb") }
87-
on-resource bcm2711-rpi-400.dtb { fat_write(${BOOT_A_PART_OFFSET}, "bcm2711-rpi-400.dtb") }
86+
on-resource bcm2708-rpi-b.dtb { fat_write(${BOOT_A_PART_OFFSET}, "bcm2708-rpi-b.dtb") }
8887
on-resource overlays/dwc2.dtbo { fat_write(${BOOT_A_PART_OFFSET}, "overlays/dwc2.dtbo") }
8988
on-resource overlays/i2c-mux.dtbo { fat_write(${BOOT_A_PART_OFFSET}, "overlays/i2c-mux.dtbo") }
9089
on-resource overlays/imx219.dtbo { fat_write(${BOOT_A_PART_OFFSET}, "overlays/imx219.dtbo") }
@@ -159,14 +158,12 @@ task upgrade.a {
159158
# Write the new boot partition files and rootfs. The MBR still points
160159
# to the B partition, so an error or power failure during this part
161160
# won't hurt anything.
161+
on-resource fixup4.dat { fat_write(${BOOT_A_PART_OFFSET}, "fixup4.dat") }
162+
on-resource start4.elf { fat_write(${BOOT_A_PART_OFFSET}, "start4.elf") }
162163
on-resource config.txt { fat_write(${BOOT_A_PART_OFFSET}, "config.txt") }
163164
on-resource cmdline.txt { fat_write(${BOOT_A_PART_OFFSET}, "cmdline.txt") }
164-
on-resource start4.elf { fat_write(${BOOT_A_PART_OFFSET}, "start4.elf") }
165-
on-resource fixup4.dat { fat_write(${BOOT_A_PART_OFFSET}, "fixup4.dat") }
166165
on-resource kernel8.img { fat_write(${BOOT_A_PART_OFFSET}, "kernel8.img") }
167-
on-resource bcm2711-rpi-4-b.dtb { fat_write(${BOOT_A_PART_OFFSET}, "bcm2711-rpi-4-b.dtb") }
168-
on-resource bcm2711-rpi-cm4.dtb { fat_write(${BOOT_A_PART_OFFSET}, "bcm2711-rpi-cm4.dtb") }
169-
on-resource bcm2711-rpi-400.dtb { fat_write(${BOOT_A_PART_OFFSET}, "bcm2711-rpi-400.dtb") }
166+
on-resource bcm2708-rpi-b.dtb { fat_write(${BOOT_A_PART_OFFSET}, "bcm2708-rpi-b.dtb") }
170167
on-resource overlays/dwc2.dtbo { fat_write(${BOOT_A_PART_OFFSET}, "overlays/dwc2.dtbo") }
171168
on-resource overlays/i2c-mux.dtbo { fat_write(${BOOT_A_PART_OFFSET}, "overlays/i2c-mux.dtbo") }
172169
on-resource overlays/imx219.dtbo { fat_write(${BOOT_A_PART_OFFSET}, "overlays/imx219.dtbo") }
@@ -210,10 +207,10 @@ task upgrade.a {
210207
uboot_setenv(uboot-env, "a.nerves_fw_misc", ${NERVES_FW_MISC})
211208
uboot_setenv(uboot-env, "a.nerves_fw_uuid", "\${FWUP_META_UUID}")
212209

213-
# Switch over to boot the new firmware
214-
# NOTE: The mbr_write is the important step. Automatic fallback is not supported, so
215-
# setting the variables is a formality for Nerves.Runtime.firmware_validation_status and
216-
# other code.
210+
# Switch over to boot the new firmware
211+
# NOTE: The mbr_write is the important step. Automatic fallback is not supported, so
212+
# setting the variables is a formality for Nerves.Runtime.firmware_validation_status and
213+
# other code.
217214
uboot_setenv(uboot-env, "nerves_fw_active", "a")
218215
uboot_setenv(uboot-env, "a.nerves_fw_validated", "1")
219216
mbr_write(mbr-a)
@@ -253,14 +250,12 @@ task upgrade.b {
253250
# Write the new boot partition files and rootfs. The MBR still points
254251
# to the A partition, so an error or power failure during this part
255252
# won't hurt anything.
253+
on-resource fixup4.dat { fat_write(${BOOT_B_PART_OFFSET}, "fixup4.dat") }
254+
on-resource start4.elf { fat_write(${BOOT_B_PART_OFFSET}, "start4.elf") }
256255
on-resource config.txt { fat_write(${BOOT_B_PART_OFFSET}, "config.txt") }
257256
on-resource cmdline.txt { fat_write(${BOOT_B_PART_OFFSET}, "cmdline.txt") }
258-
on-resource start4.elf { fat_write(${BOOT_B_PART_OFFSET}, "start4.elf") }
259-
on-resource fixup4.dat { fat_write(${BOOT_B_PART_OFFSET}, "fixup4.dat") }
260257
on-resource kernel8.img { fat_write(${BOOT_B_PART_OFFSET}, "kernel8.img") }
261-
on-resource bcm2711-rpi-4-b.dtb { fat_write(${BOOT_B_PART_OFFSET}, "bcm2711-rpi-4-b.dtb") }
262-
on-resource bcm2711-rpi-cm4.dtb { fat_write(${BOOT_B_PART_OFFSET}, "bcm2711-rpi-cm4.dtb") }
263-
on-resource bcm2711-rpi-400.dtb { fat_write(${BOOT_B_PART_OFFSET}, "bcm2711-rpi-400.dtb") }
258+
on-resource bcm2708-rpi-b.dtb { fat_write(${BOOT_B_PART_OFFSET}, "bcm2708-rpi-b.dtb") }
264259
on-resource overlays/dwc2.dtbo { fat_write(${BOOT_B_PART_OFFSET}, "overlays/dwc2.dtbo") }
265260
on-resource overlays/i2c-mux.dtbo { fat_write(${BOOT_B_PART_OFFSET}, "overlays/i2c-mux.dtbo") }
266261
on-resource overlays/imx219.dtbo { fat_write(${BOOT_B_PART_OFFSET}, "overlays/imx219.dtbo") }
@@ -304,10 +299,10 @@ task upgrade.b {
304299
uboot_setenv(uboot-env, "b.nerves_fw_misc", ${NERVES_FW_MISC})
305300
uboot_setenv(uboot-env, "b.nerves_fw_uuid", "\${FWUP_META_UUID}")
306301

307-
# Switch over to boot the new firmware
308-
# NOTE: The mbr_write is the important step. Automatic fallback is not supported, so
309-
# setting the variables is a formality for Nerves.Runtime.firmware_validation_status and
310-
# other code.
302+
# Switch over to boot the new firmware
303+
# NOTE: The mbr_write is the important step. Automatic fallback is not supported, so
304+
# setting the variables is a formality for Nerves.Runtime.firmware_validation_status and
305+
# other code.
311306
uboot_setenv(uboot-env, "nerves_fw_active", "b")
312307
uboot_setenv(uboot-env, "b.nerves_fw_validated", "1")
313308
mbr_write(mbr-b)

0 commit comments

Comments
 (0)