All of lore.kernel.org
 help / color / mirror / Atom feed
* [meta-zephyr][PATCH v3 0/5] Add 96Boards Nitrogen support
@ 2020-12-10 16:02 Wojciech Zmuda
  2020-12-10 16:02 ` [meta-zephyr][PATCH v3 1/5] zephyr-kernel: clone Nordic HAL Wojciech Zmuda
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Wojciech Zmuda @ 2020-12-10 16:02 UTC (permalink / raw)
  To: yocto
  Cc: naveen.kumar.saini, davide.ricci, jaroslaw.marek, zbigniew.bodek,
	robert.drab, amit.kucheria.ext, Wojciech Zmuda

From: Wojciech Zmuda <wojciech.zmuda@huawei.com>

Hello,

v2 -> v3:
 - fix accidentally broken QEMU builds. The build failed when do_deploy looked
   for .hex files that were generated for physical machines but not for QEMU
   (which does not need them). Fix the issue by reverting the change of generating
   .hex files. They were introduced for pyocd, but it occurs that pyocd is happy
   with ELFs, so this idea of .hex files was removed altogether from this patch set.
   Instead, zephyr-flash-pyocd gets ELFs and happily flashes Nitrogen.
 - fix building zephyr-kernel-test-all targets for physical boards. Explained in
   commit message of patch 5/5.
v1 -> v2:
 - README.txt: fix bad MACHINE examples: change _ to -, i.e. 96b_nitrogen -> 96b-nitrogen

This patch set adds support for the Nitrogen board by 96Boards.
The support consists of:
 - adding configs for Cortex-M4, nRF52832 SoC and Nitrogen board,
 - adding bbclass with pyocd-based do_flash_usb() implementation.

Tested on Nitrogen and on QEMU so I hope I didn't accidentally
break anything.

Verification:
 1. Install pyocd.
 2. Connect Nitrogen and make sure you can see Bus 001 Device 004: ID 0d28:0204 NXP ARM mbed
    in lsusb.
 3. Build a sample app:
    $ MACHINE=96b-nitrogen DISTRO=zephyr bitbake zephyr-philosophers
 4. Flash app to the board:
    $ MACHINE=96b-nitrogen DISTRO=zephyr bitbake zephyr-philosophers -c flash_usb

You can also build the test suite i.e. bitbake zephyr-kernel-test-all
and manually flash Nitrogen with images from the deploy directory. They are
not picked up by do_flash_usb implementation from zephyur-flash-pyocd,
as it works with single ELF file with the same name that the target has.
The same limitation is present in the current do_flash_usb implementation
from the zephyr-flash-dfu class.

Wojciech Zmuda (5):
  zephyr-kernel: clone Nordic HAL
  conf: machine: add support for Nordic nRF52832 Cortex-M4 chip
  conf: machine: add 96boards Nitrogen support
  zephyr-kernel: don't limit deploy to .elf file
  zephyr-flash-pyocd.bbclass: support for flashing via pyocd

 README.txt                                    | 23 +++++++++++++++++++
 classes/zephyr-flash-pyocd.bbclass            | 17 ++++++++++++++
 classes/zephyr-kernel-src.bbclass             |  7 +++---
 conf/machine/96b-nitrogen.conf                |  8 +++++++
 conf/machine/include/nrf52832.inc             | 10 ++++++++
 conf/machine/include/tune-cortexm4.inc        | 19 +++++++++++++++
 .../zephyr-kernel/zephyr-helloworld.bb        |  3 ++-
 recipes-kernel/zephyr-kernel/zephyr-image.inc |  2 +-
 .../zephyr-kernel/zephyr-kernel-common.inc    |  5 +++-
 .../zephyr-kernel/zephyr-philosophers.bb      |  3 ++-
 10 files changed, 90 insertions(+), 7 deletions(-)
 create mode 100644 classes/zephyr-flash-pyocd.bbclass
 create mode 100644 conf/machine/96b-nitrogen.conf
 create mode 100644 conf/machine/include/nrf52832.inc
 create mode 100644 conf/machine/include/tune-cortexm4.inc

-- 
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [meta-zephyr][PATCH v3 1/5] zephyr-kernel: clone Nordic HAL
  2020-12-10 16:02 [meta-zephyr][PATCH v3 0/5] Add 96Boards Nitrogen support Wojciech Zmuda
@ 2020-12-10 16:02 ` Wojciech Zmuda
  2020-12-10 16:02 ` [meta-zephyr][PATCH v3 2/5] conf: machine: add support for Nordic nRF52832 Cortex-M4 chip Wojciech Zmuda
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Wojciech Zmuda @ 2020-12-10 16:02 UTC (permalink / raw)
  To: yocto
  Cc: naveen.kumar.saini, davide.ricci, jaroslaw.marek, zbigniew.bodek,
	robert.drab, amit.kucheria.ext, Wojciech Zmuda

From: Wojciech Zmuda <wojciech.zmuda@huawei.com>

HAL for Nordic chipsets is one of Zephyr subprojects. It is downloaded
by default by west. Clone the HAL repository so it can be used for
building images for boards with Nordic chips.

Signed-off-by: Wojciech Zmuda <wojciech.zmuda@huawei.com>
---
 classes/zephyr-kernel-src.bbclass                     | 7 ++++---
 recipes-kernel/zephyr-kernel/zephyr-kernel-common.inc | 1 +
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/classes/zephyr-kernel-src.bbclass b/classes/zephyr-kernel-src.bbclass
index d245223..ea9b30b 100644
--- a/classes/zephyr-kernel-src.bbclass
+++ b/classes/zephyr-kernel-src.bbclass
@@ -5,12 +5,13 @@ PREFERRED_VERSION_zephyr-kernel ??= "2.4.0"
 SRCREV_FORMAT = "default_cmsis"
 SRCREV_default = "7a3b253ced7333f5c0269387a7f3ed1dee69739d"
 SRCREV_cmsis = "542b2296e6d515b265e25c6b7208e8fea3014f90"
-
+SRCREV_nordic = "d8a6ea9695ddf792bb18bb6035c13b1daac5d79c"
 
 SRC_URI = "git://github.com/zephyrproject-rtos/zephyr.git;protocol=https;branch=v2.4-branch;name=default \
            git://github.com/zephyrproject-rtos/cmsis.git;protocol=https;destsuffix=git/modules/cmsis;name=cmsis \
-          file://0001-cmake-add-yocto-toolchain.patch \
-        "
+           git://github.com/zephyrproject-rtos/hal_nordic.git;protocol=https;destsuffix=git/modules/hal/nordic;name=nordic \
+           file://0001-cmake-add-yocto-toolchain.patch \
+          "
 
 PV = "2.4.0+git${SRCPV}"
 
diff --git a/recipes-kernel/zephyr-kernel/zephyr-kernel-common.inc b/recipes-kernel/zephyr-kernel/zephyr-kernel-common.inc
index 3f82c20..a1f640d 100644
--- a/recipes-kernel/zephyr-kernel/zephyr-kernel-common.inc
+++ b/recipes-kernel/zephyr-kernel/zephyr-kernel-common.inc
@@ -16,6 +16,7 @@ ZEPHYR_MAKE_OUTPUT = "zephyr.elf"
 
 EXTRA_OECMAKE = " -DZEPHYR_BASE=${S} -DZEPHYR_GCC_VARIANT=yocto -DBOARD=${BOARD} -DARCH=${ARCH} -DCROSS_COMPILE=${CROSS_COMPILE} -DZEPHYR_SYSROOT=${ZEPHYR_SYSROOT} -DZEPHYR_TOOLCHAIN_VARIANT=yocto"
 EXTRA_OECMAKE_append_arm = " -DZEPHYR_MODULES=${S}/modules/cmsis"
+EXTRA_OECMAKE_append_nordic = "\;${S}/modules/hal/nordic"
 export ZEPHYR_BASE="${S}"
 
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [meta-zephyr][PATCH v3 2/5] conf: machine: add support for Nordic nRF52832 Cortex-M4 chip
  2020-12-10 16:02 [meta-zephyr][PATCH v3 0/5] Add 96Boards Nitrogen support Wojciech Zmuda
  2020-12-10 16:02 ` [meta-zephyr][PATCH v3 1/5] zephyr-kernel: clone Nordic HAL Wojciech Zmuda
