platformio / platformio-core

Your Gateway to Embedded Software Development Excellence :alien:
https://platformio.org
Apache License 2.0
7.95k stars 792 forks source link

Can't upload to Arduino Zero on programming USB port #828

Closed fraimondo closed 7 years ago

fraimondo commented 7 years ago

What kind of issue is this?

You can erase any parts of this template not applicable to your Issue.


Configuration

Operating system: MacOS Sierra

PlatformIO Version (platformio --version): PlatformIO, version 3.1.0

Description of problem

Can't upload if a configure the board as zero

Steps to Reproduce

  1. Create a project
  2. Configure board as zero
  3. Try to upload

Actual Results

It hangs with a terminal like this:

Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
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: Interface Initialised (SWD)
Info : CMSIS-DAP: FW Version = 02.01.0157
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 

Expected Results

A terminal like this:

Open On-Chip Debugger 0.9.0-gd4b7679 (2015-06-10-19:16)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
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: Interface Initialised (SWD)
Info : CMSIS-DAP: FW Version = 02.01.0157
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: 0x00000858 msp: 0x200023a0
** 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 .pioenvs/zero/firmware.bin in 3.507302s (6.843 KiB/s)
** Programming Finished **
** Verify Started **
verified 17508 bytes in 1.445675s (11.827 KiB/s)
** Verified OK **
** Resetting Target **
shutdown command invoked

If problems with PlatformIO Build System:

The content of platformio.ini:

[env:zero]
platform = atmelsam
board = zero
framework = arduino
lib_extra_dirs = ../../../arduino_libs/

Source file to reproduce issue:

Any

Additional info

I managed to find where's the problem.

The command to run openOCD it's as follows:

~/.platformio/packages/tool-openocd/bin/openocd
-f arduino_zero.cfg 
-s /Users/fraimondo/.platformio/packages/tool-openocd/share/openocd/scripts 
-s /Users/fraimondo/.platformio/packages/tool-openocd/share/openocd/scripts/board 
-s /Users/fraimondo/.platformio/packages/framework-arduinosam/variants/arduino_zero/openocd_scripts 
-c "telnet_port disabled; program {{.pioenvs/zero/firmware.bin}} verify reset 0x2000; shutdown"

I checked with the official arduino IDE and one of the -s parameters is not there. So I tried running

~/.platformio/packages/tool-openocd/bin/openocd
-f arduino_zero.cfg 
-s /Users/fraimondo/.platformio/packages/tool-openocd/share/openocd/scripts 
-s /Users/fraimondo/.platformio/packages/framework-arduinosam/variants/arduino_zero/openocd_scripts 
-c "telnet_port disabled; program {{.pioenvs/zero/firmware.bin}} verify reset 0x2000; shutdown"

And that works just fine.

ivankravets commented 7 years ago

Duplicate of https://github.com/platformio/platformio/issues/805