Discussion:
[gem5-users] ARM bootloader for real time operating system
Thawra Kadeed
2018-11-04 16:02:21 UTC
Permalink
Hello everyone,

I m trying to boot a real-time operating system (RTOS) e.g. MicroC/OS on
ARM using Gem5 full system mode.

I replaced the Linux kernel in FSConfig.py by the RTOS one.
And I need to compile the ARM bootloader (available here: system/arm/)
for RTOS rather than Linux which is explained here
"http://www.gem5.org/ARM_Kernel". The latter explanation uses gcc linux
cross compiler to do so.

However, does anyone know how can I direct/compile the ARM bootloader
for RTOS?


Thanks in advance,
Thawra
Ciro Santilli
2018-11-04 18:31:41 UTC
Permalink
Post by Thawra Kadeed
Hello everyone,
I m trying to boot a real-time operating system (RTOS) e.g. MicroC/OS on
ARM using Gem5 full system mode.
I replaced the Linux kernel in FSConfig.py by the RTOS one.
Did you have to modify that file? How exactly? Or do you mean just
pass --kernel path/to/rtos.elf (that's what I'd expect).
Post by Thawra Kadeed
And I need to compile the ARM bootloader (available here: system/arm/)
for RTOS rather than Linux which is explained here
"http://www.gem5.org/ARM_Kernel". The latter explanation uses gcc linux
cross compiler to do so.
However, does anyone know how can I direct/compile the ARM bootloader
for RTOS?
I have never booted anything besides Linux, but I really want to give
it a try some day.

Have you ever used those gem5 bootloaders for Linux to start with? If
not, here is a minimal runnable setup that builds them and puts them
in M5_PATH so they are used:
https://github.com/cirosantilli/linux-kernel-module-cheat/tree/8fb9db39316d43a6dbd571e04dd46ae73915027f#gem5-buildroot-setup-getting-started

Once you have that working, I would just try to point --kernel to the
rtos. And then if it does not work, start to step debug stuff and
examine memory / pc until you undertand why it's not booting, should
not be too hard.
Post by Thawra Kadeed
Thanks in advance,
Thawra
_______________________________________________
gem5-users mailing list
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users
Ciro Santilli
2018-11-05 11:43:22 UTC
Permalink
Thanks a lot Ciro for your answer.
I just point to the rtos.elf using --kernel, and recompiled the
available bootloader in "system/arm/" using
arm-none-eabi toolchain instead arm-linux-gnueabi so that I produce
non-linux related bootloader.
I still have an error related to "kernel panic" and debugging does not
command line: build/ARM/gem5.opt --debug-flags=Exec
configs/example/fs.py --kernel=OS2.out
Global frequency set at 1000000000000 ticks per second
warn: DRAM device capacity (8192 Mbytes) does not match the address
range assigned (512 Mbytes)
warn: Empty .text segment in
'/home/kadeed/Gem5/DiskImage/ucosii/binaries/OS2.out'. ELF file
corrupted?
/home/kadeed/Gem5/DiskImage/ucosii/binaries/OS2.out
panic: Failed to find kernel symbol 'panic'
Memory Usage: 973740 KBytes
Program aborted at tick 0
--- BEGIN LIBC BACKTRACE ---
build/ARM/gem5.opt(_Z15print_backtracev+0x15)[0x192e2f5]
build/ARM/gem5.opt(_Z12abortHandleri+0x39)[0x193ca39]
/lib64/libpthread.so.0(+0x11fb0)[0x7faa63a95fb0]
/lib64/libc.so.6(gsignal+0x10b)[0x7faa62363eab]
/lib64/libc.so.6(abort+0x123)[0x7faa6234e5b9]
build/ARM/gem5.opt[0x9fb80f]
build/ARM/gem5.opt(_ZN14LinuxArmSystemC2EP20LinuxArmSystemParams+0xcb6)[0xf819d6]
build/ARM/gem5.opt(_ZN20LinuxArmSystemParams6createEv+0x21)[0xf826c1]
build/ARM/gem5.opt[0xcbef1f]
build/ARM/gem5.opt[0xb3bd81]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x8029)[0x7faa63e142e9]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x632c)[0x7faa63e125ec]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x632c)[0x7faa63e125ec]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x632c)[0x7faa63e125ec]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x632c)[0x7faa63e125ec]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalCode+0x1d)[0x7faa63e15c4d]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x708a)[0x7faa63e1334a]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x632c)[0x7faa63e125ec]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalCode+0x1d)[0x7faa63e15c4d]
/lib64/libpython2.7.so.1.0(+0x178bcf)[0x7faa63e1bbcf]
/lib64/libpython2.7.so.1.0(PyRun_StringFlags+0x68)[0x7faa63e1bdd8]
build/ARM/gem5.opt(_Z6m5MainiPPc+0x53)[0x193b6f3]
build/ARM/gem5.opt(main+0x3f)[0x9adbef]
/lib64/libc.so.6(__libc_start_main+0xeb)[0x7faa6235011b]
build/ARM/gem5.opt(_start+0x2a)[0x9eac9a]
--- END LIBC BACKTRACE ---
Aborted (core dumped)
Do you have an idea about why it still complain about the kernel panic
which (I think) has to do with linux?
Ah, you are right, it is doing something Linux specific.

This happens because on ARM at least, gem5 detects panic by finding
the address of the panic symbol, and checking if PC is there.

This is an awesome feature, when you actually have a panic symbol :-P

The fs.py --bare-metal option should turn this off as it makes gem5
use ArmSystem instead of LinuxArmSystem.
Post by Ciro Santilli
Post by Thawra Kadeed
Hello everyone,
I m trying to boot a real-time operating system (RTOS) e.g. MicroC/OS on
ARM using Gem5 full system mode.
I replaced the Linux kernel in FSConfig.py by the RTOS one.
Did you have to modify that file? How exactly? Or do you mean just
pass --kernel path/to/rtos.elf (that's what I'd expect).
Post by Thawra Kadeed
And I need to compile the ARM bootloader (available here: system/arm/)
for RTOS rather than Linux which is explained here
"http://www.gem5.org/ARM_Kernel". The latter explanation uses gcc linux
cross compiler to do so.
However, does anyone know how can I direct/compile the ARM bootloader
for RTOS?
I have never booted anything besides Linux, but I really want to give
it a try some day.
Have you ever used those gem5 bootloaders for Linux to start with? If
not, here is a minimal runnable setup that builds them and puts them
https://github.com/cirosantilli/linux-kernel-module-cheat/tree/8fb9db39316d43a6dbd571e04dd46ae73915027f#gem5-buildroot-setup-getting-started
Once you have that working, I would just try to point --kernel to the
rtos. And then if it does not work, start to step debug stuff and
examine memory / pc until you undertand why it's not booting, should
not be too hard.
Post by Thawra Kadeed
Thanks in advance,
Thawra
_______________________________________________
gem5-users mailing list
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users
Ciro Santilli
2018-11-05 18:30:23 UTC
Permalink
Thanks, it is better now.
command line: build/ARM/gem5.opt --debug-flags=Exec
configs/example/fs.py --bare-metal --kernel=OS2.out
Global frequency set at 1000000000000 ticks per second
warn: DRAM device capacity (8192 Mbytes) does not match the address
range assigned (512 Mbytes)
warn: Empty .text segment in
'/home/kadeed/Gem5/DiskImage/ucosii/binaries/OS2.out'. ELF file
corrupted?
/home/kadeed/Gem5/DiskImage/ucosii/binaries/OS2.out
system.vncserver: Listening for connections on port 5900
system.terminal: Listening for connections on port 3456
0: system.remote_gdb: listening for remote gdb on port 7000
fatal: Kernel is mapped to invalid location (not memory). kernelStart
0x(0) - kernelEnd 0x(0) 0:0
I had this problem on aarch64, you also need:

fs.py --param 'system.highest_el_is_64 = True' \
--param 'system.auto_reset_addr_64 = True'

as explained at:
https://stackoverflow.com/questions/43682311/uart-communication-in-gem5-with-arm-bare-metal/50983650#50983650

I'm not sure about all the memory setup options.
This has to do with Gem5 memory configuration and the kernel address
which is specified in the rtos.elf file.
to address this, first I need to understand exactly how Gem5 configure
the main memory,i.e, the memory size, the rom address space, the
reserved address space and the available address space for the user.
I expected that should be in the fs.py but I have not seen that. Maybe
has to do with ARM-specific architecture file but also was not clear for
me.
So like you said, it is now like bare metal execution where you are our
expert, so can you please provide me with some info about Gem5 memory
configuration?
Thanks in advance!
Post by Ciro Santilli
Thanks a lot Ciro for your answer.
I just point to the rtos.elf using --kernel, and recompiled the
available bootloader in "system/arm/" using
arm-none-eabi toolchain instead arm-linux-gnueabi so that I produce
non-linux related bootloader.
I still have an error related to "kernel panic" and debugging does not
command line: build/ARM/gem5.opt --debug-flags=Exec
configs/example/fs.py --kernel=OS2.out
Global frequency set at 1000000000000 ticks per second
warn: DRAM device capacity (8192 Mbytes) does not match the address
range assigned (512 Mbytes)
warn: Empty .text segment in
'/home/kadeed/Gem5/DiskImage/ucosii/binaries/OS2.out'. ELF file
corrupted?
/home/kadeed/Gem5/DiskImage/ucosii/binaries/OS2.out
panic: Failed to find kernel symbol 'panic'
Memory Usage: 973740 KBytes
Program aborted at tick 0
--- BEGIN LIBC BACKTRACE ---
build/ARM/gem5.opt(_Z15print_backtracev+0x15)[0x192e2f5]
build/ARM/gem5.opt(_Z12abortHandleri+0x39)[0x193ca39]
/lib64/libpthread.so.0(+0x11fb0)[0x7faa63a95fb0]
/lib64/libc.so.6(gsignal+0x10b)[0x7faa62363eab]
/lib64/libc.so.6(abort+0x123)[0x7faa6234e5b9]
build/ARM/gem5.opt[0x9fb80f]
build/ARM/gem5.opt(_ZN14LinuxArmSystemC2EP20LinuxArmSystemParams+0xcb6)[0xf819d6]
build/ARM/gem5.opt(_ZN20LinuxArmSystemParams6createEv+0x21)[0xf826c1]
build/ARM/gem5.opt[0xcbef1f]
build/ARM/gem5.opt[0xb3bd81]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x8029)[0x7faa63e142e9]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x632c)[0x7faa63e125ec]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x632c)[0x7faa63e125ec]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x632c)[0x7faa63e125ec]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x632c)[0x7faa63e125ec]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalCode+0x1d)[0x7faa63e15c4d]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x708a)[0x7faa63e1334a]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x632c)[0x7faa63e125ec]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalCode+0x1d)[0x7faa63e15c4d]
/lib64/libpython2.7.so.1.0(+0x178bcf)[0x7faa63e1bbcf]
/lib64/libpython2.7.so.1.0(PyRun_StringFlags+0x68)[0x7faa63e1bdd8]
build/ARM/gem5.opt(_Z6m5MainiPPc+0x53)[0x193b6f3]
build/ARM/gem5.opt(main+0x3f)[0x9adbef]
/lib64/libc.so.6(__libc_start_main+0xeb)[0x7faa6235011b]
build/ARM/gem5.opt(_start+0x2a)[0x9eac9a]
--- END LIBC BACKTRACE ---
Aborted (core dumped)
Do you have an idea about why it still complain about the kernel panic
which (I think) has to do with linux?
Ah, you are right, it is doing something Linux specific.
This happens because on ARM at least, gem5 detects panic by finding
the address of the panic symbol, and checking if PC is there.
This is an awesome feature, when you actually have a panic symbol :-P
The fs.py --bare-metal option should turn this off as it makes gem5
use ArmSystem instead of LinuxArmSystem.
Post by Ciro Santilli
Post by Thawra Kadeed
Hello everyone,
I m trying to boot a real-time operating system (RTOS) e.g. MicroC/OS on
ARM using Gem5 full system mode.
I replaced the Linux kernel in FSConfig.py by the RTOS one.
Did you have to modify that file? How exactly? Or do you mean just
pass --kernel path/to/rtos.elf (that's what I'd expect).
Post by Thawra Kadeed
And I need to compile the ARM bootloader (available here: system/arm/)
for RTOS rather than Linux which is explained here
"http://www.gem5.org/ARM_Kernel". The latter explanation uses gcc linux
cross compiler to do so.
However, does anyone know how can I direct/compile the ARM bootloader
for RTOS?
I have never booted anything besides Linux, but I really want to give
it a try some day.
Have you ever used those gem5 bootloaders for Linux to start with? If
not, here is a minimal runnable setup that builds them and puts them
https://github.com/cirosantilli/linux-kernel-module-cheat/tree/8fb9db39316d43a6dbd571e04dd46ae73915027f#gem5-buildroot-setup-getting-started
Once you have that working, I would just try to point --kernel to the
rtos. And then if it does not work, start to step debug stuff and
examine memory / pc until you undertand why it's not booting, should
not be too hard.
Post by Thawra Kadeed
Thanks in advance,
Thawra
_______________________________________________
gem5-users mailing list
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users
Thawra Kadeed
2018-11-06 15:51:39 UTC
Permalink
Hello Ciro,

I actually tried to add:
test_sys.system.highest_el_is_64 = True
test_sys.system.auto_reset_addr_64 = True

to the fs.py for ARM target ISA but I had the same problem.

Then I tried to run hello world example in bare metal to simplify the
issue but also the same error:

command line: build/ARM/gem5.opt --debug-flags=Exec
configs/example/fs.py --bare-metal
--kernel=Gem5/tests/test-progs/hello/bin/arm/linux/hello

Global frequency set at 1000000000000 ticks per second
warn: DRAM device capacity (8192 Mbytes) does not match the address
range assigned (512 Mbytes)
info: kernel located at:
/home/kadeed/Gem5/tests/test-progs/hello/bin/arm/linux/hello
system.vncserver: Listening for connections on port 5900
system.terminal: Listening for connections on port 3456
0: system.remote_gdb: listening for remote gdb on port 7000

fatal: Kernel is mapped to invalid location (not memory). kernelStart
0x(8000) - kernelEnd 0x(85ff4) 0x8000:0x85ff4

It seems Gem5 maps the kernel to a reserved address place. so first how
could we make sure of which arm arch is running,
is it arm? or aarch64? we can not determine that as an option to fs.py.
I think it is normal arm, or?

I am asking because that error is issued from Gem5/src/sim/system.cc and
there is memory mapping in that file, so I am not sure if the problem
comes from the wrong mapping with the main memory (i.e. DRAM) or memory
mapped IO which has to do with arm.

Do you have any idea about the source of this error?

