Implement a class allowing flashing Arduino-101 using dfu-util. User needs to have dfu-utils installed on the host machine. All tree cores supported (x86, ARM, ARC)
Sample usage: $ MACHINE=arduino-101 bitbake xxx $ MACHINE=arduino-101 bitbake xxx -c flash_usb Signed-off-by: Juro Bystricky <juro.bystri...@intel.com> --- classes/zephyr-flash-dfu.bbclass | 34 ++++++++++++++++++++++++++++++++++ conf/machine/arduino-101-sss.conf | 1 + conf/machine/arduino-101.conf | 1 + 3 files changed, 36 insertions(+) create mode 100644 classes/zephyr-flash-dfu.bbclass diff --git a/classes/zephyr-flash-dfu.bbclass b/classes/zephyr-flash-dfu.bbclass new file mode 100644 index 0000000..2d82281 --- /dev/null +++ b/classes/zephyr-flash-dfu.bbclass @@ -0,0 +1,34 @@ + +python do_flash_usb() { + import subprocess + return_code = subprocess.call("which dfu-util", shell=True) + if return_code != 0: + bb.error("ERROR: dfu_util binary not in PATH") + sys.exit(1) + + board = d.getVar('BOARD',True) + bb.warn("Attempting to flash board: %s" % board) + + if board == 'arduino_101_sss': + iface = 'sensor_core' + elif board == 'arduino_101': + iface = 'x86_app' + elif board == 'arduino_101_ble': + iface = 'ble_core' + else: + bb.error(" Unsupported board %s" % board) + sys.exit(2) + + image = "%s/%s.elf" % (d.getVar('DEPLOY_DIR_IMAGE', True), d.getVar('PN', True)) + statement = 'dfu-util -v -a ' + iface + ' -d 8087:0aba -D ' + image.replace('elf','bin') + bb.note("command: %s" % statement) + return_code = subprocess.call(statement, shell=True) + if return_code != 0: + bb.error("Error flashig the device [%d], reset needed?" % return_code) + else: + bb.warn("Success (return code %d)" % return_code) +} + +addtask do_flash_usb + +do_flash_usb[nostamp] = "1" diff --git a/conf/machine/arduino-101-sss.conf b/conf/machine/arduino-101-sss.conf index cab5a3f..14b9861 100644 --- a/conf/machine/arduino-101-sss.conf +++ b/conf/machine/arduino-101-sss.conf @@ -16,3 +16,4 @@ PREFERRED_VERSION_binutils-cross-${TARGET_ARCH} = "2.26+gitarc" PREFERRED_VERSION_binutils-cross-canadian-${TRANSLATED_TARGET_ARCH} = "2.26+gitarc" TARGET_LINK_HASH_STYLE = "" +ZEPHYR_INHERIT_CLASSES += "zephyr-flash-dfu" diff --git a/conf/machine/arduino-101.conf b/conf/machine/arduino-101.conf index 543a41e..b38c320 100644 --- a/conf/machine/arduino-101.conf +++ b/conf/machine/arduino-101.conf @@ -8,3 +8,4 @@ require conf/machine/include/tune-iamcu.inc TUNE_PKGARCH_arduino-101 = "iamcu" TARGET_LINK_HASH_STYLE = "" +ZEPHYR_INHERIT_CLASSES += "zephyr-flash-dfu" -- 2.7.4 -- _______________________________________________ yocto mailing list yocto@yoctoproject.org https://lists.yoctoproject.org/listinfo/yocto