Programming J-Link Adafruit Metro M4 Error

I have a Segger J-Link and would like to program my Adafruit Metro M4 via platformio, that doesn’t work, Success is displayed but the old code is still in SAMD51.

platform = atmelsam
framework = arduino
board = adafruit_metro_m4

debug_tool = jlink
upload_protocol = jlink

With Atmel Studio it’s no problem

Greetings Schubert

I currently have the Adafruit Metro M4 Express with Atmel Studio
Programmed, I found a code for CDC USB
And that works, I can send CMD to the Metro via computer
send and Metro sends back. I see this in the device manager
that I have a new COM port 28.

And now I start Platformio and load a demo for the SAMD51
Led Blink, I compile and then upload. Looks at the first step
Everything looks great, but nothing works, no LED flashes.

And what do I see, the demo from Atmel Studio is still active.
That’s why my COM28 is still in the device manager.

So I don’t understand that now.

Why does Platformio (SUCCESS) tell me that he was able to program the Metro M4, but the old code is still there?

platform = atmelsam
framework = arduino
board = adafruit_metro_m4
monitor_speed = 115200
upload_protocol = jlink

Executing task in folder 240419-081949-arduino-blink: C:\Users\Schub.platformio\penv\Scripts\platformio.exe run --target upload

Processing adafruit_metro_m4 (platform: atmelsam; framework: arduino; board: adafruit_metro_m4)
---------------------------------------------------------------------------------------------------------Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: Redirecting...
PLATFORM: Atmel SAM (8.2.1) > Adafruit Metro M4
HARDWARE: SAMD51J19A 120MHz, 192KB RAM, 512KB Flash
DEBUG: Current (jlink) External (atmel-ice, jlink)

  • framework-arduino-samd-adafruit @ 1.7.13
  • framework-cmsis @ 2.50400.181126 (5.4.0)
  • framework-cmsis-atmel @ 1.2.2
  • tool-jlink @ 1.78811.0 (7.88.11)
  • toolchain-gccarmnoneeabi @ 1.90301.200702 (9.3.1)
    LDF: Library Dependency Finder → Library Dependency Finder (LDF) — PlatformIO latest documentation
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 11 compatible libraries
    Scanning dependencies…
    No dependencies
    Building in release mode
    Checking size .pio\build\adafruit_metro_m4\firmware.elf
    Advanced Memory Usage is available via “PlatformIO Home > Project Inspect”
    RAM: [ ] 1.4% (used 2664 bytes from 196608 bytes)
    Flash: [ ] 2.2% (used 11368 bytes from 524288 bytes)
    Configuring upload protocol…
    AVAILABLE: atmel-ice, jlink, sam-ba
    CURRENT: upload_protocol = jlink
    Uploading .pio\build\adafruit_metro_m4\firmware.bin
    SEGGER J-Link Commander V7.88k (Compiled Jul 5 2023 15:02:18)
    DLL version V7.88k, compiled Jul 5 2023 15:00:41

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 V9 compiled May 7 2021 16:26:12
Hardware version: V9.30
J-Link uptime (since boot): N/A (Not supported by this model)
S/N: 269302534
License(s): FlashBP, GDB
Target connection not established yet but required for command.
Device “ATSAMD51J19A” selected.

