board/raspberry: handle dtb overlays for all variants
PATCH 1/3 board/raspberry: handle dtb overlays for all variants
Most rpi defconfigs use dtb overlays, but not rpi0 / rpi2 - Making it harder to use overlays on those boards as the genimage files have to be tweaked.
To fix this, create the rpi-firmware/overlays directory in the post-build script if needed and unconditionally include it in the genimage files so rpi0/rpi2 works consistently with the other variants.
--- board/raspberrypi/genimage-raspberrypi0.cfg | 1 + board/raspberrypi/genimage-raspberrypi2.cfg | 1 + board/raspberrypi/post-build.sh | 3 +++ 3 files changed, 5 insertions(+)
board/raspberrypi/genimage-raspberrypi0.cfg +1 -0
@@ -7,6 +7,7 @@ image boot.vfat { "rpi-firmware/config.txt", "rpi-firmware/fixup.dat", "rpi-firmware/start.elf", + "rpi-firmware/overlays", "zImage" } }
board/raspberrypi/genimage-raspberrypi2.cfg +1 -0
@@ -7,6 +7,7 @@ image boot.vfat { "rpi-firmware/config.txt", "rpi-firmware/fixup.dat", "rpi-firmware/start.elf", + "rpi-firmware/overlays", "zImage" } }
board/raspberrypi/post-build.sh +3 -0
@@ -9,3 +9,6 @@ if [ -e ${TARGET_DIR}/etc/inittab ]; then sed -i '/GENERIC_SERIAL/a\ tty1::respawn:/sbin/getty -L tty1 0 vt100 # HDMI console' ${TARGET_DIR}/etc/inittab fi + +# exnsure overlays exists for genimage +mkdir -p "${BINARIES_DIR}/rpi-firmware/overlays"
Signature · 6 lines
2.30.2 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 2/3 board/raspberrypi/post-image.sh: generate genimage config from template if not present
The rpi genimage configurations are all identical, except for the boot partition files, which include:
- Device tree files (*.dtb)
- rpi-firmware files (rpi-firmware/*)
- Kernel image (Image/zImage)
All of these are quite simple to figure out programatically based on the content of BINARIES_DIR, so extend post-image.sh to fall back to generating a genimage configuration based on genimage.cfg.in if a board specific one does not exist.
--- board/raspberrypi/genimage.cfg.in | 25 +++++++++++++++++++++++++ board/raspberrypi/post-image.sh | 17 +++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 board/raspberrypi/genimage.cfg.in
board/raspberrypi/genimage.cfg.in new file +25 -0
@@ -0,0 +1,25 @@ +image boot.vfat { + vfat { + files = { +#BOOT_FILES# + } + } + + size = 32M +} + +image sdcard.img { + hdimage { + } + + partition boot { + partition-type = 0xC + bootable = "true" + image = "boot.vfat" + } + + partition rootfs { + partition-type = 0x83 + image = "rootfs.ext4" + } +}
board/raspberrypi/post-image.sh +17 -0
@@ -7,6 +7,23 @@ BOARD_NAME="$(basename ${BOARD_DIR})" GENIMAGE_CFG="${BOARD_DIR}/genimage-${BOARD_NAME}.cfg" GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp" +# generate genimage from template if a board specific variant doesn't exists +if [ ! -e "${GENIMAGE_CFG}" ]; then + GENIMAGE_CFG="${BINARIES_DIR}/genimage.cfg" + FILES=() + + for i in "${BINARIES_DIR}"/*.dtb "${BINARIES_DIR}"/rpi-firmware/*; do + FILES+=( "${i#${BINARIES_DIR}/}" ) + done + + KERNEL=$(sed -n 's/^kernel=//p' "${BINARIES_DIR}/rpi-firmware/config.txt") + FILES+=( "${KERNEL}" ) + + BOOT_FILES=$(printf '\\t\\t\\t"%s",\\n' "${FILES[@]}") + sed "s|#BOOT_FILES#|${BOOT_FILES}|" "${BOARD_DIR}/genimage.cfg.in" \ + > "${GENIMAGE_CFG}" +fi + # Pass an empty rootpath. genimage makes a full copy of the given rootpath to # ${GENIMAGE_TMP}/root so passing TARGET_DIR would be a waste of time and disk # space. We don't rely on genimage to build the rootfs image, just to insert a
Signature · 6 lines
2.30.2 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 2/3] board/raspberrypi/post-image.sh: generate genimage config from template if not present
Quoted 9 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Peter" == Peter Korsgaard <[email protected]> writes:
The rpi genimage configurations are all identical, except for the boot partition files, which include:
- Device tree files (*.dtb)
- rpi-firmware files (rpi-firmware/*)
- Kernel image (Image/zImage)
Quoted 6 lines
All of these are quite simple to figure out programatically based on the content of
BINARIES_DIR, so extendpost-image.shto fall back to generating a genimage configuration based on genimage.cfg.in if a board specific one does not exist.Signed-off-by Peter Korsgaard <[email protected]>
Committed, thanks.
Signature · 5 lines
Bye, Peter Korsgaard _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 3/3 board/raspberrypi: drop variant-specific genimage files
In reply to Peter KorsgaardNow that we have a template generating an equivalent genimage configuration.
The generated genimage is identical to these +/- file ordering and a trailing comma / newline that is ignored by genimage, E.G. for rpi3-64:
@@ -8,9 +8,10 @@
"rpi-firmware/cmdline.txt", "rpi-firmware/config.txt", "rpi-firmware/fixup.dat",
- "rpi-firmware/start.elf",
"rpi-firmware/overlays",
- "Image"
+ "rpi-firmware/start.elf",
+ "Image",
+
}--- board/raspberrypi/genimage-raspberrypi.cfg | 33 ------------------ board/raspberrypi/genimage-raspberrypi0.cfg | 32 ----------------- board/raspberrypi/genimage-raspberrypi0w.cfg | 32 ----------------- board/raspberrypi/genimage-raspberrypi2.cfg | 32 ----------------- .../raspberrypi/genimage-raspberrypi3-64.cfg | 34 ------------------- board/raspberrypi/genimage-raspberrypi3.cfg | 34 ------------------- .../raspberrypi/genimage-raspberrypi4-64.cfg | 31 ----------------- board/raspberrypi/genimage-raspberrypi4.cfg | 31 ----------------- .../genimage-raspberrypicm4io-64.cfg | 31 ----------------- .../raspberrypi/genimage-raspberrypicm4io.cfg | 31 ----------------- .../genimage-raspberrypizero2w.cfg | 32 ----------------- 11 files changed, 353 deletions(-) delete mode 100644 board/raspberrypi/genimage-raspberrypi.cfg delete mode 100644 board/raspberrypi/genimage-raspberrypi0.cfg delete mode 100644 board/raspberrypi/genimage-raspberrypi0w.cfg delete mode 100644 board/raspberrypi/genimage-raspberrypi2.cfg delete mode 100644 board/raspberrypi/genimage-raspberrypi3-64.cfg delete mode 100644 board/raspberrypi/genimage-raspberrypi3.cfg delete mode 100644 board/raspberrypi/genimage-raspberrypi4-64.cfg delete mode 100644 board/raspberrypi/genimage-raspberrypi4.cfg delete mode 100644 board/raspberrypi/genimage-raspberrypicm4io-64.cfg delete mode 100644 board/raspberrypi/genimage-raspberrypicm4io.cfg delete mode 100644 board/raspberrypi/genimage-raspberrypizero2w.cfg
board/raspberrypi/genimage-raspberrypi.cfg deleted +0 -33
@@ -1,33 +0,0 @@ -image boot.vfat { - vfat { - files = { - "bcm2708-rpi-b.dtb", - "bcm2708-rpi-b-plus.dtb", - "bcm2708-rpi-cm.dtb", - "rpi-firmware/bootcode.bin", - "rpi-firmware/cmdline.txt", - "rpi-firmware/config.txt", - "rpi-firmware/fixup.dat", - "rpi-firmware/start.elf", - "zImage" - } - } - - size = 32M -} - -image sdcard.img { - hdimage { - } - - partition boot { - partition-type = 0xC - bootable = "true" - image = "boot.vfat" - } - - partition rootfs { - partition-type = 0x83 - image = "rootfs.ext4" - } -}
board/raspberrypi/genimage-raspberrypi0.cfg deleted +0 -32
@@ -1,32 +0,0 @@ -image boot.vfat { - vfat { - files = { - "bcm2708-rpi-zero.dtb", - "rpi-firmware/bootcode.bin", - "rpi-firmware/cmdline.txt", - "rpi-firmware/config.txt", - "rpi-firmware/fixup.dat", - "rpi-firmware/start.elf", - "rpi-firmware/overlays", - "zImage" - } - } - - size = 32M -} - -image sdcard.img { - hdimage { - } - - partition boot { - partition-type = 0xC - bootable = "true" - image = "boot.vfat" - } - - partition rootfs { - partition-type = 0x83 - image = "rootfs.ext4" - } -}
board/raspberrypi/genimage-raspberrypi0w.cfg deleted +0 -32
@@ -1,32 +0,0 @@ -image boot.vfat { - vfat { - files = { - "bcm2708-rpi-zero-w.dtb", - "rpi-firmware/bootcode.bin", - "rpi-firmware/cmdline.txt", - "rpi-firmware/config.txt", - "rpi-firmware/fixup.dat", - "rpi-firmware/start.elf", - "rpi-firmware/overlays", - "zImage" - } - } - - size = 32M -} - -image sdcard.img { - hdimage { - } - - partition boot { - partition-type = 0xC - bootable = "true" - image = "boot.vfat" - } - - partition rootfs { - partition-type = 0x83 - image = "rootfs.ext4" - } -}
board/raspberrypi/genimage-raspberrypi2.cfg deleted +0 -32
@@ -1,32 +0,0 @@ -image boot.vfat { - vfat { - files = { - "bcm2709-rpi-2-b.dtb", - "rpi-firmware/bootcode.bin", - "rpi-firmware/cmdline.txt", - "rpi-firmware/config.txt", - "rpi-firmware/fixup.dat", - "rpi-firmware/start.elf", - "rpi-firmware/overlays", - "zImage" - } - } - - size = 32M -} - -image sdcard.img { - hdimage { - } - - partition boot { - partition-type = 0xC - bootable = "true" - image = "boot.vfat" - } - - partition rootfs { - partition-type = 0x83 - image = "rootfs.ext4" - } -}
board/raspberrypi/genimage-raspberrypi3-64.cfg deleted +0 -34
@@ -1,34 +0,0 @@ -image boot.vfat { - vfat { - files = { - "bcm2710-rpi-3-b.dtb", - "bcm2710-rpi-3-b-plus.dtb", - "bcm2837-rpi-3-b.dtb", - "rpi-firmware/bootcode.bin", - "rpi-firmware/cmdline.txt", - "rpi-firmware/config.txt", - "rpi-firmware/fixup.dat", - "rpi-firmware/start.elf", - "rpi-firmware/overlays", - "Image" - } - } - - size = 32M -} - -image sdcard.img { - hdimage { - } - - partition boot { - partition-type = 0xC - bootable = "true" - image = "boot.vfat" - } - - partition rootfs { - partition-type = 0x83 - image = "rootfs.ext4" - } -}
board/raspberrypi/genimage-raspberrypi3.cfg deleted +0 -34
@@ -1,34 +0,0 @@ -image boot.vfat { - vfat { - files = { - "bcm2710-rpi-3-b.dtb", - "bcm2710-rpi-3-b-plus.dtb", - "bcm2710-rpi-cm3.dtb", - "rpi-firmware/bootcode.bin", - "rpi-firmware/cmdline.txt", - "rpi-firmware/config.txt", - "rpi-firmware/fixup.dat", - "rpi-firmware/start.elf", - "rpi-firmware/overlays", - "zImage" - } - } - - size = 32M -} - -image sdcard.img { - hdimage { - } - - partition boot { - partition-type = 0xC - bootable = "true" - image = "boot.vfat" - } - - partition rootfs { - partition-type = 0x83 - image = "rootfs.ext4" - } -}
board/raspberrypi/genimage-raspberrypi4-64.cfg deleted +0 -31
@@ -1,31 +0,0 @@ -image boot.vfat { - vfat { - files = { - "bcm2711-rpi-4-b.dtb", - "rpi-firmware/cmdline.txt", - "rpi-firmware/config.txt", - "rpi-firmware/fixup4.dat", - "rpi-firmware/start4.elf", - "rpi-firmware/overlays", - "Image" - } - } - - size = 32M -} - -image sdcard.img { - hdimage { - } - - partition boot { - partition-type = 0xC - bootable = "true" - image = "boot.vfat" - } - - partition rootfs { - partition-type = 0x83 - image = "rootfs.ext4" - } -}
board/raspberrypi/genimage-raspberrypi4.cfg deleted +0 -31
@@ -1,31 +0,0 @@ -image boot.vfat { - vfat { - files = { - "bcm2711-rpi-4-b.dtb", - "rpi-firmware/cmdline.txt", - "rpi-firmware/config.txt", - "rpi-firmware/fixup4.dat", - "rpi-firmware/start4.elf", - "rpi-firmware/overlays", - "zImage" - } - } - - size = 32M -} - -image sdcard.img { - hdimage { - } - - partition boot { - partition-type = 0xC - bootable = "true" - image = "boot.vfat" - } - - partition rootfs { - partition-type = 0x83 - image = "rootfs.ext4" - } -}
board/raspberrypi/genimage-raspberrypicm4io-64.cfg deleted +0 -31
@@ -1,31 +0,0 @@ -image boot.vfat { - vfat { - files = { - "bcm2711-rpi-cm4.dtb", - "rpi-firmware/cmdline.txt", - "rpi-firmware/config.txt", - "rpi-firmware/fixup4.dat", - "rpi-firmware/start4.elf", - "rpi-firmware/overlays", - "Image" - } - } - - size = 32M -} - -image sdcard.img { - hdimage { - } - - partition boot { - partition-type = 0xC - bootable = "true" - image = "boot.vfat" - } - - partition rootfs { - partition-type = 0x83 - image = "rootfs.ext4" - } -}
board/raspberrypi/genimage-raspberrypicm4io.cfg deleted +0 -31
@@ -1,31 +0,0 @@ -image boot.vfat { - vfat { - files = { - "bcm2711-rpi-cm4.dtb", - "rpi-firmware/cmdline.txt", - "rpi-firmware/config.txt", - "rpi-firmware/fixup4.dat", - "rpi-firmware/start4.elf", - "rpi-firmware/overlays", - "zImage" - } - } - - size = 32M -} - -image sdcard.img { - hdimage { - } - - partition boot { - partition-type = 0xC - bootable = "true" - image = "boot.vfat" - } - - partition rootfs { - partition-type = 0x83 - image = "rootfs.ext4" - } -}
board/raspberrypi/genimage-raspberrypizero2w.cfg deleted +0 -32
@@ -1,32 +0,0 @@ -image boot.vfat { - vfat { - files = { - "bcm2710-rpi-zero-2-w.dtb", - "rpi-firmware/bootcode.bin", - "rpi-firmware/cmdline.txt", - "rpi-firmware/config.txt", - "rpi-firmware/fixup.dat", - "rpi-firmware/start.elf", - "rpi-firmware/overlays", - "zImage" - } - } - - size = 32M -} - -image sdcard.img { - hdimage { - } - - partition boot { - partition-type = 0xC - bootable = "true" - image = "boot.vfat" - } - - partition rootfs { - partition-type = 0x83 - image = "rootfs.ext4" - } -}
Signature · 6 lines
2.30.2 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 3/3] board/raspberrypi: drop variant-specific genimage files
Quoted 35 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Peter" == Peter Korsgaard <[email protected]> writes:
Now that we have a template generating an equivalent genimage configuration. The generated genimage is identical to these +/- file ordering and a trailing comma / newline that is ignored by genimage, E.G. for rpi3-64:
(quoted diff) +3
-2@@ -8,9 +8,10 @@ "rpi-firmware/cmdline.txt", "rpi-firmware/config.txt", "rpi-firmware/fixup.dat", - "rpi-firmware/start.elf", "rpi-firmware/overlays", - "Image" + "rpi-firmware/start.elf", + "Image", + }Signed-off-by Peter Korsgaard <[email protected]>--- board/raspberrypi/genimage-raspberrypi.cfg | 33 ------------------ board/raspberrypi/genimage-raspberrypi0.cfg | 32 ----------------- board/raspberrypi/genimage-raspberrypi0w.cfg | 32 ----------------- board/raspberrypi/genimage-raspberrypi2.cfg | 32 ----------------- .../raspberrypi/genimage-raspberrypi3-64.cfg | 34 ------------------- board/raspberrypi/genimage-raspberrypi3.cfg | 34 ------------------- .../raspberrypi/genimage-raspberrypi4-64.cfg | 31 ----------------- board/raspberrypi/genimage-raspberrypi4.cfg | 31 ----------------- .../genimage-raspberrypicm4io-64.cfg | 31 ----------------- .../raspberrypi/genimage-raspberrypicm4io.cfg | 31 ----------------- .../genimage-raspberrypizero2w.cfg | 32 ----------------- 11 files changed, 353 deletions(-) delete mode 100644 board/raspberrypi/genimage-raspberrypi.cfg delete mode 100644 board/raspberrypi/genimage-raspberrypi0.cfg delete mode 100644 board/raspberrypi/genimage-raspberrypi0w.cfg
Quoted 8 lines
delete mode 100644 board/raspberrypi/genimage-raspberrypi2.cfg delete mode 100644 board/raspberrypi/genimage-raspberrypi3-64.cfg delete mode 100644 board/raspberrypi/genimage-raspberrypi3.cfg delete mode 100644 board/raspberrypi/genimage-raspberrypi4-64.cfg delete mode 100644 board/raspberrypi/genimage-raspberrypi4.cfg delete mode 100644 board/raspberrypi/genimage-raspberrypicm4io-64.cfg delete mode 100644 board/raspberrypi/genimage-raspberrypicm4io.cfg delete mode 100644 board/raspberrypi/genimage-raspberrypizero2w.cfg
Ups, forgot to drop the now unused mkdir in post-build.sh from patch
1. Can be fixed while applying.
Signature · 5 lines
Bye, Peter Korsgaard _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 3/3] board/raspberrypi: drop variant-specific genimage files
In reply to Peter KorsgaardQuoted 18 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Peter" == Peter Korsgaard <[email protected]> writes:
Now that we have a template generating an equivalent genimage configuration. The generated genimage is identical to these +/- file ordering and a trailing comma / newline that is ignored by genimage, E.G. for rpi3-64:
(quoted diff) +3
-2@@ -8,9 +8,10 @@ "rpi-firmware/cmdline.txt", "rpi-firmware/config.txt", "rpi-firmware/fixup.dat", - "rpi-firmware/start.elf", "rpi-firmware/overlays", - "Image" + "rpi-firmware/start.elf", + "Image", + }
Quoted 1 line
Signed-off-by Peter Korsgaard <[email protected]>
Committed, thanks.
Signature · 5 lines
Bye, Peter Korsgaard _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 10 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Peter" == Peter Korsgaard <[email protected]> writes:
Most rpi defconfigs use dtb overlays, but not rpi0 / rpi2 - Making it harder to use overlays on those boards as the genimage files have to be tweaked.
To fix this, create the rpi-firmware/overlays directory in the post-build script if needed and unconditionally include it in the genimage files so rpi0/rpi2 works consistently with the other variants.
Signed-off-by Peter Korsgaard <[email protected]>
Committed, thanks.
Signature · 5 lines
Bye, Peter Korsgaard _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
"Peter" == Peter Korsgaard <[email protected]> writes:
"Peter" == Peter Korsgaard <[email protected]> writes:
Most rpi defconfigs use dtb overlays, but not rpi0 / rpi2 - Making it harder to use overlays on those boards as the genimage files have to be tweaked.
Quoted 7 lines
Quoted 5 lines
To fix this, create the rpi-firmware/overlays directory in the post-build script if needed and unconditionally include it in the genimage files so rpi0/rpi2 works consistently with the other variants.
Signed-off-by Peter Korsgaard <[email protected]>Committed, thanks.
Committed to 2023.02.x and 2023.05.x, thanks.
Signature · 5 lines
Bye, Peter Korsgaard _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot