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;
|
cmdline = concatStringsSep " " config.boot.commandLine;
|
||||||
objcopy = "${pkgs.stdenv.cc.bintools.targetPrefix}objcopy";
|
objcopy = "${pkgs.stdenv.cc.bintools.targetPrefix}objcopy";
|
||||||
stripAndZip = ''
|
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
|
${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
|
rm -f vmlinux.bin.lzma ; lzma -k -z vmlinux.bin
|
||||||
'';
|
'';
|
||||||
@ -96,7 +97,7 @@ in {
|
|||||||
# decompression code will assume that any memory after the
|
# decompression code will assume that any memory after the
|
||||||
# end of the kernel is free
|
# end of the kernel is free
|
||||||
|
|
||||||
dtbStart=$(($rootfsStart + $rootfsSize))
|
imageStart=$(($rootfsStart + $rootfsSize))
|
||||||
${if cfg.compressRoot
|
${if cfg.compressRoot
|
||||||
then ''
|
then ''
|
||||||
lzma -z9cv ${o.rootfs} > rootfs.lz
|
lzma -z9cv ${o.rootfs} > rootfs.lz
|
||||||
@ -127,22 +128,30 @@ in {
|
|||||||
|
|
||||||
dtbSize=$(binsize ./dtb )
|
dtbSize=$(binsize ./dtb )
|
||||||
|
|
||||||
${if cfg.appendDTB then ''
|
${stripAndZip}
|
||||||
imageStart=$dtbStart
|
cat ${../../pkgs/kernel/kernel_fdt.its} > mkimage.its
|
||||||
# re-package image with updated dtb
|
cat << _VARS >> mkimage.its
|
||||||
cat ${o.kernel} > vmlinux.elf
|
/ {
|
||||||
${objcopy} --update-section .appended_dtb=dtb vmlinux.elf
|
images {
|
||||||
${stripAndZip}
|
kernel {
|
||||||
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
|
description = "${arch} Liminix kernel";
|
||||||
# dtc -I dtb -O dts -o /dev/stdout dtb | grep -A10 chosen ; exit 1
|
data = /incbin/("./vmlinux.bin.lzma");
|
||||||
tftpcmd="tftpboot $(hex $imageStart) result/image "
|
load = <0x${lib.toHexString hw.loadAddress}>;
|
||||||
bootcmd="bootm $(hex $imageStart)"
|
entry = <0x${lib.toHexString hw.entryPoint}>;
|
||||||
'' else ''
|
arch = "${arch}";
|
||||||
imageStart=$(($dtbStart + $dtbSize))
|
compression = "lzma";
|
||||||
tftpcmd="tftpboot $(hex $imageStart) result/image; tftpboot $(hex $dtbStart) result/dtb "
|
};
|
||||||
ln -s ${image} image
|
fdt-1 {
|
||||||
bootcmd="${bootCommand} $(hex $imageStart) - $(hex $dtbStart)"
|
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
|
cat > boot.scr << EOF
|
||||||
setenv serverip ${cfg.serverip}
|
setenv serverip ${cfg.serverip}
|
||||||
@ -156,7 +165,7 @@ in {
|
|||||||
then "lzmadec $(hex $rootfsLzStart) $(hex $rootfsStart); "
|
then "lzmadec $(hex $rootfsLzStart) $(hex $rootfsStart); "
|
||||||
else ""
|
else ""
|
||||||
} $bootcmd
|
} $bootcmd
|
||||||
EOF
|
EOF
|
||||||
'';
|
'';
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user