@ 2020-12-10 16:02 ` Wojciech Zmuda
  2020-12-10 16:02 ` [meta-zephyr][PATCH v3 3/5] conf: machine: add 96boards Nitrogen support Wojciech Zmuda
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Wojciech Zmuda @ 2020-12-10 16:02 UTC (permalink / raw)
  To: yocto
  Cc: naveen.kumar.saini, davide.ricci, jaroslaw.marek, zbigniew.bodek,
	robert.drab, amit.kucheria.ext, Wojciech Zmuda

From: Wojciech Zmuda <wojciech.zmuda@huawei.com>

Add include for Cortex-M4 tunes and nRF52832. The nRF config
appends 'nordic' to MACHINEOVERRIDES, so the kernel recipe
can include Nordic HAL when this override is detected.

Signed-off-by: Wojciech Zmuda <wojciech.zmuda@huawei.com>
---
 conf/machine/include/nrf52832.inc      | 10 ++++++++++
 conf/machine/include/tune-cortexm4.inc | 19 +++++++++++++++++++
 2 files changed, 29 insertions(+)
 create mode 100644 conf/machine/include/nrf52832.inc
 create mode 100644 conf/machine/include/tune-cortexm4.inc

diff --git a/conf/machine/include/nrf52832.inc b/conf/machine/include/nrf52832.inc
new file mode 100644
index 0000000..73e628a
--- /dev/null
+++ b/conf/machine/include/nrf52832.inc
@@ -0,0 +1,10 @@
+#@TYPE: Machine
+#@NAME: nrf52832
+
+#@DESCRIPTION: Machine configuration for Nordic Semiconductor nRF52832 (Cortex-M4) SoC.
+
+require conf/machine/include/tune-cortexm4.inc
+
+MACHINEOVERRIDES =. "nordic:"
+
+TUNE_FEATURES = "armv7m cortexm4"
diff --git a/conf/machine/include/tune-cortexm4.inc b/conf/machine/include/tune-cortexm4.inc
new file mode 100644
index 0000000..a823b6b
--- /dev/null
+++ b/conf/machine/include/tune-cortexm4.inc
@@ -0,0 +1,19 @@
+DEFAULTTUNE ?= "cortexm4"
+
+require conf/machine/include/arm/arch-armv7a.inc
+
+TUNEVALID[cortexm4] = "Enable Cortex-M4 specific processor optimizations"
+TUNE_CCARGS .= "${@bb.utils.contains('TUNE_FEATURES', 'cortexm4', ' -mcpu=cortex-m4', '', d)}"
+AVAILTUNES += "cortexm4"
+
+TUNEVALID[armv7m] = "Enable Cortex-M4 specific processor optimizations"
+TUNE_CCARGS .= "${@bb.utils.contains('TUNE_FEATURES', 'armv7m', ' -march=armv7e-m', '', d)}"
+MACHINEOVERRIDES =. "${@bb.utils.contains('TUNE_FEATURES', 'armv7m', 'armv7m:', '' ,d)}"
+
+TUNE_PKGARCH_tune-cortexm4 = "cortexm4"
+
+ARMPKGARCH_tune-cortexm4 = "armv7m"
+PACKAGE_EXTRA_ARCHS_tune-cortexm4 ="cortexm4"
+
+TUNE_FEATURES_tune-cortexm4 = "armv7m vfp cortexm4"
+PACKAGE_EXTRA_ARCHS_tune-cortexm4 = "${PACKAGE_EXTRA_ARCHS_tune-armv7at} armv7m-vfp armv7m"
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [meta-zephyr][PATCH v3 3/5] conf: machine: add 96boards Nitrogen support
  2020-12-10 16:02 [meta-zephyr][PATCH v3 0/5] Add 96Boards Nitrogen support Wojciech Zmuda
  2020-12-10 16:02 ` [meta-zephyr][PATCH v3 1/5] zephyr-kernel: clone Nordic HAL Wojciech Zmuda
  2020-12-10 16:02 ` [meta-zephyr][PATCH v3 2/5] conf: machine: add support for Nordic nRF52832 Cortex-M4 chip Wojciech Zmuda
