Skip to content

Instantly share code, notes, and snippets.

@Informatic
Last active January 5, 2023 19:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Informatic/10f0832d8971c4d874210dc984462e5b to your computer and use it in GitHub Desktop.
Save Informatic/10f0832d8971c4d874210dc984462e5b to your computer and use it in GitHub Desktop.
Example FIT image descriptor with signatures & buildroot post-image hook / https://blog.inf.re/buildroot-cheatsheet.html
/dts-v1/;
/ {
description = "Example FIT image";
#address-cells = <1>;
images {
kernel@1 {
description = "default kernel";
data = /incbin/("./zImage");
type = "kernel";
arch = "arm";
os = "linux";
compression = "none";
load = <0x42000000>;
entry = <0x42000000>;
hash@1 {
algo = "sha1";
};
};
ramdisk@1 {
description = "rootfs";
data = /incbin/("./rootfs.cpio.gz");
type = "ramdisk";
arch = "arm";
os = "linux";
compression = "gzip";
load = <00000000>;
entry = <00000000>;
hash@1 {
algo = "sha1";
};
};
fdt@1 {
description = "device tree";
data = /incbin/("./sun8i-h2-plus-orangepi-zero.dtb");
type = "flat_dt";
arch = "arm";
compression = "none";
hash@1 {
algo = "sha1";
};
};
};
configurations {
default = "config@1";
config@1 {
description = "default configuration";
kernel = "kernel@1";
ramdisk = "ramdisk@1";
fdt = "fdt@1";
signature@1 {
algo = "sha1,rsa2048";
key-name-hint = "dev";
sign-images = "fdt", "kernel", "ramdisk";
};
};
};
};
#!/bin/sh
# post-image-signatures.sh - build full .itb image with signatures
set -e
BOARD_DIR="$( dirname "${0}" )"
KEYS_DIR="${BOARD_DIR}/../../keys"
MKIMAGE="${HOST_DIR}/bin/mkimage"
IMAGE_ITS="image.its"
OUTPUT_NAME="image.itb"
# We have to copy .its file over to images/ for /incbin/ to work
cp "${BOARD_DIR}/${IMAGE_ITS}" "${BINARIES_DIR}"
cd "${BINARIES_DIR}"
echo " -> Building..."
"${MKIMAGE}" -D "-I dts -O dtb -p 2000" -f ${IMAGE_ITS} ${OUTPUT_NAME}
echo " -> Signing..."
"${MKIMAGE}" -D "-I dts -O dtb -p 2000" -F -k "${KEYS_DIR}" -K "${BUILD_DIR}/uboot-2017.03/dts/dt.dtb" -r ${OUTPUT_NAME}
rm ${IMAGE_ITS}
# Rebuild uboot with patched dtb
cd "${BUILD_DIR}/.."
make uboot-rebuild
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment