Make our own init script

The problem with the Stage 1 script is that is spawning another tee
process to forward the output to the console, but this is not required.
So let's only keep the memtool running by creating our own init script.
This commit is contained in:
Rodrigo Arias 2024-07-09 18:21:33 +02:00
parent c6726cce28
commit 9ed8f812c8

View File

@ -80,6 +80,20 @@
compressor = "gzip"; compressor = "gzip";
kernelModules = [ ]; kernelModules = [ ];
# Custom init script
extraFiles."/init2".source = pkgs.writeScript "init2" ''
#!${config.system.build.extraUtils}/bin/ash
set -x
export PATH=${config.system.build.extraUtils}/bin
memtool $((64 * 1024))
# Unlikely to reach this point
exec /init
'';
# Add the csrtool to the initrd so we can change the # Add the csrtool to the initrd so we can change the
# in-order/out-of-order, and memtool to stress the memory. # in-order/out-of-order, and memtool to stress the memory.
extraUtilsCommands = '' extraUtilsCommands = ''
@ -91,14 +105,7 @@
# dead. Monitor from the host with: # dead. Monitor from the host with:
# while [ 1 ]; do xxd -s $((0x1bfff0000 - 0x60000000)) \ # while [ 1 ]; do xxd -s $((0x1bfff0000 - 0x60000000)) \
# -l 4 /dev/qdma34000-MM-1; sleep 0.2; done # -l 4 /dev/qdma34000-MM-1; sleep 0.2; done
preDeviceCommands = preDeviceCommands = ''
# Run our memtool to hang the kernel here. Set the maximum block
# size to 64K.
''
memtool $((64 * 1024))
''
+
''
echo "Creating a heartbeat counter at 0x1bfff0000" echo "Creating a heartbeat counter at 0x1bfff0000"
sh -c 'hb=0; while [ 1 ]; do let hb=$hb+1; devmem 0x1bfff0000 32 $hb; done' & sh -c 'hb=0; while [ 1 ]; do let hb=$hb+1; devmem 0x1bfff0000 32 $hb; done' &
'' ''
@ -272,7 +279,7 @@
# tp_printk write ftrace events to console # tp_printk write ftrace events to console
# trace_buf_size=1M set ftrace buffer to 1M # trace_buf_size=1M set ftrace buffer to 1M
# #
setenv bootargs "root=/dev/ram0 loglevel=7 debug rw earlycon=sbi console=hvc0 init=${init}" setenv bootargs "root=/dev/ram0 loglevel=7 debug rw earlycon=sbi console=hvc0 rdinit=/init2 init=${init}"
EOF EOF