Thanks a lot for your contributions!
Post by Ciro Santilli
Thanks, it is better now.
command line: build/ARM/gem5.opt --debug-flags=Exec
configs/example/fs.py --bare-metal --kernel=OS2.out
Global frequency set at 1000000000000 ticks per second
warn: DRAM device capacity (8192 Mbytes) does not match the address
range assigned (512 Mbytes)
warn: Empty .text segment in
'/home/kadeed/Gem5/DiskImage/ucosii/binaries/OS2.out'. ELF file
corrupted?
/home/kadeed/Gem5/DiskImage/ucosii/binaries/OS2.out
system.vncserver: Listening for connections on port 5900
system.terminal: Listening for connections on port 3456
0: system.remote_gdb: listening for remote gdb on port 7000
fatal: Kernel is mapped to invalid location (not memory). kernelStart
0x(0) - kernelEnd 0x(0) 0:0
fs.py --param 'system.highest_el_is_64 = True' \
--param 'system.auto_reset_addr_64 = True'
https://stackoverflow.com/questions/43682311/uart-communication-in-gem5-with-arm-bare-metal/50983650#50983650
I'm not sure about all the memory setup options.
This has to do with Gem5 memory configuration and the kernel address
which is specified in the rtos.elf file.
to address this, first I need to understand exactly how Gem5 configure
the main memory,i.e, the memory size, the rom address space, the
reserved address space and the available address space for the user.
I expected that should be in the fs.py but I have not seen that. Maybe
has to do with ARM-specific architecture file but also was not clear for
me.
So like you said, it is now like bare metal execution where you are our
expert, so can you please provide me with some info about Gem5 memory
configuration?
Thanks in advance!
Post by Ciro Santilli
Thanks a lot Ciro for your answer.
I just point to the rtos.elf using --kernel, and recompiled the
available bootloader in "system/arm/" using
arm-none-eabi toolchain instead arm-linux-gnueabi so that I produce
non-linux related bootloader.
I still have an error related to "kernel panic" and debugging does not
command line: build/ARM/gem5.opt --debug-flags=Exec
configs/example/fs.py --kernel=OS2.out
Global frequency set at 1000000000000 ticks per second
warn: DRAM device capacity (8192 Mbytes) does not match the address
range assigned (512 Mbytes)
warn: Empty .text segment in
'/home/kadeed/Gem5/DiskImage/ucosii/binaries/OS2.out'. ELF file
corrupted?
/home/kadeed/Gem5/DiskImage/ucosii/binaries/OS2.out
panic: Failed to find kernel symbol 'panic'
Memory Usage: 973740 KBytes
Program aborted at tick 0
--- BEGIN LIBC BACKTRACE ---
build/ARM/gem5.opt(_Z15print_backtracev+0x15)[0x192e2f5]
build/ARM/gem5.opt(_Z12abortHandleri+0x39)[0x193ca39]
/lib64/libpthread.so.0(+0x11fb0)[0x7faa63a95fb0]
/lib64/libc.so.6(gsignal+0x10b)[0x7faa62363eab]
/lib64/libc.so.6(abort+0x123)[0x7faa6234e5b9]
build/ARM/gem5.opt[0x9fb80f]
build/ARM/gem5.opt(_ZN14LinuxArmSystemC2EP20LinuxArmSystemParams+0xcb6)[0xf819d6]
build/ARM/gem5.opt(_ZN20LinuxArmSystemParams6createEv+0x21)[0xf826c1]
build/ARM/gem5.opt[0xcbef1f]
build/ARM/gem5.opt[0xb3bd81]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x8029)[0x7faa63e142e9]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x632c)[0x7faa63e125ec]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x632c)[0x7faa63e125ec]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x632c)[0x7faa63e125ec]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x632c)[0x7faa63e125ec]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalCode+0x1d)[0x7faa63e15c4d]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x708a)[0x7faa63e1334a]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x632c)[0x7faa63e125ec]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalCode+0x1d)[0x7faa63e15c4d]
/lib64/libpython2.7.so.1.0(+0x178bcf)[0x7faa63e1bbcf]
/lib64/libpython2.7.so.1.0(PyRun_StringFlags+0x68)[0x7faa63e1bdd8]
build/ARM/gem5.opt(_Z6m5MainiPPc+0x53)[0x193b6f3]
build/ARM/gem5.opt(main+0x3f)[0x9adbef]
/lib64/libc.so.6(__libc_start_main+0xeb)[0x7faa6235011b]
build/ARM/gem5.opt(_start+0x2a)[0x9eac9a]
--- END LIBC BACKTRACE ---
Aborted (core dumped)
Do you have an idea about why it still complain about the kernel panic
which (I think) has to do with linux?
Ah, you are right, it is doing something Linux specific.
This happens because on ARM at least, gem5 detects panic by finding
the address of the panic symbol, and checking if PC is there.
This is an awesome feature, when you actually have a panic symbol :-P
The fs.py --bare-metal option should turn this off as it makes gem5
use ArmSystem instead of LinuxArmSystem.
Post by Ciro Santilli
Post by Thawra Kadeed
Hello everyone,
I m trying to boot a real-time operating system (RTOS) e.g. MicroC/OS on
ARM using Gem5 full system mode.
I replaced the Linux kernel in FSConfig.py by the RTOS one.
Did you have to modify that file? How exactly? Or do you mean just
pass --kernel path/to/rtos.elf (that's what I'd expect).
Post by Thawra Kadeed
And I need to compile the ARM bootloader (available here: system/arm/)
for RTOS rather than Linux which is explained here
"http://www.gem5.org/ARM_Kernel". The latter explanation uses gcc linux
cross compiler to do so.
However, does anyone know how can I direct/compile the ARM bootloader
for RTOS?
I have never booted anything besides Linux, but I really want to give
it a try some day.
Have you ever used those gem5 bootloaders for Linux to start with? If
not, here is a minimal runnable setup that builds them and puts them
https://github.com/cirosantilli/linux-kernel-module-cheat/tree/8fb9db39316d43a6dbd571e04dd46ae73915027f#gem5-buildroot-setup-getting-started
Once you have that working, I would just try to point --kernel to the
rtos. And then if it does not work, start to step debug stuff and
examine memory / pc until you undertand why it's not booting, should
not be too hard.
Post by Thawra Kadeed
Thanks in advance,
Thawra
_______________________________________________
gem5-users mailing list
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users
Ciro Santilli
2018-11-06 16:43:46 UTC
Permalink
Post by Thawra Kadeed
Hello Ciro,
test_sys.system.highest_el_is_64 = True
test_sys.system.auto_reset_addr_64 = True
to the fs.py for ARM target ISA but I had the same problem.
Then I tried to run hello world example in bare metal to simplify the
This is a good idea.
Post by Thawra Kadeed
command line: build/ARM/gem5.opt --debug-flags=Exec
configs/example/fs.py --bare-metal
--kernel=Gem5/tests/test-progs/hello/bin/arm/linux/hello
I'm not sure this is supposed to work, since you are normally not
supposed to run userland examples as baremetal images. But maybe it
should run until it blows up on syscalls?

