I am trying to use OpenOCD + RPi to program an ATSAMD21J18A via SWD. I have a connection, can see flash info but programming fails with a Flash write discontinued / NVM programming error.
I have a feeling it has something to do with Erase or reset.
This is the error point:
** Programming Started **
Flash write discontinued at 0x00012f84, next section at 0x00013f00
SAMD: NVM programming error
Failed to erase row containing 00000200
SAMD: failed to erase sector 2 at 0x00000200
failed erasing sectors 0 to 303
embedded:startup.tcl:530: Error: ** Programming Failed **
in procedure 'program'
in procedure 'program_error' called at file "embedded:startup.tcl", line 595
at file "embedded:startup.tcl", line 530
My code:
sudo openocd -f interface/raspberrypi2-native.cfg \
-c "transport select swd" \
-c "set WORKAREASIZE 0" \
-c "set CHIPNAME at91samd21j18" \
-c "adapter speed 400" \
-c "adapter srst delay 200" \
-f target/at91samdXX.cfg \
-c "at91samd bootloader 0" \
-c "program openocd_hex/123456.hex verify"\
-c "at91samd bootloader 8192"
raspberrypi2-native.cfg file
adapter driver bcm2835gpio
bcm2835gpio_peripheral_base 0x3F000000
# Transition delay calculation: SPEED_COEFF/khz - SPEED_OFFSET
# These depend on system clock, calibrated for stock 700MHz
# bcm2835gpio_speed SPEED_COEFF SPEED_OFFSET
bcm2835gpio_speed_coeffs 146203 36
# Each of the JTAG lines need a gpio number set: tck tms tdi tdo
# Header pin numbers: 23 22 19 21
bcm2835gpio_jtag_nums 11 25 10 9
# Each of the SWD lines need a gpio number set: swclk swdio
# Header pin numbers: SWCLK:23 SWDIO:22
bcm2835gpio_swd_nums 11 25
# If you define trst or srst, use appropriate reset_config
# Header pin numbers: TRST - 26, SRST - 18
# bcm2835gpio_trst_num 7
# reset_config trst_only
bcm2835gpio_srst_num 24
# reset_config srst_only srst_push_pull
# or if you have both connected,
# reset_config trst_and_srst srst_push_pull
I've used telnet localhost 4444 to feed line by line, but I get the same error when I try to program. Tried changing adapter speed/delay, tried flash write_image, flash info 0 shows no protection.
How critical is the reset pin connection for this set-up. I may have an issue there.
I suspect the command -c "at91samd bootloader 0" does not work as expected and flash stays locked.
You have first issue "init" to close up OpenOCD initialization, then prepare the device for programming by "reset init". The script "program" calls both "init" and "reset init", but it is too late for "at91samd bootloader 0".
Try this:
openocd -f interface/raspberrypi2-native.cfg \
-c "transport select swd" \
-f target/at91samdXX.cfg \
-c "init;reset init;at91samd bootloader 0" \
-c "flash write_image erase openocd_hex/123456.hex"
and if it works, add "verify_image openocd_hex/123456.hex" and setting bootloader protection.
If the problem persists, please run with -d and upload full debug log to some paste bin service.
Thank you Tom,
I should have thought to dig into the debug output.
I tried the code as you mentioned, but have the same result:
openocd -f interface/raspberrypi2-native.cfg \
Open On-Chip Debugger 0.11.0+dev-00034-g4c00f96fc-dirty (2021-03-14-16:46)
Licensed under GNU GPL v2
For bug reports, read
BCM2835 GPIO config: srst = 24
swd
Info : BCM2835 GPIO JTAG/SWD bitbang driver
Info : clock speed 400 kHz
Info : SWD DPIDR 0x0bc11477
Info : at91samd.cpu: hardware has 4 breakpoints, 2 watchpoints
Info : starting gdb server for at91samd.cpu on 3333
Info : Listening on port 3333 for gdb connections
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0xfffffffe msp: 0xfffffffc
Info : SAMD MCU: SAMD21J18A (256KB Flash, 32KB RAM)
Info : Flash write discontinued at 0x00012f84, next section at 0x00013f00
Error: SAMD: NVM programming error
Error: Failed to erase row containing 00000100
Error: SAMD: failed to erase sector 1 at 0x00000100
Error: failed erasing sectors 0 to 303
auto erase enabled
I have uploaded the debug to pastebin.com/zeeGgXTz
Thanks
From: Tom tom_van@users.sourceforge.net
Sent: Wednesday, March 17, 2021 4:34 PM
To: [openocd:tickets] 299@tickets.openocd.p.re.sourceforge.net
Subject: [openocd:tickets] #299 OpenOCD SAMD21 programming from RPI Error
Flash write discontinued / NVM programming error
I suspect the command -c "at91samd bootloader 0" does not work as expected
and flash stays locked.
You have first issue "init" to close up OpenOCD initialization, then prepare
the device for programming by "reset init". The script "program" calls both
"init" and "reset init", but it is too late for "at91samd bootloader 0".
Try this:
openocd -f interface/raspberrypi2-native.cfg \
-c "transport select swd" \
-f target/at91samdXX.cfg \
-c "init;reset init;at91samd bootloader 0" \
-c "flash write_image erase openocd_hex/123456.hex"
and if it works, add "verify_image openocd_hex/123456.hex" and setting
bootloader protection.
If the problem persists, please run with -d and upload full debug log to
some paste bin service.
[tickets:#299] https://sourceforge.net/p/openocd/tickets/299/ OpenOCD
SAMD21 programming from RPI Error Flash write discontinued / NVM programming
error
Status: new
Milestone: 0.10.0
Created: Wed Mar 17, 2021 04:24 PM UTC by Gregory Cronin
Last Updated: Wed Mar 17, 2021 04:24 PM UTC
Owner: nobody
I am trying to use OpenOCD + RPi to program an ATSAMD21J18A via SWD. I have
a connection, can see flash info but programming fails with a Flash write
discontinued / NVM programming error.
I have a feeling it has something to do with Erase or reset.
This is the error point:
0x00013f00
SAMD: NVM programming error
Failed to erase row containing 00000200
SAMD: failed to erase sector 2 at 0x00000200
failed erasing sectors 0 to 303
embedded:startup.tcl:530: Error: ** Programming Failed **
in procedure 'program'
in procedure 'program_error' called at file
"embedded:startup.tcl", line 595
at file "embedded:startup.tcl", line 530
My code:
raspberrypi2-native.cfg file
I've used telnet localhost 4444 to feed line by line, but I get the same
error when I try to program. Tried changing adapter speed/delay, tried flash
write_image, flash info 0 shows no protection.
How critical is the reset pin connection for this set-up. I may have an
issue there.
Sent from sourceforge.net because you indicated interest in
https://sourceforge.net/p/openocd/tickets/299/
To unsubscribe from further messages, please visit
https://sourceforge.net/auth/subscriptions/
Related
Tickets: #299
at91samd bootloader command help reads:
..."Changes are stored immediately but take affect after the MCU is reset"
So you need add one more "reset init" before "flash write_image..."
BTW: I'm sure your original commands resulted in error
Error: The 'at91samd bootloader' command must be used after 'init'
Next time please copy whole OpenOCD output!
Added reset init but hit similar error.
sudo openocd -f interface/raspberrypi2-native.cfg \
Open On-Chip Debugger 0.11.0+dev-00034-g4c00f96fc-dirty (2021-03-14-16:46)
Licensed under GNU GPL v2
For bug reports, read
BCM2835 GPIO config: srst = 24
swd
Info : BCM2835 GPIO JTAG/SWD bitbang driver
Info : clock speed 400 kHz
Info : SWD DPIDR 0x0bc11477
Info : at91samd.cpu: hardware has 4 breakpoints, 2 watchpoints
Info : starting gdb server for at91samd.cpu on 3333
Info : Listening on port 3333 for gdb connections
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0xfffffffe msp: 0xfffffffc
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0xfffffffe msp: 0xfffffffc
Info : SAMD MCU: SAMD21J18A (256KB Flash, 32KB RAM)
Info : Flash write discontinued at 0x00012f84, next section at 0x00013f00
Error: SAMD: NVM programming error
Error: Failed to erase row containing 00000100
Error: SAMD: failed to erase sector 1 at 0x00000100
Error: failed erasing sectors 0 to 303
auto erase enabled
here is output:
https://pastebin.com/XEv0zdn5
thanks
From: Tom tom_van@users.sourceforge.net
Sent: Wednesday, March 17, 2021 5:49 PM
To: [openocd:tickets] 299@tickets.openocd.p.re.sourceforge.net
Subject: [openocd:tickets] #299 OpenOCD SAMD21 programming from RPI Error
Flash write discontinued / NVM programming error
BTW: I'm sure your original commands resulted in error
Error: The 'at91samd bootloader' command must be used after 'init'
Next time please copy whole OpenOCD output!
[tickets:#299] https://sourceforge.net/p/openocd/tickets/299/ OpenOCD
SAMD21 programming from RPI Error Flash write discontinued / NVM programming
error
Status: new
Milestone: 0.10.0
Created: Wed Mar 17, 2021 04:24 PM UTC by Gregory Cronin
Last Updated: Wed Mar 17, 2021 09:39 PM UTC
Owner: nobody
I am trying to use OpenOCD + RPi to program an ATSAMD21J18A via SWD. I have
a connection, can see flash info but programming fails with a Flash write
discontinued / NVM programming error.
I have a feeling it has something to do with Erase or reset.
This is the error point:
0x00013f00
SAMD: NVM programming error
Failed to erase row containing 00000200
SAMD: failed to erase sector 2 at 0x00000200
failed erasing sectors 0 to 303
embedded:startup.tcl:530: Error: ** Programming Failed **
in procedure 'program'
in procedure 'program_error' called at file
"embedded:startup.tcl", line 595
at file "embedded:startup.tcl", line 530
My code:
raspberrypi2-native.cfg file
I've used telnet localhost 4444 to feed line by line, but I get the same
error when I try to program. Tried changing adapter speed/delay, tried flash
write_image, flash info 0 shows no protection.
How critical is the reset pin connection for this set-up. I may have an
issue there.
Sent from sourceforge.net because you indicated interest in
https://sourceforge.net/p/openocd/tickets/299/
To unsubscribe from further messages, please visit
https://sourceforge.net/auth/subscriptions/
Related
Tickets: #299
Both logs shows a parity error at SWD level.
The problem is most probably in the wiring (too long wires, crosstalks between SWCLK and SWDIO, poor grounding, EMI etc...)
I will check.
Does the reset pin need to be connected?
gc
From: Tom tom_van@users.sourceforge.net
Sent: Thursday, March 18, 2021 2:15 AM
To: [openocd:tickets] 299@tickets.openocd.p.re.sourceforge.net
Subject: [openocd:tickets] #299 OpenOCD SAMD21 programming from RPI Error
Flash write discontinued / NVM programming error
Both logs shows a parity error at SWD level.
The problem is most probably in the wiring (too long wires, crosstalks
between SWCLK and SWDIO, poor grounding, EMI etc...)
[tickets:#299] https://sourceforge.net/p/openocd/tickets/299/ OpenOCD
SAMD21 programming from RPI Error Flash write discontinued / NVM programming
error
Status: new
Milestone: 0.10.0
Created: Wed Mar 17, 2021 04:24 PM UTC by Gregory Cronin
Last Updated: Wed Mar 17, 2021 09:48 PM UTC
Owner: nobody
I am trying to use OpenOCD + RPi to program an ATSAMD21J18A via SWD. I have
a connection, can see flash info but programming fails with a Flash write
discontinued / NVM programming error.
I have a feeling it has something to do with Erase or reset.
This is the error point:
0x00013f00
SAMD: NVM programming error
Failed to erase row containing 00000200
SAMD: failed to erase sector 2 at 0x00000200
failed erasing sectors 0 to 303
embedded:startup.tcl:530: Error: ** Programming Failed **
in procedure 'program'
in procedure 'program_error' called at file
"embedded:startup.tcl", line 595
at file "embedded:startup.tcl", line 530
My code:
raspberrypi2-native.cfg file
I've used telnet localhost 4444 to feed line by line, but I get the same
error when I try to program. Tried changing adapter speed/delay, tried flash
write_image, flash info 0 shows no protection.
How critical is the reset pin connection for this set-up. I may have an
issue there.
Sent from sourceforge.net because you indicated interest in
https://sourceforge.net/p/openocd/tickets/299/
To unsubscribe from further messages, please visit
https://sourceforge.net/auth/subscriptions/
Related
Tickets: #299
thank you Tom, I had success.
The main issue was that this ATSAMD21J18A required a reduced adapter speed.
I did not use the reset pin or require "at91samd bootloader 0" on this application.
This script works for me using a R-P1 3B+ as the programming adapter:
openocd -f interface/raspberrypi2-native.cfg \
-c "transport select swd" \
-f target/at91samdXX.cfg \
-c "adapter speed 200" \
-c "program 123456.hex verify" \
-c "shutdown"