Newer
Older
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
# Compiling and programming the ATSAMD51J18A
First, install the patched version of [openocd](../openocd/README.md).
This assumes you did it successfuly and have it correctly programed in your path.
To compile the code, you can just use `make`.
The extra targets of interest are:
* `make clean` to clean your environment (sometimes needed before compiling, if things changed but were not discovered)
* `make program` to program the binary onto the chip using openocd
* `make openocd` to start openocd for debugging
* `make debug` to use gdb to debug the chip via openocd
## Programming
For `make program` to work, you need to have the correct openocd binary accessible in the path.
If it's not the default one, change it in `Makefile`.
You also need to be connected to your programming tool.
The configuration assumes an ATMEL ICE programmer, but you can easily change that in `program.cfg` and `debug.cfg` (if needed, might work by default).
A successful programming looks like that:

## Debugging with GDB
For debug, you need to start openocd with the debug configuration.
In one terminal, do
```
make openocd
```
If everything is well, this is what you should get:

and in the other, you can start the gdb session with
```
make debug
```
Type c+(ENTER) to continue the program (it halts by default).
Type (CTRL)+c to stop the program. The rest is all with `gdb`.