In any case, the Stack Overflow answer points to:
https://github.com/cirosantilli/linux-kernel-module-cheat/tree/753cbe68ff50bea0982e1791c8a2178a999d8377#baremetal-setup-getting-started
which is fully automated and just works. Get that running first as a
baseline.
Post by Thawra Kadeed
Global frequency set at 1000000000000 ticks per second
warn: DRAM device capacity (8192 Mbytes) does not match the address
range assigned (512 Mbytes)
/home/kadeed/Gem5/tests/test-progs/hello/bin/arm/linux/hello
system.vncserver: Listening for connections on port 5900
system.terminal: Listening for connections on port 3456
0: system.remote_gdb: listening for remote gdb on port 7000
fatal: Kernel is mapped to invalid location (not memory). kernelStart
0x(8000) - kernelEnd 0x(85ff4) 0x8000:0x85ff4
It seems Gem5 maps the kernel to a reserved address place. so first how
could we make sure of which arm arch is running,
is it arm? or aarch64? we can not determine that as an option to fs.py.
I think it is normal arm, or?
I am asking because that error is issued from Gem5/src/sim/system.cc and
there is memory mapping in that file, so I am not sure if the problem
comes from the wrong mapping with the main memory (i.e. DRAM) or memory
mapped IO which has to do with arm.
Do you have any idea about the source of this error?
Thanks a lot for your contributions!
Post by Ciro Santilli
Thanks, it is better now.
command line: build/ARM/gem5.opt --debug-flags=Exec
configs/example/fs.py --bare-metal --kernel=OS2.out
Global frequency set at 1000000000000 ticks per second
warn: DRAM device capacity (8192 Mbytes) does not match the address
range assigned (512 Mbytes)
warn: Empty .text segment in
'/home/kadeed/Gem5/DiskImage/ucosii/binaries/OS2.out'. ELF file
corrupted?
/home/kadeed/Gem5/DiskImage/ucosii/binaries/OS2.out
system.vncserver: Listening for connections on port 5900
system.terminal: Listening for connections on port 3456
0: system.remote_gdb: listening for remote gdb on port 7000
fatal: Kernel is mapped to invalid location (not memory). kernelStart
0x(0) - kernelEnd 0x(0) 0:0
fs.py --param 'system.highest_el_is_64 = True' \
--param 'system.auto_reset_addr_64 = True'
https://stackoverflow.com/questions/43682311/uart-communication-in-gem5-with-arm-bare-metal/50983650#50983650
I'm not sure about all the memory setup options.
This has to do with Gem5 memory configuration and the kernel address
which is specified in the rtos.elf file.
to address this, first I need to understand exactly how Gem5 configure
the main memory,i.e, the memory size, the rom address space, the
reserved address space and the available address space for the user.
I expected that should be in the fs.py but I have not seen that. Maybe
has to do with ARM-specific architecture file but also was not clear for
me.
So like you said, it is now like bare metal execution where you are our
expert, so can you please provide me with some info about Gem5 memory
configuration?
Thanks in advance!
Post by Ciro Santilli
Thanks a lot Ciro for your answer.
I just point to the rtos.elf using --kernel, and recompiled the
available bootloader in "system/arm/" using
arm-none-eabi toolchain instead arm-linux-gnueabi so that I produce
non-linux related bootloader.
I still have an error related to "kernel panic" and debugging does not
command line: build/ARM/gem5.opt --debug-flags=Exec
configs/example/fs.py --kernel=OS2.out
Global frequency set at 1000000000000 ticks per second
warn: DRAM device capacity (8192 Mbytes) does not match the address
range assigned (512 Mbytes)
warn: Empty .text segment in
'/home/kadeed/Gem5/DiskImage/ucosii/binaries/OS2.out'. ELF file
corrupted?
/home/kadeed/Gem5/DiskImage/ucosii/binaries/OS2.out
panic: Failed to find kernel symbol 'panic'
Memory Usage: 973740 KBytes
Program aborted at tick 0
--- BEGIN LIBC BACKTRACE ---
build/ARM/gem5.opt(_Z15print_backtracev+0x15)[0x192e2f5]
build/ARM/gem5.opt(_Z12abortHandleri+0x39)[0x193ca39]
/lib64/libpthread.so.0(+0x11fb0)[0x7faa63a95fb0]
/lib64/libc.so.6(gsignal+0x10b)[0x7faa62363eab]
/lib64/libc.so.6(abort+0x123)[0x7faa6234e5b9]
build/ARM/gem5.opt[0x9fb80f]
build/ARM/gem5.opt(_ZN14LinuxArmSystemC2EP20LinuxArmSystemParams+0xcb6)[0xf819d6]
build/ARM/gem5.opt(_ZN20LinuxArmSystemParams6createEv+0x21)[0xf826c1]
build/ARM/gem5.opt[0xcbef1f]
build/ARM/gem5.opt[0xb3bd81]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x8029)[0x7faa63e142e9]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x632c)[0x7faa63e125ec]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x632c)[0x7faa63e125ec]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x632c)[0x7faa63e125ec]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x632c)[0x7faa63e125ec]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalCode+0x1d)[0x7faa63e15c4d]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x708a)[0x7faa63e1334a]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x632c)[0x7faa63e125ec]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalCode+0x1d)[0x7faa63e15c4d]
/lib64/libpython2.7.so.1.0(+0x178bcf)[0x7faa63e1bbcf]
/lib64/libpython2.7.so.1.0(PyRun_StringFlags+0x68)[0x7faa63e1bdd8]
build/ARM/gem5.opt(_Z6m5MainiPPc+0x53)[0x193b6f3]
build/ARM/gem5.opt(main+0x3f)[0x9adbef]
/lib64/libc.so.6(__libc_start_main+0xeb)[0x7faa6235011b]
build/ARM/gem5.opt(_start+0x2a)[0x9eac9a]
--- END LIBC BACKTRACE ---
Aborted (core dumped)
Do you have an idea about why it still complain about the kernel panic
which (I think) has to do with linux?
Ah, you are right, it is doing something Linux specific.
This happens because on ARM at least, gem5 detects panic by finding
the address of the panic symbol, and checking if PC is there.
This is an awesome feature, when you actually have a panic symbol :-P
The fs.py --bare-metal option should turn this off as it makes gem5
use ArmSystem instead of LinuxArmSystem.
Post by Ciro Santilli
Post by Thawra Kadeed
Hello everyone,
I m trying to boot a real-time operating system (RTOS) e.g. MicroC/OS on
ARM using Gem5 full system mode.
I replaced the Linux kernel in FSConfig.py by the RTOS one.
Did you have to modify that file? How exactly? Or do you mean just
pass --kernel path/to/rtos.elf (that's what I'd expect).
Post by Thawra Kadeed
And I need to compile the ARM bootloader (available here: system/arm/)
for RTOS rather than Linux which is explained here
"http://www.gem5.org/ARM_Kernel". The latter explanation uses gcc linux
cross compiler to do so.
However, does anyone know how can I direct/compile the ARM bootloader
for RTOS?
I have never booted anything besides Linux, but I really want to give
it a try some day.
Have you ever used those gem5 bootloaders for Linux to start with? If
not, here is a minimal runnable setup that builds them and puts them
https://github.com/cirosantilli/linux-kernel-module-cheat/tree/8fb9db39316d43a6dbd571e04dd46ae73915027f#gem5-buildroot-setup-getting-started
Once you have that working, I would just try to point --kernel to the
rtos. And then if it does not work, start to step debug stuff and
examine memory / pc until you undertand why it's not booting, should
not be too hard.
Post by Thawra Kadeed
Thanks in advance,
Thawra
_______________________________________________
gem5-users mailing list
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users
Thawra Kadeed
2018-11-20 14:59:40 UTC
Permalink
Hello,