@ 2020-12-10 16:02 ` Wojciech Zmuda
  2020-12-10 16:02 ` [meta-zephyr][PATCH v3 4/5] zephyr-flash-pyocd.bbclass: support for flashing via pyocd Wojciech Zmuda
  2020-12-10 16:02 ` [meta-zephyr][PATCH v3 5/5] classes: build zephyr-kernel-test-all for non-qemu boards Wojciech Zmuda
  4 siblings, 0 replies; 6+ messages in thread
From: Wojciech Zmuda @ 2020-12-10 16:02 UTC (permalink / raw)
  To: yocto
  Cc: naveen.kumar.saini, davide.ricci, jaroslaw.marek, zbigniew.bodek,
	robert.drab, amit.kucheria.ext, Wojciech Zmuda

From: Wojciech Zmuda <wojciech.zmuda@huawei.com>

The board is based on Nordic nRF52832 Cortex-M4 chip.
The support depends on Nordic HAL. It has been verified
with zephyr-philosophers and zephyr-shell sample applications.

Signed-off-by: Wojciech Zmuda <wojciech.zmuda@huawei.com>
---
 conf/machine/96b-nitrogen.conf | 7 +++++++
 1 file changed, 7 insertions(+)
 create mode 100644 conf/machine/96b-nitrogen.conf

diff --git a/conf/machine/96b-nitrogen.conf b/conf/machine/96b-nitrogen.conf
new file mode 100644
index 0000000..d1905f2
--- /dev/null
+++ b/conf/machine/96b-nitrogen.conf
@@ -0,0 +1,7 @@
+#@TYPE: Machine
+#@NAME: 96b_nitrogen
+
+#@DESCRIPTION: Machine configuration for 96Boards Nitrogen Board.
+
+require conf/machine/include/nrf52832.inc
+ARCH_96b-nitrogen = "arm"
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [meta-zephyr][PATCH v3 4/5] zephyr-flash-pyocd.bbclass: support for flashing via pyocd
  2020-12-10 16:02 [meta-zephyr][PATCH v3 0/5] Add 96Boards Nitrogen support Wojciech Zmuda
                   ` (2 preceding siblings ...)
  2020-12-10 16:02 ` [meta-zephyr][PATCH v3 3/5] conf: machine: add 96boards Nitrogen support Wojciech Zmuda
@ 2020-12-10 16:02 ` Wojciech Zmuda
  2020-12-10 16:02 ` [meta-zephyr][PATCH v3 5/5] classes: build zephyr-kernel-test-all for non-qemu boards Wojciech Zmuda
  4 siblings, 0 replies; 6+ messages in thread
From: Wojciech Zmuda @ 2020-12-10 16:02 UTC (permalink / raw)
  To: yocto
  Cc: naveen.kumar.saini, davide.ricci, jaroslaw.marek, zbigniew.bodek,
	robert.drab, amit.kucheria.ext, Wojciech Zmuda

From: Wojciech Zmuda <wojciech.zmuda@huawei.com>

Implement do_flash_usb for boards supported by pyocd:

    MACHINE=xxx bitbake yyy -c flash_usb

Pyocd support abundance of boards, however for now this
meta-layer supports only one board that can be flashed
using pyocd, that is 96Boards Nitrogen.

Describe the feature in README.

Signed-off-by: Wojciech Zmuda <wojciech.zmuda@huawei.com>
---
 README.txt                         | 23 +++++++++++++++++++++++
 classes/zephyr-flash-pyocd.bbclass | 16 ++++++++++++++++
 conf/machine/96b-nitrogen.conf     |  1 +
 3 files changed, 40 insertions(+)
 create mode 100644 classes/zephyr-flash-pyocd.bbclass

diff --git a/README.txt b/README.txt
index 6463339..bda872b 100644
--- a/README.txt
+++ b/README.txt
@@ -43,6 +43,29 @@ The same sample, for Nios2 image:
     $ MACHINE=qemu-nios2 bitbake zephyr-philosophers
     $ runqemu qemu-nios2
 
+Flashing
+=================================
+
+You can flash Zephyr samples to boards. Currently, the following MACHINEs
+are supported:
+ * DFU:
+  - arduino-101-sss
+  - arduino-101
+  - arduino-101-ble
+ * pyocd:
+  - 96b-nitrogen
+
+To flash the example you built with command e.g.
+
+    $ MACHINE=96b-nitrogen bitbake zephyr-philosophers
+
+call similar command with explicit flash_usb command:
+
+    $ MACHINE=96b-nitrogen bitbake zephyr-philosophers -c flash_usb
+
+dfu-util and/or pyocd need to be installed in your system. If you observe
+permission errors or the flashing process seem to hang, follow those instructions:
+https://github.com/pyocd/pyOCD/tree/master/udev
 
 Building and Running Zephyr Tests
 =================================
diff --git a/classes/zephyr-flash-pyocd.bbclass b/classes/zephyr-flash-pyocd.bbclass
new file mode 100644
index 0000000..04500af
--- /dev/null
+++ b/classes/zephyr-flash-pyocd.bbclass
@@ -0,0 +1,16 @@
+python do_flash_usb() {
+    from pyocd.core.helpers import ConnectHelper
+    from pyocd.flash.file_programmer import FileProgrammer
+
+    image = f"{d.getVar('DEPLOY_DIR_IMAGE')}/{d.getVar('PN')}.elf"
+    bb.plain(f"Attempting to flash {image} to board {d.getVar('BOARD')}")
+
+    with ConnectHelper.session_with_chosen_probe() as session:
+        FileProgrammer(session).program(image)
+        session.board.target.reset()
+}
+
+addtask do_flash_usb
+
+do_flash_usb[nostamp] = "1"
+do_flash_usb[vardepsexclude] = "BB_ORIGENV"
diff --git a/conf/machine/96b-nitrogen.conf b/conf/machine/96b-nitrogen.conf
index d1905f2..998db4c 100644
--- a/conf/machine/96b-nitrogen.conf
+++ b/conf/machine/96b-nitrogen.conf
@@ -4,4 +4,5 @@
 #@DESCRIPTION: Machine configuration for 96Boards Nitrogen Board.
 
 require conf/machine/include/nrf52832.inc
+ZEPHYR_INHERIT_CLASSES += "zephyr-flash-pyocd"
 ARCH_96b-nitrogen = "arm"
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [meta-zephyr][PATCH v3 5/5] classes: build zephyr-kernel-test-all for non-qemu boards
  2020-12-10 16:02 [meta-zephyr][PATCH v3 0/5] Add 96Boards Nitrogen support Wojciech Zmuda
                   ` (3 preceding siblings ...)
  2020-12-10 16:02 ` [meta-zephyr][PATCH v3 4/5] zephyr-flash-pyocd.bbclass: support for flashing via pyocd Wojciech Zmuda
@ 2020-12-10 16:02 ` Wojciech Zmuda
  4 siblings, 0 replies; 6+ messages in thread