Connecting to target via SWD
InitTarget() start
SWD selected. Executing JTAG → SWD switching sequence.
DAP initialized successfully.
InitTarget() end - Took 5.40ms
Found SW-DP with ID 0x2BA01477
DPIDR: 0x2BA01477
CoreSight SoC-400 or earlier
Scanning AP map to find all available APs
AP[2]: Stopped AP scan as end of AP map seems to be reached
AP[0]: AHB-AP (IDR: 0x24770011)
AP[1]: AHB-AP (IDR: 0x74770001)
Iterating through AP map to find AHB-AP to use
AP[0]: Core found
AP[0]: AHB-AP ROM base: 0x41003000
CPUID register: 0x410FC241. Implementer code: 0x41 (ARM)
Found Cortex-M4 r0p1, Little endian.
FPUnit: 6 code (BP) slots and 2 literal slots
CoreSight components:
ROMTbl[0] @ 41003000
[0][0]: E00FF000 CID B105100D PID 000BB4C4 ROM Table
ROMTbl[1] @ E00FF000
[1][0]: E000E000 CID B105E00D PID 000BB00C SCS-M7
[1][1]: E0001000 CID B105E00D PID 003BB002 DWT
[1][2]: E0002000 CID B105E00D PID 002BB003 FPB
[1][3]: E0000000 CID B105E00D PID 003BB001 ITM
[1][4]: E0040000 CID B105900D PID 000BB9A1 TPIU
[1][5]: E0041000 CID B105900D PID 000BB925 ETM
[1][6]: E0042000 CID B105900D PID 003BB907 ETB
Memory zones:
Zone: “Default” Description: Default access mode
Cortex-M4 identified.
PC = 000024B0, CycleCnt = 3640D474
R0 = 00000000, R1 = 30100000, R2 = 00000001, R3 = 00000040
R4 = 20000330, R5 = 00000033, R6 = 000024A5, R7 = 000024BD
R8 = DF9B76FD, R9 = 77FFF7F7, R10= EFFEFEFD, R11= EFDDFFFE
R12= 00001E8D
SP(R13)= 2000C3E8, MSP= 2000C3E8, PSP= BFEFBFEC, R14(LR) = 000019C1
XPSR = 61000000: APSR = nZCvq, EPSR = 01000000, IPSR = 000 (NoException)
CFBP = 00000000, CONTROL = 00, FAULTMASK = 00, BASEPRI = 00, PRIMASK = 00

FPS0 = 0002C806, FPS1 = 80180240, FPS2 = 0018A018, FPS3 = 27992101
FPS4 = 20655483, FPS5 = E0022250, FPS6 = 8D615850, FPS7 = 2208E210
FPS8 = 80081241, FPS9 = 518A2024, FPS10= B2001424, FPS11= 9757903A
FPS12= C8625EE8, FPS13= 48626021, FPS14= 9000D4E4, FPS15= 0C80A30E
FPS16= 00A25D0A, FPS17= 6821102A, FPS18= 0401108E, FPS19= 9210E145
FPS20= 000249B1, FPS21= 2B115050, FPS22= 4010304E, FPS23= 00081804
FPS24= 03480822, FPS25= 06320411, FPS26= 2A81D420, FPS27= 0A220025
FPS28= 00004A00, FPS29= C4A42303, FPS30= 40801242, FPS31= 4B80D500
FPSCR= 00000000
J-Link>loadbin .pio\build\adafruit_metro_m4\firmware.bin, 0x4000
‘loadbin’: Performing implicit reset & halt of MCU.
Reset: Halt core after reset via DEMCR.VC_CORERESET.
Reset: Reset device via AIRCR.SYSRESETREQ.
Downloading file [.pio\build\adafruit_metro_m4\firmware.bin]…
Comparing flash [100%] Done.
Erasing flash [100%] Done.
Programming flash [100%] Done.
J-Link: Flash download: Bank 0 @ 0x00000000: 1 range affected (16384 bytes)
J-Link: Flash download: Total: 0.210s (Prepare: 0.041s, Compare: 0.005s, Erase: 0.084s, Program & Verify: 0.059s, Restore: 0.019s)
J-Link: Flash download: Program & Verify speed: 271 KB/s
Reset delay: 0 ms
Reset type NORMAL: Resets core & peripherals via SYSRESETREQ & VECTRESET bit.
Reset: Halt core after reset via DEMCR.VC_CORERESET.
Reset: Reset device via AIRCR.SYSRESETREQ.

Script processing completed.

====================================== [SUCCESS] Took 4.12 seconds ====================================== * Terminal will be reused by tasks, press any key to close it.

Hello everyone, I have my Segger J-LINK
Connected to my Metro M4 with a 10-pin cable and
now try changing platformio.ini to

platform = atmelsam
framework = arduino
board = adafruit_metro_m4
monitor_speed = 115200
upload_protocol = jlink-jtag

And here I get a nasty error.
Configuring upload protocol…
AVAILABLE: atmel-ice, jlink, jlink-jtag, sam-ba
CURRENT: upload_protocol = jlink-jtag
Uploading .pio\build\adafruit_metro_m4\firmware.bin
The command “JLink.exe” is either misspelled or
could not be found.
*** [upload] Error 1

Can someone please help

Greetings Schubert

It’s been dealt with. Now it’s working