diff options
author | Anas Nashif <anas.nashif@intel.com> | 2016-01-15 12:18:53 -0500 |
---|---|---|
committer | Anas Nashif <anas.nashif@intel.com> | 2016-02-05 20:25:29 -0500 |
commit | 51be9a50a41c7d89ae61dd809578534d1d714bfa (patch) | |
tree | bb8e1cf9d0d14aa31792d6ed5cd664c9259c6c1c /scripts/support | |
parent | c4c919dbe03dbb4992e73d1f903de79d19811c20 (diff) |
Add flash support for boards using latest SDK
Using the latest SDK (0.7.2) you can flash directly using make
by specifying the board, for example
make BOARD=arduino_101 flash
This will build and flash the generated binary to the board.
Change-Id: I90254abd69874efbb449ef318079958980c23074
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Diffstat (limited to 'scripts/support')
-rw-r--r-- | scripts/support/openocd.sh | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/scripts/support/openocd.sh b/scripts/support/openocd.sh new file mode 100644 index 000000000..b70fa1e7f --- /dev/null +++ b/scripts/support/openocd.sh @@ -0,0 +1,53 @@ +#!/bin/sh + +OPENOCD_CMD="${OPENOCD:-openocd} -s ${OPENOCD_DEFAULT_PATH}" +OPENOCD_CONFIG=${ZEPHYR_BASE}/boards/${BOARD_NAME}/support/openocd.cfg +BIN_NAME=${O}/${KERNEL_BIN_NAME} + +test_config() { + if [ ! -f "${OPENOCD_CONFIG}" ]; then + echo "Error: Unable to locate OpenOCD configuration file: ${OPENOCD_CONFIG}" + exit 1 + fi + if [ ! -f "${OPENOCD}" ]; then + echo "Error: Unable to locate OpenOCD executable: ${OPENOCD}" + exit 1 + fi +} + +test_bin() { + if [ ! -f "${BIN_NAME}" ]; then + echo "Error: Unable to locate image binary: ${BIN_NAME}" + exit 1 + fi +} + +do_flash() { + test_config + test_bin + + # flash device with specified image + sh -c "${OPENOCD_CMD} -f '${OPENOCD_CONFIG}' \ + -c 'init' \ + -c 'targets' \ + ${OPENOCD_PRE_CMD} \ + -c 'reset halt' \ + -c ${OPENOCD_LOAD_CMD} \ + -c 'reset halt' \ + -c ${OPENOCD_VERIFY_CMD} \ + ${OPENOCD_POST_CMD} \ + -c 'reset run' \ + -c 'shutdown'" + echo 'Done flashing' +} + + +CMD="$1" +shift + +case "${CMD}" in + flash) + echo "Flashing Target Device" + do_flash "$@" + ;; +esac |