summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSadeep Madurange <sadeep@asciimx.com>2026-04-24 21:25:29 +0800
committerSadeep Madurange <sadeep@asciimx.com>2026-04-24 21:25:29 +0800
commit1b7fff91b4adf903fd1ee0485274e095a00af523 (patch)
treea823bf07b2b4b457340b0353a1970a10274f3eb1
parent4c010f5b96e1326ff4f6eb4bc44e5e397c27d72f (diff)
downloadwww-1b7fff91b4adf903fd1ee0485274e095a00af523.tar.gz
Arduino Due post.
-rw-r--r--_log/arduino-due.md25
1 files changed, 7 insertions, 18 deletions
diff --git a/_log/arduino-due.md b/_log/arduino-due.md
index 900098d..1330dbf 100644
--- a/_log/arduino-due.md
+++ b/_log/arduino-due.md
@@ -1,13 +1,9 @@
---
-title: Bare-metal ATSAM3X8E
+title: Bare-metal ATSAM3X8E (Arduino Due)
date: 2024-09-16
layout: post
---
-Bought an Arduino Due to play with ARM Cortex chips. Locked out of the chip for
-days—no dev tools (Arduino IDE, Microchip Studio) for OpenBSD. Need to find a
-way to bring up the bare-metal ATSAM3X8E.
-
Three on-chip memories: ROM, flash0, flash1. ARM Cortex-M chips boot into
0x00000. GPNVM bits map one of them to 0x00000:
@@ -16,8 +12,8 @@ Three on-chip memories: ROM, flash0, flash1. ARM Cortex-M chips boot into
- GPNVM1=1 and GPNVM2=1 → flash1.
On power-up, control jumps to ROM. Without a user program, Atmel's SAM-BA
-bootloader traps execution in ROM. Must remap memory via SWD to force chip to
-boot from flash, bypassing factory bootloader.
+bootloader traps execution in the ROM. Must remap memory via SWD to force chip
+to boot from flash, bypassing factory bootloader.
Toolchain: ST-LINK/V2 programmer, OpenOCD, ARM GNU Compiler Toolchain.
@@ -49,8 +45,7 @@ $ telnet localhost 4444
Full command list in OpenOCD manual AT91SAM3 (flash driver section).
-At a minimum, vector table must be initialized with stack pointer and reset
-vector:
+Initialize vector table with the stack pointer and the reset vector:
```
__attribute__((noreturn)) void _reset(void)
@@ -72,8 +67,8 @@ extern const unsigned int _sp;
__attribute__ ((section(".vtor"))) const void* _tab[] = { &_sp, _reset };
```
-Linker script places vector table at start of flash0 and initializes stack
-pointer to top of RAM (descending stack):
+Linker script: Place the vector table at the start of flash0 and initialize the
+stack pointer to the top of the RAM:
```
MEMORY
@@ -95,11 +90,7 @@ SECTIONS
_sp = ORIGIN(ram) + LENGTH(ram);
```
-Getting linker script right wasn't easy—long hours with the datasheet, OpenOCD
-manual. David Barrass from OpenBSD and folks at OpenOCD mailing lists (bless
-them!) helped generously.
-
-Build and upload program:
+Build and upload the program:
```
$ arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -T script.ld \
@@ -109,8 +100,6 @@ $ arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -T script.ld \
$ openocd -f openocd-due.cfg -c "program a.elf verify reset exit"
```
-Chip unlocked. I'm in.
-
Commit: <a
href="https://git.asciimx.com/bare-metal-arduino-due/commit/?id=318496925ca76668dd9d63c3d060376f489276f8"
class="external" target="_blank" rel="noopener noreferrer">3184969</a>.