blob: 8176b3b0235f3fb3e5071b3ac70294e89d97a6ca (
plain)
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
59
60
61
62
|
---
title: ATSAM3X8E bare-metal notes
date: 2024-09-16
layout: post
---
Bypassing ATSAM3X8E (Due) bootloader via Serial Wire Debug (SWD).
Toolchain: ST-LINK/V2 programmer, OpenOCD, ARM GNU Compiler Toolchain.
ARM chips boot into 0x00000. GPNVM bits map one of ROM, flash0, flash1 to
0x00000:
- GPNVM1=0 → ROM (default).
- GPNVM1=1 and GPNVM2=0 → flash0.
- GPNVM1=1 and GPNVM2=1 → flash1.
By default, control jumps to Atmel's SAM-BA bootloader in ROM. To bypass, set
GPNVM1=1 and place vector table at 0x80000 (flash0).
Connect ST-LINK/v2 to Arduino Due's DEBUG port:
<table style="border: none; width: 100%;">
<tr style="border: none;">
<td style="border: none; width: 50%; vertical-align: top; background-color: transparent;">
<img src="schematic.png" alt="Pinout" style="width: 100%">
<p style="text-align: center;">Wiring</p>
</td>
<td style="border: none; width: 50%; vertical-align: top; background-color: transparent;">
<img src="connections.jpeg" alt="Circuit" style="width: 100%">
<p style="text-align: center;">Arduino Due</p>
</td>
</tr>
</table>
Remap memory:
```
$ openocd -f openocd-due.cfg
$ telnet localhost 4444
> halt
> at91sam3 gpnvm show
> at91sam3 gpnvm set 1
> at91sam3 gpnvm show
```
Full command list is in OpenOCD manual AT91SAM3 (flash driver section).
Compile and upload program:
```
$ arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -T script.ld \
-nostartfiles \
-nostdlib \
-o a.elf main.c
$ openocd -f openocd-due.cfg -c "program a.elf verify reset exit"
```
Commit: <a
href="https://git.asciimx.com/bare-metal-arduino-due/commit/?id=318496925ca76668dd9d63c3d060376f489276f8"
class="external" target="_blank" rel="noopener noreferrer">3184969</a>.
|