OpenOCD Troubleshooting: Can't Find File.cfg

You attempt to run OpenOCD and it exits immediately with a warning:

Can't find [file].cfg

OpenOCD has failed to find one or more config files. This guide will help you diagnose and correct the problem.

Can't Find openocd.cfg
If you see this message, you have likely run OpenOCD with no command line arguments. OpenOCD requires at least one config file to tell it how to communicate with your hardware. If you don't specify any, it searches for openocd.cfg. However, OpenOCD doesn't provide openocd.cfg by default. Even if it did, it wouldn't do any good because it wouldn't be tailored to any particular hardware.

Find the config files with your hardware. If you have compiled OpenOCD from source, they are most likely located in your OpenOCD directory, at tcl/interface, tcl/board, or tcl/target. Run OpenOCD again, using the -f switch to specify the path to each config file. For example:

openocd -f interface/flyswatter2.cfg -f board/hammer.cfg

If you know how to write your own config files you can also write your own openocd.cfg and place it in the same directory as the OpenOCD binary, but this is not necessary. See the links at the bottom of this page for more information on config files.

Can't Find a File Specified with -f
You run OpenOCD with the -f switch and OpenOCD can't find the file. For example, suppose you ran OpenOCD as above and saw the following error:

Can't find board/hammer.cfg

Make sure the config file exists and the path you specified is correct. If the file is present on your computer, make sure OpenOCD can find it from one of its default search paths. See OpenOCD Config File Paths for information on how OpenOCD finds config files.

Can't Find Another Config File
OpenOCD prints a runtime error stating that it can't open a config file you didn't specify with -f. For example, suppose you ran OpenOCD as follows:

openocd -f interface/flyswatter2.cfg -f board/hammer.cfg

...and saw this error:

Runtime Error: embedded:startup.tcl:58: Can't find target/samsung_s3c2410.cfg

So why was OpenOCD looking for samsung_s3c2410.cfg? The hammer.cfg file contains the line:

source [find target/samsung_s3c2410.cfg]

...to load the config file for the Hammer's CPU. When OpenOCD parses hammer.cfg it also searches for target/samsung_s3c2410.cfg, just as if you had specified it with the -f switch.

If OpenOCD fails to find a file specified in another config file, make sure the file path is valid for OpenOCD's search paths. You may need to specify an additional search path with the -s switch. See OpenOCD Config File Paths for more information on search paths and the -s switch.

More Information
Running OpenOCD on Linux

OpenOCD Config File Paths