blob: ed49e78e397b23b3b63533709307b0d55f0d8e5e (
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ATSAM3X8E bare-metal notes</title>
<link rel="stylesheet" href="/assets/css/main.css">
<link rel="stylesheet" href="/assets/css/skeleton.css">
</head>
<body>
<div id="nav-container" class="container">
<ul id="navlist" class="left">
<li >
<a href="/" class="link-decor-none">hme</a>
</li>
<li >
<a href="/projects/" class="link-decor-none">poc</a>
</li>
<li >
<a href="/about/" class="link-decor-none">abt</a>
</li>
<li>
<a href="/cgi-bin/find.cgi" class="link-decor-none">lup</a>
</li>
<li>
<a href="/feed.xml" class="link-decor-none">rss</a>
</li>
</ul>
</div>
<main>
<div class="container">
<div class="container-2">
<h2 class="center" id="title">ATSAM3X8E BARE-METAL NOTES</h2>
<h5 class="center">16 SEPTEMBER 2024</h5>
<br>
<div class="twocol justify"><p>Bypassing ATSAM3X8E (Due) bootloader via Serial Wire Debug (SWD).</p>
<p>Toolchain: ST-LINK/V2 programmer, OpenOCD, ARM GNU Compiler Toolchain.</p>
<p>ARM chips boot into 0x00000. GPNVM bits map one of ROM, flash0, flash1 to
0x00000:</p>
<ul>
<li>GPNVM1=0 → ROM (default).</li>
<li>GPNVM1=1 and GPNVM2=0 → flash0.</li>
<li>GPNVM1=1 and GPNVM2=1 → flash1.</li>
</ul>
<p>By default, control jumps to Atmel’s SAM-BA bootloader in ROM. To bypass, set
GPNVM1=1 and place vector table at 0x80000 (flash0).</p>
<p>Connect ST-LINK/v2 to Arduino Due’s DEBUG port:</p>
<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>
<p>Remap memory:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ openocd -f openocd-due.cfg
$ telnet localhost 4444
> halt
> at91sam3 gpnvm show
> at91sam3 gpnvm set 1
> at91sam3 gpnvm show
</code></pre></div></div>
<p>Full command list is in OpenOCD manual AT91SAM3 (flash driver section).</p>
<p>Compile and upload program:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ 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"
</code></pre></div></div>
<p>Commit:
<a href="https://git.asciimx.com/bare-metal-arduino-due/commit/?id=318496925ca76668dd9d63c3d060376f489276f8">3184969</a></p>
</div>
<p class="post-author right">by W. D. Sadeep Madurange</p>
</div>
</div>
</main>
<div class="footer">
<div class="container">
<div class="twelve columns right container-2">
<p id="footer-text">© ASCIIMX - 2026</p>
</div>
</div>
</div>
</body>
</html>
|