[PATCH v4 0/5] RISC-V: NEORV32 CPU, peripherials, and machine

Michael Levit posted 5 patches 4 days, 18 hours ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20251109191532.32419-1-michael@videogpu.com
Maintainers: Palmer Dabbelt <palmer@dabbelt.com>, Alistair Francis <alistair.francis@wdc.com>, Weiwei Li <liwei1518@gmail.com>, Daniel Henrique Barboza <dbarboza@ventanamicro.com>, Liu Zhiwei <zhiwei_liu@linux.alibaba.com>, Paolo Bonzini <pbonzini@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>
configs/devices/riscv32-softmmu/default.mak |   1 +
docs/system/riscv/neorv32.rst               | 112 +++++
docs/system/target-riscv.rst                |   1 +
hw/char/Kconfig                             |   3 +
hw/char/meson.build                         |   1 +
hw/char/neorv32_uart.c                      | 285 ++++++++++++
hw/misc/Kconfig                             |   2 +
hw/misc/meson.build                         |   1 +
hw/misc/neorv32_sysinfo.c                   | 201 ++++++++
hw/misc/neorv32_sysinfo.h                   |  88 ++++
hw/misc/neorv32_sysinfo_rtl.h               | 239 ++++++++++
hw/riscv/Kconfig                            |   8 +
hw/riscv/meson.build                        |   1 +
hw/riscv/neorv32.c                          | 215 +++++++++
hw/ssi/Kconfig                              |   4 +
hw/ssi/meson.build                          |   1 +
hw/ssi/neorv32_spi.c                        | 478 ++++++++++++++++++++
include/hw/char/neorv32_uart.h              |  54 +++
include/hw/riscv/neorv32.h                  |  54 +++
include/hw/ssi/neorv32_spi.h                |  57 +++
target/riscv/cpu-qom.h                      |   1 +
target/riscv/cpu.c                          |  17 +
target/riscv/cpu.h                          |   3 +
target/riscv/cpu_cfg.h                      |   1 +
target/riscv/cpu_cfg_fields.h.inc           |   1 +
target/riscv/cpu_vendorid.h                 |   2 +
target/riscv/meson.build                    |   1 +
target/riscv/neorv32_csr.c                  |  40 ++
28 files changed, 1872 insertions(+)
create mode 100644 docs/system/riscv/neorv32.rst
create mode 100644 hw/char/neorv32_uart.c
create mode 100644 hw/misc/neorv32_sysinfo.c
create mode 100644 hw/misc/neorv32_sysinfo.h
create mode 100644 hw/misc/neorv32_sysinfo_rtl.h
create mode 100644 hw/riscv/neorv32.c
create mode 100644 hw/ssi/neorv32_spi.c
create mode 100644 include/hw/char/neorv32_uart.h
create mode 100644 include/hw/riscv/neorv32.h
create mode 100644 include/hw/ssi/neorv32_spi.h
create mode 100644 target/riscv/neorv32_csr.c
[PATCH v4 0/5] RISC-V: NEORV32 CPU, peripherials, and machine
Posted by Michael Levit 4 days, 18 hours ago
This v4 reworks the initial NEORV32 submissions.

The series introduces:
  * a minimal NEORV32 RV32 CPU type and vendor CSR hook,
  * the SYSINFO MMIO block,
  * a small UART device,
  * an SPI controller with command-mode chip-select,
  * and the 'neorv32' RISC-V board wiring the above, plus docs.

Tested by booting the NEORV32 bootloader as -bios and chaining into a
Hello World from an MTD-backed SPI flash image, with UART on stdio.

Changes since v3:
  * Clean-up and fix documentation build errors
  * Fixed extra blank lines

Thanks Daniel for the review and for providing the documentation fix suggestions.

Changes since v2:
  * Clean-up all errors and most of the warnings generated by scripts/checkpatch.pl
  * Sync with master, fix compile error
  * No intentional functional changes; only file organization and clarity.
  * Kept default.mak entry off by default (n).

Patch layout
============
  1/5  target/riscv: add NEORV32 RV32 CPU type and vendor CSR hooks
  2/5  hw/misc: add NEORV32 SYSINFO block (CLK/MISC/SOC/CACHE)
  3/5  hw/char: add NEORV32 UART (CTRL/DATA, fifo, chardev)
  4/5  hw/ssi: add NEORV32 SPI controller (SSI master, CS command)
  5/5  hw/riscv: introduce 'neorv32' board, docs, and riscv32 device config

Quick usage
===========
  $ ./configure --target-list=riscv32-softmmu --enable-debug --enable-fdt
  $ make -j$(nproc)

Prepare a flash image (64MiB) and place your app at 4MiB offset:
  $ dd if=/dev/zero of=$HOME/flash_contents.bin bs=1 count=$((0x04000000))
  $ dd if=/path/to/neorv32_exe.bin of=$HOME/flash_contents.bin \\
       bs=1 seek=$((0x00400000)) conv=notrunc

Run bootloader and chain-load your app:
  $ ./build/qemu-system-riscv32 -nographic -machine neorv32 \\
      -bios /path/to/neorv32/bootloader/neorv32_raw_exe.bin \\
      -drive file=$HOME/flash_contents.bin,if=mtd,format=raw

Debugging:
  $ ... -s -S   # gdbstub on :1234, start paused



Thanks for reviewing!
Michael

