Add BR2_EXTERNAL skeleton

This commit is contained in:
2026-03-27 20:57:59 -03:00
parent 27cfa662a3
commit 162a815132
16 changed files with 632 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
/* genimage.cfg - SD card image layout for Raspberry Pi
*
* Partition layout:
* - boot (FAT32, 64MB): kernel, device tree, bootloader files
* - rootfs (ext4, 256MB): root filesystem
*
* The final image is written to sdcard.img.
*
* Adjust partition sizes as needed for your project. Projects can
* override this file by providing their own genimage.cfg and setting
* GENIMAGE_CFG in their post-image script.
*/
image boot.vfat {
vfat {
files = {
"bcm2710-rpi-3-b.dtb",
"bcm2711-rpi-4-b.dtb",
"rpi-firmware/bootcode.bin",
"rpi-firmware/start.elf",
"rpi-firmware/fixup.dat",
"rpi-firmware/config.txt",
"rpi-firmware/cmdline.txt",
"Image"
}
}
size = 64M
}
image rootfs.ext4 {
ext4 {
label = "rootfs"
}
size = 256M
}
image sdcard.img {
hdimage {
}
partition boot {
partition-type = 0xC
bootable = "true"
image = "boot.vfat"
}
partition rootfs {
partition-type = 0x83
image = "rootfs.ext4"
}
}

View File

@@ -0,0 +1,12 @@
# /etc/network/interfaces - Common network configuration
#
# This file is part of the shared rootfs overlay and provides a
# sensible default network configuration for all Raspberry Pi projects.
# Projects can override this by placing their own version in their
# project-specific overlay (which is applied after this one).
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp

34
board/raspberrypi/post_build.sh Executable file
View File

@@ -0,0 +1,34 @@
#!/bin/sh
# post_build.sh - Common post-build script for Raspberry Pi
#
# Called by Buildroot after assembling the target rootfs.
# Arguments:
# $1 = path to the target rootfs directory (e.g., output/target)
#
# Environment:
# BR2_EXTERNAL_RPI_COMMON_PATH = path to this external tree
#
# Use this script for:
# - Fixing file permissions
# - Creating symlinks
# - Generating config files that depend on build-time variables
# - Stripping unnecessary files from the rootfs
#
# Do NOT use this for:
# - Installing packages (use rootfs overlay or a package .mk instead)
# - Modifying files outside $1
set -e
TARGET_DIR="$1"
# Example: ensure /etc/hostname exists with a default value
if [ ! -f "${TARGET_DIR}/etc/hostname" ]; then
echo "rpi-common" > "${TARGET_DIR}/etc/hostname"
fi
# Example: remove unnecessary documentation to save space
rm -rf "${TARGET_DIR}/usr/share/man"
rm -rf "${TARGET_DIR}/usr/share/doc"
echo ">>> Common post-build script completed"

35
board/raspberrypi/post_image.sh Executable file
View File

@@ -0,0 +1,35 @@
#!/bin/sh
# post_image.sh - Common post-image script for Raspberry Pi
#
# Called by Buildroot after filesystem images (ext4, etc.) are generated.
# Arguments:
# $1 = path to the images directory (e.g., output/images)
#
# Environment:
# BR2_EXTERNAL_RPI_COMMON_PATH = path to this external tree
# BINARIES_DIR = same as $1
# BUILD_DIR = path to the build directory
#
# This script uses genimage to assemble the final SD card image
# from the boot files and root filesystem.
set -e
BOARD_DIR="${BR2_EXTERNAL_RPI_COMMON_PATH}/board/raspberrypi"
# Use project-specific genimage.cfg if it exists, otherwise use common one.
# Projects can override by setting GENIMAGE_CFG in their own post-image script.
GENIMAGE_CFG="${GENIMAGE_CFG:-${BOARD_DIR}/genimage.cfg}"
# genimage requires a temporary directory
GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
rm -rf "${GENIMAGE_TMP}"
genimage \
--rootpath "${TARGET_DIR}" \
--tmppath "${GENIMAGE_TMP}" \
--inputpath "${BINARIES_DIR}" \
--outputpath "${BINARIES_DIR}" \
--config "${GENIMAGE_CFG}"
echo ">>> SD card image generated: ${BINARIES_DIR}/sdcard.img"