diff mbox series

[4/6] configs/qemu: add qemu_arc_defconfig

Message ID 20231231172538.1279608-5-wbx@openadk.org
State Superseded
Headers show
Series rework arc architecture support | expand

Commit Message

Waldemar Brodkorb Dec. 31, 2023, 5:25 p.m. UTC
Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
---
 board/qemu/arc/linux.config | 32 ++++++++++++++++++++++++++++++++
 board/qemu/arc/readme.txt   |  8 ++++++++
 configs/qemu_arc_defconfig  | 30 ++++++++++++++++++++++++++++++
 3 files changed, 70 insertions(+)
 create mode 100644 board/qemu/arc/linux.config
 create mode 100644 board/qemu/arc/readme.txt
 create mode 100644 configs/qemu_arc_defconfig

Comments

Yann E. MORIN Dec. 31, 2023, 8:27 p.m. UTC | #1
Waldemar, All,

On 2023-12-31 18:25 +0100, Waldemar Brodkorb spake thusly:
> Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>

Add a bit of explanations in the commit log, especially given the
following...

> ---
[--SNIP--]
> diff --git a/board/qemu/arc/readme.txt b/board/qemu/arc/readme.txt
> new file mode 100644
> index 0000000000..93bb9c2152
> --- /dev/null
> +++ b/board/qemu/arc/readme.txt
> @@ -0,0 +1,8 @@
> +You need Qemu fork from here:
> +https://github.com/foss-for-synopsys-dwc-arc-processors/qemu

So, we are dropping all the arc specific versions for the toolchain
components, but we eventually introduce a defconfig that relies on an
arc specific version of qemu, that we do not even package in Buildroot,
so that users can't even enable host-qemu in Buildroot.

That is a bit sad...

What is the rationale for introducing this defconfig, then?

Regards,
Yann E. MORIN.

> +Run the emulation with:
> +
> + qemu-system-arc -monitor none -serial stdio -netdev user,id=eth0 -device virtio-net-device,netdev=eth0 -cpu archs -kernel output/images/vmlinux -nographic # qemu_arc_defconfig
> +
> +The login prompt will appear in the terminal that started Qemu.
> diff --git a/configs/qemu_arc_defconfig b/configs/qemu_arc_defconfig
> new file mode 100644
> index 0000000000..d65e28a3d0
> --- /dev/null
> +++ b/configs/qemu_arc_defconfig
> @@ -0,0 +1,30 @@
> +# Architecture
> +BR2_arc=y
> +BR2_arcle=y
> +BR2_archs38=y
> +
> +# System
> +BR2_SYSTEM_DHCP="eth0"
> +
> +# Filesystem
> +# BR2_TARGET_ROOTFS_TAR is not set
> +BR2_TARGET_ROOTFS_INITRAMFS=y
> +
> +# Image
> +BR2_ROOTFS_POST_IMAGE_SCRIPT="board/qemu/post-image.sh"
> +BR2_ROOTFS_POST_SCRIPT_ARGS="$(BR2_DEFCONFIG)"
> +
> +# Linux headers same as kernel
> +BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_6_1=y
> +
> +# Kernel
> +BR2_LINUX_KERNEL=y
> +BR2_LINUX_KERNEL_CUSTOM_VERSION=y
> +BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.1.44"
> +BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
> +BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/arc/linux.config"
> +BR2_LINUX_KERNEL_VMLINUX=y
> +
> +# host-qemu for gitlab testing
> +BR2_PACKAGE_HOST_QEMU=y
> +BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE=y
> -- 
> 2.30.2
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
Waldemar Brodkorb Dec. 31, 2023, 9:55 p.m. UTC | #2
Hi Yann, All,
Yann E. MORIN wrote,

> Waldemar, All,
> 
> On 2023-12-31 18:25 +0100, Waldemar Brodkorb spake thusly:
> > Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
> 
> Add a bit of explanations in the commit log, especially given the
> following...
> 
> > ---
> [--SNIP--]
> > diff --git a/board/qemu/arc/readme.txt b/board/qemu/arc/readme.txt
> > new file mode 100644
> > index 0000000000..93bb9c2152
> > --- /dev/null
> > +++ b/board/qemu/arc/readme.txt
> > @@ -0,0 +1,8 @@
> > +You need Qemu fork from here:
> > +https://github.com/foss-for-synopsys-dwc-arc-processors/qemu
> 
> So, we are dropping all the arc specific versions for the toolchain
> components, but we eventually introduce a defconfig that relies on an
> arc specific version of qemu, that we do not even package in Buildroot,
> so that users can't even enable host-qemu in Buildroot.
> 
> That is a bit sad...
> 
> What is the rationale for introducing this defconfig, then?

Qemu is more widely known then the nsimdrv. And I think when ARCv3
support is added to Buildroot it can be used to test it, too.

I thought it would be nice to have instead of only rely on the nsim
defconfig we have now.

Can we keep it? What others say?

best regards
 Waldemar
Alexey Brodkin Jan. 1, 2024, 2:47 p.m. UTC | #3
Hi Waldemar, Yann, all,

> Yann E. MORIN wrote,
> 
> > Waldemar, All,
> >
> > On 2023-12-31 18:25 +0100, Waldemar Brodkorb spake thusly:
> > > Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
> >
> > Add a bit of explanations in the commit log, especially given the
> > following...
> >
> > > ---
> > [--SNIP--]
> > > diff --git a/board/qemu/arc/readme.txt b/board/qemu/arc/readme.txt
> > > new file mode 100644
> > > index 0000000000..93bb9c2152
> > > --- /dev/null
> > > +++ b/board/qemu/arc/readme.txt
> > > @@ -0,0 +1,8 @@
> > > +You need Qemu fork from here:
> > > +https://urldefense.com/v3/__https://github.com/foss-for-synopsys-dwc-arc-processors/qemu__;!!A4F2R9G_pg!fgGSAQfVckRuijplS-p83y-PGaKlg6lK_iA1kW3cneXd4lEGQc_FCtOb5-gwAhS2NWDw2jkfqPDZYkeaBQ$
> >
> > So, we are dropping all the arc specific versions for the toolchain
> > components, but we eventually introduce a defconfig that relies on an
> > arc specific version of qemu, that we do not even package in Buildroot,
> > so that users can't even enable host-qemu in Buildroot.
> >
> > That is a bit sad...
> >
> > What is the rationale for introducing this defconfig, then?

If there's a pre-built binary of QEMU for ARC, can we use it instead of packaging
it via Buildroot? I.e. what if in Buildroot's Dockerfile we will just pull-in
a binary instead of installing it via "apt get"?

> Qemu is more widely known then the nsimdrv. And I think when ARCv3
> support is added to Buildroot it can be used to test it, too.

Indeed, with QEMU we'll be able to finally enable runtime testing for ARC as there're
no license-related limitaiton in case of QEMU such that we have with Free nSIM.

-Alexey
Yann E. MORIN Jan. 1, 2024, 8:18 p.m. UTC | #4
Waldemar, All,

On 2023-12-31 22:55 +0100, Waldemar Brodkorb spake thusly:
> Yann E. MORIN wrote,
> > On 2023-12-31 18:25 +0100, Waldemar Brodkorb spake thusly:
> > > Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
[--SNIP--]
> > > +You need Qemu fork from here:
> > > +https://github.com/foss-for-synopsys-dwc-arc-processors/qemu
> > So, we are dropping all the arc specific versions for the toolchain
> > components, but we eventually introduce a defconfig that relies on an
> > arc specific version of qemu, that we do not even package in Buildroot,
> > so that users can't even enable host-qemu in Buildroot.
> > That is a bit sad...
> > What is the rationale for introducing this defconfig, then?
> Qemu is more widely known then the nsimdrv.

OK, fair enough.

Still, Qemu with ARC support is not sidely available (e.h .it's not ins
distros), and we do not have a way to easily build it from source,
leaving to the user the duty to find how to do get such a Qemu.

And since you point to the source tree (which is nice), it implies one
has to build from source on their own, which we know is a bit tedious...

> And I think when ARCv3
> support is added to Buildroot

*When* is the key word here. I know Alexey has said he was looking into
it, but IIRC the topic has been pending since last August, so I would
like to decorelate the two topics.

> it can be used to test it, too.

That does not change the fact that it is a forked version, not readily
available, that we do not build in Buildroot, and that the user has to
manually build from source on their own, which is still problematic.

> I thought it would be nice to have instead of only rely on the nsim
> defconfig we have now.

That I agree on, but I don;t think it is a good-enough reason to be
using a non-upstream Qemu.

> Can we keep it? What others say?

"Mom, dad, it's a cute doggy/kitten/duck/poney/hedghog! Can we keep it?"

Let's see what other maintainers think, of course.

And in any case, that does not diminish the fact that the commit log
should contain a proper rationale.

Regards,
Yann E. MORIN.
Alexey Brodkin Jan. 6, 2024, 10:22 p.m. UTC | #5
Hi Waldemar,

> Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>

So that's another good trigger from your side ;)

>  board/qemu/arc/linux.config | 32 ++++++++++++++++++++++++++++++++
>  board/qemu/arc/readme.txt   |  8 ++++++++
>  configs/qemu_arc_defconfig  | 30 ++++++++++++++++++++++++++++++
>  3 files changed, 70 insertions(+)
>  create mode 100644 board/qemu/arc/linux.config
>  create mode 100644 board/qemu/arc/readme.txt
>  create mode 100644 configs/qemu_arc_defconfig

As a matter of fact, we may do it much simpler as most of the things are
already in place. We just need to switch HAPS defconfig to a UP kernel,
enable DHCP on eth0:
----------------->8--------------
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
----------------->8--------------

and voila!
----------------->8--------------
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

Linux version 5.16.0 (abrodkin@us01arcgnu3) (arc-buildroot-linux-gnu-gcc.br_real (Buildroot 2023.11-520-g38ba3bd175-dirty) 13.1.1 20230516, GNU ld (GNU Binutils) 2.40.90.20230703) #2 PREEMPT Sat Jan 6 14:15:43 PST 2024
Memory @ 80000000 [1024M]
Memory @ 100000000 [1024M] Not used
OF: fdt: Machine model: snps,zebu_hs
earlycon: uart8250 at MMIO32 0xf0000000 (options '115200n8')
printk: bootconsole [uart8250] enabled
archs-intc      : 16 priority levels (default 1) FIRQ (not used)

IDENTITY        : ARCVER [0x54] ARCNUM [0x0] CHIPID [0xffff]
processor [0]   : HS38 R3.10a (ARCv2 ISA)
Timers          : Timer0 Timer1
ISA Extn        : atomic ll64 unalign mpy[opt 9] div_rem
MMU [v4]        : 8k PAGE, 2M Super Page (not used) , swalk 2 lvl, JTLB 1024 (256x4), uDTLB 8, uITLB 4, PAE40 (not used)
I-Cache         : 64K, 4way/set, 64B Line, VIPT aliasing
D-Cache         : 64K, 2way/set, 64B Line, PIPT
Peripherals     : 0xc0000000
Vector Table    : 0x80000000
FPU             : SP DP

...

Freeing unused kernel image (initmem) memory: 1296K
This architecture does not have kernel memory protection.
Run /init as init process
  with arguments:
    /init
  with environment:
    HOME=/
    TERM=linux
Saving 2048 bits of non-creditable seed for next boot
Starting syslogd: OK
Starting klogd: OK
Running sysctl: OK
Starting network: udhcpc: started, v1.36.1
udhcpc: broadcasting discover
udhcpc: broadcasting select for 10.0.2.15, server 10.0.2.2
udhcpc: lease of 10.0.2.15 obtained from 10.0.2.2, lease time 86400
deleting routers
adding dns 10.0.2.3
OK

