Skip to content

issue with uploading sketch via programmer (sam-ice) #164

Open
@tuxedo0801

Description

@tuxedo0801

Hi,
I have an Elecrow Crowduino M0 SD and have some issues with uploading a sketch.

Environment:

  • Arduino IDE 1.6.11 from arduino.cc
  • Arduino SAMD Boards (32-bits ARM Cortex-M0+) 1.6.6 via Boardmanager
  • Blink Sketch

I've flashed the bootloader with arduino IDE + programmer "ATMEL SAM-ICE". Works great:

C:\Users\<user>\AppData\Local\Arduino15\packages\arduino\tools\openocd\0.9.0-arduino/bin/openocd.exe -d2 -s C:\Users\<user>\AppData\Local\Arduino15\packages\arduino\tools\openocd\0.9.0-arduino/share/openocd/scripts/ -f C:\Users\<user>\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.6/variants/arduino_zero/openocd_scripts/arduino_zero.cfg -c telnet_port disabled; init; halt; at91samd bootloader 0; program {{C:\Users\<user>\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.6/bootloaders/zero/samd21_sam_ba.bin}} verify reset; shutdown 
Open On-Chip Debugger 0.9.0-gd4b7679 (2015-06-10-22:24)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
debug_level: 2
Info : only one transport option; autoselect 'swd'
adapter speed: 500 kHz
adapter_nsrst_delay: 100
cortex_m reset_config sysresetreq
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: JTAG Supported
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : CMSIS-DAP: FW Version = 01.21.0076
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 1 TDO = 1 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 500 kHz
Info : SWD IDCODE 0x0bc11477
Info : at91samd21g18.cpu: hardware has 4 breakpoints, 2 watchpoints
target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x61000000 pc: 0x000041b6 msp: 0x20007fe8
target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x61000000 pc: 0x000005e8 msp: 0x20007ffc
** Programming Started **
auto erase enabled
Info : SAMD MCU: SAMD21G18A (256KB Flash, 32KB RAM)
wrote 16384 bytes from file C:\Users\<user>\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.6/bootloaders/zero/samd21_sam_ba.bin in 1.898500s (8.428 KiB/s)
** Programming Finished **
** Verify Started **
verified 5972 bytes in 0.521500s (11.183 KiB/s)
** Verified OK **
** Resetting Target **
shutdown command invoked

Uploading a sketch via USB works also:

Der Sketch verwendet 8.356 Bytes (3%) des Programmspeicherplatzes. Das Maximum sind 262.144 Bytes.
Erzwinge Reset durch öffnen/schließen mit 1200 bps auf dem Port COM12
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
PORTS {COM12, } / {COM12, } => {}
Uploading using selected port: COM12
C:\Users\<user>\AppData\Local\Arduino15\packages\arduino\tools\bossac\1.6.1-arduino/bossac.exe -i -d --port=COM12 -U true -i -e -w -v C:\Users\<user>\AppData\Local\Temp\buildbb61b02d674ae2bfb0845dfb247346a1.tmp/Blink.ino.bin -R 
Set binary mode
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
version()=v2.0 [Arduino:XYZ] May  9 2016 16:06:46
chipId=0x10010005
Connected at 921600 baud
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
Atmel SMART device 0x10010005 found
write(addr=0x20004000,size=0x34)
writeWord(addr=0x20004030,value=0x10)
writeWord(addr=0x20004020,value=0x20008000)
Device       : ATSAMD21G18A
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
Chip ID      : 10010005
version()=v2.0 [Arduino:XYZ] May  9 2016 16:06:46
Version      : v2.0 [Arduino:XYZ] May  9 2016 16:06:46
Address      : 8192
Pages        : 3968
Page Size    : 64 bytes
Total Size   : 248KB
Planes       : 1
Lock Regions : 16
Locked       : readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
none
readWord(addr=0x41004018)=0
Security     : false
Boot Flash   : true
readWord(addr=0x40000834)=0x7000a
BOD          : true
readWord(addr=0x40000834)=0x7000a
BOR          : true
Arduino      : FAST_CHIP_ERASE
Arduino      : FAST_MULTI_PAGE_WRITE
Arduino      : CAN_CHECKSUM_MEMORY_BUFFER
Erase flash
chipErase(addr=0x2000)
done in 0.807 seconds

Write 8508 bytes to flash (133 pages)
write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x2000, size=0x1000)

[==============                ] 48% (64/133 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x3000, size=0x1000)

[============================  ] 96% (128/133 pages)write(addr=0x20005000,size=0x140)
writeBuffer(scr_addr=0x20005000, dst_addr=0x4000, size=0x140)

[==============================] 100% (133/133 pages)
done in 0.060 seconds

Verify 8508 bytes of flash with checksum.
checksumBuffer(start_addr=0x2000, size=0x1000) = 917e
checksumBuffer(start_addr=0x3000, size=0x1000) = 9f85
checksumBuffer(start_addr=0x4000, size=0x13c) = 67f9
Verify successful
done in 0.013 seconds
CPU reset.
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
writeWord(addr=0xe000ed0c,value=0x5fa0004)

But uploading the same sketch via programmer (again atmel sam-ice):

Open On-Chip Debugger 0.9.0-gd4b7679 (2015-06-10-22:24)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
debug_level: 2
Info : only one transport option; autoselect 'swd'
adapter speed: 500 kHz
adapter_nsrst_delay: 100
cortex_m reset_config sysresetreq
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: JTAG Supported
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : CMSIS-DAP: FW Version = 01.21.0076
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 1 TDO = 1 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 500 kHz
Info : SWD IDCODE 0x0bc11477
Info : at91samd21g18.cpu: hardware has 4 breakpoints, 2 watchpoints
target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x41000000 pc: 0x000005e8 msp: 0x20007ffc
** Programming Started **
auto erase enabled
Info : SAMD MCU: SAMD21G18A (256KB Flash, 32KB RAM)
wrote 32768 bytes from file C:\Users\<user>\AppData\Local\Temp\buildbb61b02d674ae2bfb0845dfb247346a1.tmp/Blink.ino.elf in 3.812762s (8.393 KiB/s)
** Programming Finished **
** Verify Started **
verified 16700 bytes in 1.427786s (11.422 KiB/s)
** Verified OK **
** Resetting Target **
shutdown command invoked

Seems to work because no error is shown. But Arduino is not executing blink sketch and is not accepting any new sketch via USB (even with double-tap-reset). I have to flash the bootloader again (with sam-ice) to get the arduino back into a working state (to accept sketch upload via USB)

What's wrong? Any hints?

br,
Alex

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions