Skip to content

GPIO-based DTR reset needed for upload on Raspberry Pi/UP2 board etc. #34

@deadprogram

Description

@deadprogram

First of all, thanks for working on this project, I have been wanting a Golang-based CLI for the Arduino toolchain for the longest time.

It would appear that in order to upload code to an Arduino that is connected directly to the ttyAMA0 serial port via the pins on a Raspberry Pi, UP2 board or other board, a GPIO pin-based DTR reset needs to be implemented.

Such like an implementation could be an additional flag named something like gpioreset that is conditional similar to what https://github.com/arduino/arduino-cli/blob/master/commands/upload/upload.go#L212 does, but that pulls the GPIO pin high/low similar to https://github.com/platformio/platformio-core/pull/687/files#diff-9df12ed969b3177c694a1020f4de5cc8R82 but of course allowing a specific GPIO pin to be specified.

For example:

arduino-cli upload -p /dev/ttyAMA0 -gpioreset 4 --fqbn atmel-avr-xminis:avr:atmega328 Arduino/MyFirstSketch

would use GPIO4 to perform the reset before attempting the upload.

Any thoughts on this?

Activity

deadprogram

deadprogram commented on Sep 25, 2018

@deadprogram
Author

Anyone have any opinion on this?

cmaglie

cmaglie commented on Sep 26, 2018

@cmaglie
Member

I'm not very practical with these boards but, there is no really other way to associate GPIO 4 to DTR of ttyAMA0? Doing that would fix the problem from the root.

I'm also wondering if this should be fixed on the uploader instead of hardcoding in the CLI. There is a way to autodetect the gpionumber? Is the Arduino IDE able to upload?

deadprogram

deadprogram commented on Sep 26, 2018

@deadprogram
Author

Hi @cmaglie I have just gone thru the CLI code, and realized that the CLI is literally just a CLI and still needs all of the build tools for any give platform such as avrdude to perform the upload. I had not dug far enough into the CLI code to realize that it is not a replacement for the toolchain.

So there are 2 techniques used in order to deal with the DTR being a separate pin when programming an Arduino from for example a Raspberry Pi or UP2 board.

It seems useful to be able to do the ioctrl strace hack for the user based on command flags passed into the arduino-cli upload command. Alternative would be I suppose use the cli to install the tools, and then manually do the symlinking based on the install location used by the CLI.

facchinm

facchinm commented on Sep 26, 2018

@facchinm
Member

Hi @deadprogram ,
on the last avrdude (6.3.0-arduino14) we added linuxspi programmer which specifically targets RPI-like boards (see https://github.com/arduino/Arduino/issues/7795#issuecomment-406189258); you need to modify avrdude.conf but it's a one time operation and we can avoid adding platform-specific code to the cli

deadprogram

deadprogram commented on Sep 26, 2018

@deadprogram
Author

That looks very cool @facchinm thanks for the reply.

The board I am wanting to flash is the GrovePi. This is the script that does it using a patched avrdude: https://github.com/RobertLucian/GrovePi/blob/master/Firmware/grovepi_firmware_update.sh

Pinging @RobertLucian will this allow replacing the custom patched avrdude you are maintaining for @DexterInd for the mainline version?

RobertLucian

RobertLucian commented on Oct 8, 2018

@RobertLucian

@deadprogram I'm gonna have a look at this stuff - it's been a while since we looked into avrdude. I think it's very likely that this can replace ours. I also love the idea of having mainstream support to it, which is great!

weswitt

weswitt commented on Dec 10, 2018

@weswitt

I flash Arduino boards from an RPI all the time using the linuxgpio programmer. Just connect your pi to the Arduino using SPI and it works great.

masci

masci commented on Aug 5, 2019

@masci
Contributor

Closing since discussion has been stale for a while, feel free to re-open if latest messages didn't work.

dwright213

dwright213 commented on Nov 20, 2019

@dwright213

I'm still running into this Error during Upload: cannot perform reset: cannot set DTR message when I attempt to upload.

The board I'm using is an Arduino zero compatible, Mechaduino board. Is there some additional piece of software am going to need to upload to this board?

added a commit that references this issue on Nov 16, 2020
def90bb
added a commit that references this issue on Aug 9, 2021
7fa8e7c
noeldum

noeldum commented on Feb 24, 2022

@noeldum

Nearly 4 years later what is the conclusion on this?

How do I control a DTR line from arduino-cli? Has the suggested solution been implemented?

For portability is it possible to have arduino-cli triggering a reset command rather than gpio direct control maybe? Then the user would write this reset command.

@deadprogram how did you sort this in the end?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @deadprogram@masci@cmaglie@noeldum@facchinm

      Issue actions

        GPIO-based DTR reset needed for upload on Raspberry Pi/UP2 board etc. · Issue #34 · arduino/arduino-cli