Skip to content

Commit 0c05319

Browse files
carlocaionestephanosio
authored andcommitted
riscv: Introduce qemu_riscv32e board.
To support and test RV32E. Signed-off-by: Carlo Caione <[email protected]>
1 parent 673f41e commit 0c05319

File tree

8 files changed

+151
-0
lines changed

8 files changed

+151
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright (c) 2022 Carlo Caione <[email protected]>
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config BOARD_QEMU_RISCV32E
5+
bool "QEMU RISCV32E target"
6+
depends on SOC_RISCV_VIRT
7+
select QEMU_TARGET
8+
select RISCV_ISA_RV32E
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright (c) 2022 Carlo Caione <[email protected]>
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config BUILD_OUTPUT_BIN
5+
default n
6+
7+
config BOARD
8+
default "qemu_riscv32e" if BOARD_QEMU_RISCV32E
9+
10+
# Use thread local storage by default so that
11+
# this feature gets more CI coverage.
12+
config THREAD_LOCAL_STORAGE
13+
default y
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright (c) 2022 Carlo Caione <[email protected]>
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
set(SUPPORTED_EMU_PLATFORMS qemu)
5+
6+
set(QEMU_binary_suffix riscv32)
7+
set(QEMU_CPU_TYPE_${ARCH} riscv32)
8+
9+
set(QEMU_FLAGS_${ARCH}
10+
-nographic
11+
-machine virt
12+
-bios none
13+
-m 256
14+
)
15+
16+
board_set_debugger_ifnset(qemu)
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
.. _qemu_riscv32e:
2+
3+
RISCV32E Emulation (QEMU)
4+
#########################
5+
6+
Overview
7+
********
8+
9+
The RISCV32E QEMU board configuration is used to emulate the RISCV32 (RV32E) architecture.
10+
11+
.. figure:: qemu_riscv32.png
12+
:width: 600px
13+
:align: center
14+
:alt: Qemu
15+
16+
Qemu (Credit: qemu.org)
17+
18+
Programming and Debugging
19+
*************************
20+
21+
Applications for the ``qemu_riscv32e`` board configuration can be built and run in
22+
the usual way for emulated boards (see :ref:`build_an_application` and
23+
:ref:`application_run` for more details).
24+
25+
Flashing
26+
========
27+
28+
While this board is emulated and you can't "flash" it, you can use this
29+
configuration to run basic Zephyr applications and kernel tests in the QEMU
30+
emulated environment. For example, with the :ref:`synchronization_sample`:
31+
32+
.. zephyr-app-commands::
33+
:zephyr-app: samples/synchronization
34+
:host-os: unix
35+
:board: qemu_riscv32e
36+
:goals: run
37+
38+
This will build an image with the synchronization sample app, boot it using
39+
QEMU, and display the following console output:
40+
41+
.. code-block:: console
42+
43+
*** Booting Zephyr OS build v3.1.0-rc1-59-g0d66cc1f6645 ***
44+
thread_a: Hello World from cpu 0 on qemu_riscv32e!
45+
thread_b: Hello World from cpu 0 on qemu_riscv32e!
46+
thread_a: Hello World from cpu 0 on qemu_riscv32e!
47+
thread_b: Hello World from cpu 0 on qemu_riscv32e!
48+
thread_a: Hello World from cpu 0 on qemu_riscv32e!
49+
thread_b: Hello World from cpu 0 on qemu_riscv32e!
50+
thread_a: Hello World from cpu 0 on qemu_riscv32e!
51+
thread_b: Hello World from cpu 0 on qemu_riscv32e!
52+
thread_a: Hello World from cpu 0 on qemu_riscv32e!
53+
thread_b: Hello World from cpu 0 on qemu_riscv32e!
54+
thread_a: Hello World from cpu 0 on qemu_riscv32e!
55+
thread_b: Hello World from cpu 0 on qemu_riscv32e!
56+
57+
Exit QEMU by pressing :kbd:`CTRL+A` :kbd:`x`.
58+
59+
Debugging
60+
=========
61+
62+
Refer to the detailed overview about :ref:`application_debugging`.
4.78 KB
Loading
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright (c) 2022 Carlo Caione <[email protected]>
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
*/
7+
8+
/dts-v1/;
9+
10+
#include <virt.dtsi>
11+
12+
/ {
13+
chosen {
14+
zephyr,console = &uart0;
15+
zephyr,shell-uart = &uart0;
16+
zephyr,sram = &ram0;
17+
};
18+
};
19+
20+
&uart0 {
21+
status = "okay";
22+
};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
identifier: qemu_riscv32e
2+
name: QEMU Emulation for RISC-V (RV32E) 32-bit
3+
type: qemu
4+
simulation: qemu
5+
arch: riscv32
6+
toolchain:
7+
- zephyr
8+
- xtools
9+
supported:
10+
- netif
11+
testing:
12+
default: true
13+
ignore_tags:
14+
- net
15+
- bluetooth
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
CONFIG_SOC_SERIES_RISCV_VIRT=y
4+
CONFIG_SOC_RISCV_VIRT=y
5+
CONFIG_BOARD_QEMU_RISCV32E=y
6+
CONFIG_CONSOLE=y
7+
CONFIG_SERIAL=y
8+
CONFIG_UART_NS16550=y
9+
CONFIG_UART_CONSOLE=y
10+
CONFIG_PLIC=y
11+
CONFIG_RISCV_MACHINE_TIMER=y
12+
CONFIG_STACK_SENTINEL=y
13+
CONFIG_QEMU_ICOUNT_SHIFT=6
14+
CONFIG_XIP=n
15+
CONFIG_RISCV_PMP=y

0 commit comments

Comments
 (0)