summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWojciech Zmuda <wojciech.zmuda@huawei.com>2020-12-10 16:02:10 +0000
committerNaveen Saini <naveen.kumar.saini@intel.com>2020-12-14 08:16:12 +0800
commitb74dee01fc18854182c922089bd712f39bb3a9d5 (patch)
treef52c320b038487b41926d16d246ebbf9e05746bb
parent1247d07c6cf2b7d670cc9af407e4951bd72e4f26 (diff)
downloadmeta-zephyr-b74dee01fc18854182c922089bd712f39bb3a9d5.tar.gz
meta-zephyr-b74dee01fc18854182c922089bd712f39bb3a9d5.tar.bz2
meta-zephyr-b74dee01fc18854182c922089bd712f39bb3a9d5.zip
zephyr-flash-pyocd.bbclass: support for flashing via pyocd
Implement do_flash_usb for boards supported by pyocd: MACHINE=xxx bitbake yyy -c flash_usb Pyocd support abundance of boards, however for now this meta-layer supports only one board that can be flashed using pyocd, that is 96Boards Nitrogen. Describe the feature in README. Signed-off-by: Wojciech Zmuda <wojciech.zmuda@huawei.com> Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com>
-rw-r--r--README.txt23
-rw-r--r--classes/zephyr-flash-pyocd.bbclass16
-rw-r--r--conf/machine/96b-nitrogen.conf1
3 files changed, 40 insertions, 0 deletions
diff --git a/README.txt b/README.txt
index 6463339..bda872b 100644
--- a/README.txt
+++ b/README.txt
@@ -43,6 +43,29 @@ The same sample, for Nios2 image:
$ MACHINE=qemu-nios2 bitbake zephyr-philosophers
$ runqemu qemu-nios2
+Flashing
+=================================
+
+You can flash Zephyr samples to boards. Currently, the following MACHINEs
+are supported:
+ * DFU:
+ - arduino-101-sss
+ - arduino-101
+ - arduino-101-ble
+ * pyocd:
+ - 96b-nitrogen
+
+To flash the example you built with command e.g.
+
+ $ MACHINE=96b-nitrogen bitbake zephyr-philosophers
+
+call similar command with explicit flash_usb command:
+
+ $ MACHINE=96b-nitrogen bitbake zephyr-philosophers -c flash_usb
+
+dfu-util and/or pyocd need to be installed in your system. If you observe
+permission errors or the flashing process seem to hang, follow those instructions:
+https://github.com/pyocd/pyOCD/tree/master/udev
Building and Running Zephyr Tests
=================================
diff --git a/classes/zephyr-flash-pyocd.bbclass b/classes/zephyr-flash-pyocd.bbclass
new file mode 100644
index 0000000..04500af
--- /dev/null
+++ b/classes/zephyr-flash-pyocd.bbclass
@@ -0,0 +1,16 @@
+python do_flash_usb() {
+ from pyocd.core.helpers import ConnectHelper
+ from pyocd.flash.file_programmer import FileProgrammer
+
+ image = f"{d.getVar('DEPLOY_DIR_IMAGE')}/{d.getVar('PN')}.elf"
+ bb.plain(f"Attempting to flash {image} to board {d.getVar('BOARD')}")
+
+ with ConnectHelper.session_with_chosen_probe() as session:
+ FileProgrammer(session).program(image)
+ session.board.target.reset()
+}
+
+addtask do_flash_usb
+
+do_flash_usb[nostamp] = "1"
+do_flash_usb[vardepsexclude] = "BB_ORIGENV"
diff --git a/conf/machine/96b-nitrogen.conf b/conf/machine/96b-nitrogen.conf
index d1905f2..998db4c 100644
--- a/conf/machine/96b-nitrogen.conf
+++ b/conf/machine/96b-nitrogen.conf
@@ -4,4 +4,5 @@
#@DESCRIPTION: Machine configuration for 96Boards Nitrogen Board.
require conf/machine/include/nrf52832.inc
+ZEPHYR_INHERIT_CLASSES += "zephyr-flash-pyocd"
ARCH_96b-nitrogen = "arm"