From: Wojciech Zmuda @ 2020-12-10 16:02 UTC (permalink / raw)
  To: yocto
  Cc: naveen.kumar.saini, davide.ricci, jaroslaw.marek, zbigniew.bodek,
	robert.drab, amit.kucheria.ext, Wojciech Zmuda

From: Wojciech Zmuda <wojciech.zmuda@huawei.com>

Machines not inheriting zephyr-qemuboot did not have
IMGDEPLOYDIR variable set, which is required for building
zephyr-kernel-test-all. The build was fine for qemu-xxx machines,
but for physical boards it failed somewhere inside python code
when .join() got an empty argument incoming from IMGDEPLOYDIR.
Move IMGDEPLOYDIR to zephyr class, so it's defined for
qemu and non-qemu machines.

Signed-off-by: Wojciech Zmuda <wojciech.zmuda@huawei.com>
---
 classes/zephyr-qemuboot.bbclass | 3 ---
 classes/zephyr.bbclass          | 3 +++
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/classes/zephyr-qemuboot.bbclass b/classes/zephyr-qemuboot.bbclass
index 39de3f0..5ac1c86 100644
--- a/classes/zephyr-qemuboot.bbclass
+++ b/classes/zephyr-qemuboot.bbclass
@@ -11,9 +11,6 @@ IMAGE_LINK_NAME = "${PN}-image-${MACHINE}"
 # Create a link with "-image-" in the name just to keep runqemu happy
 QEMU_IMAGE_LINK = "${DEPLOY_DIR_IMAGE}/${PN}-image-${MACHINE}.elf"
 
