1

I'm trying to flash the Arduino Bootloader on a bare ATSAMD21G with STLink via SWD programming and OpenOCD.

These are the steps that I took:

  1. Create *.hex file to flash with ArduinoCore-samd repository
  2. Connect SWD pins from ST-Link to the ATSAMD21G pins enter image description here enter image description here
  3. Execute OpenOCD command

    openocd -f interface/stlink-v2.cfg -c "set CHIPNAME at91samd21g18; set ENDIAN little; set CPUTAPID 0x0bc11477; source [find target/at91samdXX.cfg]" -c "init" -c "reset init" -c "load_image {/Path/To/ArduinoCore-samd/bootloaders/zero/samd21_sam_ba.hex} 0 ihex" -c "verify_image {/Path/To/ArduinoCore-samd/bootloaders/zero/samd21_sam_ba.hex} 0 ihex" -c "reset run" -c "exit"
    
  4. Command Line output:

    Open On-Chip Debugger 0.10.0
    Licensed under GNU GPL v2
    
    For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
    Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
    Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
    none separate
    adapter speed: 400 kHz
    Info : Unable to match requested speed 400 kHz, using 240 kHz
    Info : Unable to match requested speed 400 kHz, using 240 kHz
    Info : clock speed 240 kHz
    Info : STLINK v2 JTAG v17 API v2 SWIM v0 VID 0x0483 PID 0x3748
    Info : using stlink api v2
    Info : Target voltage: 2.922730
    Info : at91samd21g18.cpu: hardware has 4 breakpoints, 2 watchpoints
    target halted due to debug-request, current mode: Thread
    xPSR: 0x61000000 pc: 0x00000f10 msp: 0x20007ffc
    in procedure 'reset'
    in procedure 'ocd_bouncer'
    in procedure 'ocd_process_reset'
    in procedure 'ocd_process_reset_inner' called at file "embedded:startup.tcl", line 248
    in procedure 'at91samd21g18.cpu' called at file "embedded:startup.tcl", line 331
    in procedure 'ocd_bouncer'
    
    5824 bytes written at address 0x00000000
    downloaded 5824 bytes in 0.132341s (42.976 KiB/s)
    target halted due to breakpoint, current mode: Thread
    xPSR: 0x61000000 pc: 0x2000002e msp: 0x20007ffc
    verified 5824 bytes in 0.481737s (11.806 KiB/s)
    in procedure 'reset'
    in procedure 'ocd_bouncer'
    in procedure 'ocd_process_reset'
    in procedure 'ocd_process_reset_inner' called at file "embedded:startup.tcl", line 248
    in procedure 'at91samd21g18.cpu' called at file "embedded:startup.tcl", line 331
    in procedure 'ocd_bouncer'
    

Really unsure what steps I am missing as it does not seem to flash the bootloader at all. I cannot detect M0 on the USB port after trying to execute the OpenOCD command. Thanks!

Sayanee
  • 119
  • 2
  • 2
    Actually the verification message seems to indicate the code was flashed. You may need to look at non-code configuration settings, possible errors in the code, clocking, board or electrical issues, etc. Perhaps you should try using SWD to load a test program that flashes an LED or generatures actual UART output without a bootloader or needing USB to work. – Chris Stratton Nov 30 '19 at 16:23

0 Answers0