Automatically load U-Boot environment on boot

This commit is contained in:
Rodrigo Arias 2024-08-30 13:46:00 +02:00
parent 8a123d93bf
commit 742ce37cec

View File

@ -230,6 +230,11 @@
cat .config
echo ---------------------------
'';
postBuild = ''
echo --------------------------- generated env starts
cat include/generated/env.in
echo --------------------------- generated env ends
'';
#
# CONFIG_SERIAL_PRESENT=n
# CONFIG_SYS_NS16550=n
@ -280,17 +285,14 @@
initrd = "${config.system.build.initialRamdisk}/initrd";
rev = if self ? rev then self.rev
else throw ("Refusing to build from a dirty Git tree!");
in prev.runCommand "uboot.txt" {} ''
cat > $out <<EOF
# Git commit: ${rev}
# Create pmem of 3 GiB [0x140000000, 0x200000000)
fdt mknode / pmem@0x140000000
fdt set /pmem@0x140000000 compatible "pmem-region"
fdt set /pmem@0x140000000 reg <0x1 0x40000000 0x0 0xc0000000>
#fdt mknode / pmem@0x140000000
#fdt set /pmem@0x140000000 compatible "pmem-region"
#fdt set /pmem@0x140000000 reg <0x1 0x40000000 0x0 0xc0000000>
# Reduce memory to 3 GiB [0x80000000, 0x140000000)
fdt set /memory@80000000 reg <0x0 0x80000000 0x0 0xc0000000>
#fdt set /memory@80000000 reg <0x0 0x80000000 0x0 0xc0000000>
# Set kernel bootcmd options.
# rdinit=/preinit boot custom preinit script
@ -307,14 +309,14 @@
# tp_printk write ftrace events to console
# trace_buf_size=1M set ftrace buffer to 1M
#
setenv bootargs "root=/dev/ram0 loglevel=7 debug rw earlycon=sbi console=hvc0 systemd.log_level=debug systemd.log_target=console rdinit=/preinit init=${init}"
in prev.runCommand "uboot.txt" {} ''
cat > $out <<EOF
git_commit=${rev}
xtrace=yes
bootargs=root=/dev/ram0 loglevel=7 debug rw earlycon=sbi console=hvc0 rdinit=/preinit init=${init}
ramdisk_size=$(stat --format %s $(readlink -f ${initrd}))
bootcmd=booti \''${kernel_addr_r} \''${ramdisk_addr_r}:\''${ramdisk_size} \''${fdtcontroladdr}
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: rec {
@ -342,7 +344,7 @@
"FW_PAYLOAD_FDT_ADDR=0xc0000000"
];
patches = [
./opensbi-timer-debug.patch
./opensbi-timer-debug.patch # Print calls to machine trap
#./opensbi-enable-meip.patch
#./opensbi-enable-seip.patch
#./opensbi-test-plic.patch # Working delegation test, disabled for now