-# qemuboot writes into IMGDEPLOYDIR, force to write to DEPLOY_DIR_IMAGE
-IMGDEPLOYDIR = "${DEPLOY_DIR_IMAGE}"
-
 CLEANFUNCS += "bootconf_clean"
 
 python bootconf_clean() {
diff --git a/classes/zephyr.bbclass b/classes/zephyr.bbclass
index ead762a..6fceb04 100644
--- a/classes/zephyr.bbclass
+++ b/classes/zephyr.bbclass
@@ -10,6 +10,9 @@ TERMINFO = "${STAGING_DATADIR_NATIVE}/terminfo"
 KCONFIG_CONFIG_COMMAND ??= "menuconfig"
 ZEPHYR_BOARD ?= "${MACHINE}"
 
+# qemuboot writes into IMGDEPLOYDIR, force to write to DEPLOY_DIR_IMAGE
+IMGDEPLOYDIR = "${DEPLOY_DIR_IMAGE}"
+
 python () {
     # Translate MACHINE into Zephyr BOARD
     # Zephyr BOARD is basically our MACHINE, except we must use "-" instead of "_"
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-12-10 16:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-10 16:02 [meta-zephyr][PATCH v3 0/5] Add 96Boards Nitrogen support Wojciech Zmuda
2020-12-10 16:02 ` [meta-zephyr][PATCH v3 1/5] zephyr-kernel: clone Nordic HAL Wojciech Zmuda
2020-12-10 16:02 ` [meta-zephyr][PATCH v3 2/5] conf: machine: add support for Nordic nRF52832 Cortex-M4 chip Wojciech Zmuda
2020-12-10 16:02 ` [meta-zephyr][PATCH v3 3/5] conf: machine: add 96boards Nitrogen support Wojciech Zmuda
2020-12-10 16:02 ` [meta-zephyr][PATCH v3 4/5] zephyr-flash-pyocd.bbclass: support for flashing via pyocd Wojciech Zmuda
2020-12-10 16:02 ` [meta-zephyr][PATCH v3 5/5] classes: build zephyr-kernel-test-all for non-qemu boards Wojciech Zmuda

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.