diff mbox series

ARC: Enable excution of ARCv2 defconfigs in simulation

Message ID 20240107000323.543754-1-abrodkin@synopsys.com
State New
Headers show
Series ARC: Enable excution of ARCv2 defconfigs in simulation | expand

Commit Message

Alexey Brodkin Jan. 7, 2024, 12:03 a.m. UTC
Even though we initially called defconfig after FPGA prototyping
platform HAPS, it's nevertheless is useful for running the same image
in software simulation.

We do a couple of quirks to the config though:
1. Switch from SMP Linux config to UP.
   That's needed to make it runnable in Free nSIM which doesn't
   support SMP (licenceable full version does support SMP though).

2. Add default Ethernet interface for DHCP boot-time initialization
   so that in nSIM & QEMU we get a networking interface out of the box
   on start.

And while at it, improve documentation with build & run commands.
And to make instructions smaller and more readable swhich from explicit
passing all the optopns to the nSIM driver to use of so-called "props"
files (basically, a newline-separated list of options).

Inspired by Waldemar's patch [1].

Assumes ARCv3 defconfigs from [2] are already in place, otherwise
a subtly rework will be required.

[1] https://lists.buildroot.org/pipermail/buildroot/2023-December/681898.html
[2] https://lists.buildroot.org/pipermail/buildroot/2024-January/682466.html

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
Inspired-by: Waldemar Brodkorb <wbx@openadk.org>
Cc: Yann E. MORIN <yann.morin.1998@free.fr>
---
 board/synopsys/nsim/arc700.props    |  17 ++++
 board/synopsys/nsim/hs4x.props      |  18 +++++
 board/synopsys/nsim/readme.txt      | 117 ++++++++++++++++++----------
 configs/snps_archs38_haps_defconfig |   3 +-
 4 files changed, 111 insertions(+), 44 deletions(-)
 create mode 100644 board/synopsys/nsim/arc700.props
 create mode 100644 board/synopsys/nsim/hs4x.props
diff mbox series

Patch

