Debian Codegraph @

docs/configuration.md

raw symbols SCIP
1 ---
2 title: Configuration
3 ---
4
5 This guide documents how to configure pyOCD.
6
7 ## Introduction
8
9 pyOCD allows you to control many aspects of its behaviour by setting
10 _session options_. There are multiple ways to set these options.
11
12 - Many of the most commonly used session options have dedicated command line arguments.
13 - Options can be placed in a YAML config file.
14 - Arbitrary options can be set individually with the <tt>-O<i>option</i>=<i>value</i></tt> command line argument.
15 - If you are using the Python API, see the [session options developer documentation]({% link _docs/api/using_session_options.md %}) for information about using session options.
16
17 The priorities of the different session option sources, from highest to lowest:
18
19 1. Dedicated command-line arguments.
20 2. `-O` command-line arguments.
21 3. Probe-specific options from a config file.
22 4. Global options from a config file.
23 5. Changes to an option's default value. Used only in rare cases for certain subcommands.
24 6. The option's default value.
25
26 <div class="alert alert-info">
27 <p>
28 The full set of session options is documented in the
29 <a href="{% link _docs/options.md %}">Session options list</a> reference.
30 </p>
31 </div>
32
33 ## Project directory
34
35 To help pyOCD automatically find configuration files and other resources, it has the concept of
36 the project directory.
37
38 When pyOCD looks for files such as the config file or a user script, it first expands '~'
39 references to the home directory. Then it checks whether the filename is absolute, and if so, it
40 uses the filename as-is. Otherwise, it looks for the file in the project directory.
41
42 By default, the project directory is simply the working directory where you ran the `pyocd` tool.
43 You can change the project directory to another location with the `-j`, `--project`, or `--dir` command line
44 arguments. This can be helpful if you are running pyOCD from another tool or application. The project
45 directory can also be set using the `PYOCD_PROJECT_DIR` environment variable. Command line arguments
46 have precedence over the environment variable.
47
48 ## Config file
49
50 pyOCD supports a YAML configuration file that lets you set session options that either apply to
51 all probes or to a single probe, based on the probe's unique ID.
52
53 The easiest way to use a config file is to place a `pyocd.yaml` file in the project directory.
54 An alternate `.yml` extension and
55 optional dot prefix on the config file name are allowed. Alternatively, you can use the
56 `--config` command line option, for instance `--config=myconfig.yaml`. Finally, you can set the
57 `config_file` option. If there is a need to prevent reading a config file, use the `--no-config`
58 argument.
59
60 The top level of the YAML file is a dictionary. The keys in the top-level dictionary must be names
61 of session options, or the key `probes`. Session options are set to the value corresponding to the
62 dictionary entry. Unrecognized option names are ignored.
63
64 If there is a top-level `probes` key, its value must be a dictionary with keys that match a
65 substring of debug probe unique IDs. Usually you would just use the complete unique ID shown by
66 listing connected boards (i.e., `pyocd list`). The values for the unique ID entries are
67 dictionaries containing session options, just like the top level of the YAML file. Of course, these
68 options are only applied when connecting with the given probe. If the probe unique ID
69 substring listed in the config file matches more than one probe, the corresponding options
70 will be applied to all matching probes.
71
72 Options set in the config file will override any options set via the command line.
73
74 Example config file:
75 ````yaml
76 probes:
77 066EFF555051897267233656: # Probe's unique ID.
78 target_override: stm32l475xg
79 test_binary: stm32l475vg_iot01a.bin
80
81 # Global options
82 auto_unlock: false
83 frequency: 8000000 # Set 8 MHz SWD default for all probes
84 ````
85
86