use FIT images not appended DTB for aarch64 uimage

hark-how-all-the-belkin-rings
Daniel Barlow 2023-10-01 22:13:51 +01:00
parent 2a5669c2cd
commit 269e972970
2 changed files with 59 additions and 3 deletions

View File

@ -0,0 +1,50 @@
/dts-v1/;
// used on aarch64 to provide a U-bootable image that combines
// kernel and fdt
/ {
description = "Simple image with single Linux kernel and FDT blob";
#address-cells = <1>;
images {
kernel {
description = "Vanilla Linux kernel";
// data = /incbin/("./vmlinux.bin.gz");
type = "kernel";
arch = "arm64";
os = "linux";
// compression = "gzip";
// load = <00000000>;
// entry = <00000000>;
hash-1 {
algo = "crc32";
};
hash-2 {
algo = "sha1";
};
};
fdt-1 {
description = "Flattened Device Tree blob";
// data = /incbin/("./target.dtb");
type = "flat_dt";
arch = "arm64";
compression = "none";
hash-1 {
algo = "crc32";
};
hash-2 {
algo = "sha1";
};
};
};
configurations {
default = "conf-1";
conf-1 {
description = "Boot Linux kernel with FDT blob";
kernel = "kernel";
fdt = "fdt-1";
};
};
};

View File

@ -35,7 +35,6 @@ stdenv.mkDerivation {
dtc -I dtb -O dts -o tmp.dts ${dtb}
echo '/{ chosen { bootargs = ${builtins.toJSON commandLine}; }; };' >> tmp.dts
dtc -I dts -O dtb -o tmp.dtb tmp.dts
${objcopy} --update-section .appended_dtb=tmp.dtb vmlinux.elf || ${objcopy} --add-section .appended_dtb=${dtb} vmlinux.elf
'';
buildPhase =
@ -51,9 +50,16 @@ stdenv.mkDerivation {
in ''
${objcopy} -O binary -R .reginfo -R .notes -R .note -R .comment -R .mdebug -R .note.gnu.build-id -S vmlinux.elf vmlinux.bin
rm -f vmlinux.bin.lzma ; lzma -k -z vmlinux.bin
mkimage -A ${arch} -O linux -T kernel -C lzma -a ${loadAddress} -e ${entryPoint} -n '${lib.toUpper arch} Liminix Linux ${extraName}' -d vmlinux.bin.lzma kernel.uimage
cat ${./kernel_fdt.its} > mkimage.its
echo '/ { images { kernel { data = /incbin/("./vmlinux.bin.lzma"); }; }; };' >> mkimage.its
echo '/ { images { kernel { load = <${loadAddress}>; }; }; };' >> mkimage.its
echo '/ { images { kernel { entry = <${entryPoint}>; }; }; };' >> mkimage.its
echo '/ { images { kernel { compression = "lzma"; }; }; };' >> mkimage.its
echo '/ { images { fdt-1 { data = /incbin/("./tmp.dtb"); }; }; }; ' >> mkimage.its
mkimage -f mkimage.its mkimage.itb
mkimage -l mkimage.itb
'';
installPhase = ''
cp kernel.uimage $out
cp mkimage.itb $out
'';
}