Use openocd provided by CIPD

Updates Pigweed tools to use OpenOCD provided by CIPD.

Change-Id: Iea80343373bc5d36d223dd327b854e89ee9e274a
diff --git a/env_setup/cipd/ensure_file b/env_setup/cipd/ensure_file
index 6a59273..3b1cc2d 100644
--- a/env_setup/cipd/ensure_file
+++ b/env_setup/cipd/ensure_file
@@ -41,6 +41,9 @@
 # Bloaty (Embedded Fork)
 pigweed/third_party/bloaty-embedded/${platform} git_revision:551e70f736e0dc40184c568095b25851f62ea0db
 
+# OpenOCD
+pigweed/third_party/openocd/${platform} git_revision:646566e006acd58fb9ac405511d3ecca79f26d55
+
 # GCC ARM None EABI
 pigweed/third_party/gcc-arm-none-eabi/${platform} version:9-2019-q4-major
 
diff --git a/env_setup/cipd/update.py b/env_setup/cipd/update.py
index 8c9690c..9699168 100755
--- a/env_setup/cipd/update.py
+++ b/env_setup/cipd/update.py
@@ -78,6 +78,8 @@
                                          prefix='cipdsetup') as temp:
             print('PATH="{}"'.format(os.pathsep.join(paths)), file=temp)
             print('export PATH', file=temp)
+            print('CIPD_INSTALL_DIR="{}"'.format(args.install_dir), file=temp)
+            print('export CIPD_INSTALL_DIR', file=temp)
 
             print('. {}'.format(temp.name))
 
diff --git a/targets/stm32f429i-disc1/py/stm32f429i_disc1_utils/unit_test_runner.py b/targets/stm32f429i-disc1/py/stm32f429i_disc1_utils/unit_test_runner.py
index 361076f..a3698f6 100755
--- a/targets/stm32f429i-disc1/py/stm32f429i_disc1_utils/unit_test_runner.py
+++ b/targets/stm32f429i-disc1/py/stm32f429i_disc1_utils/unit_test_runner.py
@@ -27,6 +27,10 @@
 # Path to default openocd configuration file.
 _OPENOCD_CONFIG = os.path.join(_DIR, 'openocd_stm32f4xx.cfg')
 
+# Path to scripts provided by openocd.
+_OPENOCD_SCRIPTS_DIR = os.path.join(os.getenv('CIPD_INSTALL_DIR'), 'share',
+                                    'openocd', 'scripts')
+
 _LOG = logging.getLogger('unit_test_runner')
 
 # Verification of test pass/failure depends on these strings. If the formatting
@@ -89,8 +93,8 @@
     flash_tool = os.getenv('OPENOCD_PATH', default_flasher)
 
     cmd = [
-        flash_tool, '-f', openocd_config, '-c', 'init', '-c', 'reset run',
-        '-c', 'exit'
+        flash_tool, '-s', _OPENOCD_SCRIPTS_DIR, '-f', openocd_config, '-c',
+        'init', '-c', 'reset run', '-c', 'exit'
     ]
     _LOG.debug('Resetting device')
 
@@ -155,7 +159,10 @@
     flash_tool = os.getenv('OPENOCD_PATH', default_flasher)
 
     openocd_command = ' '.join(['program', binary, 'reset', 'exit'])
-    cmd = [flash_tool, '-f', openocd_config, '-c', openocd_command]
+    cmd = [
+        flash_tool, '-s', _OPENOCD_SCRIPTS_DIR, '-f', openocd_config, '-c',
+        openocd_command
+    ]
     _LOG.info('Flashing firmware to device')
 
     process = subprocess.run(cmd,