Michael (5):
  target/riscv: add NEORV32 RV32 CPU type and vendor CSR hooks
  hw/misc: add NEORV32 SYSINFO block (CLK/MISC/SOC/CACHE)
  hw/char: add NEORV32 UART (CTRL/DATA, fifo, chardev)
  hw/ssi: add NEORV32 SPI controller (SSI master, CS command)
  hw/riscv: introduce 'neorv32' board, docs, and riscv32 device config

 configs/devices/riscv32-softmmu/default.mak |   1 +
 docs/system/riscv/neorv32.rst               | 112 +++++
 docs/system/target-riscv.rst                |   1 +
 hw/char/Kconfig                             |   3 +
 hw/char/meson.build                         |   1 +
 hw/char/neorv32_uart.c                      | 285 ++++++++++++
 hw/misc/Kconfig                             |   2 +
 hw/misc/meson.build                         |   1 +
 hw/misc/neorv32_sysinfo.c                   | 201 ++++++++
 hw/misc/neorv32_sysinfo.h                   |  88 ++++
 hw/misc/neorv32_sysinfo_rtl.h               | 239 ++++++++++
 hw/riscv/Kconfig                            |   8 +
 hw/riscv/meson.build                        |   1 +
 hw/riscv/neorv32.c                          | 215 +++++++++
 hw/ssi/Kconfig                              |   4 +
 hw/ssi/meson.build                          |   1 +
 hw/ssi/neorv32_spi.c                        | 478 ++++++++++++++++++++
 include/hw/char/neorv32_uart.h              |  54 +++
 include/hw/riscv/neorv32.h                  |  54 +++
 include/hw/ssi/neorv32_spi.h                |  57 +++
 target/riscv/cpu-qom.h                      |   1 +
 target/riscv/cpu.c                          |  17 +
 target/riscv/cpu.h                          |   3 +
 target/riscv/cpu_cfg.h                      |   1 +
 target/riscv/cpu_cfg_fields.h.inc           |   1 +
 target/riscv/cpu_vendorid.h                 |   2 +
 target/riscv/meson.build                    |   1 +
 target/riscv/neorv32_csr.c                  |  40 ++
 28 files changed, 1872 insertions(+)
 create mode 100644 docs/system/riscv/neorv32.rst
 create mode 100644 hw/char/neorv32_uart.c
 create mode 100644 hw/misc/neorv32_sysinfo.c
 create mode 100644 hw/misc/neorv32_sysinfo.h
 create mode 100644 hw/misc/neorv32_sysinfo_rtl.h
 create mode 100644 hw/riscv/neorv32.c
 create mode 100644 hw/ssi/neorv32_spi.c
 create mode 100644 include/hw/char/neorv32_uart.h
 create mode 100644 include/hw/riscv/neorv32.h
 create mode 100644 include/hw/ssi/neorv32_spi.h
 create mode 100644 target/riscv/neorv32_csr.c

-- 
2.51.1
Re: [PATCH v4 0/5] RISC-V: NEORV32 CPU, peripherials, and machine
Posted by Thomas Huth 4 days, 1 hour ago
On 09/11/2025 20.15, Michael Levit wrote:
> 
> This v4 reworks the initial NEORV32 submissions.
> 
> The series introduces:
>    * a minimal NEORV32 RV32 CPU type and vendor CSR hook,
>    * the SYSINFO MMIO block,
>    * a small UART device,
>    * an SPI controller with command-mode chip-select,
>    * and the 'neorv32' RISC-V board wiring the above, plus docs.
> 
> Tested by booting the NEORV32 bootloader as -bios and chaining into a
> Hello World from an MTD-backed SPI flash image, with UART on stdio.

  Hi!

Are these binaries available publically somewhere on the internet? If so, 
could you please add a test in tests/functional/riscv32 that make sure that 
the machine is basically working, so we don't face any regressions in the 
future?

  Thanks,
   Thomas
Re: [PATCH v4 0/5] RISC-V: NEORV32 CPU, peripherials, and machine
Posted by Michael Levit 3 days, 18 hours ago
>
>
> Are these binaries available publically somewhere on the internet?


Currently, as far as I know, there are no prebuilt binaries — only source
files for the bootloader and firmware examples in the NEORV32 repository.
I compile the binaries and prepare the flash image locally.


> If so,
> could you please add a test in tests/functional/riscv32 that make sure
> that
> the machine is basically working, so we don't face any regressions in the
> future?
>

I can upload the generated image to my GitHub repository, or alternatively
to some QEMU-related storage if there’s a preferred location?
The test image is around 4 MB, plus a few kilobytes for the bootloader.
I will add the test of course.

Thanks for the review and feedback!
Re: [PATCH v4 0/5] RISC-V: NEORV32 CPU, peripherials, and machine
Posted by Thomas Huth 3 days, 6 hours ago
On 10/11/2025 19.46, Michael Levit wrote:
> 
>     Are these binaries available publically somewhere on the internet? 
> 
> 
> Currently, as far as I know, there are no prebuilt binaries — only source
> files for the bootloader and firmware examples in the NEORV32 repository.
> I compile the binaries and prepare the flash image locally.
> 
>     If so,
>     could you please add a test in tests/functional/riscv32 that make sure that
>     the machine is basically working, so we don't face any regressions in the
>     future?
> 
> 
> I can upload the generated image to my GitHub repository, or alternatively
> to some QEMU-related storage if there’s a preferred location?

The QEMU project does not maintain a storage for such third party binaries, 
so if you could put them on your GitHub repo, that would be great!

  Thanks,
   Thomas


> The test image is around 4 MB, plus a few kilobytes for the bootloader.
> I will add the test of course.
> 
> Thanks for the review and feedback!
>