Open tuxedo0801 opened 8 years ago
Retested with Arduino IDE 1.6.12... Same result. Retested with "Sloeber Arduino Eclipse IDE" (http://eclipse.baeyens.it/) which uses same Arduino Core Samd 1.6.6 ... Same result as with Arduino IDE.
So it's not the IDE itself, but rather the Core Samd 1.6.6
Went back to 1.6.5 and 1.6.4 with Arduino IDE ... But this gave me some errors on execution.
A friend of mine is using the same setup with Arduino IDE 1.6.10 and Core Samd 1.6.4, also on Windows.. with success.
No idea what wents wrong.
Hi @tuxedo0801 ,
I believe your problem can be related with linker script offsets.
By default, both programming via USB or via programmer use flash_with_bootloader.ld
.
This loads the sketch at 0x2000, and the bootloader is responsible to start the sketch from that position. Unfortunately, the bootloader gets erased during the second programming due to its size.
A patch to address it is here https://github.com/arduino/OpenOCD/pull/2, I'll attach here a binary for Windows so you can test it on your environment.
If this is a bug: Question is why a friend of mine is able to upload sketch via atmel ice...
only difference: he's using a differen arduino zero board.
The board I use: Elecrow Crowduino M0 SD The board he's using: Arduino M0 Pro (with atmel ice, instead of onboard debugger)
But used samd is exactly the same...
M0 pro has 0x4000 as bootloader offset, while our implementation is smaller (thus it gives you more space for sketches) but it encounters the openocd bug. The attached file should be ok (the build procedure is not yet validated but it should work) openocd.zip
Sorry for late response ...Now using Linux, attached openocd is windows version :-(
But I tried the current "nightlybuild" of samd-core (with linux). Normal "uploading sketch" uses openocd to upload the sketch:
/home/achristian/.arduino15/packages/arduino/tools/openocd/0.9.0-arduino5-static/bin/openocd -d2 -s /home/achristian/.arduino15/packages/arduino/tools/openocd/0.9.0-arduino5-static/share/openocd/scripts/ -f /home/achristian/.arduino15/packages/arduino-beta/hardware/samd/9.9.9-Hourly/variants/arduino_zero/openocd_scripts/arduino_zero.cfg -c telnet_port disabled; program {{/tmp/arduino_build_282547/M0dularisPlusBlink.ino.bin}} verify reset 0x2000; shutdown
Open On-Chip Debugger 0.9.0-g688b0b6 (2017-01-12-14:57)
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: 0x81000000 pc: 0x00000614 msp: 0x20007ffc
** Programming Started **
auto erase enabled
Info : SAMD MCU: SAMD21G18A (256KB Flash, 32KB RAM)
Warn : Adding extra erase range, 00000000 to 0x00001fff
wrote 24576 bytes from file /tmp/arduino_build_282547/M0dularisPlusBlink.ino.bin in 2.732562s (8.783 KiB/s)
** Programming Finished **
** Verify Started **
verified 9712 bytes in 0.817418s (11.603 KiB/s)
** Verified OK **
** Resetting Target **
shutdown command invoked
Works. Blink sketch runs fine. "Uploading via Programmer" gives me:
/home/achristian/.arduino15/packages/arduino/tools/openocd/0.9.0-arduino5-static/bin/openocd -d2 -s /home/achristian/.arduino15/packages/arduino/tools/openocd/0.9.0-arduino5-static/share/openocd/scripts/ -f /home/achristian/.arduino15/packages/arduino-beta/hardware/samd/9.9.9-Hourly/variants/arduino_zero/openocd_scripts/arduino_zero.cfg -c telnet_port disabled; program {{/tmp/arduino_build_282547/M0dularisPlusBlink.ino.elf}} verify reset; shutdown
Open On-Chip Debugger 0.9.0-g688b0b6 (2017-01-12-14:57)
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: 0x81000000 pc: 0x00000614 msp: 0x20007ffc
** Programming Started **
auto erase enabled
Info : SAMD MCU: SAMD21G18A (256KB Flash, 32KB RAM)
wrote 32768 bytes from file /tmp/arduino_build_282547/M0dularisPlusBlink.ino.elf in 3.694437s (8.662 KiB/s)
** Programming Finished **
** Verify Started **
verified 17904 bytes in 1.517887s (11.519 KiB/s)
** Verified OK **
** Resetting Target **
shutdown command invoked
Does not work: Blink sketch isn't running.
The difference seems to be the missing "verify reset 0x2000; shutdown " when using the menuitem "upload via programmer" ...
There are a couple of problems here:
The "upload using programmer" uses 0 as offset, as you noticed. If you don't change the linker script too, the sketch won't start since it will be flashed in the wrong location.
To allow a clean, bootloader-less, programming, you should change boardname.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld
into boardname.build.ldscript=linker_scripts/gcc/flash_without_bootloader.ld
in the core's boards.txt
openocd-0.9.0-arduino6-static-x86_64-linux-gnu.tar.bz2.zip
Latest version uses 0.9.0-arduino6, but issue it still present:
/home/achristian/.arduino15/packages/arduino/tools/openocd/0.9.0-arduino6-static/bin/openocd -d2 -s /home/achristian/.arduino15/packages/arduino/tools/openocd/0.9.0-arduino6-static/share/openocd/scripts/ -f /home/achristian/.arduino15/packages/arduino/hardware/samd/1.6.18/variants/arduino_zero/openocd_scripts/arduino_zero.cfg -c telnet_port disabled; program {{/tmp/arduino_build_197081/M0dularisPlus_v1.0_Testsuite.ino.elf}} verify reset; shutdown
Open On-Chip Debugger 0.9.0-g932ec70 (2017-02-15-11:32)
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: 0x81000000 pc: 0x00000614 msp: 0x20007ffc
** Programming Started **
auto erase enabled
Info : SAMD: partitioning the first flash page into 8 subpages
Info : SAMD MCU: SAMD21G18A (256KB Flash, 32KB RAM)
wrote 49152 bytes from file /tmp/arduino_build_197081/M0dularisPlus_v1.0_Testsuite.ino.elf in 5.530165s (8.680 KiB/s)
** Programming Finished **
** Verify Started **
verified 48624 bytes in 3.998532s (11.875 KiB/s)
** Verified OK **
** Resetting Target **
shutdown command invoked
Flashign bootloader and then flashing sketch via programmer will halt/not boot th SAMD. Flashing BL after flashing the sketch, board starts up successfully.
ping
ping again
Upstream OpenOCD seems to work. https://sourceforge.net/p/openocd/code/ci/master/tree/
Perhaps now would be a good time to update Arduino's OpenOCD. https://github.com/arduino/OpenOCD/issues/5
ping again... Issue still present with 1.6.20 :-(
+100 Almost yet another year later. This really is a problem, and I figured it would have been solved by now.
This is precisely why I resorted to containing the entire Arduino environment with sophisticated shell scripts.
SAMD Beta package contains an updated version of openocd (0.10.0-arduino7). To test if it solves the issue, please download the core for MKRVidor, then navigate to Arduino15/ packages/arduino/samd-beta/1.6.25/
folder and rename boards.txt.disabled
into boards.txt
Hi, I have an Elecrow Crowduino M0 SD and have some issues with uploading a sketch.
Environment:
I've flashed the bootloader with arduino IDE + programmer "ATMEL SAM-ICE". Works great:
Uploading a sketch via USB works also:
But uploading the same sketch via programmer (again atmel sam-ice):
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