mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
gem5: use --param to automate aarch64 baremetal BS, oh yeah
This commit is contained in:
28
README.adoc
28
README.adoc
@@ -850,15 +850,15 @@ The semihosting patch is required to enable <<semihosting>>, on which base funct
|
||||
Note that `./build-baremetal` requires the `--gem5` option, and generates separate executable images for both, as can be seen from:
|
||||
|
||||
....
|
||||
echo "$(./getvar --arch arm --baremetal prompt image)"
|
||||
echo "$(./getvar --arch arm --baremetal prompt --gem5 image)"
|
||||
echo "$(./getvar --arch aarch64 --baremetal prompt image)"
|
||||
echo "$(./getvar --arch aarch64 --baremetal prompt --gem5 image)"
|
||||
....
|
||||
|
||||
This is unlike the Linux kernel that has a single image for both QEMU and gem5:
|
||||
|
||||
....
|
||||
echo "$(./getvar --arch arm image)"
|
||||
echo "$(./getvar --arch arm --gem5 image)"
|
||||
echo "$(./getvar --arch aarch64 image)"
|
||||
echo "$(./getvar --arch aarch64 --gem5 image)"
|
||||
....
|
||||
|
||||
The reason for that is that on baremetal we don't parse the <<device-tree,device tress>> from memory like the Linux kernel does, which tells the kernel for example the UART address, and many other system parameters.
|
||||
@@ -879,16 +879,6 @@ echo "$(./getvar --arch arm --baremetal prompt --gem5 --machine RealViewPBX
|
||||
|
||||
But just stick to newer and better `VExpress_GEM5_V1` unless you have a good reason to use `RealViewPBX`.
|
||||
|
||||
gem5 aarch64 baremetal currently requires you to apply a small patch before running:
|
||||
|
||||
....
|
||||
./build-baremetal --arch aarch64 --gem5
|
||||
patch -d "$(./getvar gem5_src_dir)" -p 1 < patches/manual/gem5-aarch64-baremetal.patch
|
||||
./run --arch arm --baremetal prompt --gem5
|
||||
....
|
||||
|
||||
Source: link:patches/manual/gem5-aarch64-baremetal.patch[]
|
||||
|
||||
This patch is required only for baremetal because the Linux bootloader enters 32 bit mode and switches to 64 for us, but the in the baremetal system we use our own bootloader.
|
||||
|
||||
Therefore we must tell gem5 to start the system in aarch64 mode for us with the options:
|
||||
@@ -9592,9 +9582,15 @@ You can also get a simplified graphical view of the tree with:
|
||||
xdg-open "$(./getvar --arch arm --gem5 m5out_dir)/config.dot.pdf"
|
||||
....
|
||||
|
||||
Modifying the `config.ini` file does nothing since it gets overwritten every time.
|
||||
Modifying the `config.ini` file manually does nothing since it gets overwritten every time.
|
||||
|
||||
You can modify those configurations in `fs.py` easily by hacking up the `fs.py` file just before it runs, see for example: link:patches/manual/gem5-aarch64-baremetal.patch[]
|
||||
Set custom configs with the `--param` option of `fs.py`, e.g. we can make gem5 wait for GDB to connect with:
|
||||
|
||||
....
|
||||
fs.py --param 'system.cpu[0].wait_for_remote_gdb = True'
|
||||
....
|
||||
|
||||
More complex settings involving new classes however require patching the config files, although it is easy to hack this up. See for example: link:patches/manual/gem5-semihost.patch[].
|
||||
|
||||
=== m5term
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
diff --git a/configs/example/fs.py b/configs/example/fs.py
|
||||
index 3997ed76c..c3259825d 100644
|
||||
--- a/configs/example/fs.py
|
||||
+++ b/configs/example/fs.py
|
||||
@@ -376,5 +376,7 @@ if buildEnv['TARGET_ISA'] == "arm" and options.generate_dtb:
|
||||
sys = getattr(root, sysname)
|
||||
sys.dtb_filename = create_dtb_for_system(sys, '%s.dtb' % sysname)
|
||||
|
||||
+test_sys.highest_el_is_64 = True
|
||||
+test_sys.auto_reset_addr_64 = True
|
||||
Simulation.setWorkCountOptions(test_sys, options)
|
||||
Simulation.run(options, root, test_sys, FutureClass)
|
||||
4
run
4
run
@@ -167,6 +167,10 @@ def main(args, extra_args=None):
|
||||
]
|
||||
if not args.baremetal is None:
|
||||
cmd.append('--bare-metal')
|
||||
if args.arch == 'aarch64':
|
||||
# https://stackoverflow.com/questions/43682311/uart-communication-in-gem5-with-arm-bare-metal/50983650#50983650
|
||||
cmd.extend(['--param', 'system.highest_el_is_64 = True'])
|
||||
cmd.extend(['--param', 'system.auto_reset_addr_64 = True'])
|
||||
elif args.gem5_script == 'biglittle':
|
||||
if args.gem5_restore is not None:
|
||||
cpt_dir = common.gem_list_checkpoint_dirs()[-args.gem5_restore]
|
||||
|
||||
Reference in New Issue
Block a user