Skip to content

Commit b749bb6

Browse files
committed
boards: qemu: add board definition for the or1k architecture
Qemu includes support for the OpenRISC 1000 CPU architecture. This patch adds a Zephyr virtual board definition which enables usage of this feature. The board definition closely mirrors the Qemu MIPS Malta board definition. Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
1 parent 3e53a79 commit b749bb6

File tree

10 files changed

+223
-0
lines changed

10 files changed

+223
-0
lines changed

MAINTAINERS.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5576,6 +5576,7 @@ OpenRISC Arch:
55765576
- jhol
55775577
files:
55785578
- arch/openrisc/
5579+
- boards/qemu/or1k/
55795580
- drivers/timer/*openrisc*
55805581
- include/zephyr/arch/openrisc/
55815582
- soc/qemu/or1k/

boards/qemu/or1k/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#
2+
# Copyright (c) 2025 Joel Holdsworth <jholdsworth@nvidia.com>
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
7+
config BOARD_QEMU_OR1K
8+
select QEMU_TARGET

boards/qemu/or1k/Kconfig.defconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#
2+
# Copyright (c) 2025 NVIDIA Corporation <jholdsworth@nvidia.com>
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
7+
if BOARD_QEMU_OR1K
8+
9+
config BUILD_OUTPUT_BIN
10+
default n
11+
12+
config QEMU_ICOUNT_SHIFT
13+
default 6 if QEMU_ICOUNT
14+
15+
endif # BOARD_QEMU_OR1K

boards/qemu/or1k/Kconfig.qemu_or1k

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#
2+
# Copyright (c) 2025 NVIDIA Corporation <jholdsworth@nvidia.com>
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
7+
config BOARD_QEMU_OR1K
8+
select SOC_QEMU_OR1K

boards/qemu/or1k/board.cmake

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
set(SUPPORTED_EMU_PLATFORMS qemu)
4+
5+
set(QEMU_binary_suffix or1k)
6+
set(QEMU_CPU_TYPE_${ARCH} or1k)
7+
8+
set(QEMU_FLAGS_${ARCH}
9+
-machine or1k-sim
10+
-nographic
11+
)
12+
13+
board_set_debugger_ifnset(qemu)

boards/qemu/or1k/board.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
board:
2+
name: qemu_or1k
3+
full_name: QEMU Emulation for OpenRISC 1000
4+
vendor: qemu
5+
socs:
6+
- name: qemu_or1k

boards/qemu/or1k/doc/index.rst

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
.. _qemu_or1k:
2+
3+
OpenRISC 1000 Emulation (QEMU)
4+
##############################
5+
6+
Overview
7+
********
8+
9+
This board configuration will use QEMU to emulate the OpenRISC 1000 platform.
10+
11+
This configuration provides support for an or1k CPU core and these devices:
12+
13+
* OpenRISC Interrupt Controller
14+
* OpenRISC Tick Timer
15+
* NS16550 UART
16+
17+
18+
.. note::
19+
This board configuration makes no claims about its suitability for use
20+
with an actual OpenRISC 1000 hardware system, or any other hardware system.
21+
22+
Hardware
23+
********
24+
25+
Supported Features
26+
==================
27+
28+
The following hardware features are supported:
29+
30+
+--------------------------------+------------+----------------------+
31+
| Interface | Controller | Driver/Component |
32+
+================================+============+======================+
33+
| OpenRISC Interrupt Controller | on-chip | interrupt controller |
34+
+--------------------------------+------------+----------------------+
35+
| OpenRISC Tick Timer | on-chip | system clock |
36+
+--------------------------------+------------+----------------------+
37+
| NS16550 UART | FPGA | serial port |
38+
+--------------------------------+------------+----------------------+
39+
40+
The kernel currently does not support other hardware features on this platform.
41+
42+
Devices
43+
========
44+
System Clock
45+
------------
46+
47+
Qemu Tick Timer timer uses a clock frequency of 20 MHz,
48+
see hw/openrisc/cputimer.c in Qemu source tree for details.
49+
50+
Serial Port
51+
-----------
52+
53+
This board configuration uses a single serial communication channel
54+
with UART3.
55+
56+
Programming and Debugging
57+
*************************
58+
59+
Use this configuration to run basic Zephyr applications and kernel tests in the QEMU
60+
emulated environment, for example, with the :zephyr:code-sample:`synchronization` sample:
61+
62+
.. zephyr-app-commands::
63+
:zephyr-app: samples/synchronization
64+
:host-os: unix
65+
:board: qemu_or1k
66+
:goals: run
67+
68+
This will build an image with the synchronization sample app, boot it using
69+
QEMU, and display the following console output:
70+
71+
.. code-block:: console
72+
73+
*** Booting Zephyr OS build zephyr-v3.5.0-3843-g5a1358a9ef ***
74+
thread_a: Hello World from cpu 0 on qemu_or1k!
75+
thread_b: Hello World from cpu 0 on qemu_or1k!
76+
thread_a: Hello World from cpu 0 on qemu_or1k!
77+
thread_b: Hello World from cpu 0 on qemu_or1k!
78+
thread_a: Hello World from cpu 0 on qemu_or1k!
79+
thread_b: Hello World from cpu 0 on qemu_or1k!
80+
thread_a: Hello World from cpu 0 on qemu_or1k!
81+
thread_b: Hello World from cpu 0 on qemu_or1k!
82+
thread_a: Hello World from cpu 0 on qemu_or1k!
83+
thread_b: Hello World from cpu 0 on qemu_or1k!
84+
85+
86+
Exit QEMU by pressing :kbd:`CTRL+A` :kbd:`x`.
87+
88+
89+
References
90+
**********
91+
92+
https://www.qemu.org/

boards/qemu/or1k/qemu_or1k.dts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* 2025 NVIDIA Corporation <jholdsworth@nvidia.com>
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/dts-v1/;
8+
9+
#include "skeleton.dtsi"
10+
11+
/ {
12+
model = "Qemu OpenRISC 1000";
13+
compatible = "opencores,or1ksim";
14+
interrupt-parent = <&pic>;
15+
16+
chosen {
17+
zephyr,sram = &sram0;
18+
zephyr,console = &uart3;
19+
zephyr,shell-uart = &uart3;
20+
};
21+
22+
cpus {
23+
#address-cells = <1>;
24+
#size-cells = <0>;
25+
26+
cpu@0 {
27+
device_type = "cpu";
28+
compatible = "opencores,or1200-rtlsvn481";
29+
reg = <0>;
30+
clock-frequency = <20000000>;
31+
32+
pic: interrupt-controller {
33+
#interrupt-cells = <1>;
34+
compatible = "opencores,or1k-pic-level";
35+
interrupt-controller;
36+
};
37+
};
38+
};
39+
40+
41+
sram0: memory@0 {
42+
device_type = "memory";
43+
compatible = "mmio-sram";
44+
reg = <0x00000000 0x08000000>;
45+
};
46+
47+
uart3: serial@90000300 {
48+
compatible = "ns16550";
49+
reg = <0x90000300 0x100>;
50+
reg-shift = <0>;
51+
interrupts = <2>;
52+
/* no matter for emulated port */
53+
clock-frequency = <20000000>;
54+
current-speed = <115200>;
55+
status = "okay";
56+
};
57+
};

boards/qemu/or1k/qemu_or1k.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
identifier: qemu_or1k
2+
name: QEMU emulation for OpenRISC 1000
3+
type: qemu
4+
simulation:
5+
- name: qemu
6+
arch: openrisc
7+
toolchain:
8+
- zephyr
9+
- cross-compile
10+
ram: 128
11+
testing:
12+
default: true
13+
ignore_tags:
14+
- net
15+
- bluetooth
16+
vendor: qemu

boards/qemu/or1k/qemu_or1k_defconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
CONFIG_OPENRISC_TICK_TIMER=y
4+
CONFIG_CONSOLE=y
5+
CONFIG_SERIAL=y
6+
CONFIG_UART_CONSOLE=y
7+
CONFIG_STACK_SENTINEL=y

0 commit comments

Comments
 (0)