kcuzner / avrdude

avrdude with a Linux SPI programmer type
http://kevincuzner.com/2013/05/27/raspberry-pi-as-an-avr-programmer/
107 stars 68 forks source link

If a file open in linuxspi_gpio_op_wr fails, retry after a delay #17

Closed per1234 closed 6 years ago

per1234 commented 6 years ago

Setting the reset pin direction immediately after export doesn't allow enough time for the udev rule to give access rights to the gpio user group. This causes avrdude commands run as non-root to fail:

avrdude: linuxspi_gpio_op_wr(): Unable to open file /sys/class/gpio/gpio25/direction

This code is based on the patch in https://github.com/kcuzner/avrdude/issues/10 but it doesn't impose a fixed delay of 2 seconds. On my RPi 3 B+, I find a delay of 50 ms is all that's needed.

Your patch is currently being beta tested for inclusion in the next release of the Arduino IDE/Arduino AVR Boards but this issue makes the linuxspi programmer not terribly useful to Arduino IDE users. So, even if things aren't moving forward quickly for merging your patch in mainline AVRDUDE, it would still be very helpful to get this issue resolved and the patch updated.

I welcome any suggestions for improvement of this code.

Fixes https://github.com/kcuzner/avrdude/issues/10 CC: @thinkingcow

kcuzner commented 6 years ago

Looking at this, I don't like fixed delays/timeouts, but I don't see an immediate path to fixing that. I think this is a necessary change and I'll merge it.