soc: neorv32: update to support NEORV32 v1.11.1

Update the NEORV32 SoC, peripheral drivers, and board to support NEORV32
v1.11.1. Notable changes include:

- Optional RISC-V ISA Kconfigs are now selected on the board level.
- Peripheral registers are now automatically reset in hardware, no need for
  software initialization code.
- The NEORV32 GPIO controller now supports 32 pins, not 64. Interrupt
  support will be submitted in a separate PR.
- Default board configuration has 64k RAM and is clocked at 18 MHz.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
This commit is contained in:
Henrik Brix Andersen 2025-02-26 16:11:03 +00:00 committed by Benjamin Cabé
commit 63c24d9d34
20 changed files with 340 additions and 409 deletions

View file

@ -1,4 +1,4 @@
# Copyright (c) 2021 Henrik Brix Andersen <henrik@brixandersen.dk>
# Copyright (c) 2021,2025 Henrik Brix Andersen <henrik@brixandersen.dk>
# SPDX-License-Identifier: Apache-2.0
if((CONFIG_BOARD_NEORV32) AND (CONFIG_BUILD_OUTPUT_BIN))
@ -18,7 +18,7 @@ if((CONFIG_BOARD_NEORV32) AND (CONFIG_BUILD_OUTPUT_BIN))
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
COMMAND ${IMAGE_GEN}
ARGS -app_img
ARGS -app_vhd
${CONFIG_KERNEL_BIN_NAME}.bin
${CONFIG_KERNEL_BIN_NAME}.vhd
${PROJECT_BINARY_DIR}

View file

@ -0,0 +1,7 @@
# Copyright (c) 2021,2025 Henrik Brix Andersen <henrik@brixandersen.dk>
# SPDX-License-Identifier: Apache-2.0
config BOARD_NEORV32
select RISCV_ISA_RV32I
select RISCV_ISA_EXT_M
select ATOMIC_OPERATIONS_C

View file

@ -13,7 +13,7 @@ For more information about the NEORV32, see the following websites:
- `The NEORV32 RISC-V Processor Datasheet`_
- `The NEORV32 RISC-V Processor User Guide`_
The currently supported version is 1.8.6.
The currently supported version is NEORV32 v1.11.1.
Supported Features
==================
@ -27,7 +27,7 @@ using :ref:`devicetree overlays <use-dt-overlays>`.
System Clock
============
The default board configuration assumes a system clock of 100 MHz. The clock
The default board configuration assumes a system clock of 18 MHz. The clock
frequency can be overridden by changing the ``clock-frequency`` property of the
``cpu0`` devicetree node.
@ -37,9 +37,10 @@ CPU
The default board configuration assumes the NEORV32 CPU implementation has the
following RISC-V ISA extensions enabled:
- C (Compresses Instructions)
- I (Base Integer Instruction Set, 32-bit)
- M (Integer Multiplication and Division)
- Zicsr (Control and Status Register (CSR) Instructions)
- Zicsr (Control and Status Register (CSR) Instructions, always enabled)
- Zifencei (Instruction-fetch fence, always enabled)
Internal Instruction Memory
===========================
@ -52,7 +53,7 @@ instruction memory can be overridden by changing the ``reg`` property of the
Internal Data Memory
====================
The default board configuration assumes the NEORV32 SoC implementation has a 32k
The default board configuration assumes the NEORV32 SoC implementation has a 64k
byte internal data memory (DMEM). The size of the data memory can be overridden
by changing the ``reg`` property of the ``dmem`` devicetree node.
@ -115,21 +116,21 @@ implementation with the On-Chip Debugger (OCD) and bootloader enabled.
The default board configuration uses an :ref:`openocd-debug-host-tools`
configuration similar to the example provided by the NEORV32 project. Other
JTAGs can be used by providing further arguments when building. Here is an
example for using the Flyswatter JTAG:
JTAGs can be used by providing further arguments when flashing. Here is an
example for using the Flyswatter JTAG @ 2 kHz:
.. zephyr-app-commands::
:zephyr-app: samples/hello_world
:board: neorv32
:goals: flash
:gen-args: -DBOARD_RUNNER_ARGS_openocd="--config;interface/ftdi/flyswatter.cfg;--config;neorv32.cfg;--cmd-pre-init;'adapter speed 2000'"
:flash-args: --config interface/ftdi/flyswatter.cfg --config neorv32.cfg --cmd-pre-init 'adapter speed 2000'
After flashing, you should see message similar to the following in the terminal:
.. code-block:: console
*** Booting Zephyr OS build zephyr-vn.n.nn ***
Hello World! neorv32
Hello World! neorv32/neorv32
Note, however, that the application was not persisted in flash memory by the
above steps. It was merely written to internal block RAM in the FPGA. It will
@ -176,7 +177,7 @@ similar to the following in the terminal:
.. code-block:: console
*** Booting Zephyr OS build zephyr-vn.n.nn ***
Hello World! neorv32
Hello World! neorv32/neorv32
.. _The NEORV32 RISC-V Processor GitHub:
https://github.com/stnolting/neorv32

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Henrik Brix Andersen <henrik@brixandersen.dk>
* Copyright (c) 2021,2025 Henrik Brix Andersen <henrik@brixandersen.dk>
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -29,25 +29,9 @@
zephyr,uart-pipe = &uart0;
};
soc {
imem: memory@0 {
compatible = "soc-nv-flash", "mmio-sram";
reg = <0x0 DT_SIZE_K(64)>;
};
bootrom: memory@ffff0000 {
compatible = "soc-nv-flash", "mmio-sram";
reg = <0xffff0000 DT_SIZE_K(4)>;
};
dmem: memory@80000000 {
compatible = "mmio-sram";
reg = <0x80000000 DT_SIZE_K(32)>;
};
};
leds {
compatible = "gpio-leds";
led0: led0 {
gpios = <&gpio 0 GPIO_ACTIVE_HIGH>;
label = "LED_0";
@ -71,7 +55,30 @@
};
&cpu0 {
clock-frequency = <DT_FREQ_M(100)>;
riscv,isa = "rv32im_zicsr_zifencei";
clock-frequency = <DT_FREQ_M(18)>;
};
&bootrom {
status = "okay";
};
&imem {
status = "okay";
reg = <0x0 DT_SIZE_K(64)>;
};
&dmem {
status = "okay";
reg = <0x80000000 DT_SIZE_K(64)>;
};
&clint {
status = "okay";
};
&mtimer {
status = "okay";
};
&uart0 {
@ -79,10 +86,6 @@
current-speed = <19200>;
};
&gpio_lo {
status = "okay";
};
&gpio_hi {
&gpio {
status = "okay";
};

View file

@ -5,7 +5,7 @@ arch: riscv
toolchain:
- cross-compile
- zephyr
ram: 32
ram: 64
flash: 64
supported:
- gpio

View file

@ -1,7 +1,6 @@
# Copyright (c) 2021 Henrik Brix Andersen <henrik@brixandersen.dk>
# Copyright (c) 2021,2025 Henrik Brix Andersen <henrik@brixandersen.dk>
# SPDX-License-Identifier: Apache-2.0
CONFIG_SOC_NEORV32_ISA_C=y
CONFIG_SERIAL=y
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y