I just started using PlatformIO and I have what is hopefully an easy question.
I have an Adafruit Feather M0 (ATSAMD21G18 processor) that I’m attempting to upload via JLink. My test program is the simple LED blink program. It compiles without errors and appears to upload also without errors, however doesn’t run.
This same program uploads and runs correctly on this processor when compiled and uploaded using Atmel Studio (and JLink).
The BOOTPROT fuse in the processor is cleared.
Here’s the test code:
#include <Arduino.h>
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(0, LOW);
}
void loop()
{
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
delay(1000);
}
The platformio.ini file is:
[env:adafruit_feather_m0]
platform = atmelsam
board = adafruit_feather_m0
framework = arduino
debug_tool = jlink
; SWD interface
upload_protocol = jlink
; JTAG interface
;upload_protocol = jlink-jtag
The .gitignore file is:
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
And the build and upload log is at the end of this post (I looked for a way to attach a file, but could not find it. If there is a way, please let me know).
Any help would be appreciated, thanks,
Jack
Build/Upload Log:
> Executing task: C:\Users\jtgar\.platformio\penv\Scripts\platformio.exe run --verbose --target upload --environment adafruit_feather_m0 <
Processing adafruit_feather_m0 (platform: atmelsam; board: adafruit_feather_m0; framework: arduino; debug_tool: jlink; upload_protocol: jlink)
----------------------------------------------------------------------------------------------CONFIGURATION: https://docs.platformio.org/page/boards/atmelsam/adafruit_feather_m0.html
PLATFORM: Atmel SAM (6.3.1) > Adafruit Feather M0
HARDWARE: SAMD21G18A 48MHz, 32KB RAM, 256KB Flash
DEBUG: Current (jlink) External (atmel-ice, blackmagic, jlink)
PACKAGES:
- framework-arduino-samd-adafruit 1.7.2
- framework-cmsis 2.50400.181126 (5.4.0)
- framework-cmsis-atmel 1.2.2
- tool-jlink 1.75001.0 (7.50.1)
- toolchain-gccarmnoneeabi 1.90301.200702 (9.3.1)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 11 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
MethodWrapper(["checkprogsize"], [".pio\build\adafruit_feather_m0\firmware.elf"])
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [= ] 10.3% (used 3380 bytes from 32768 bytes)
Flash: [ ] 4.2% (used 10960 bytes from 262144 bytes)
.pio\build\adafruit_feather_m0\firmware.elf :
section size addr
.text 10704 8192
.data 256 536870912
.bss 3124 536871168
.ARM.attributes 40 0
.comment 67 0
.debug_frame 692 0
Total 14883
<lambda>(["upload"], [".pio\build\adafruit_feather_m0\firmware.bin"])
AVAILABLE: atmel-ice, blackmagic, jlink, sam-ba
CURRENT: upload_protocol = jlink
JLink.exe -device ATSAMD21G18 -speed 4000 -if swd -autoconnect 1 -NoGui 1 -CommanderScript "C:\Users\jtgar\~Software\Arduino\PlatformIO\Debug_Feather_Test\.pio\build\adafruit_feather_m0\upload.jlink"
SEGGER J-Link Commander V7.50a (Compiled Jul 8 2021 18:18:11)
DLL version V7.50a, compiled Jul 8 2021 18:16:52
J-Link Command File read successfully.
Processing script file...
J-Link connection not established yet but required for command.
Connecting to J-Link via USB...O.K.
Firmware: J-Link V11 compiled Jun 29 2021 16:12:24
Hardware version: V11.00
S/N: 261005798
License(s): FlashBP, GDB
OEM: SEGGER-EDU
VTref=3.309V
Target connection not established yet but required for command.
Device "ATSAMD21G18" selected.
Connecting to target via SWD
InitTarget() start
InitTarget()
InitTarget() end
Found SW-DP with ID 0x0BC11477
DPIDR: 0x0BC11477
Scanning AP map to find all available APs
AP[1]: Stopped AP scan as end of AP map has been reached
AP[0]: AHB-AP (IDR: 0x04770031)
Iterating through AP map to find AHB-AP to use
AP[0]: Core found
AP[0]: AHB-AP ROM base: 0x41003000
CPUID register: 0x410CC601. Implementer code: 0x41 (ARM)
Found Cortex-M0 r0p1, Little endian.
FPUnit: 4 code (BP) slots and 0 literal slots
CoreSight components:
ROMTbl[0] @ 41003000
ROMTbl[0][0]: E00FF000, CID: B105100D, PID: 000BB4C0 ROM Table
ROMTbl[1] @ E00FF000
ROMTbl[1][0]: E000E000, CID: B105E00D, PID: 000BB008 SCS
ROMTbl[1][1]: E0001000, CID: B105E00D, PID: 000BB00A DWT
ROMTbl[1][2]: E0002000, CID: B105E00D, PID: 000BB00B FPB
ROMTbl[0][1]: 41006000, CID: B105900D, PID: 001BB932 MTB-M0+
Cortex-M0 identified.
PC = 000021C8, CycleCnt = 00000000
R0 = 20000120, R1 = E000E010, R2 = 00000001, R3 = 00000000
R4 = E000ED00, R5 = 00000000, R6 = 00007EFC, R7 = 00000000
R8 = F6DDFFBF, R9 = 3DF7F946, R10= 7FF3FDF7, R11= FA7FE8B8
R12= 20000120
SP(R13)= 20007FB0, MSP= 20007FB0, PSP= FFBBCDF4, R14(LR) = 0000222D
XPSR = 41000000: APSR = nZcvq, EPSR = 01000000, IPSR = 000 (NoException)
CFBP = 00000000, CONTROL = 00, FAULTMASK = 00, BASEPRI = 00, PRIMASK = 00
FPU regs: FPU not enabled / not implemented on connected CPU.
Downloading file [.pio\build\adafruit_feather_m0\firmware.bin]...
Comparing flash [100%] Done.
J-Link: Flash download: Bank 0 @ 0x00000000: Skipped. Contents already match
O.K.
Reset delay: 0 ms
Reset type NORMAL: Resets core & peripherals via SYSRESETREQ & VECTRESET bit.
ResetTarget() start
ResetTarget() end
Script processing completed.
================================ [SUCCESS] Took 3.29 seconds ================================
Terminal will be reused by tasks, press any key to close it.