ArduinoCore-avr icon indicating copy to clipboard operation
ArduinoCore-avr copied to clipboard

Adding SPI programming on a Raspberry Pi (from the IDE)

Open lewispg228 opened this issue 5 years ago • 9 comments

I've been working on a stand-alone AVR programming solution for SparkFun over the past couple years. Currently, we use Python (watching a GPIO) to engage a bash file that calls avrdude. We have found that the SPI hardware built into the raspberry pi is very reliable and it would be awesome to be able to also develop within the arduino IDE (on a raspi), and upload via SPI.

Would this be possible? Is it a crazy request?

lewispg228 avatar Jul 18 '18 19:07 lewispg228

I have a semi-working proof of concept. Maybe you could take a look at it and we can discuss it further in this thread: https://github.com/per1234/Arduino_Boards/pull/1

It's currently implemented in SparkFun AVR Boards but the change could be applied to Arduino AVR Boards instead if this is something Arduino wants.

per1234 avatar Jul 19 '18 04:07 per1234

Hi @lewispg228 , if you switch to latest avrdude (6.3.0-arduino14) which is included in the hourly build of the IDE you'll get linuxspi programmer support for free :wink: You only need to specify where the reset pin is connected on the RPi gpios in your avrdude.conf like this:

programmer
  id = "linuxspi";
  desc = "Use Linux SPI device in /dev/spidev*";
  type = "linuxspi";
  reset = 67;
;

Once added, you can program the Arduino with avrdude -c linuxspi -P /dev/spidev0.0 ...

facchinm avatar Jul 19 '18 07:07 facchinm

Since there is some activity on this topic, I wanted to leave a note in case it might help someone else avoid the confusion I initially suffered:

With the current 6.3.0-arduino14 version of AVRDUDE provided by Arduino, use of the linuxspi programmer will fail if run as non-root. This issue has since been fixed by https://github.com/facchinm/avrdude/pull/2 but Arduino has not done an AVRDUDE release since that time.

per1234 avatar Sep 26 '18 11:09 per1234

Closing this issue since a solution is available as mentioned in above post by @facchinm (https://github.com/arduino/ArduinoCore-avr/issues/282#issuecomment-406189258).

aentinger avatar Sep 17 '19 12:09 aentinger

@lxrobotics this proposal is about adding a linuxspi programmer option to the Tools > Programmer menu in the Arduino IDE so that this programmer can be used from inside the Arduino IDE. The comment you referenced is not at all a solution for that.

I understand completely if the decision is that Arduino does not want to add official support for this programmer, but, if so, that should be stated clearly as the reason for closing the issue.

I've been able to implement this, but it was blocked by a bug in avrdude. Although that that patch was merged long ago, there was no release of a new version of avrdude since then. I believe it might be in avrdude 6.3.0-arduino17 that comes with the newly released Arduino AVR Boards 1.8.1, though I haven't checked that yet since no versioning system is used in Arduino's avrdude development process.

per1234 avatar Sep 17 '19 13:09 per1234

Sorry, I've apparently misread and will reopen this issue. In any case, it's wrongly placed here then and should be moved into the Arduino IDE repository.

aentinger avatar Sep 17 '19 13:09 aentinger

I think it makes sense in the ArduinoCore-avr repository. The reason being that the programmer definition would be added to the programmers.txt file in that repository.

I'd be happy to submit a PR for that if Arduino is interested in this. If not, I will publish a 3rd party dummy hardware core that adds the linuxspi programmer definition, installable via Boards Manager. That solution is a bit less ideal due to the quirky way the Arduino IDE handles platform.txt in this usage.

per1234 avatar Sep 17 '19 13:09 per1234

@per1234 can you please prepare such a PR?

aentinger avatar Sep 17 '19 14:09 aentinger

Hello everyone,

I am looking to flash an ATmega328p with my raspberry Pi using the Arduino IDE. Is the solution available ? Or should we export the binary and flash through the terminal ?

Thanks

adrienlaveau avatar May 30 '21 10:05 adrienlaveau