From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by mx.groups.io with SMTP id smtpd.web10.6397.1607422575596756199 for ; Tue, 08 Dec 2020 02:16:15 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lwGE4wUP; spf=pass (domain: gmail.com, ip: 209.85.221.66, mailfrom: zmuda.w@gmail.com) Received: by mail-wr1-f66.google.com with SMTP id t4so15624260wrr.12 for ; Tue, 08 Dec 2020 02:16:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zqKfYQEeoQUBb8ufdIyGdLUnDUossdA3fpiWpgBi4to=; b=lwGE4wUPmy0yjmBs/Dxz1IdA/Fw9UzJEB8AcDKfvv1CejlxEKHJdWkYmn2g5B6Mpek HXMITHzYD7zi//UgExMKc7w7n3YKVIeCPDE4ti9VblHWftbppVTHKVLTWObR+Z2OaFac 3TVgcbKfpGZgWzL8f3JXwL8dMUxvoob9++H+ZbNtAYeScyaGpDwoqSbGsI5D9Beh9R8o 9fm4Hr3NV1KXtV3m7gAemXpLy8KyKWdxqI4vXoB+jGRkC1sj0nlmuob4WsR02qeZZpJr mkHE/+zF3v8OevFmFFTa1vV1fVT05IhVdCU5tazV32IO6unbyzET18sxQfmQy9ymiIO/ 6amw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zqKfYQEeoQUBb8ufdIyGdLUnDUossdA3fpiWpgBi4to=; b=e1OrVXgX8PARfLxdyxL216RvyqMjLZI22/4iCeyOUGt+k5qbU8kX9KLhvTGIL4xgbw c+9kX7vq0vK2nLkrJOoAqEdNOU6g5tkBrDd9AT87SUzuadScb6ZJHy8Zzkql8g3vsEb8 6sYUoZ31EsDbI9g5hR878f0xsvvdCg4BvNZQ1yh6Ak5t9tCAag+AL7H/ShNH/iRd6WYC hrQX8tezdNtEXmcn5Xtt8nFv1oQ5KtMKgdH3YjfQvYuWgq8zqum94ZZEi++de/KP8DUl twTkDtOVc7FJqi09OXHF6CImnpJCat5cnBSwL0EQ4d5DX27QjgJH3L1X+GKoFvO4Q9pe N76g== X-Gm-Message-State: AOAM532yhOSYBQfycCNAMieq6gMPVmaba46NeB8PDWAvGxloUsaNpg8L EJiU4VrcV2dnWe1v04/oK2OrFjcXlTUmwseycco= X-Google-Smtp-Source: ABdhPJz/cqyMVgABnODrR9yrvkwtAZ7IumjC4kQAtquQO1c74sAFoiOQRRSGQ0+GUHqEyeVvUuT1Uh8TjD7Av0E0vM4= X-Received: by 2002:a5d:4408:: with SMTP id z8mr24747966wrq.204.1607422574081; Tue, 08 Dec 2020 02:16:14 -0800 (PST) MIME-Version: 1.0 References: <20201206201521.3377-1-wojciech.zmuda@huawei.com> <20201206201521.3377-6-wojciech.zmuda@huawei.com> <7c9d12e428954c44964906065281af1e@intel.com> In-Reply-To: <7c9d12e428954c44964906065281af1e@intel.com> From: "Wojciech Zmuda" Date: Tue, 8 Dec 2020 11:16:03 +0100 Message-ID: Subject: Re: [yocto] [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass: support for flashing via pyocd To: "Saini, Naveen Kumar" Cc: "yocto@lists.yoctoproject.org" Content-Type: multipart/alternative; boundary="000000000000883aef05b5f13b46" --000000000000883aef05b5f13b46 Content-Type: text/plain; charset="UTF-8" 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' ; 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 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 > --- > 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 > > --000000000000883aef05b5f13b46 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Naveen,

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

Best regards,
Wojciech

On Tue, 8 Dec 202= 0 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.ric= ci@huawei.com; zbigniew.bodek@huawei.com; jaroslaw.marek@huawei.com; robert.drab@huawei.com; Wojci= ech Zmuda <wojciech.zmuda@huawei.com>
Subject: RE: [yocto] [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass: s= upport for flashing via pyocd

Thanks for the patches.=C2=A0 Please find my comments below.

-----Original Message-----
From: yoc= to@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.ric= ci@huawei.com; zbigniew.bodek@huawei.com; jaroslaw.marek@huawei.com; robert.drab@huawei.com; Wojci= ech Zmuda <wojciech.zmuda@huawei.com>
Subject: [yocto] [meta-zephyr][PATCH 5/5] zephyr-flash-pyocd.bbclass: suppo= rt for flashing via pyocd

Flash boards supported via pyocd:

=C2=A0 =C2=A0 MACHINE=3Dxxx bitbake yyy -c flash_usb

The only supported board for now is 96Boards Nitrogen. Modify its config ac= cordingly.

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>
---
=C2=A0README.txt=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | 23 +++= ++++++++++++++++
=C2=A0classes/zephyr-flash-pyocd.bbclass=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 | 17 ++++++++++++++
=C2=A0conf/machine/96b-nitrogen.conf=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 |=C2=A0 1 +
=C2=A0.../zephyr-kernel/zephyr-helloworld.bb=C2=A0 =C2=A0 =C2=A0 =C2= =A0 |=C2=A0 1 +
=C2=A0.../zephyr-kernel/zephyr-philosophers.bb=C2=A0 =C2=A0 =C2=A0 = |=C2=A0 1 +
=C2=A05 files changed, 43 insertions(+)
=C2=A0create 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:
=C2=A0 =C2=A0 =C2=A0$ MACHINE=3Dqemu-nios2 bitbake zephyr-philosophers
=C2=A0 =C2=A0 =C2=A0$ runqemu qemu-nios2

+Flashing
+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D
+
+You can flash Zephyr samples to boards. Currently, the following
+MACHINEs are supported:
+ * DFU:
+=C2=A0 - arduino_101_sss
+=C2=A0 - arduino_101
+=C2=A0 - arduino_101_ble
+ * pyocd:
+=C2=A0 - 96b_nitrogen
+
+To flash the example you built with command e.g.
+
+=C2=A0 =C2=A0 $ MACHINE=3D96b_nitrogen bitbake zephyr-philosophers
[Naveen Saini] Typo here, MACHINE=3D96b-nitrogen
+
+call similar command with explicit flash_usb command:
+
+=C2=A0 =C2=A0 $ MACHINE=3D96b_nitrogen bitbake zephyr-philosophers -c flas= h_usb
[Naveen Saini]=C2=A0 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 tho= se instructions:
+https://github.com/pyocd/pyOCD/tree/master/udev<= br>
=C2=A0Building and Running Zephyr Tests
=C2=A0=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
diff --git a/classes/zephyr-flash-pyocd.bbclass b/classes/zephyr-flash-pyoc= d.bbclass
new file mode 100644
index 0000000..aafe9e7
--- /dev/null
+++ b/classes/zephyr-flash-pyocd.bbclass
@@ -0,0 +1,17 @@
+
+python do_flash_usb() {
+=C2=A0 =C2=A0 from pyocd.core.helpers import ConnectHelper
+=C2=A0 =C2=A0 from pyocd.flash.file_programmer import FileProgrammer
+
+=C2=A0 =C2=A0 image =3D f"{d.getVar('DEPLOY_DIR_IMAGE')}/{d.g= etVar('PN')}.hex"
+=C2=A0 =C2=A0 bb.plain(f"Attempting to flash {image} to board
+ {d.getVar('BOARD')}")
+
+=C2=A0 =C2=A0 with ConnectHelper.session_with_chosen_probe() as session: +=C2=A0 =C2=A0 =C2=A0 =C2=A0 FileProgrammer(session).program(image)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 session.board.target.reset()
+}
+
+addtask do_flash_usb
+
+do_flash_usb[nostamp] =3D "1"
+do_flash_usb[vardepsexclude] =3D "BB_ORIGENV"
diff --git a/conf/machine/96b-nitrogen.conf b/conf/machine/96b-nitrogen.con= f index d1905f2..998db4c 100644
--- a/conf/machine/96b-nitrogen.conf
+++ b/conf/machine/96b-nitrogen.conf
@@ -4,4 +4,5 @@
=C2=A0#@DESCRIPTION: Machine configuration for 96Boards Nitrogen Board.

=C2=A0require conf/machine/include/nrf52832.inc
+ZEPHYR_INHERIT_CLASSES +=3D "zephyr-flash-pyocd"
=C2=A0ARCH_96b-nitrogen =3D "arm"
diff --git a/recipes-kernel/zephyr-kernel/zephyr-helloworld.bb b/reci= pes-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 =3D "${ZEPHYR_SRC_DIR}"

=C2=A0do_deploy () {
=C2=A0 =C2=A0 =C2=A0install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.elf ${DEPL= OYDIR}/${PN}.elf
+=C2=A0 =C2=A0 install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.hex
+ ${DEPLOYDIR}/${PN}.hex
=C2=A0}
[Naveen Saini]=C2=A0 No *.hex file while building for MACHINE=3Dqemu-x86=C2= =A0 Error log:=C2=A0 ...build/zephyr/zephyr.hex': No such file or direc= tory


=C2=A0addtask 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 =3D "${ZEPHYR_SRC_DIR}"

=C2=A0do_deploy () {
=C2=A0 =C2=A0 =C2=A0install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.elf ${DEPL= OYDIR}/${PN}.elf
+=C2=A0 =C2=A0 install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT}.hex
+ ${DEPLOYDIR}/${PN}.hex
=C2=A0}

[Naveen Saini]=C2=A0 No *.hex file while building for MACHINE=3Dqemu-x86=C2= =A0 Error log:=C2=A0 ...build/zephyr/zephyr.hex': No such file or direc= tory

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

Build breaks with error: ......build/zephyr/zephyr.elf.elf': No such fi= le or directory

=C2=A0addtask deploy after do_compile
--
2.25.1

--000000000000883aef05b5f13b46--