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>
diff --git a/scripts/support/pyocd.sh b/scripts/support/pyocd.sh
index 11f4fdc..be9fcc0 100755
--- a/scripts/support/pyocd.sh
+++ b/scripts/support/pyocd.sh
@@ -9,6 +9,11 @@
 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 @@
 
     # 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 @@
         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"