Skip to contentSkip to conversation

Support for Zephyr qemu_nios2 board

PATCH New Juro Bystricky 1 participant 5 messages Jan 24, 2017

lore
Share & tools
lore
#0 lore raw

cover Support for Zephyr qemu_nios2 board

This set of patches implements the support for Zephyr qemu_nios2. It implements the full toolchain (binutils, GCC, newlib) and also QEMU for Altera Nios2. The Nios2 support is fairly minimalistic, no tunes to support HW multiply, HW divide etc. as they are not required by Zephyr.

Upstream QEMU does not support Nios2, so a patch was needed to provide the Nios2 emulation (CPU, intc, timer, ...)

As with all other supported Zephyr boards, the BOARD=qemu_nios2 required the creation of a corresponding MACHINE=qemu-nios2

Usage is described in the (updated) README.txt file.

Juro Bystricky (4):
qemu-nios2: New MACHINE
qemuzephyrrunner.py: support for qemu-nios2 zephyr-kernel-test.inc: exclude tests not suitable for Nios2 README.txt: Updated for qemu-nios2

 README.txt                                         |   32 +-
 conf/machine/include/tune-nios2.inc                |   19 +
 conf/machine/qemu-nios2.conf                       |   11 +
 lib/oeqa/utils/qemuzephyrrunner.py                 |    6 +
 .../qemu/files/nios2-add-support.patch             | 9239 ++++++++++++++++++++
 recipes-devtools/qemu/qemu_2.7.%.bbappend          |   12 +
 .../zephyr-kernel/zephyr-kernel-test.inc           |    3 +
 7 files changed, 9309 insertions(+), 13 deletions(-)
 create mode 100644 conf/machine/include/tune-nios2.inc
 create mode 100644 conf/machine/qemu-nios2.conf
 create mode 100644 recipes-devtools/qemu/files/nios2-add-support.patch
 create mode 100644 recipes-devtools/qemu/qemu_2.7.%.bbappend
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/4 qemu-nios2: New MACHINE

Added support for Zephyr qemu-nios2 BOARD. Nios2 CPU is not supported natively by upstream QEMU, so a Nios2 specific patch needs to be applied.

