forked from dan/liminix
WIP: create a FIT image for TFTP booting
TODO: make 'traditional' and FIT methods work side-by-side
This commit is contained in:
parent
2e513eb4a7
commit
a3f6234ef0
@ -73,6 +73,7 @@ in {
|
||||
cmdline = concatStringsSep " " config.boot.commandLine;
|
||||
objcopy = "${pkgs.stdenv.cc.bintools.targetPrefix}objcopy";
|
||||
stripAndZip = ''
|
||||
cp vmlinux vmlinux.elf; chmod +w vmlinux.elf
|
||||
${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
|
||||
'';
|
||||
@ -96,7 +97,7 @@ in {
|
||||
# decompression code will assume that any memory after the
|
||||
# end of the kernel is free
|
||||
|
||||
dtbStart=$(($rootfsStart + $rootfsSize))
|
||||
imageStart=$(($rootfsStart + $rootfsSize))
|
||||
${if cfg.compressRoot
|
||||
then ''
|
||||
lzma -z9cv ${o.rootfs} > rootfs.lz
|
||||
@ -127,22 +128,30 @@ in {
|
||||
|
||||
dtbSize=$(binsize ./dtb )
|
||||
|
||||
${if cfg.appendDTB then ''
|
||||
imageStart=$dtbStart
|
||||
# re-package image with updated dtb
|
||||
cat ${o.kernel} > vmlinux.elf
|
||||
${objcopy} --update-section .appended_dtb=dtb vmlinux.elf
|
||||
${stripAndZip}
|
||||
mkimage -A ${arch} -O linux -T kernel -C lzma -a $(hex ${toString hw.loadAddress}) -e $(hex ${toString hw.entryPoint}) -n '${lib.toUpper arch} Liminix Linux tftpboot' -d vmlinux.bin.lzma image
|
||||
# dtc -I dtb -O dts -o /dev/stdout dtb | grep -A10 chosen ; exit 1
|
||||
tftpcmd="tftpboot $(hex $imageStart) result/image "
|
||||
bootcmd="bootm $(hex $imageStart)"
|
||||
'' else ''
|
||||
imageStart=$(($dtbStart + $dtbSize))
|
||||
tftpcmd="tftpboot $(hex $imageStart) result/image; tftpboot $(hex $dtbStart) result/dtb "
|
||||
ln -s ${image} image
|
||||
bootcmd="${bootCommand} $(hex $imageStart) - $(hex $dtbStart)"
|
||||
''}
|
||||
${stripAndZip}
|
||||
cat ${../../pkgs/kernel/kernel_fdt.its} > mkimage.its
|
||||
cat << _VARS >> mkimage.its
|
||||
/ {
|
||||
images {
|
||||
kernel {
|
||||
description = "${arch} Liminix kernel";
|
||||
data = /incbin/("./vmlinux.bin.lzma");
|
||||
load = <0x${lib.toHexString hw.loadAddress}>;
|
||||
entry = <0x${lib.toHexString hw.entryPoint}>;
|
||||
arch = "${arch}";
|
||||
compression = "lzma";
|
||||
};
|
||||
fdt-1 {
|
||||
description = "${arch} Liminix DTB";
|
||||
data = /incbin/("./dtb");
|
||||
arch = "${arch}";
|
||||
};
|
||||
};
|
||||
};
|
||||
_VARS
|
||||
mkimage -f mkimage.its image
|
||||
tftpcmd="tftpboot $(hex $imageStart) result/image "
|
||||
bootcmd="bootm $(hex $imageStart)"
|
||||
|
||||
cat > boot.scr << EOF
|
||||
setenv serverip ${cfg.serverip}
|
||||
@ -156,7 +165,7 @@ in {
|
||||
then "lzmadec $(hex $rootfsLzStart) $(hex $rootfsStart); "
|
||||
else ""
|
||||
} $bootcmd
|
||||
EOF
|
||||
EOF
|
||||
'';
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user