Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Commit

Permalink
added OpenOCD programming example
Browse files Browse the repository at this point in the history
  • Loading branch information
majbthrd committed Apr 28, 2018
1 parent cc6614e commit 6253025
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,31 @@ When branching to the user application, the bootloader includes functionality to
[Rowley Crossworks for ARM](http://www.rowley.co.uk/arm/) is presently needed to compile this code. With Crossworks for ARM v4.1.1, using the Clang 5.0.1 compiler produces an 1010 byte image. The more mainstream GCC does not appear to be optimized enough to produce an image that comes anywhere close to fitting into 1024 bytes.

There is no dependency in the code on the [Rowley Crossworks for ARM](http://www.rowley.co.uk/arm/) toolchain per se, but at this time I am not aware of any other ready-to-use Clang ARM cross-compiler package that I can readily point users to.

## Programming targets with bootloader

[OpenOCD](http://openocd.org/) is open-source and freely available. Given a debug unit interfaced to the target, it will not only program the flash but it also has built-in support for setting the BOOTPROT bits to provide write-protection of the bootloader.

Testing was done with OpenOCD v0.10.0 using both the debug units built-in to the ATSAMD11-XPRO and ATSAMD21-XPRO as well as the [Dapper Miser CMSIS-DAP](https://github.com/majbthrd/DapperMiser) debug unit.

Your mileage may vary, particularly with earlier releases of OpenOCD. (The wisdom of the Internet implies earlier versions of OpenOCD had bugs with setting the BOOTPROT bits.) You don't have to use the BOOTPROT bits, but adding write-protection to the bootloader is generally a desirable attribute.

####Step 1: disable existing BOOTPROT write-protection, if any

```
openocd -f interface/cmsis-dap.cfg -f target/at91samdXX.cfg -c "init; halt; at91samd bootloader 0; exit"
```

####Step 2: program the bootloader (the file Dx1bootloader-v1_00-PA15.srec in this example)

```
openocd -f interface/cmsis-dap.cfg -f target/at91samdXX.cfg -c "program Dx1bootloader-v1_00-PA15.srec verify; exit"
```

####Step 3: enable the BOOTPROT bits for write-protecting a 1kB bootloader

```
openocd -f interface/cmsis-dap.cfg -f target/at91samdXX.cfg -c "init; halt; at91samd bootloader 1024; exit"
```

Once the bootloader is programmed, the user should be able to dispense with having to repeatedly connect the target to a debug unit and use OpenOCD (or equivalent) to program updates. New user firmware can be downloaded over the target's USB connection as shown in the Usage section above.

0 comments on commit 6253025

Please sign in to comment.