Welcome to the HAPS Development Platform
zebu_hs login: root
# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0
       valid_lft forever preferred_lft forever
# ping 10.0.2.2
PING 10.0.2.2 (10.0.2.2): 56 data bytes
64 bytes from 10.0.2.2: seq=0 ttl=255 time=1.046 ms
64 bytes from 10.0.2.2: seq=1 ttl=255 time=0.068 ms
64 bytes from 10.0.2.2: seq=2 ttl=255 time=0.040 ms
----------------->8--------------

Let me send yet another substitution for another patch of yours, sorry ;)

-Alexey
diff mbox series

Patch

diff --git a/board/qemu/arc/linux.config b/board/qemu/arc/linux.config
new file mode 100644
index 0000000000..40c7b950e8
--- /dev/null
+++ b/board/qemu/arc/linux.config
@@ -0,0 +1,32 @@ 
+CONFIG_ARC=y
+CONFIG_ISA_ARCV2=y
+CONFIG_ARC_CPU_HS=y
+CONFIG_MMU=y
+CONFIG_ARC_HAS_ACCL_REGS=y
+CONFIG_ARC_MMU_V4=y
+CONFIG_ARC_PAGE_SIZE_8K=y
+CONFIG_COMPAT_32BIT_TIME=y
+CONFIG_VIRTIO=y
+CONFIG_VIRTIO_NET=y
+CONFIG_VIRTIO_CONSOLE=y
+CONFIG_VIRTIO_MENU=y
+CONFIG_VIRTIO_MMIO=y
+CONFIG_ARC_BUILTIN_DTB_NAME="haps_hs"
+CONFIG_NETDEVICES=y
+CONFIG_NET_CORE=y
+CONFIG_ETHERNET=y
+CONFIG_NET=y
+CONFIG_PACKET=y
+CONFIG_UNIX=y
+CONFIG_INET=y
+CONFIG_SERIAL_EARLYCON=y
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_8250_NR_UARTS=4
+CONFIG_SERIAL_8250_RUNTIME_UARTS=4
+CONFIG_SERIAL_8250_DWLIB=y
+CONFIG_SERIAL_8250_DW=y
+CONFIG_SERIAL_OF_PLATFORM=y
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_TMPFS=y
diff --git a/board/qemu/arc/readme.txt b/board/qemu/arc/readme.txt
new file mode 100644
index 0000000000..93bb9c2152
--- /dev/null
+++ b/board/qemu/arc/readme.txt
@@ -0,0 +1,8 @@ 
+You need Qemu fork from here:
+https://github.com/foss-for-synopsys-dwc-arc-processors/qemu
+
+Run the emulation with:
+
+ qemu-system-arc -monitor none -serial stdio -netdev user,id=eth0 -device virtio-net-device,netdev=eth0 -cpu archs -kernel output/images/vmlinux -nographic # qemu_arc_defconfig
+
+The login prompt will appear in the terminal that started Qemu.
diff --git a/configs/qemu_arc_defconfig b/configs/qemu_arc_defconfig
new file mode 100644
index 0000000000..d65e28a3d0
--- /dev/null
+++ b/configs/qemu_arc_defconfig
@@ -0,0 +1,30 @@ 
+# Architecture
+BR2_arc=y
+BR2_arcle=y
+BR2_archs38=y
+
+# System
+BR2_SYSTEM_DHCP="eth0"
+
+# Filesystem
+# BR2_TARGET_ROOTFS_TAR is not set
+BR2_TARGET_ROOTFS_INITRAMFS=y
+
+# Image
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/qemu/post-image.sh"
+BR2_ROOTFS_POST_SCRIPT_ARGS="$(BR2_DEFCONFIG)"
+
+# Linux headers same as kernel
+BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_6_1=y
+
+# Kernel
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.1.44"
+BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/arc/linux.config"
+BR2_LINUX_KERNEL_VMLINUX=y
+
+# host-qemu for gitlab testing
+BR2_PACKAGE_HOST_QEMU=y
+BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE=y