The guys at OpenCores released a new version of their OpenRisc core, tweaking many hardware bug but also porting Linux kernel 2.6.24 to their simulation platform, that is called
or1ksim. The procedure (found here) to try Linux on the new simulator is straightforward and involves executing a script. The script hides most of the complexity of the procedure, but essentially it:
- Downloads the source code of Linux kernel, OpenRisc simulator and necessary tools
- Downloads and applies the patches to the original sources that add OpenRisc support to the compiler, the kernel and the other tools
- Compiles the compiler (
or32-elf-gcc) and the toolchain
- Compiles the
- Compiles the Linux kernel with a pre-built filesystem image (
- Runs the kernel with the simulator, opening an
xtermto connect to the simulator console.
To understand what does the script do behind the scenes, many log files remain in the build directory, and the script itself is very linear and easy to understand. A couple of things I discovered:
- If you run the script with root privileges, it modifies the
initrdimage by mounting it as an
ext2partition and copying a freshly built Busybox-based filesystem.
initrdimage is converted into an object file (
initrd.o) containing a big array (2MiB) of initialized memory. The object file is then linked into the
vmlinuxkernel image; the exact position can be found in the file
System.map, searching for the
- To run the simulator again, the command line is “
or32-elf-sim -f or1ksim_linux.cfg vmlinux“, but the
PATHmust be set to point also to the “
or1ksim-0.4.0/bin” directory; the files
vmlinuxare in the Linux build directory “
or1ksimuser manual is here, but a free OpenCores account is needed to download it.
- To exit the simulator, type
Ctrl-Cinside the terminal where
or1ksimhas been executed, then execute
To study the details of the toolchain, another good starting point is to look at the patch files that are downloaded inside the “
or32-download” directory and identify the parts of the original tools that are modified.