diff --git a/board/synopsys/nsim/arc700.props b/board/synopsys/nsim/arc700.props
new file mode 100644
index 0000000000..c923bdb3da
--- /dev/null
+++ b/board/synopsys/nsim/arc700.props
@@ -0,0 +1,17 @@ 
+nsim_mem-dev=uart0,kind=dwuart,base=0xf0000000,irq=24
+icache=32768,64,2,0
+dcache=32768,64,4,0
+nsim_mmu=3
+nsim_isa_family=a700
+nsim_isa_atomic_option=1
+nsim_isa_dpfp=none
+nsim_isa_shift_option=2
+nsim_isa_swap_option=1
+nsim_isa_bitscan_option=1
+nsim_isa_sat=1
+nsim_isa_mpy32=1
+nsim_isa_enable_timer_0=1
+nsim_isa_enable_timer_1=1
+isa_counters=1
+nsim_isa_pct_counters=8
+nsim_isa_pct_size=48
diff --git a/board/synopsys/nsim/hs4x.props b/board/synopsys/nsim/hs4x.props
new file mode 100644
index 0000000000..46470d9c9e
--- /dev/null
+++ b/board/synopsys/nsim/hs4x.props
@@ -0,0 +1,18 @@ 
+nsim_isa_family=av2hs
+nsim_isa_core=1
+nsim_isa_atomic_option=1
+nsim_isa_ll64_option=1
+nsim_isa_mpy_option=9
+nsim_isa_div_rem_option=2
+nsim_isa_sat=1
+nsim_isa_code_density_option=2
+nsim_isa_enable_timer_0=1
+nsim_isa_enable_timer_1=1
+nsim_isa_rtc_option=1
+icache=65536,64,4,0
+dcache=65536,64,2,0
+mmu_version=4
+mmu_pagesize=8192
+nsim_mem-dev=uart0,kind=dwuart,base=0xf0000000,irq=24
+nsim_isa_number_of_interrupts=32
+nsim_isa_number_of_external_interrupts=32
diff --git a/board/synopsys/nsim/readme.txt b/board/synopsys/nsim/readme.txt
index e43a70038f..5fbf07d3f3 100644
--- a/board/synopsys/nsim/readme.txt
+++ b/board/synopsys/nsim/readme.txt
@@ -1,46 +1,77 @@ 
-How to build it
-===============
-
-Configure build for the selected nSIM target. For instance, for
-ARC700 nSIM target use the following defauilt configuration:
-$ make snps_arc700_nsim_defconfig
-
-Optionally modify the configuration:
-$ make menuconfig
-
-Build:
-$ make
-
-How to use it
-=============
-
-Resulting image can be booted using ARC nSIM instruction set simulator.
-Free version of nSIM is available for download:
-- https://www.synopsys.com/cgi-bin/dwarcnsim/req1.cgi
-It provides nsimdrv binary for Linux that can be used stand-alone
-or with GDB.
-
-To run ARC700 image use the following command:
-$ nsimdrv \
-	-prop=nsim_mem-dev=uart0,kind=dwuart,base=0xf0000000,irq=24 \
-	-prop=icache=32768,64,2,0 \
-	-prop=dcache=32768,64,4,0 \
-	-prop=nsim_isa_enable_timer_0=1 \
-	-prop=nsim_isa_enable_timer_1=1 \
-	-prop=nsim_isa_host_timer=1 \
-	-prop=nsim_mmu=3 \
-	-prop=nsim_isa_family=a700 \
-	-prop=nsim_isa_atomic_option=1 \
-	-prop=nsim_isa_dpfp=none \
-	-prop=nsim_isa_shift_option=2 \
-	-prop=nsim_isa_swap_option=1 \
-	-prop=nsim_isa_bitscan_option=1 \
-	-prop=nsim_isa_sat=1 \
-	-prop=nsim_isa_mpy32=1 \
-	-prop=isa_counters=1 \
-	-prop=nsim_isa_pct_counters=8 \
-	-prop=nsim_isa_pct_size=48 \
-	output/images/vmlinux
+Synopsys ARC processors capable of running the Linux kernel could be
+modelled in software simulation or on a FPGA prototyping system.
+
+And while there're tools for cycle-accurate simulation, most of them are
+proprietary and so rarely avaialble for the open source community, but also
+by their nature they are painfully slow - booting Linux on such platfroms
+may easily take days depending on the size of the Linux kernel image,
+enabled kernel features etc.
+
+As opposed to cycle-accurate models there're so-called instruction set
+simulators, which only model functionality observed by the software running
+on the processor, but not all the internal states of the CPU. Those are
+way faster compared to their cycle-accurate siblings and so it's not only
+possible to boot the kernel, one could easily run complex and huge software
+packages like full-scale Linux distributions, modern web-browsers, even
+3D games (with use of the host's GPU as SW rendering of 3D is slow even on
+real prcessors implemented in silicon).
+
+Speaking of such fast instruction set simulators for ARC processors,
+there're 2 major options:
+
+1. nSIM - it's a proprietary simulator from Synopsys which may model
+   all possible configurations of ARC processors and so provides
+   a lot of flexibility to the user. And there's a Free version of it
+   which was made available specifically to enable open source community
+   to run major open source projects for ARC cores such as
+   embedded Linux builds, Zephyr RTOS and the likes.
+
+   Free version of nSIM is available for download:
+   - https://www.synopsys.com/cgi-bin/dwarcnsim/req1.cgi
+   It provides nsimdrv binary for Linux that can be used stand-alone
+   or with GDB.
+
+2. QEMU - it's a widely used open source simulator by now avaialble for most
+   of known CPU architectures. QEMU doesn't model yet all ARC processors
+   and their miriads of options and extensions, but it supports well
+   features required to run Linux-based images.
+
+   QEMU port for ARC is now in the process of upstreaming and so for a time
+   being needs to be built from Synopsys fork on GitHub, see:
+   https://github.com/foss-for-synopsys-dwc-arc-processors/qemu.
+
+   It could be built as easy as:
+   ------------------------>8-----------------------
+   git clone https://github.com/foss-for-synopsys-dwc-arc-processors/qemu
+   cd qemu
+   ./configure --target-list=arc-softmmu,arc64-softmmu
+   make
+   ------------------------>8-----------------------
+
+3. Except for simulators it's clearly possible to run Linux-based images
+   on the FPGA prototyping system. It runs even faster than aforementioned
+   simulators, but not everyone has a luxury of accessing such a setup.
+
+But what's especially nice and convenient that we may run exactly the same image
+on all 3 platforms listed above: nSIM, QEMU & HAPS FPGA system. That allows to
+cross-test platforms against each other, separate feature development (done on
+a functional simulator) from performance profiling (on FPGA) as well as do many
+other funny things.
+
+Below there're instructions on how to build and run Linux images on all
+current ARC processor families capable of runnign Linux.
+
+Build & run image on ARC 700:
+ * Build:       make snps_arc700_nsim_defconfig && make
+ * Run in nSIM: nsimdrv -propsfile=board/synopsys/nsim/arc700.props output/images/vmlinux
+
+Build & run image on ARC HS38:
+ * Build:       make snps_archs38_haps_defconfig && make
+ * Run in nSIM: nsimdrv -propsfile=board/synopsys/nsim/hs4x.props output/images/vmlinux
+ * Run in QEMU: qemu-system-arc -M virt,ram_start=0x80000000 -cpu archs -m 2G -display none \
+                        -nographic -monitor none -kernel output/images/vmlinux \
+                        -netdev user,id=net0 -device virtio-net-device,netdev=net0 \
+                        -device virtio-rng-pci
 
 Build & run image on ARC HS58:
  * Build:       make snps_arc32_defconfig && make
diff --git a/configs/snps_archs38_haps_defconfig b/configs/snps_archs38_haps_defconfig
index 02e020bb47..c2ec480806 100644
--- a/configs/snps_archs38_haps_defconfig
+++ b/configs/snps_archs38_haps_defconfig
@@ -6,6 +6,7 @@  BR2_archs38=y
 BR2_TARGET_GENERIC_HOSTNAME="zebu_hs"
 BR2_TARGET_GENERIC_ISSUE="Welcome to the HAPS Development Platform"
 BR2_TARGET_ROOTFS_INITRAMFS=y
+BR2_SYSTEM_DHCP="eth0"
 
 # Linux headers same as kernel, a 5.16 series
 BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_16=y
@@ -14,5 +15,5 @@  BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_16=y
 BR2_LINUX_KERNEL=y
 BR2_LINUX_KERNEL_CUSTOM_VERSION=y
 BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.16"
-BR2_LINUX_KERNEL_DEFCONFIG="haps_hs_smp"
+BR2_LINUX_KERNEL_DEFCONFIG="haps_hs"
 BR2_LINUX_KERNEL_VMLINUX=y