# OpenOCD on FOX Board D27

<abstract>
This article illustrates how to program a Berta H10 or a BrizioH10 board using OpenOCD and a FOX Board D27
</abstract>

## Mandatory

Install on your Fox Board D27 the gpiod package as from the following articles :

* @article='gpiod'
* @article='libgpiod'

## Wirings - BertaH10

| ACME Sensor 1 pin # | FOX Signals | GPIO ID | H10 J12 pin # | H10 Signals          |
|---------------------|-------------|---------|---------------|----------------------|
| 2                   | PD27        | 123     | 1             | NRST                 |
| 3                   | PD26        | 122     | 7             | SWCLK                |
| 4                   | PD28        | 124     | 9             | SWDIO                |
| 5                   | PD30        | 126     | 10            | V_LOAD (R 1K serial) |
| 6                   | GND         |         | 6-8           | GND                  |

## Wirings - BrizioH10

| FOX Connector pin # | FOX Signals | GPIO ID | H10 pin       | H10 Signals          |
|---------------------|-------------|---------|---------------|----------------------|
| J2.23               | PC11        |  75     | E15           | NRST                 |
| J2.25               | PC19        |  83     | E16           | SWCLK                |
| J2.24               | PC20        |  84     | E15           | SWDIO                |
| J2.1                | 3V3_USER    | ---     | W2, W3        | V_LOAD               |
| J2.39               | GND         | ---     | E24, W1       | GND                  |

## Install Open OCD

Install on your Fox Board D27 the OpenOCD package (we used the microSD image available [here](/download_foxd27))

	sudo apt update
	sudo apt install openocd
	
	openocd -v
	Open On-Chip Debugger 0.12.0

## Preparing config file for Openocd	

Create a file called <code>openocd.cfg</code> with this content:

### BertaH10

	adapter driver linuxgpiod
	adapter gpio srst  123 -chip 0   
	adapter gpio swclk 122 -chip 0
	adapter gpio swdio 124 -chip 0            
	reset_config srst_only srst_open_drain  
	transport select swd
	set CHIPNAME samr34
	source [find target/at91samdXX.cfg]

### BrizioH10

	adapter driver linuxgpiod
	adapter gpio srst   85 -chip 0   
	adapter gpio swclk  83 -chip 0
	adapter gpio swdio  84 -chip 0            
	reset_config srst_only srst_open_drain  
	transport select swd
	set CHIPNAME samr34
	source [find target/at91samdXX.cfg]


Launch the H10 programming using this line:

	openocd -f openocd.cfg -c "program firmware.bin verify" -c "reset run" -c "exit"

## Links

* <https://openocd.org/>

## Useful commands

	openocd -c "adapter driver list"

