Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
deadprogram opened this issue Sep 7, 2018 · 10 comments · Fixed by #345
Closed

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

deadprogram opened this issue Sep 7, 2018 · 10 comments · Fixed by #345
Labels
type: enhancement Proposed improvement

Comments

@deadprogram
Copy link

deadprogram commented Sep 7, 2018

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?

@deadprogram
Copy link
Author

Anyone have any opinion on this?

@cmaglie
Copy link
Member

cmaglie commented Sep 26, 2018

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?

@cmaglie cmaglie added the type: enhancement Proposed improvement label Sep 26, 2018
@deadprogram
Copy link
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
Copy link
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
Copy link
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
Copy link

@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
Copy link

weswitt commented Dec 10, 2018

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
Copy link
Contributor

masci commented Aug 5, 2019

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

@dwright213
Copy link

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?

per1234 pushed a commit that referenced this issue Nov 16, 2020
print troubleshooting info, added broker port, general cleanup
per1234 added a commit that referenced this issue Aug 9, 2021
@noeldum
Copy link

noeldum commented Feb 24, 2022

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
Labels
type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants