mirror of
https://git.yoctoproject.org/meta-zephyr
synced 2026-09-15 18:49:31 +02:00
zephyr-flash-dfu.bbclass: add reset & retries support
Arduino-101 needs to be reset in order to enter "flash mode". The flash window is about 5 seconds. If the flashing fails, prompt the user to press reset. After the device is flashed, it remains in the "flash mode" until it is reset again, so it needs to enter the flash mode via reset only once even if we flash images for multiple cores. So we only prompt for reset once. Signed-off-by: Juro Bystricky <juro.bystricky@intel.com>
This commit is contained in:
@@ -6,8 +6,7 @@ python do_flash_usb() {
|
||||
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)
|
||||
board = d.getVar('BOARD', True)
|
||||
|
||||
if board == 'arduino_101_sss':
|
||||
iface = 'sensor_core'
|
||||
@@ -19,14 +18,39 @@ python do_flash_usb() {
|
||||
bb.error(" Unsupported board %s" % board)
|
||||
sys.exit(2)
|
||||
|
||||
# We need to serialize flashing of separate images (when using multiconfig)
|
||||
lock = bb.utils.lockfile(os.path.join(d.getVar('TOPDIR', True),"flash-dfu.lock"), False, True)
|
||||
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)
|
||||
bb.plain("Attempting to flash board: %s" % board)
|
||||
|
||||
# Arduino-101 needs to be reset in order to enter "flash mode".
|
||||
# The flash window is about 5 seconds.
|
||||
# However, if the device is flashed, it remains in the "flash mode"
|
||||
# until it is reset again, so it needs to enter the flash mode via reset
|
||||
# only once even if we flash images for multiple cores. So we only prompt
|
||||
# for reset once.
|
||||
|
||||
timeout = 5
|
||||
promptneeded = True
|
||||
while (timeout > 0):
|
||||
time.sleep(0.5)
|
||||
timeout = timeout - 0.5
|
||||
return_code = subprocess.call(statement, shell=True)
|
||||
if return_code == 0:
|
||||
break
|
||||
if promptneeded:
|
||||
bb.warn("\n\n *** Failed to flash %s. *** \n Press reset, will retry for five seconds...\n" % board)
|
||||
promptneeded = False
|
||||
|
||||
if return_code != 0:
|
||||
bb.error("Error flashig the device [%d], reset needed?" % return_code)
|
||||
bb.error("Error flashing %s [%d]" % (board,return_code))
|
||||
else:
|
||||
bb.warn("Success (return code %d)" % return_code)
|
||||
bb.plain("Success (return code %d)" % return_code)
|
||||
|
||||
bb.utils.unlockfile(lock)
|
||||
}
|
||||
|
||||
addtask do_flash_usb
|
||||
|
||||
Reference in New Issue
Block a user