Generate U-Boot commands

This commit is contained in:
Rodrigo Arias 2024-03-07 16:49:48 +01:00
parent 66e3c36f77
commit bf767d623b
3 changed files with 28 additions and 1 deletions

View File

@ -61,10 +61,12 @@
build = nixosconf.config.system.build; build = nixosconf.config.system.build;
in pkgs.mkShell { in pkgs.mkShell {
pname = "lagarto-hun-shell"; pname = "lagarto-hun-shell";
TOPLEVEL = build.toplevel;
OPENSBI = syspkgs.opensbi; OPENSBI = syspkgs.opensbi;
KERNEL = build.kernel; KERNEL = build.kernel;
INITRD = build.initialRamdisk; INITRD = build.initialRamdisk;
ROOTFS = build.sdImage; ROOTFS = build.sdImage;
UBOOT_ENV = syspkgs.uboot-env;
}; };
}; };
} }

View File

@ -11,6 +11,7 @@ rsync -a fpga/env.sh "$dst"
rsync "$OPENSBI/share/opensbi/lp64/fpga/openpiton/firmware/fw_payload.bin" "$dst/opensbi.bin" rsync "$OPENSBI/share/opensbi/lp64/fpga/openpiton/firmware/fw_payload.bin" "$dst/opensbi.bin"
rsync "$KERNEL/Image" "$dst/kernel.bin" rsync "$KERNEL/Image" "$dst/kernel.bin"
rsync "$INITRD/initrd" "$dst/initrd.bin" rsync "$INITRD/initrd" "$dst/initrd.bin"
rsync "$ROOTFS/rootfs.img" "$dst/rootfs.img" rsync "$ROOTFS/sd-image/rootfs.img" "$dst/rootfs.img"
rsync "$UBOOT_ENV" "$dst/uboot.env"
echo "Now go to $dst and run ./boot.sh" echo "Now go to $dst and run ./boot.sh"

View File

@ -81,6 +81,30 @@
''; '';
}; };
uboot-env = let
init = "${config.system.build.toplevel}/init";
initrd = "${config.system.build.initialRamdisk}/initrd";
in prev.runCommand "uboot.txt" {} ''
cat > $out <<EOF
# Create pmem
fdt mknode / pmem@0x180000000
fdt set /pmem@0x180000000 compatible "pmem-region"
fdt set /pmem@0x180000000 reg <0x1 0x80000000 0x0 0x80000000>
# Reduce memory
fdt set /memory@80000000 reg <0x00000000 0x80000000 0x00000001 0x00000000>
# Set kernel options
setenv bootargs "root=/dev/ram0 loglevel=7 debug rw earlycon=sbi boot.trace console=hvc0 init=${init}"
EOF
# Populate the bood commands from the initrd size
echo "# Boot system" >> $out
echo "setenv ramdisk_size $(stat --format %s $(readlink -f ${initrd}))" >> $out
echo 'booti ''${kernel_addr_r} ''${ramdisk_addr_r}:''${ramdisk_size} ''${fdtcontroladdr}' >> $out
'';
opensbi = prev.opensbi.overrideAttrs (old: { opensbi = prev.opensbi.overrideAttrs (old: {
makeFlags = old.makeFlags ++ [ makeFlags = old.makeFlags ++ [
"PLATFORM=fpga/openpiton" "PLATFORM=fpga/openpiton"