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.
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.
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:
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