Re: [yocto] [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass: support for flashing via pyocd

2020-12-13 Thread Naveen Saini
Merged. Thank you for patches.

Regards,
Naveen

From: Wojciech Żmuda 
Sent: Friday, December 11, 2020 12:09 AM
To: Saini, Naveen Kumar 
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 
mailto:naveen.kumar.sa...@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 mailto:zmud...@gmail.com>>
Sent: Wednesday, December 9, 2020 11:07 PM
To: Saini, Naveen Kumar 
mailto:naveen.kumar.sa...@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 
mailto:naveen.kumar.sa...@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' mailto:zmud...@gmail.com>>; 
yocto@lists.yoctoproject.org<mailto:yocto@lists.yoctoproject.org>
Cc: davide.ri...@huawei.com<mailto:davide.ri...@huawei.com>; 
zbigniew.bo...@huawei.com<mailto:zbigniew.bo...@huawei.com>; 
jaroslaw.ma...@huawei.com<mailto:jaroslaw.ma...@huawei.com>; 
robert.d...@huawei.com<mailto:robert.d...@huawei.com>; Wojciech Zmuda 
mailto:wojciech.zm...@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> 
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.ri...@huawei.com<mailto:davide.ri...@huawei.com>; 
zbigniew.bo...@huawei.com<mailto:zbigniew.bo...@huawei.com>; 
jaroslaw.ma...@huawei.com<mailto:jaroslaw.ma...@huawei.com>; 
robert.d...@huawei.com<mailto:robert.d...@huawei.com>; Wojciech Zmuda 
mailto:wojciech.zm...@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 
mailto:wojciech.zm...@huawei.com>>
---
 README.txt| 23 +++
 classes/zeph

Re: [yocto] [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass: support for flashing via pyocd

2020-12-10 Thread Wojciech Zmuda
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.sa...@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 
> *Sent:* Wednesday, December 9, 2020 11:07 PM
> *To:* Saini, Naveen Kumar 
> *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.sa...@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' ; yocto@lists.yoctoproject.org
> Cc: davide.ri...@huawei.com; zbigniew.bo...@huawei.com;
> jaroslaw.ma...@huawei.com; robert.d...@huawei.com; Wojciech Zmuda <
> wojciech.zm...@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  On
> Behalf Of Wojciech Zmuda
> Sent: Monday, December 7, 2020 4:15 AM
> To: yocto@lists.yoctoproject.org
> Cc: davide.ri...@huawei.com; zbigniew.bo...@huawei.com;
> jaroslaw.ma...@huawei.com; robert.d...@huawei.com; Wojciech Zmuda <
> wojciech.zm...@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 
> ---
>  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

Re: [yocto] [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass: support for flashing via pyocd

2020-12-09 Thread Wojciech Zmuda
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.sa...@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' ; yocto@lists.yoctoproject.org
> Cc: davide.ri...@huawei.com; zbigniew.bo...@huawei.com;
> jaroslaw.ma...@huawei.com; robert.d...@huawei.com; Wojciech Zmuda <
> wojciech.zm...@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  On
> Behalf Of Wojciech Zmuda
> Sent: Monday, December 7, 2020 4:15 AM
> To: yocto@lists.yoctoproject.org
> Cc: davide.ri...@huawei.com; zbigniew.bo...@huawei.com;
> jaroslaw.ma...@huawei.com; robert.d...@huawei.com; Wojciech Zmuda <
> wojciech.zm...@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 
> ---
>  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 000..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"
> +  

Re: [yocto] [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass: support for flashing via pyocd

2020-12-08 Thread Wojciech Zmuda
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.sa...@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' ; yocto@lists.yoctoproject.org
> Cc: davide.ri...@huawei.com; zbigniew.bo...@huawei.com;
> jaroslaw.ma...@huawei.com; robert.d...@huawei.com; Wojciech Zmuda <
> wojciech.zm...@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  On
> Behalf Of Wojciech Zmuda
> Sent: Monday, December 7, 2020 4:15 AM
> To: yocto@lists.yoctoproject.org
> Cc: davide.ri...@huawei.com; zbigniew.bo...@huawei.com;
> jaroslaw.ma...@huawei.com; robert.d...@huawei.com; Wojciech Zmuda <
> wojciech.zm...@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 
> ---
>  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 000..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/recipe

Re: [yocto] [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass: support for flashing via pyocd

2020-12-07 Thread Naveen Saini
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' ; yocto@lists.yoctoproject.org
Cc: davide.ri...@huawei.com; zbigniew.bo...@huawei.com; 
jaroslaw.ma...@huawei.com; robert.d...@huawei.com; Wojciech Zmuda 

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  On Behalf Of 
Wojciech Zmuda
Sent: Monday, December 7, 2020 4:15 AM
To: yocto@lists.yoctoproject.org
Cc: davide.ri...@huawei.com; zbigniew.bo...@huawei.com; 
jaroslaw.ma...@huawei.com; robert.d...@huawei.com; Wojciech Zmuda 

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 
---
 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 000..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}.el

Re: [yocto] [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass: support for flashing via pyocd

2020-12-07 Thread Naveen Saini
Thanks for the patches.  Please find my comments below.

-Original Message-
From: yocto@lists.yoctoproject.org  On Behalf Of 
Wojciech Zmuda
Sent: Monday, December 7, 2020 4:15 AM
To: yocto@lists.yoctoproject.org
Cc: davide.ri...@huawei.com; zbigniew.bo...@huawei.com; 
jaroslaw.ma...@huawei.com; robert.d...@huawei.com; Wojciech Zmuda 

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 
---
 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 000..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_

[yocto] [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass: support for flashing via pyocd

2020-12-06 Thread 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 
---
 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 000..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


-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#51663): https://lists.yoctoproject.org/g/yocto/message/51663
Mute This Topic: https://lists.yoctoproject.org/mt/78763460/21656
Group Owner: yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-