zephyr-flash-pyocd.bbclass: Handle import error for pyocd modules

Signed-off-by: Andrei Gherzan <andrei.gherzan@huawei.com>
Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com>
This commit is contained in:
Andrei Gherzan
2021-02-16 15:33:07 +00:00
committed by Naveen Saini
parent bdbe1a04c1
commit 7dcb47371b

View File

@@ -1,8 +1,11 @@
CONNECT_TIMEOUT_SECONDS ?= "30"
python do_flash_usb() {
from pyocd.core.helpers import ConnectHelper
from pyocd.flash.file_programmer import FileProgrammer
try:
from pyocd.core.helpers import ConnectHelper
from pyocd.flash.file_programmer import FileProgrammer
except ImportError:
bb.fatal("Flashing with pyocd needs the relevant python package. Make sure your host provides it or consult your distribution packages for how to install this prerequisite.")
timeout = int(d.getVar('CONNECT_TIMEOUT_SECONDS'))
image = f"{d.getVar('DEPLOY_DIR_IMAGE')}/{d.getVar('PN')}.elf"