[YOCTO#10660]

---
 conf/machine/include/tune-nios2.inc                |   19 +
 conf/machine/qemu-nios2.conf                       |   11 +
 .../qemu/files/nios2-add-support.patch             | 9239 ++++++++++++++++++++
 recipes-devtools/qemu/qemu_2.7.%.bbappend          |   12 +
 4 files changed, 9281 insertions(+)
 create mode 100644 conf/machine/include/tune-nios2.inc
 create mode 100644 conf/machine/qemu-nios2.conf
 create mode 100644 recipes-devtools/qemu/files/nios2-add-support.patch
 create mode 100644 recipes-devtools/qemu/qemu_2.7.%.bbappend
conf/machine/include/tune-nios2.inc new file +19 -0
new file mode 100644
index 0000000..80db79d
@@ -0,0 +1,19 @@
+
+# Nios2 Architecture Definition
+
+DEFAULTTUNE ?= "nios2"
+
+TUNE_ARCH = "nios2"
+TUNE_PKGARCH = "nios2"
+TUNE_FEATURES_tune-nios2 = "nios2"
+TUNE_CCARGS = ""
+
+TUNEVALID[nios2] = "Altera Nios2"
+
+def nios2_machdata_setfunc(machdata, d):
+    machdata["elf"] = {"nios2":  (113, 0, 0, True, 32), }
+    return machdata
+
+PACKAGEQA_EXTRA_MACHDEFFUNCS = "nios2_machdata_setfunc"
+
+PACKAGE_EXTRA_ARCHS_tune-nios2 = "nios2"
conf/machine/qemu-nios2.conf new file +11 -0
new file mode 100644
index 0000000..d74017f
@@ -0,0 +1,11 @@
+#@TYPE: Machine
+#@NAME: qemu-nios2
+#@DESCRIPTION: Machine for Zephyr BOARD qemu_nios2
+
+require conf/machine/include/qemu.inc
+require conf/machine/include/tune-nios2.inc
+
+# For runqemu (TBD)
+QB_SYSTEM_NAME = "qemu-system-nios2"
+QB_MACHINE = "-machine altera_10m50_zephyr"
+QB_OPT_APPEND = "-nographic -cpu=nios2"
recipes-devtools/qemu/files/nios2-add-support.patch new file +9239 -0

2,970 lines not on this page · raw message

recipes-devtools/qemu/qemu_2.7.%.bbappend new file +12 -0
new file mode 100644
index 0000000..f3ff73c

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.7.4

Part of the diff is not shown here. View the raw message.

#2 lore raw

PATCH 2/4 qemuzephyrrunner.py: support for qemu-nios2

In reply to Juro Bystricky
---
 lib/oeqa/utils/qemuzephyrrunner.py | 6 ++++++
 1 file changed, 6 insertions(+)
lib/oeqa/utils/qemuzephyrrunner.py +6 -0
index 441e0d6..2011434 100644
@@ -74,6 +74,12 @@ class QemuZephyrRunner(QemuRunner):
         elif 'x86' in self.machine:
             qemu_binary = 'qemu-system-i386'
             qemu_machine_args = '-machine type=pc-0.14'
+        elif 'nios2' in self.machine:
+            qemu_binary = 'qemu-system-nios2'
+            qemu_machine_args = '-machine altera_10m50_zephyr'
+        else:
+            bb.error("Unsupported QEMU: %s" % self.machine)
+            return False
 
         self.origchldhandler = signal.getsignal(signal.SIGCHLD)
         signal.signal(signal.SIGCHLD, self.handleSIGCHLD)
Signature · 1 line
2.7.4
#3 lore raw

PATCH 3/4 zephyr-kernel-test.inc: exclude tests not suitable for Nios2

In reply to Juro Bystricky
---
 recipes-kernel/zephyr-kernel/zephyr-kernel-test.inc | 3 +++
 1 file changed, 3 insertions(+)
recipes-kernel/zephyr-kernel/zephyr-kernel-test.inc +3 -0
index ecc183c..2e92ca2 100644
@@ -12,6 +12,9 @@ ZEPHYRTESTS_remove_arm += "test_critical"
 #Remove ARM specific tests
 ZEPHYRTESTS_remove_x86 += "test_context test_arm_irq_vector_table"
 
+#Remove tests not intended for Nios2
+ZEPHYRTESTS_remove_nios2 += "test_context test_arm_irq_vector_table test_mem_safe"
+
 # List of all available tests
 ZEPHYRTESTS = " \
     test_arm_irq_vector_table  \
Signature · 1 line
2.7.4
#4 lore raw

PATCH 4/4 README.txt: Updated for qemu-nios2

In reply to Juro Bystricky

Also replaced all "qemux86" with "qemu-x86"

---
 README.txt | 32 +++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 13 deletions(-)
README.txt +19 -13
index cb9a36a..230ad41 100644
@@ -3,6 +3,8 @@ Building Zephyr Images via bitbake recipes
 
 Prerequisites:
 
+Yocto distro "morty"
+
 Modify local conf by adding:
     DISTRO="zephyr"
 
@@ -11,29 +13,27 @@ Add "meta-zephyr" to BBLAYERS
 
 Building and Running Zephyr tests
 =================================
-Presently only toolchains for ARM and x86 are supported.
+Presently only toolchains for ARM, x86, IAMCU and Nios2 are supported.
 (For ARM we use CortexM3 toolchain)
 
-Default Zephyr BOARD is selected as follows:
-
-BOARD_arm ?= "qemu_cortex_m3"
-BOARD_x86 ?= "qemu_x86"
-
 You can build and test an individual existing Zephyr test.
 This is done by appending the actual test name to the "zephyr-kernel-test",
 for example:
 
-    $ MACHINE=qemux86 bitbake zephyr-kernel-test-test_sleep
-    $ MACHINE=qemux86 bitbake zephyr-kernel-test-test_sleep -ctestimage
+    $ MACHINE=qemu-x86 bitbake zephyr-kernel-test-test_sleep
+    $ MACHINE=qemu-x86 bitbake zephyr-kernel-test-test_sleep -ctestimage
 
-You can also build and run all Zephyr existing tests (as slisted in the file
+You can also build and run all Zephyr existing tests (as listed in the file
 zephyr-kernel-test.inc). For example:
-    $ MACHINE=qemux86 bitbake zephyr-kernel-test-all
-    $ MACHINE=qemux86 bitbake zephyr-kernel-test-all -ctestimage
+    $ MACHINE=qemu-x86 bitbake zephyr-kernel-test-all
+    $ MACHINE=qemu-x86 bitbake zephyr-kernel-test-all -ctestimage
 or 
     $ MACHINE=qemu-cortex-m3 bitbake zephyr-kernel-test-all
     $ MACHINE=qemu-cortex-m3 bitbake zephyr-kernel-test-all -ctestimage
-    
+or 
+    $ MACHINE=qemu-nios2 bitbake zephyr-kernel-test-all
+    $ MACHINE=qemu-nios2 bitbake zephyr-kernel-test-all -ctestimage
+        
 
 
 Building and Running Zephyr Samples
@@ -41,7 +41,7 @@ Building and Running Zephyr Samples
 You can also build Zephyr samples. There is a sample recipe that builds
 Zephyr "philosophers" sample:
     
-    $ MACHINE=qemux86 bitbake zephyr-philosophers
+    $ MACHINE=qemu-x86 bitbake zephyr-philosophers
     
 You can run the created "philosophers" image in qemu (at this point
 the various paths have to be entered manually):
@@ -57,3 +57,9 @@ The same sample, for ARM image:
            -kernel ./tmp/deploy/images/qemu-cortex-m3/philosophers.elf \
            -cpu cortex-m3 -machine lm3s6965evb -nographic -vga none
 
+The same sample, for Nios2 image:
+    $ MACHINE=qemu-nios2 bitbake zephyr-philosophers
+    $ ./tmp/sysroots/x86_64-linux/usr/bin/qemu-system-nios2  \
+           -kernel ./tmp/deploy/images/qemu-nios2/philosophers.elf \
+           -cpu nios2 -machine altera_10m50_zephyr -nographic
+
Signature · 1 line
2.7.4