I am still trying to boot a real-time operating system (RTOS) in Gem5 in
bare-metal mode.

I tried to run some bare-metal examples (from the internet) and it works
fine.

When I change the kernel to RTOS kernel I get the following error:

Input:
build/ARM/gem5.opt --debug-flag=XBar configs/example/fs.py --bare-metal
--disk-image=/common/fake.iso
--kernel=/Gem5/DiskImage/ucosii/binaries/OS2.out
--machine-type=RealView_PBX --dtb-filename=none --mem-size=256MB

output:
warn: Empty .text segment in '/Gem5/DiskImage/ucosii/binaries/OS2.out'.
ELF file corrupted?
info: kernel located at:
/home/kadeed/Gem5/DiskImage/ucosii/binaries/OS2.out
system.vncserver: Listening for connections on port 5900
system.terminal: Listening for connections on port 3456
0: system.remote_gdb: listening for remote gdb on port 7000
0: system.membus: recvFunctional: src system.membus.slave[0]
packet WriteReq [80000000:8000003f]

panic: invalid access size: 64



I understood from that error that there is a problem in ARM ISA, it is
like the used ARM in fs.py is ARM32 and the one to which the kernel is
compiled is ARM64.

I tried in Gem5 to use /system/arm/aarch64_bootloader because I thought
this will tell Gem5 that we want ARM64 configuration not ARM32 but does
not change, the same error.

