I have a custom board based on the SamD21 (original prototypes were Arduino Zero based, and therefore my OpenOCD scripts are almost identical to those supplied).
On my custom board, I reconfigure the SWD pins in software as GPIOs, meaning the board NEEDS a reset before it can be uploaded to.
I can successfully upload to the device if I manually reset the board the moment before the upload takes place from vMicro, however if I time the reset wrong, it obviously fails as the pins are then configured as a GPIO within ~2 seconds of power up. I'd like to avoid lengthening this delay if at all possible.
Is there anyway I can automatically initiate this reset the moment before upload? Atmel Studio is able to upload all the time, without fail (watching with my logic analyzer Atmel Studio pulls the reset pin low everytime the moment before upload, whereas vMicro does not).
I have tried within my board platform.txt (which I have confirmed vMicro is using) adding "init; reset halt;" just before the program command. I.e:
tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; reset halt; program {{{build.path}/{build.project_name}.bin}} verify reset 0x2000; shutdown"
tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; reset halt; program {{{build.path}/{build.project_name}.elf}} verify reset; shutdown"
However, this fails to pull the reset line low when checked with my logic analyser, and when trying to program the device. I believe my reset-config is correct in openOCD as if I add "connect_assert_srst" (which pulls the reset line low when the target connects automatically - as described here:
http://openocd.org/doc/html/Reset-Configuration.html) in my arduino_zero.cfg file, the reset line does get pulled low.
I am using an Atmel ICE programmer. Does anyone have any idea what I'm doing wrong?