scripts: pyocd.sh: Add support for passing board_id to pyocd commands

If we have more than one board of a given type we need to be able to
specify the board_id to select which specific board that the pyocd
command should target.  Introduce an environment variable PYOCD_BOARD_ID
to we can set that will get passed to the pyocd command that needs it.

Here's an example:

$ make -C samples/hello_world/ BOARD=frdm_k64f flash PYOCD_BOARD_ID=1234

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2017-06-15 08:59:13 -05:00 committed by Kumar Gala
commit c5940fa673

View file

@ -9,6 +9,11 @@ BIN_NAME=${O}/${KERNEL_BIN_NAME}
ELF_NAME=${O}/${KERNEL_ELF_NAME}
GDB_PORT=${GDB_PORT:-3333}
PYOCD_BOARD_ID_ARG=""
if [ -n "${PYOCD_BOARD_ID}" ]; then
PYOCD_BOARD_ID_ARG="-b ${PYOCD_BOARD_ID}"
fi
test_config() {
if ! which ${PYOCD_FLASHTOOL} >/dev/null 2>&1; then
echo "Error: Unable to locate pyOCD flash tool: ${PYOCD_FLASHTOOL}"
@ -33,7 +38,7 @@ do_flash() {
# flash device with specified image
echo "Flashing Target Device"
${PYOCD_FLASHTOOL} -t ${PYOCD_TARGET} ${BIN_NAME}
${PYOCD_FLASHTOOL} -t ${PYOCD_TARGET} ${PYOCD_BOARD_ID_ARG} ${BIN_NAME}
}
@ -59,7 +64,7 @@ do_debugserver() {
SETSID=
fi
echo "pyOCD GDB server running on port ${GDB_PORT}"
${SETSID} ${PYOCD_GDBSERVER} -p ${GDB_PORT} -t ${PYOCD_TARGET}
${SETSID} ${PYOCD_GDBSERVER} -p ${GDB_PORT} -t ${PYOCD_TARGET} ${PYOCD_BOARD_ID_ARG}
}
CMD="$1"