I also have this warn in the output:
warn: Empty .text segment in '/Gem5/DiskImage/ucosii/binaries/OS2.out'.
ELF file corrupted?

I compiled the RTOS using a toolchain, I did not make a Makefile for
that because it is a bit tricky. However, I do not think for time being
the error message has to do with this warn!

Does anybody have an idea about that error?


Regards,
Thawra
Post by Ciro Santilli
Post by Thawra Kadeed
Hello Ciro,
test_sys.system.highest_el_is_64 = True
test_sys.system.auto_reset_addr_64 = True
to the fs.py for ARM target ISA but I had the same problem.
Then I tried to run hello world example in bare metal to simplify the
This is a good idea.
Post by Thawra Kadeed
command line: build/ARM/gem5.opt --debug-flags=Exec
configs/example/fs.py --bare-metal
--kernel=Gem5/tests/test-progs/hello/bin/arm/linux/hello
I'm not sure this is supposed to work, since you are normally not
supposed to run userland examples as baremetal images. But maybe it
should run until it blows up on syscalls?
https://github.com/cirosantilli/linux-kernel-module-cheat/tree/753cbe68ff50bea0982e1791c8a2178a999d8377#baremetal-setup-getting-started
which is fully automated and just works. Get that running first as a
baseline.
Post by Thawra Kadeed
Global frequency set at 1000000000000 ticks per second
warn: DRAM device capacity (8192 Mbytes) does not match the address
range assigned (512 Mbytes)
/home/kadeed/Gem5/tests/test-progs/hello/bin/arm/linux/hello
system.vncserver: Listening for connections on port 5900
system.terminal: Listening for connections on port 3456
0: system.remote_gdb: listening for remote gdb on port 7000
fatal: Kernel is mapped to invalid location (not memory). kernelStart
0x(8000) - kernelEnd 0x(85ff4) 0x8000:0x85ff4
It seems Gem5 maps the kernel to a reserved address place. so first how
could we make sure of which arm arch is running,
is it arm? or aarch64? we can not determine that as an option to fs.py.
I think it is normal arm, or?
I am asking because that error is issued from Gem5/src/sim/system.cc and
there is memory mapping in that file, so I am not sure if the problem
comes from the wrong mapping with the main memory (i.e. DRAM) or memory
mapped IO which has to do with arm.
Do you have any idea about the source of this error?
Thanks a lot for your contributions!
Post by Ciro Santilli
Thanks, it is better now.
command line: build/ARM/gem5.opt --debug-flags=Exec
configs/example/fs.py --bare-metal --kernel=OS2.out
Global frequency set at 1000000000000 ticks per second
warn: DRAM device capacity (8192 Mbytes) does not match the address
range assigned (512 Mbytes)
warn: Empty .text segment in
'/home/kadeed/Gem5/DiskImage/ucosii/binaries/OS2.out'. ELF file
corrupted?
/home/kadeed/Gem5/DiskImage/ucosii/binaries/OS2.out
system.vncserver: Listening for connections on port 5900
system.terminal: Listening for connections on port 3456
0: system.remote_gdb: listening for remote gdb on port 7000
fatal: Kernel is mapped to invalid location (not memory). kernelStart
0x(0) - kernelEnd 0x(0) 0:0
fs.py --param 'system.highest_el_is_64 = True' \
--param 'system.auto_reset_addr_64 = True'
https://stackoverflow.com/questions/43682311/uart-communication-in-gem5-with-arm-bare-metal/50983650#50983650
I'm not sure about all the memory setup options.
This has to do with Gem5 memory configuration and the kernel address
which is specified in the rtos.elf file.
to address this, first I need to understand exactly how Gem5 configure
the main memory,i.e, the memory size, the rom address space, the
reserved address space and the available address space for the user.
I expected that should be in the fs.py but I have not seen that. Maybe
has to do with ARM-specific architecture file but also was not clear for
me.
So like you said, it is now like bare metal execution where you are our
expert, so can you please provide me with some info about Gem5 memory
configuration?
Thanks in advance!
Post by Ciro Santilli
Thanks a lot Ciro for your answer.
I just point to the rtos.elf using --kernel, and recompiled the
available bootloader in "system/arm/" using
arm-none-eabi toolchain instead arm-linux-gnueabi so that I produce
non-linux related bootloader.
I still have an error related to "kernel panic" and debugging does not
command line: build/ARM/gem5.opt --debug-flags=Exec
configs/example/fs.py --kernel=OS2.out
Global frequency set at 1000000000000 ticks per second
warn: DRAM device capacity (8192 Mbytes) does not match the address
range assigned (512 Mbytes)
warn: Empty .text segment in
'/home/kadeed/Gem5/DiskImage/ucosii/binaries/OS2.out'. ELF file
corrupted?
/home/kadeed/Gem5/DiskImage/ucosii/binaries/OS2.out
panic: Failed to find kernel symbol 'panic'
Memory Usage: 973740 KBytes
Program aborted at tick 0
--- BEGIN LIBC BACKTRACE ---
build/ARM/gem5.opt(_Z15print_backtracev+0x15)[0x192e2f5]
build/ARM/gem5.opt(_Z12abortHandleri+0x39)[0x193ca39]
/lib64/libpthread.so.0(+0x11fb0)[0x7faa63a95fb0]
/lib64/libc.so.6(gsignal+0x10b)[0x7faa62363eab]
/lib64/libc.so.6(abort+0x123)[0x7faa6234e5b9]
build/ARM/gem5.opt[0x9fb80f]
build/ARM/gem5.opt(_ZN14LinuxArmSystemC2EP20LinuxArmSystemParams+0xcb6)[0xf819d6]
build/ARM/gem5.opt(_ZN20LinuxArmSystemParams6createEv+0x21)[0xf826c1]
build/ARM/gem5.opt[0xcbef1f]
build/ARM/gem5.opt[0xb3bd81]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x8029)[0x7faa63e142e9]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x632c)[0x7faa63e125ec]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x632c)[0x7faa63e125ec]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x632c)[0x7faa63e125ec]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x632c)[0x7faa63e125ec]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalCode+0x1d)[0x7faa63e15c4d]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x708a)[0x7faa63e1334a]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x632c)[0x7faa63e125ec]
/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712)[0x7faa63e159b2]
/lib64/libpython2.7.so.1.0(PyEval_EvalCode+0x1d)[0x7faa63e15c4d]
/lib64/libpython2.7.so.1.0(+0x178bcf)[0x7faa63e1bbcf]
/lib64/libpython2.7.so.1.0(PyRun_StringFlags+0x68)[0x7faa63e1bdd8]
build/ARM/gem5.opt(_Z6m5MainiPPc+0x53)[0x193b6f3]
build/ARM/gem5.opt(main+0x3f)[0x9adbef]
/lib64/libc.so.6(__libc_start_main+0xeb)[0x7faa6235011b]
build/ARM/gem5.opt(_start+0x2a)[0x9eac9a]
--- END LIBC BACKTRACE ---
Aborted (core dumped)
Do you have an idea about why it still complain about the kernel panic
which (I think) has to do with linux?
Ah, you are right, it is doing something Linux specific.
This happens because on ARM at least, gem5 detects panic by finding
the address of the panic symbol, and checking if PC is there.
This is an awesome feature, when you actually have a panic symbol :-P
The fs.py --bare-metal option should turn this off as it makes gem5
use ArmSystem instead of LinuxArmSystem.
Post by Ciro Santilli
Post by Thawra Kadeed
Hello everyone,
I m trying to boot a real-time operating system (RTOS) e.g. MicroC/OS
on
ARM using Gem5 full system mode.
I replaced the Linux kernel in FSConfig.py by the RTOS one.
Did you have to modify that file? How exactly? Or do you mean just
pass --kernel path/to/rtos.elf (that's what I'd expect).
Post by Thawra Kadeed
And I need to compile the ARM bootloader (available here: system/arm/)
for RTOS rather than Linux which is explained here
"http://www.gem5.org/ARM_Kernel". The latter explanation uses gcc linux
cross compiler to do so.
However, does anyone know how can I direct/compile the ARM bootloader
for RTOS?
I have never booted anything besides Linux, but I really want to give
it a try some day.
Have you ever used those gem5 bootloaders for Linux to start with? If
not, here is a minimal runnable setup that builds them and puts them
https://github.com/cirosantilli/linux-kernel-module-cheat/tree/8fb9db39316d43a6dbd571e04dd46ae73915027f#gem5-buildroot-setup-getting-started
Once you have that working, I would just try to point --kernel to the
rtos. And then if it does not work, start to step debug stuff and
examine memory / pc until you undertand why it's not booting, should
not be too hard.
Post by Thawra Kadeed
Thanks in advance,
Thawra
_______________________________________________
gem5-users mailing list
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users
Loading...