Cannot upload to Adafruit Feather M0 using JLink

Hello again,
I made some progress but I still have one issue to clear up. I had been attempting to upload a release version of my test using the Check Mark (PlatformIO Build) and Right Arrow (PlatformIO Upload) at the bottom of the screen (ctrl alt b and ctrl alt u). This always failed.

Based on what you said in your last reply that “debugging should work automatically”, I decided to attempt to build and upload a debug version using the Run->Start Debugging menu (I had not tried this previously because I wanted to start with what I thought was the simplest test, which was to upload a release version of my test program).

Uploading a debug version worked correctly. I was able to run my test, step through it, set breakpoints, watches, etc. without any problems.

The remaining issue I have now is how to upload a release version. Is the Check Mark (PlatformIO Build) and Right Arrow (PlatformIO Upload) at the bottom of the screen the correct way to do this? As you can see from the log, it “thinks” it uploading. Also, I do not see the JLink progress dialog (I do see it when uploading a debug version).

Am I missing something in my ini file?

Again, I’m attempting to upload the simple LED blink test to an Adafruit Feather (ATSAMD21G18 processor), via JLink with the BOOTPROT fuse in the processor cleared (no bootloader).

I’ve attached my current platformio.ini and a verbose download log.

And again, thanks for the help you’ve been giving me,

Jack

platformio.ini

[env:adafruit_feather_m0]
platform = atmelsam
board = adafruit_feather_m0
framework = arduino

; change arduino linker script
board_build.arduino.ldscript = flash_without_bootloader.ld

debug_tool = jlink
; SWD interface
upload_protocol = jlink
; JTAG interface
;upload_protocol = jlink-jtag

Verbose 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; board_build.arduino.ldscript: flash_without_bootloader.ld; 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 10956 bytes from 262144 bytes)
.pio\build\adafruit_feather_m0\firmware.elf  :

section            size        addr

.text             10700           0

.data               256   536870912

.bss               3124   536871168

.ARM.attributes      40           0

.comment             67           0

.debug_frame        692           0

Total             14879
<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_Test2\.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.296V
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 = 00000242, CycleCnt = 00000000
R0 = 00000099, R1 = 00134F0C, R2 = 00000000, R3 = 000003E8
R4 = 0000004D, R5 = 4B6CC744, R6 = 00014070, R7 = FFFFFFFF
R8 = F6DDFFBF, R9 = 39F7F947, R10= 7FF3FDF7, R11= FA3FE8A8
R12= 000003E8
SP(R13)= 20007FD8, MSP= 20007FD8, PSP= DF3BFDF4, R14(LR) = 00000253
XPSR = 81000000: 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.
Erasing flash     [100%] Done.
Programming flash [100%] Done.
J-Link: Flash download: Bank 0 @ 0x00000000: 1 range affected (4608 bytes)
J-Link: Flash download: Total: 0.107s (Prepare: 0.033s, Compare: 0.014s, Erase: 0.016s, Program & Verify: 0.029s, Restore: 0.014s)
J-Link: Flash download: Program & Verify speed: 154 KiB/s
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.13 seconds ===============================

Terminal will be reused by tasks, press any key to close it.