Skip to content

Commit d418392

Browse files
committed
linux: Add instructions for running linux on or1ksim
1 parent d4cf837 commit d418392

1 file changed

Lines changed: 111 additions & 0 deletions

File tree

docs/linux-on-or1ksim.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
title: Linux on or1ksim
3+
layout: page
4+
parent: Linux
5+
nav_order: 2
6+
---
7+
8+
# Prerequisites
9+
10+
#### System
11+
12+
- An x86 Linux workstation
13+
- The `curl` and `telnet` command line utilities
14+
- 2.5 GB of disk space
15+
16+
#### Files
17+
18+
- [or1ksim.cfg](or1ksim.cfg) - config needed for or1ksim
19+
- [or1ksim-2025-04-27.tar.gz](https://github.com/openrisc/or1ksim/releases/download/2025-04-27/or1ksim-2025-04-27.tar.gz)
20+
- [or1k-none-linux-musl-15.1.0-20250621.tar.xz](https://github.com/stffrdhrn/or1k-toolchain-build/releases/download/or1k-15.1.0-20250621/or1k-none-linux-musl-15.1.0-20250621.tar.xz) - OpenRISC musl linux userspace toolchain
21+
- [linux-6.15.5.tar.xz](https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.15.5.tar.xz) - Linux kernel source code
22+
- [busybox-small-rootfs-20250708.tar.xz](https://github.com/stffrdhrn/or1k-rootfs-build/releases/download/or1k-20250708/busybox-small-rootfs-20250708.tar.xz) - Linux rootfs for userspace programs
23+
24+
# Linux on or1ksim Tutorial
25+
26+
In this tutorial we will cover building a Linux kernel and booting it on or1ksim
27+
with a [busybox](https://busybox.net) root filesystem. This is a typical environment which can be used
28+
to test and develop userspace binaries or do Linux Kernel development.
29+
30+
QEMU is also a good alternative simulator, QEMU provides SMP support and runs much faster. However,
31+
or1ksim is an [instruction set simulator](https://en.wikipedia.org/wiki/Instruction_set_simulator) which
32+
provides more accurate tracing.
33+
34+
We break this tutorial down into parts:
35+
36+
- Downloading the pieces
37+
- Comping the kernel
38+
- Running the kernel
39+
- Interacting with the simulator
40+
- Adding custom userspace programs
41+
42+
## Downloading the Pieces
43+
44+
To get started we will create a temporary directly and setup our environment, if
45+
you plan to do a lot of OpenRISC development consider adding these tools to your
46+
`PATH` permanently.
47+
48+
To get everything you need run:
49+
50+
```bash
51+
mkdir /tmp/linux-on-or1ksim/
52+
cd /tmp/linux-on-or1ksim/
53+
54+
# Download linux source, or1ksim, a busybox rootfs and our toolchain
55+
curl -L -O https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.15.5.tar.xz
56+
curl -L -O https://github.com/openrisc/or1ksim/releases/download/2025-04-27/or1ksim-2025-04-27.tar.gz
57+
curl -L -O https://github.com/stffrdhrn/or1k-rootfs-build/releases/download/or1k-20250708/busybox-small-rootfs-20250708.tar.xz
58+
curl -L -O https://github.com/stffrdhrn/or1k-toolchain-build/releases/download/or1k-15.1.0-20250621/or1k-none-linux-musl-15.1.0-20250621.tar.xz
59+
60+
# Extract everything
61+
tar -xf linux-6.15.5.tar.xz
62+
tar -xf or1ksim-2025-04-27.tar.gz
63+
tar -xf busybox-small-rootfs-20250708.tar.xz
64+
tar -xf or1k-none-linux-musl-15.1.0-20250621.tar.xz
65+
66+
export PATH=$PATH:$PWD/or1k/bin:$PWD/or1k-none-linux-musl/bin
67+
```
68+
69+
Building linux
70+
71+
```bash
72+
make -C linux-6.15.5 \
73+
ARCH=openrisc \
74+
CROSS_COMPILE=or1k-none-linux-musl- \
75+
defconfig
76+
make -C linux-6.15.5 \
77+
-j12 \
78+
ARCH=openrisc \
79+
CROSS_COMPILE=or1k-none-linux-musl- \
80+
CONFIG_INITRAMFS_SOURCE="$PWD/busybox-small-rootfs-20250708/initramfs/ $PWD/busybox-small-rootfs-20250708/initramfs.devnodes"
81+
```
82+
83+
Booting linux
84+
85+
#### Terminal 1
86+
87+
```bash
88+
# Download an example config for or1ksim
89+
curl -L -O https://github.com/stffrdhrn/or1k-utils/raw/refs/heads/master/or1ksim.cfg
90+
91+
or1l-elf-sim -f or1ksim.cfg linux-6.15.5/vmlinux
92+
```
93+
94+
Logging in
95+
96+
#### Terminal 2
97+
98+
In a second terminal while or1ksim is running login to the simulator
99+
using `telnet`.
100+
101+
```bash
102+
telnet localhost 10084
103+
```
104+
105+
## Further Reading
106+
107+
- [openrisc/or1ksim](https://github.com/openrisc/or1ksim) - The or1ksim home page and git repo
108+
- [or1ksim Releases](https://github.com/openrisc/or1ksim/releases) - Nightly build and point release
109+
- [Linux Releases](https://kernel.org) - Linux release tarballs
110+
- [OpenRISC toolchain Releases](https://github.com/stffrdhrn/or1k-toolchain-build/releases) - Toolchain point releases
111+
- [OpenRISC rootfs Releases](https://github.com/stffrdhrn/or1k-rootfs-build/releases) - Rootfs point release

0 commit comments

Comments
 (0)