File: ARCHITECTURE.md

package info (click to toggle)
pyocd 0.13.1+dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 2,112 kB
  • sloc: python: 19,899; xml: 182; ansic: 112; makefile: 65; sh: 47
file content (58 lines) | stat: -rw-r--r-- 2,419 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
Architecture
============

## Object graph

The diagram below shows the most interesting parts of the pyOCD object graph, i.e. those parts
that a user of the Python API will interact with. The connections in the diagram represent
composition, not inheritance.

```
          Session
             |
             |-----> DebugProbe
             |
           Board
             |
       CoreSightTarget
             |
   /---------|-----------\
   |         |           |
 Flash   CortexM[]   DebugPort
             |           |
         MemoryMap  AccessPort[]
```

The root of the runtime object graph is a `Session` object. This object holds references to the debug
probe and the board. It is also responsible for managing per-session user options that control
various features and settings.

Attached to the board is a `CoreSightTarget` instance, which represents an MCU. This owns the
CoreSight related objects for communicating with the DP and APs, the flash programming interface,
and a `CortexM` object for each CPU core on the device. Both `CoreSightTarget` and `CortexM` are
subclasses of the abstract `Target` class, which is referenced below, and share most of the same
APIs.

## Targets and boards

Target and board support are two separate but related pieces of functionality.

#### Target support

Each supported target enables debugging and flash programming a given MCU. A single target can be
used for potentially multiple boards, or there may not be board with the target. Users can
override the target type on the command line or when creating the `Session`.

Each supported target is defined as a `CoreSightTarget` subclass held in a Python file in the
`pyocd/target` directory. If the target has internal or connected flash, then a `Flash` subclass
will be paired with it in the same source file. Some device families have family subclasses under
`pyocd/target/family`.

#### Board information

pyOCD can automatically identify a board and its target type using the board information.
The board information is stored in the `BOARD_ID_TO_INFO` dictionary in `pyocd/board/board_ids.py`.
This dictionary maps a 4-character board ID to a board name, target type, and test firmware binary.
The board ID is generally the same as the board's Mbed platform ID, though non-Mbed boards that use
[Arm DAPLink](https://github.com/ARMmbed/DAPLink) firmware also have board IDs allocated from
the same namespace.