#!/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"