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

Hello,

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

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] 12+ messages in thread

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

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] 12+ messages in thread

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

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] 12+ messages in thread

* [meta-zephyr][PATCH 3/5] conf: machine: add 96boards Nitrogen support
  2020-12-06 20:15 [meta-zephyr][PATCH 0/5] Add 96Boards Nitrogen support zmuda.w
  2020-12-06 20:15 ` [meta-zephyr][PATCH 1/5] zephyr-kernel: clone Nordic HAL Wojciech Zmuda
  2020-12-06 20:15 ` [meta-zephyr][PATCH 2/5] conf: machine: add support for Nordic nRF52832 Cortex-M4 chip Wojciech Zmuda
@ 2020-12-06 20:15 ` Wojciech Zmuda
  2020-12-06 20:15 ` [meta-zephyr][PATCH 4/5] zephyr-kernel: don't limit deploy to .elf file Wojciech Zmuda
  2020-12-06 20:15 ` [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass: support for flashing via pyocd Wojciech Zmuda
  4 siblings, 0 replies; 12+ messages in thread
From: Wojciech Zmuda @ 2020-12-06 20:15 UTC (permalink / raw)
  To: yocto
  Cc: davide.ricci, zbigniew.bodek, jaroslaw.marek, robert.drab,
	Wojciech Zmuda

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] 12+ messages in thread

* [meta-zephyr][PATCH 4/5] zephyr-kernel: don't limit deploy to .elf file
  2020-12-06 20:15 [meta-zephyr][PATCH 0/5] Add 96Boards Nitrogen support zmuda.w
                   ` (2 preceding siblings ...)
  2020-12-06 20:15 ` [meta-zephyr][PATCH 3/5] conf: machine: add 96boards Nitrogen support Wojciech Zmuda
@ 2020-12-06 20:15 ` Wojciech Zmuda
  2020-12-06 20:15 ` [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass: support for flashing via pyocd Wojciech Zmuda
  4 siblings, 0 replies; 12+ messages in thread
From: Wojciech Zmuda @ 2020-12-06 20:15 UTC (permalink / raw)
  To: yocto
  Cc: davide.ricci, zbigniew.bodek, jaroslaw.marek, robert.drab,
	Wojciech Zmuda

Depending on the target board and/or flashing method, it may be desirable
to have access to .bin or .hex files instead of .elf. Remove .elf extension
from ZEPHYR_MAKE_OUTPUT and let users of that variable specify the extension.

Append .elf to all identified users, since they worked with .elf so far.

Signed-off-by: Wojciech Zmuda <wojciech.zmuda@huawei.com>
---
 recipes-kernel/zephyr-kernel/zephyr-helloworld.bb     | 2 +-
 recipes-kernel/zephyr-kernel/zephyr-image.inc         | 2 +-
 recipes-kernel/zephyr-kernel/zephyr-kernel-common.inc | 4 +++-
 recipes-kernel/zephyr-kernel/zephyr-philosophers.bb   | 2 +-
 4 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/recipes-kernel/zephyr-kernel/zephyr-helloworld.bb b/recipes-kernel/zephyr-kernel/zephyr-helloworld.bb
index 84db068..1400e72 100644
--- a/recipes-kernel/zephyr-kernel/zephyr-helloworld.bb
+++ b/recipes-kernel/zephyr-kernel/zephyr-helloworld.bb
@@ -7,7 +7,7 @@ ZEPHYR_BASE = "${S}"
 OECMAKE_SOURCEPATH = "${ZEPHYR_SRC_DIR}"
 
 do_deploy () {
-    install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT} ${DEPLOYDIR}/${PN}.elf
+    install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.elf ${DEPLOYDIR}/${PN}.elf
 }
 
 addtask deploy after do_compile
diff --git a/recipes-kernel/zephyr-kernel/zephyr-image.inc b/recipes-kernel/zephyr-kernel/zephyr-image.inc
index e8b8871..48d3675 100644
--- a/recipes-kernel/zephyr-kernel/zephyr-image.inc
+++ b/recipes-kernel/zephyr-kernel/zephyr-image.inc
@@ -10,7 +10,7 @@ ZEPHYR_BASE = "${S}"
 OECMAKE_SOURCEPATH = "${S}/${ZEPHYR_SRC_DIR}"
 
 do_deploy () {
-    install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT} ${DEPLOYDIR}/${ZEPHYR_IMAGENAME}
+    install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.elf ${DEPLOYDIR}/${ZEPHYR_IMAGENAME}
 }
 
 addtask deploy after do_compile
diff --git a/recipes-kernel/zephyr-kernel/zephyr-kernel-common.inc b/recipes-kernel/zephyr-kernel/zephyr-kernel-common.inc
index a1f640d..ea6cd7a 100644
--- a/recipes-kernel/zephyr-kernel/zephyr-kernel-common.inc
+++ b/recipes-kernel/zephyr-kernel/zephyr-kernel-common.inc
@@ -11,7 +11,9 @@ IMAGE_NO_MANIFEST = "1"
 ZEPHYR_GCC_VARIANT="yocto"
 ZEPHYR_SYSROOT="${STAGING_DIR_TARGET}"
 
-ZEPHYR_MAKE_OUTPUT = "zephyr.elf"
+# Output image name. There are several variants i.e. .bin, .elf, .hex.
+# Let the user append desired suffix.
+ZEPHYR_MAKE_OUTPUT = "zephyr"
 
 
 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"
diff --git a/recipes-kernel/zephyr-kernel/zephyr-philosophers.bb b/recipes-kernel/zephyr-kernel/zephyr-philosophers.bb
index b8262ca..5f7fbcb 100644
--- a/recipes-kernel/zephyr-kernel/zephyr-philosophers.bb
+++ b/recipes-kernel/zephyr-kernel/zephyr-philosophers.bb
@@ -7,7 +7,7 @@ ZEPHYR_BASE = "${S}"
 OECMAKE_SOURCEPATH = "${ZEPHYR_SRC_DIR}"
 
 do_deploy () {
-    install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT} ${DEPLOYDIR}/${PN}.elf
+    install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.elf ${DEPLOYDIR}/${PN}.elf
 }
 
 addtask deploy after do_compile
-- 
2.25.1


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

* [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass: support for flashing via pyocd
  2020-12-06 20:15 [meta-zephyr][PATCH 0/5] Add 96Boards Nitrogen support zmuda.w
                   ` (3 preceding siblings ...)
  2020-12-06 20:15 ` [meta-zephyr][PATCH 4/5] zephyr-kernel: don't limit deploy to .elf file Wojciech Zmuda
@ 2020-12-06 20:15 ` Wojciech Zmuda
  2020-12-07 12:06   ` [yocto] " Naveen Saini
  4 siblings, 1 reply; 12+ messages in thread
From: Wojciech Zmuda @ 2020-12-06 20:15 UTC (permalink / raw)
  To: yocto
  Cc: davide.ricci, zbigniew.bodek, jaroslaw.marek, robert.drab,
	Wojciech Zmuda

Flash boards supported via pyocd:

    MACHINE=xxx bitbake yyy -c flash_usb

The only supported board for now is 96Boards Nitrogen. Modify its
config accordingly.

Modify helloworld and philosopers samples with adidtional .hex
output file deployment, as this format is required by pyocd.

Describe the feature in README.

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

diff --git a/README.txt b/README.txt
index 6463339..4366764 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..aafe9e7
--- /dev/null
+++ b/classes/zephyr-flash-pyocd.bbclass
@@ -0,0 +1,17 @@
+
+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')}.hex"
+    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"
diff --git a/recipes-kernel/zephyr-kernel/zephyr-helloworld.bb b/recipes-kernel/zephyr-kernel/zephyr-helloworld.bb
index 1400e72..9b77975 100644
--- a/recipes-kernel/zephyr-kernel/zephyr-helloworld.bb
+++ b/recipes-kernel/zephyr-kernel/zephyr-helloworld.bb
@@ -8,6 +8,7 @@ OECMAKE_SOURCEPATH = "${ZEPHYR_SRC_DIR}"
 
 do_deploy () {
     install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.elf ${DEPLOYDIR}/${PN}.elf
+    install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.hex ${DEPLOYDIR}/${PN}.hex
 }
 
 addtask deploy after do_compile
diff --git a/recipes-kernel/zephyr-kernel/zephyr-philosophers.bb b/recipes-kernel/zephyr-kernel/zephyr-philosophers.bb
index 5f7fbcb..f720999 100644
--- a/recipes-kernel/zephyr-kernel/zephyr-philosophers.bb
+++ b/recipes-kernel/zephyr-kernel/zephyr-philosophers.bb
@@ -8,6 +8,7 @@ OECMAKE_SOURCEPATH = "${ZEPHYR_SRC_DIR}"
 
 do_deploy () {
     install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.elf ${DEPLOYDIR}/${PN}.elf
+    install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.hex ${DEPLOYDIR}/${PN}.hex
 }
 
 addtask deploy after do_compile
-- 
2.25.1


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

* Re: [yocto] [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass: support for flashing via pyocd
  2020-12-06 20:15 ` [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass: support for flashing via pyocd Wojciech Zmuda
@ 2020-12-07 12:06   ` Naveen Saini
  2020-12-08  1:47     ` Naveen Saini
  0 siblings, 1 reply; 12+ messages in thread
From: Naveen Saini @ 2020-12-07 12:06 UTC (permalink / raw)
  To: Wojciech Zmuda, yocto
  Cc: davide.ricci, zbigniew.bodek, jaroslaw.marek, robert.drab,
	Wojciech Zmuda

Thanks for the patches.  Please find my comments below.

-----Original Message-----
From: yocto@lists.yoctoproject.org <yocto@lists.yoctoproject.org> On Behalf Of Wojciech Zmuda
Sent: Monday, December 7, 2020 4:15 AM
To: yocto@lists.yoctoproject.org
Cc: davide.ricci@huawei.com; zbigniew.bodek@huawei.com; jaroslaw.marek@huawei.com; robert.drab@huawei.com; Wojciech Zmuda <wojciech.zmuda@huawei.com>
Subject: [yocto] [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass: support for flashing via pyocd

Flash boards supported via pyocd:

    MACHINE=xxx bitbake yyy -c flash_usb

The only supported board for now is 96Boards Nitrogen. Modify its config accordingly.

Modify helloworld and philosopers samples with adidtional .hex output file deployment, as this format is required by pyocd.

Describe the feature in README.

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

diff --git a/README.txt b/README.txt
index 6463339..4366764 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
[Naveen Saini] Typo here, MACHINE=96b-nitrogen
+
+call similar command with explicit flash_usb command:
+
+    $ MACHINE=96b_nitrogen bitbake zephyr-philosophers -c flash_usb
[Naveen Saini]  Same as above

+
+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..aafe9e7
--- /dev/null
+++ b/classes/zephyr-flash-pyocd.bbclass
@@ -0,0 +1,17 @@
+
+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')}.hex"
+    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"
diff --git a/recipes-kernel/zephyr-kernel/zephyr-helloworld.bb b/recipes-kernel/zephyr-kernel/zephyr-helloworld.bb
index 1400e72..9b77975 100644
--- a/recipes-kernel/zephyr-kernel/zephyr-helloworld.bb
+++ b/recipes-kernel/zephyr-kernel/zephyr-helloworld.bb
@@ -8,6 +8,7 @@ OECMAKE_SOURCEPATH = "${ZEPHYR_SRC_DIR}"
 
 do_deploy () {
     install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.elf ${DEPLOYDIR}/${PN}.elf
+    install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.hex 
+ ${DEPLOYDIR}/${PN}.hex
 }
[Naveen Saini]  No *.hex file while building for MACHINE=qemu-x86
 Error log:  ...build/zephyr/zephyr.hex': No such file or directory


 addtask deploy after do_compile
diff --git a/recipes-kernel/zephyr-kernel/zephyr-philosophers.bb b/recipes-kernel/zephyr-kernel/zephyr-philosophers.bb
index 5f7fbcb..f720999 100644
--- a/recipes-kernel/zephyr-kernel/zephyr-philosophers.bb
+++ b/recipes-kernel/zephyr-kernel/zephyr-philosophers.bb
@@ -8,6 +8,7 @@ OECMAKE_SOURCEPATH = "${ZEPHYR_SRC_DIR}"
 
 do_deploy () {
     install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.elf ${DEPLOYDIR}/${PN}.elf
+    install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.hex 
+ ${DEPLOYDIR}/${PN}.hex
 }
 
[Naveen Saini]  No *.hex file while building for MACHINE=qemu-x86
 Error log:  ...build/zephyr/zephyr.hex': No such file or directory

Could you also try to build testcases !!
$ MACHINE=96b-nitrogen bitbake zephyr-kernel-test-all

Build breaks with error: ......build/zephyr/zephyr.elf.elf': No such file or directory

 addtask deploy after do_compile
--
2.25.1


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

* Re: [yocto] [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass: support for flashing via pyocd
  2020-12-07 12:06   ` [yocto] " Naveen Saini
@ 2020-12-08  1:47     ` Naveen Saini
  2020-12-08 10:16       ` Wojciech Zmuda
  2020-12-09 15:07       ` Wojciech Zmuda
  0 siblings, 2 replies; 12+ messages in thread
From: Naveen Saini @ 2020-12-08  1:47 UTC (permalink / raw)
  To: Wojciech Zmuda, yocto
  Cc: davide.ricci, zbigniew.bodek, jaroslaw.marek, robert.drab,
	Wojciech Zmuda

You have missed few of my comments in v2 !

Regards,
Naveen

-----Original Message-----
From: Saini, Naveen Kumar 
Sent: Monday, December 7, 2020 8:06 PM
To: 'Wojciech Zmuda' <zmuda.w@gmail.com>; yocto@lists.yoctoproject.org
Cc: davide.ricci@huawei.com; zbigniew.bodek@huawei.com; jaroslaw.marek@huawei.com; robert.drab@huawei.com; Wojciech Zmuda <wojciech.zmuda@huawei.com>
Subject: RE: [yocto] [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass: support for flashing via pyocd

Thanks for the patches.  Please find my comments below.

-----Original Message-----
From: yocto@lists.yoctoproject.org <yocto@lists.yoctoproject.org> On Behalf Of Wojciech Zmuda
Sent: Monday, December 7, 2020 4:15 AM
To: yocto@lists.yoctoproject.org
Cc: davide.ricci@huawei.com; zbigniew.bodek@huawei.com; jaroslaw.marek@huawei.com; robert.drab@huawei.com; Wojciech Zmuda <wojciech.zmuda@huawei.com>
Subject: [yocto] [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass: support for flashing via pyocd

Flash boards supported via pyocd:

    MACHINE=xxx bitbake yyy -c flash_usb

The only supported board for now is 96Boards Nitrogen. Modify its config accordingly.

Modify helloworld and philosopers samples with adidtional .hex output file deployment, as this format is required by pyocd.

Describe the feature in README.

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

diff --git a/README.txt b/README.txt
index 6463339..4366764 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
[Naveen Saini] Typo here, MACHINE=96b-nitrogen
+
+call similar command with explicit flash_usb command:
+
+    $ MACHINE=96b_nitrogen bitbake zephyr-philosophers -c flash_usb
[Naveen Saini]  Same as above

+
+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..aafe9e7
--- /dev/null
+++ b/classes/zephyr-flash-pyocd.bbclass
@@ -0,0 +1,17 @@
+
+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')}.hex"
+    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"
diff --git a/recipes-kernel/zephyr-kernel/zephyr-helloworld.bb b/recipes-kernel/zephyr-kernel/zephyr-helloworld.bb
index 1400e72..9b77975 100644
--- a/recipes-kernel/zephyr-kernel/zephyr-helloworld.bb
+++ b/recipes-kernel/zephyr-kernel/zephyr-helloworld.bb
@@ -8,6 +8,7 @@ OECMAKE_SOURCEPATH = "${ZEPHYR_SRC_DIR}"
 
 do_deploy () {
     install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.elf ${DEPLOYDIR}/${PN}.elf
+    install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.hex
+ ${DEPLOYDIR}/${PN}.hex
 }
[Naveen Saini]  No *.hex file while building for MACHINE=qemu-x86  Error log:  ...build/zephyr/zephyr.hex': No such file or directory


 addtask deploy after do_compile
diff --git a/recipes-kernel/zephyr-kernel/zephyr-philosophers.bb b/recipes-kernel/zephyr-kernel/zephyr-philosophers.bb
index 5f7fbcb..f720999 100644
--- a/recipes-kernel/zephyr-kernel/zephyr-philosophers.bb
+++ b/recipes-kernel/zephyr-kernel/zephyr-philosophers.bb
@@ -8,6 +8,7 @@ OECMAKE_SOURCEPATH = "${ZEPHYR_SRC_DIR}"
 
 do_deploy () {
     install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.elf ${DEPLOYDIR}/${PN}.elf
+    install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.hex
+ ${DEPLOYDIR}/${PN}.hex
 }
 
[Naveen Saini]  No *.hex file while building for MACHINE=qemu-x86  Error log:  ...build/zephyr/zephyr.hex': No such file or directory

Could you also try to build testcases !!
$ MACHINE=96b-nitrogen bitbake zephyr-kernel-test-all

Build breaks with error: ......build/zephyr/zephyr.elf.elf': No such file or directory

 addtask deploy after do_compile
--
2.25.1


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

* Re: [yocto] [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass: support for flashing via pyocd
  2020-12-08  1:47     ` Naveen Saini
@ 2020-12-08 10:16       ` Wojciech Zmuda
  2020-12-09 15:07       ` Wojciech Zmuda
  1 sibling, 0 replies; 12+ messages in thread
From: Wojciech Zmuda @ 2020-12-08 10:16 UTC (permalink / raw)
  To: Saini, Naveen Kumar; +Cc: yocto

[-- Attachment #1: Type: text/plain, Size: 6233 bytes --]

Hi Naveen,

You're right, I'm sorry. I didn't notice the rest of your comments. I'll
take care of it and will push v3 today with the rest of the changes.

Best regards,
Wojciech

On Tue, 8 Dec 2020 at 02:47, Saini, Naveen Kumar <
naveen.kumar.saini@intel.com> wrote:

> You have missed few of my comments in v2 !
>
> Regards,
> Naveen
>
> -----Original Message-----
> From: Saini, Naveen Kumar
> Sent: Monday, December 7, 2020 8:06 PM
> To: 'Wojciech Zmuda' <zmuda.w@gmail.com>; yocto@lists.yoctoproject.org
> Cc: davide.ricci@huawei.com; zbigniew.bodek@huawei.com;
> jaroslaw.marek@huawei.com; robert.drab@huawei.com; Wojciech Zmuda <
> wojciech.zmuda@huawei.com>
> Subject: RE: [yocto] [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass:
> support for flashing via pyocd
>
> Thanks for the patches.  Please find my comments below.
>
> -----Original Message-----
> From: yocto@lists.yoctoproject.org <yocto@lists.yoctoproject.org> On
> Behalf Of Wojciech Zmuda
> Sent: Monday, December 7, 2020 4:15 AM
> To: yocto@lists.yoctoproject.org
> Cc: davide.ricci@huawei.com; zbigniew.bodek@huawei.com;
> jaroslaw.marek@huawei.com; robert.drab@huawei.com; Wojciech Zmuda <
> wojciech.zmuda@huawei.com>
> Subject: [yocto] [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass:
> support for flashing via pyocd
>
> Flash boards supported via pyocd:
>
>     MACHINE=xxx bitbake yyy -c flash_usb
>
> The only supported board for now is 96Boards Nitrogen. Modify its config
> accordingly.
>
> Modify helloworld and philosopers samples with adidtional .hex output file
> deployment, as this format is required by pyocd.
>
> Describe the feature in README.
>
> Signed-off-by: Wojciech Zmuda <wojciech.zmuda@huawei.com>
> ---
>  README.txt                                    | 23 +++++++++++++++++++
>  classes/zephyr-flash-pyocd.bbclass            | 17 ++++++++++++++
>  conf/machine/96b-nitrogen.conf                |  1 +
>  .../zephyr-kernel/zephyr-helloworld.bb        |  1 +
>  .../zephyr-kernel/zephyr-philosophers.bb      |  1 +
>  5 files changed, 43 insertions(+)
>  create mode 100644 classes/zephyr-flash-pyocd.bbclass
>
> diff --git a/README.txt b/README.txt
> index 6463339..4366764 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
> [Naveen Saini] Typo here, MACHINE=96b-nitrogen
> +
> +call similar command with explicit flash_usb command:
> +
> +    $ MACHINE=96b_nitrogen bitbake zephyr-philosophers -c flash_usb
> [Naveen Saini]  Same as above
>
> +
> +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..aafe9e7
> --- /dev/null
> +++ b/classes/zephyr-flash-pyocd.bbclass
> @@ -0,0 +1,17 @@
> +
> +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')}.hex"
> +    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"
> diff --git a/recipes-kernel/zephyr-kernel/zephyr-helloworld.bb
> b/recipes-kernel/zephyr-kernel/zephyr-helloworld.bb
> index 1400e72..9b77975 100644
> --- a/recipes-kernel/zephyr-kernel/zephyr-helloworld.bb
> +++ b/recipes-kernel/zephyr-kernel/zephyr-helloworld.bb
> @@ -8,6 +8,7 @@ OECMAKE_SOURCEPATH = "${ZEPHYR_SRC_DIR}"
>
>  do_deploy () {
>      install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.elf
> ${DEPLOYDIR}/${PN}.elf
> +    install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.hex
> + ${DEPLOYDIR}/${PN}.hex
>  }
> [Naveen Saini]  No *.hex file while building for MACHINE=qemu-x86  Error
> log:  ...build/zephyr/zephyr.hex': No such file or directory
>
>
>  addtask deploy after do_compile
> diff --git a/recipes-kernel/zephyr-kernel/zephyr-philosophers.bb
> b/recipes-kernel/zephyr-kernel/zephyr-philosophers.bb
> index 5f7fbcb..f720999 100644
> --- a/recipes-kernel/zephyr-kernel/zephyr-philosophers.bb
> +++ b/recipes-kernel/zephyr-kernel/zephyr-philosophers.bb
> @@ -8,6 +8,7 @@ OECMAKE_SOURCEPATH = "${ZEPHYR_SRC_DIR}"
>
>  do_deploy () {
>      install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.elf
> ${DEPLOYDIR}/${PN}.elf
> +    install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.hex
> + ${DEPLOYDIR}/${PN}.hex
>  }
>
> [Naveen Saini]  No *.hex file while building for MACHINE=qemu-x86  Error
> log:  ...build/zephyr/zephyr.hex': No such file or directory
>
> Could you also try to build testcases !!
> $ MACHINE=96b-nitrogen bitbake zephyr-kernel-test-all
>
> Build breaks with error: ......build/zephyr/zephyr.elf.elf': No such file
> or directory
>
>  addtask deploy after do_compile
> --
> 2.25.1
>
>

[-- Attachment #2: Type: text/html, Size: 8984 bytes --]

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

* Re: [yocto] [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass: support for flashing via pyocd
  2020-12-08  1:47     ` Naveen Saini
  2020-12-08 10:16       ` Wojciech Zmuda
@ 2020-12-09 15:07       ` Wojciech Zmuda
       [not found]         ` <0637042547e547ffb5f8f351afe5aeba@intel.com>
  1 sibling, 1 reply; 12+ messages in thread
From: Wojciech Zmuda @ 2020-12-09 15:07 UTC (permalink / raw)
  To: Saini, Naveen Kumar; +Cc: yocto

[-- Attachment #1: Type: text/plain, Size: 7294 bytes --]

Hi Naveen,

I fixed the missing .hex issue and I'm ready to send v3.

I also experimented with your last suggestion, i.e. building test cases
with MACHINE=96b-nitrogen and I observed the following:

It is possible to build when I provide IMGDEPLOYDIR variable somewhere,
e.g. in 96b-nitrogen.conf. However, for other platforms, this variable is
provided only in classes/zephyr-qemuboot.bbclass. I've also tried to build
test cases for arduino-101-ble and it failed with the following reason:

    Error, the PACKAGE_ARCHS variable (all any noarch
${PACKAGE_EXTRA_ARCHS_tune-armv6m} cortexm0-vfp arduino_101_ble) for
DEFAULTTUNE (cortexm0) does not contain TUNE_PKGARCH (cortexm0t2-vfp).

Additionally, when I provided IMGDEPLOYDIR in 96b-nitrogen.conf, I tried to
execute test cases with -c testimage. It failed on running qemu.

According to my observations, my understanding is that the test cases are
currently designed for being verified on qemu. Do you expect the
96b-nitrogen support to contain automatic test cases execution on the
hardware, or just the possibility of building? If it just the matter of
building the .elf files (you can flash them manually), then I can push v3
today.

Best regards,
Wojciech


On Tue, 8 Dec 2020 at 02:47, Saini, Naveen Kumar <
naveen.kumar.saini@intel.com> wrote:

> You have missed few of my comments in v2 !
>
> Regards,
> Naveen
>
> -----Original Message-----
> From: Saini, Naveen Kumar
> Sent: Monday, December 7, 2020 8:06 PM
> To: 'Wojciech Zmuda' <zmuda.w@gmail.com>; yocto@lists.yoctoproject.org
> Cc: davide.ricci@huawei.com; zbigniew.bodek@huawei.com;
> jaroslaw.marek@huawei.com; robert.drab@huawei.com; Wojciech Zmuda <
> wojciech.zmuda@huawei.com>
> Subject: RE: [yocto] [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass:
> support for flashing via pyocd
>
> Thanks for the patches.  Please find my comments below.
>
> -----Original Message-----
> From: yocto@lists.yoctoproject.org <yocto@lists.yoctoproject.org> On
> Behalf Of Wojciech Zmuda
> Sent: Monday, December 7, 2020 4:15 AM
> To: yocto@lists.yoctoproject.org
> Cc: davide.ricci@huawei.com; zbigniew.bodek@huawei.com;
> jaroslaw.marek@huawei.com; robert.drab@huawei.com; Wojciech Zmuda <
> wojciech.zmuda@huawei.com>
> Subject: [yocto] [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass:
> support for flashing via pyocd
>
> Flash boards supported via pyocd:
>
>     MACHINE=xxx bitbake yyy -c flash_usb
>
> The only supported board for now is 96Boards Nitrogen. Modify its config
> accordingly.
>
> Modify helloworld and philosopers samples with adidtional .hex output file
> deployment, as this format is required by pyocd.
>
> Describe the feature in README.
>
> Signed-off-by: Wojciech Zmuda <wojciech.zmuda@huawei.com>
> ---
>  README.txt                                    | 23 +++++++++++++++++++
>  classes/zephyr-flash-pyocd.bbclass            | 17 ++++++++++++++
>  conf/machine/96b-nitrogen.conf                |  1 +
>  .../zephyr-kernel/zephyr-helloworld.bb        |  1 +
>  .../zephyr-kernel/zephyr-philosophers.bb      |  1 +
>  5 files changed, 43 insertions(+)
>  create mode 100644 classes/zephyr-flash-pyocd.bbclass
>
> diff --git a/README.txt b/README.txt
> index 6463339..4366764 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
> [Naveen Saini] Typo here, MACHINE=96b-nitrogen
> +
> +call similar command with explicit flash_usb command:
> +
> +    $ MACHINE=96b_nitrogen bitbake zephyr-philosophers -c flash_usb
> [Naveen Saini]  Same as above
>
> +
> +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..aafe9e7
> --- /dev/null
> +++ b/classes/zephyr-flash-pyocd.bbclass
> @@ -0,0 +1,17 @@
> +
> +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')}.hex"
> +    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"
> diff --git a/recipes-kernel/zephyr-kernel/zephyr-helloworld.bb
> b/recipes-kernel/zephyr-kernel/zephyr-helloworld.bb
> index 1400e72..9b77975 100644
> --- a/recipes-kernel/zephyr-kernel/zephyr-helloworld.bb
> +++ b/recipes-kernel/zephyr-kernel/zephyr-helloworld.bb
> @@ -8,6 +8,7 @@ OECMAKE_SOURCEPATH = "${ZEPHYR_SRC_DIR}"
>
>  do_deploy () {
>      install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.elf
> ${DEPLOYDIR}/${PN}.elf
> +    install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.hex
> + ${DEPLOYDIR}/${PN}.hex
>  }
> [Naveen Saini]  No *.hex file while building for MACHINE=qemu-x86  Error
> log:  ...build/zephyr/zephyr.hex': No such file or directory
>
>
>  addtask deploy after do_compile
> diff --git a/recipes-kernel/zephyr-kernel/zephyr-philosophers.bb
> b/recipes-kernel/zephyr-kernel/zephyr-philosophers.bb
> index 5f7fbcb..f720999 100644
> --- a/recipes-kernel/zephyr-kernel/zephyr-philosophers.bb
> +++ b/recipes-kernel/zephyr-kernel/zephyr-philosophers.bb
> @@ -8,6 +8,7 @@ OECMAKE_SOURCEPATH = "${ZEPHYR_SRC_DIR}"
>
>  do_deploy () {
>      install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.elf
> ${DEPLOYDIR}/${PN}.elf
> +    install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.hex
> + ${DEPLOYDIR}/${PN}.hex
>  }
>
> [Naveen Saini]  No *.hex file while building for MACHINE=qemu-x86  Error
> log:  ...build/zephyr/zephyr.hex': No such file or directory
>
> Could you also try to build testcases !!
> $ MACHINE=96b-nitrogen bitbake zephyr-kernel-test-all
>
> Build breaks with error: ......build/zephyr/zephyr.elf.elf': No such file
> or directory
>
>  addtask deploy after do_compile
> --
> 2.25.1
>
>

[-- Attachment #2: Type: text/html, Size: 10155 bytes --]

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

* Re: [yocto] [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass: support for flashing via pyocd
       [not found]         ` <0637042547e547ffb5f8f351afe5aeba@intel.com>
@ 2020-12-10 16:09           ` Wojciech Zmuda
  2020-12-14  0:12             ` Naveen Saini
  0 siblings, 1 reply; 12+ messages in thread
From: Wojciech Zmuda @ 2020-12-10 16:09 UTC (permalink / raw)
  To: Saini, Naveen Kumar; +Cc: yocto

[-- Attachment #1: Type: text/plain, Size: 8835 bytes --]

Hi Naveen,

I investigated the arduino-101-ble problem and for me it's non trivial to
fix. It's not related to the same missing variable that I spotted in the
Nitrogen case, but rather there are some inconsistencies with
architecture-related variables i.e. PACKAGE_ARCHS and TUNE_xxx. I did not
find any way to fix it.

For now I pushed v3 with Nitrogen support. If I find a way to straighten
out the Arduino case, I'll push a separate patch set for that.

BTW, I also have 96boards Avenger96 support patch set ready. It depends on
one commit from the Nitrogen patch set (Cortex-M4 tune), so I'll send it
out right after Nitrogen support is merged.

Regards,
Wojciech

On Thu, 10 Dec 2020 at 08:20, Saini, Naveen Kumar <
naveen.kumar.saini@intel.com> wrote:

> Hi Wojciech,
>
>
>
> Yes, testcases are currently being verified only on qemu, so if we can
> just build testcases for now that should be sufficient. If you are able to
> flash and execute tests manually on HW, that would work. Please send v3.
>
>
>
> Can you fix for arduino-101-ble  as well ?
>
>
>
> Naveen
>
>
>
> *From:* Wojciech Żmuda <zmuda.w@gmail.com>
> *Sent:* Wednesday, December 9, 2020 11:07 PM
> *To:* Saini, Naveen Kumar <naveen.kumar.saini@intel.com>
> *Cc:* yocto@lists.yoctoproject.org
> *Subject:* Re: [yocto] [meta-zephyr][PATCH 5/5]
> zephyr-flash-pyocd.bbclass: support for flashing via pyocd
>
>
>
> Hi Naveen,
>
>
>
> I fixed the missing .hex issue and I'm ready to send v3.
>
>
>
> I also experimented with your last suggestion, i.e. building test cases
> with MACHINE=96b-nitrogen and I observed the following:
>
>
>
> It is possible to build when I provide IMGDEPLOYDIR variable somewhere,
> e.g. in 96b-nitrogen.conf. However, for other platforms, this variable is
> provided only in classes/zephyr-qemuboot.bbclass. I've also tried to build
> test cases for arduino-101-ble and it failed with the following reason:
>
>
>
>     Error, the PACKAGE_ARCHS variable (all any noarch
> ${PACKAGE_EXTRA_ARCHS_tune-armv6m} cortexm0-vfp arduino_101_ble) for
> DEFAULTTUNE (cortexm0) does not contain TUNE_PKGARCH (cortexm0t2-vfp).
>
>
>
> Additionally, when I provided IMGDEPLOYDIR in 96b-nitrogen.conf, I tried
> to execute test cases with -c testimage. It failed on running qemu.
>
>
>
> According to my observations, my understanding is that the test cases are
> currently designed for being verified on qemu. Do you expect the
> 96b-nitrogen support to contain automatic test cases execution on the
> hardware, or just the possibility of building? If it just the matter of
> building the .elf files (you can flash them manually), then I can push v3
> today.
>
>
>
> Best regards,
>
> Wojciech
>
>
>
>
>
> On Tue, 8 Dec 2020 at 02:47, Saini, Naveen Kumar <
> naveen.kumar.saini@intel.com> wrote:
>
> You have missed few of my comments in v2 !
>
> Regards,
> Naveen
>
> -----Original Message-----
> From: Saini, Naveen Kumar
> Sent: Monday, December 7, 2020 8:06 PM
> To: 'Wojciech Zmuda' <zmuda.w@gmail.com>; yocto@lists.yoctoproject.org
> Cc: davide.ricci@huawei.com; zbigniew.bodek@huawei.com;
> jaroslaw.marek@huawei.com; robert.drab@huawei.com; Wojciech Zmuda <
> wojciech.zmuda@huawei.com>
> Subject: RE: [yocto] [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass:
> support for flashing via pyocd
>
> Thanks for the patches.  Please find my comments below.
>
> -----Original Message-----
> From: yocto@lists.yoctoproject.org <yocto@lists.yoctoproject.org> On
> Behalf Of Wojciech Zmuda
> Sent: Monday, December 7, 2020 4:15 AM
> To: yocto@lists.yoctoproject.org
> Cc: davide.ricci@huawei.com; zbigniew.bodek@huawei.com;
> jaroslaw.marek@huawei.com; robert.drab@huawei.com; Wojciech Zmuda <
> wojciech.zmuda@huawei.com>
> Subject: [yocto] [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass:
> support for flashing via pyocd
>
> Flash boards supported via pyocd:
>
>     MACHINE=xxx bitbake yyy -c flash_usb
>
> The only supported board for now is 96Boards Nitrogen. Modify its config
> accordingly.
>
> Modify helloworld and philosopers samples with adidtional .hex output file
> deployment, as this format is required by pyocd.
>
> Describe the feature in README.
>
> Signed-off-by: Wojciech Zmuda <wojciech.zmuda@huawei.com>
> ---
>  README.txt                                    | 23 +++++++++++++++++++
>  classes/zephyr-flash-pyocd.bbclass            | 17 ++++++++++++++
>  conf/machine/96b-nitrogen.conf                |  1 +
>  .../zephyr-kernel/zephyr-helloworld.bb        |  1 +
>  .../zephyr-kernel/zephyr-philosophers.bb      |  1 +
>  5 files changed, 43 insertions(+)
>  create mode 100644 classes/zephyr-flash-pyocd.bbclass
>
> diff --git a/README.txt b/README.txt
> index 6463339..4366764 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
> [Naveen Saini] Typo here, MACHINE=96b-nitrogen
> +
> +call similar command with explicit flash_usb command:
> +
> +    $ MACHINE=96b_nitrogen bitbake zephyr-philosophers -c flash_usb
> [Naveen Saini]  Same as above
>
> +
> +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..aafe9e7
> --- /dev/null
> +++ b/classes/zephyr-flash-pyocd.bbclass
> @@ -0,0 +1,17 @@
> +
> +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')}.hex"
> +    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"
> diff --git a/recipes-kernel/zephyr-kernel/zephyr-helloworld.bb
> b/recipes-kernel/zephyr-kernel/zephyr-helloworld.bb
> index 1400e72..9b77975 100644
> --- a/recipes-kernel/zephyr-kernel/zephyr-helloworld.bb
> +++ b/recipes-kernel/zephyr-kernel/zephyr-helloworld.bb
> @@ -8,6 +8,7 @@ OECMAKE_SOURCEPATH = "${ZEPHYR_SRC_DIR}"
>
>  do_deploy () {
>      install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.elf
> ${DEPLOYDIR}/${PN}.elf
> +    install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.hex
> + ${DEPLOYDIR}/${PN}.hex
>  }
> [Naveen Saini]  No *.hex file while building for MACHINE=qemu-x86  Error
> log:  ...build/zephyr/zephyr.hex': No such file or directory
>
>
>  addtask deploy after do_compile
> diff --git a/recipes-kernel/zephyr-kernel/zephyr-philosophers.bb
> b/recipes-kernel/zephyr-kernel/zephyr-philosophers.bb
> index 5f7fbcb..f720999 100644
> --- a/recipes-kernel/zephyr-kernel/zephyr-philosophers.bb
> +++ b/recipes-kernel/zephyr-kernel/zephyr-philosophers.bb
> @@ -8,6 +8,7 @@ OECMAKE_SOURCEPATH = "${ZEPHYR_SRC_DIR}"
>
>  do_deploy () {
>      install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.elf
> ${DEPLOYDIR}/${PN}.elf
> +    install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.hex
> + ${DEPLOYDIR}/${PN}.hex
>  }
>
> [Naveen Saini]  No *.hex file while building for MACHINE=qemu-x86  Error
> log:  ...build/zephyr/zephyr.hex': No such file or directory
>
> Could you also try to build testcases !!
> $ MACHINE=96b-nitrogen bitbake zephyr-kernel-test-all
>
> Build breaks with error: ......build/zephyr/zephyr.elf.elf': No such file
> or directory
>
>  addtask deploy after do_compile
> --
> 2.25.1
>
>

[-- Attachment #2: Type: text/html, Size: 13959 bytes --]

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

* Re: [yocto] [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass: support for flashing via pyocd
  2020-12-10 16:09           ` Wojciech Zmuda
@ 2020-12-14  0:12             ` Naveen Saini
  0 siblings, 0 replies; 12+ messages in thread
From: Naveen Saini @ 2020-12-14  0:12 UTC (permalink / raw)
  To: Wojciech Żmuda; +Cc: yocto

[-- Attachment #1: Type: text/plain, Size: 9637 bytes --]

Merged. Thank you for patches.

Regards,
Naveen

From: Wojciech Żmuda <zmuda.w@gmail.com>
Sent: Friday, December 11, 2020 12:09 AM
To: Saini, Naveen Kumar <naveen.kumar.saini@intel.com>
Cc: yocto@lists.yoctoproject.org
Subject: Re: [yocto] [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass: support for flashing via pyocd

Hi Naveen,

I investigated the arduino-101-ble problem and for me it's non trivial to fix. It's not related to the same missing variable that I spotted in the Nitrogen case, but rather there are some inconsistencies with architecture-related variables i.e. PACKAGE_ARCHS and TUNE_xxx. I did not find any way to fix it.

For now I pushed v3 with Nitrogen support. If I find a way to straighten out the Arduino case, I'll push a separate patch set for that.

BTW, I also have 96boards Avenger96 support patch set ready. It depends on one commit from the Nitrogen patch set (Cortex-M4 tune), so I'll send it out right after Nitrogen support is merged.

Regards,
Wojciech

On Thu, 10 Dec 2020 at 08:20, Saini, Naveen Kumar <naveen.kumar.saini@intel.com<mailto:naveen.kumar.saini@intel.com>> wrote:
Hi Wojciech,

Yes, testcases are currently being verified only on qemu, so if we can just build testcases for now that should be sufficient. If you are able to flash and execute tests manually on HW, that would work. Please send v3.

Can you fix for arduino-101-ble  as well ?

Naveen

From: Wojciech Żmuda <zmuda.w@gmail.com<mailto:zmuda.w@gmail.com>>
Sent: Wednesday, December 9, 2020 11:07 PM
To: Saini, Naveen Kumar <naveen.kumar.saini@intel.com<mailto:naveen.kumar.saini@intel.com>>
Cc: yocto@lists.yoctoproject.org<mailto:yocto@lists.yoctoproject.org>
Subject: Re: [yocto] [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass: support for flashing via pyocd

Hi Naveen,

I fixed the missing .hex issue and I'm ready to send v3.

I also experimented with your last suggestion, i.e. building test cases with MACHINE=96b-nitrogen and I observed the following:

It is possible to build when I provide IMGDEPLOYDIR variable somewhere, e.g. in 96b-nitrogen.conf. However, for other platforms, this variable is provided only in classes/zephyr-qemuboot.bbclass. I've also tried to build test cases for arduino-101-ble and it failed with the following reason:

    Error, the PACKAGE_ARCHS variable (all any noarch ${PACKAGE_EXTRA_ARCHS_tune-armv6m} cortexm0-vfp arduino_101_ble) for DEFAULTTUNE (cortexm0) does not contain TUNE_PKGARCH (cortexm0t2-vfp).

Additionally, when I provided IMGDEPLOYDIR in 96b-nitrogen.conf, I tried to execute test cases with -c testimage. It failed on running qemu.

According to my observations, my understanding is that the test cases are currently designed for being verified on qemu. Do you expect the 96b-nitrogen support to contain automatic test cases execution on the hardware, or just the possibility of building? If it just the matter of building the .elf files (you can flash them manually), then I can push v3 today.

Best regards,
Wojciech


On Tue, 8 Dec 2020 at 02:47, Saini, Naveen Kumar <naveen.kumar.saini@intel.com<mailto:naveen.kumar.saini@intel.com>> wrote:
You have missed few of my comments in v2 !

Regards,
Naveen

-----Original Message-----
From: Saini, Naveen Kumar
Sent: Monday, December 7, 2020 8:06 PM
To: 'Wojciech Zmuda' <zmuda.w@gmail.com<mailto:zmuda.w@gmail.com>>; yocto@lists.yoctoproject.org<mailto:yocto@lists.yoctoproject.org>
Cc: davide.ricci@huawei.com<mailto:davide.ricci@huawei.com>; zbigniew.bodek@huawei.com<mailto:zbigniew.bodek@huawei.com>; jaroslaw.marek@huawei.com<mailto:jaroslaw.marek@huawei.com>; robert.drab@huawei.com<mailto:robert.drab@huawei.com>; Wojciech Zmuda <wojciech.zmuda@huawei.com<mailto:wojciech.zmuda@huawei.com>>
Subject: RE: [yocto] [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass: support for flashing via pyocd

Thanks for the patches.  Please find my comments below.

-----Original Message-----
From: yocto@lists.yoctoproject.org<mailto:yocto@lists.yoctoproject.org> <yocto@lists.yoctoproject.org<mailto:yocto@lists.yoctoproject.org>> On Behalf Of Wojciech Zmuda
Sent: Monday, December 7, 2020 4:15 AM
To: yocto@lists.yoctoproject.org<mailto:yocto@lists.yoctoproject.org>
Cc: davide.ricci@huawei.com<mailto:davide.ricci@huawei.com>; zbigniew.bodek@huawei.com<mailto:zbigniew.bodek@huawei.com>; jaroslaw.marek@huawei.com<mailto:jaroslaw.marek@huawei.com>; robert.drab@huawei.com<mailto:robert.drab@huawei.com>; Wojciech Zmuda <wojciech.zmuda@huawei.com<mailto:wojciech.zmuda@huawei.com>>
Subject: [yocto] [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass: support for flashing via pyocd

Flash boards supported via pyocd:

    MACHINE=xxx bitbake yyy -c flash_usb

The only supported board for now is 96Boards Nitrogen. Modify its config accordingly.

Modify helloworld and philosopers samples with adidtional .hex output file deployment, as this format is required by pyocd.

Describe the feature in README.

Signed-off-by: Wojciech Zmuda <wojciech.zmuda@huawei.com<mailto:wojciech.zmuda@huawei.com>>
---
 README.txt                                    | 23 +++++++++++++++++++
 classes/zephyr-flash-pyocd.bbclass            | 17 ++++++++++++++
 conf/machine/96b-nitrogen.conf                |  1 +
 .../zephyr-kernel/zephyr-helloworld.bb<http://zephyr-helloworld.bb>        |  1 +
 .../zephyr-kernel/zephyr-philosophers.bb<http://zephyr-philosophers.bb>      |  1 +
 5 files changed, 43 insertions(+)
 create mode 100644 classes/zephyr-flash-pyocd.bbclass

diff --git a/README.txt b/README.txt
index 6463339..4366764 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
[Naveen Saini] Typo here, MACHINE=96b-nitrogen
+
+call similar command with explicit flash_usb command:
+
+    $ MACHINE=96b_nitrogen bitbake zephyr-philosophers -c flash_usb
[Naveen Saini]  Same as above

+
+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..aafe9e7
--- /dev/null
+++ b/classes/zephyr-flash-pyocd.bbclass
@@ -0,0 +1,17 @@
+
+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')}.hex"
+    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"
diff --git a/recipes-kernel/zephyr-kernel/zephyr-helloworld.bb<http://zephyr-helloworld.bb> b/recipes-kernel/zephyr-kernel/zephyr-helloworld.bb<http://zephyr-helloworld.bb>
index 1400e72..9b77975 100644
--- a/recipes-kernel/zephyr-kernel/zephyr-helloworld.bb<http://zephyr-helloworld.bb>
+++ b/recipes-kernel/zephyr-kernel/zephyr-helloworld.bb<http://zephyr-helloworld.bb>
@@ -8,6 +8,7 @@ OECMAKE_SOURCEPATH = "${ZEPHYR_SRC_DIR}"

 do_deploy () {
     install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.elf ${DEPLOYDIR}/${PN}.elf
+    install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.hex
+ ${DEPLOYDIR}/${PN}.hex
 }
[Naveen Saini]  No *.hex file while building for MACHINE=qemu-x86  Error log:  ...build/zephyr/zephyr.hex': No such file or directory


 addtask deploy after do_compile
diff --git a/recipes-kernel/zephyr-kernel/zephyr-philosophers.bb<http://zephyr-philosophers.bb> b/recipes-kernel/zephyr-kernel/zephyr-philosophers.bb<http://zephyr-philosophers.bb>
index 5f7fbcb..f720999 100644
--- a/recipes-kernel/zephyr-kernel/zephyr-philosophers.bb<http://zephyr-philosophers.bb>
+++ b/recipes-kernel/zephyr-kernel/zephyr-philosophers.bb<http://zephyr-philosophers.bb>
@@ -8,6 +8,7 @@ OECMAKE_SOURCEPATH = "${ZEPHYR_SRC_DIR}"

 do_deploy () {
     install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.elf ${DEPLOYDIR}/${PN}.elf
+    install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.hex
+ ${DEPLOYDIR}/${PN}.hex
 }

[Naveen Saini]  No *.hex file while building for MACHINE=qemu-x86  Error log:  ...build/zephyr/zephyr.hex': No such file or directory

Could you also try to build testcases !!
$ MACHINE=96b-nitrogen bitbake zephyr-kernel-test-all

Build breaks with error: ......build/zephyr/zephyr.elf.elf': No such file or directory

 addtask deploy after do_compile
--
2.25.1

[-- Attachment #2: Type: text/html, Size: 19396 bytes --]

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

end of thread, other threads:[~2020-12-14  0:12 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-06 20:15 [meta-zephyr][PATCH 0/5] Add 96Boards Nitrogen support zmuda.w
2020-12-06 20:15 ` [meta-zephyr][PATCH 1/5] zephyr-kernel: clone Nordic HAL Wojciech Zmuda
2020-12-06 20:15 ` [meta-zephyr][PATCH 2/5] conf: machine: add support for Nordic nRF52832 Cortex-M4 chip Wojciech Zmuda
2020-12-06 20:15 ` [meta-zephyr][PATCH 3/5] conf: machine: add 96boards Nitrogen support Wojciech Zmuda
2020-12-06 20:15 ` [meta-zephyr][PATCH 4/5] zephyr-kernel: don't limit deploy to .elf file Wojciech Zmuda
2020-12-06 20:15 ` [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass: support for flashing via pyocd Wojciech Zmuda
2020-12-07 12:06   ` [yocto] " Naveen Saini
2020-12-08  1:47     ` Naveen Saini
2020-12-08 10:16       ` Wojciech Zmuda
2020-12-09 15:07       ` Wojciech Zmuda
     [not found]         ` <0637042547e547ffb5f8f351afe5aeba@intel.com>
2020-12-10 16:09           ` Wojciech Zmuda
2020-12-14  0:12             ` Naveen Saini

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.