-
Notifications
You must be signed in to change notification settings - Fork 0
[WIP] Add Pi_grammer programmer #1
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
base: master
Are you sure you want to change the base?
Conversation
This allows the SPI pins of a Raspberry Pi to be used as an ISP programmer.
Thanks @per1234 ! Really appreciate your fast response! I've been giving this a shot, and get the following error: I think it may have something to do with the version of avrdude that my raspi is using (or rather, which version it is using from the IDE, and which version I can call from a command line. A couple things:
/home/pi/.arduino15/packages/SparkFun/hardware/avr/1.1.10 Is this the proper way to try this out? Also, I tried doing the same calls from command line to see if I could get it to work, and it learned some things. The exact same call to avrdude (like in the IDE verbose output), will emulate the same error. But then I tried calling straight up "avrdude", and it worked... What seems strange to me is that the avrdude that came with my recent download is older (?) at 6.3 While the avrdude that is linked to my environment variable "avrdude" is 6.3-20171130 Any thoughts as to what is going on here? THANKS!!! |
Also, I just stumbled upon your "every other time it works" problem: avrdude: linuxspi_gpio_op_wr(): Unable to open file /sys/class/gpio/gpio26/direction Strangely enough, it will work every time from the command line if the command is preseeded by a "sudo", so I'm guessing it's a permissions thing. I dug into the folder for the gpio26 direction file, and it's opened up to all users, so I'm stumped as to what is causing this. |
Update: I currently got it working from the IDE (still fails every other time, but heck, at least the other issue is gone). It was the fact that the current release of the Arduino IDE comes with older avrdude (6.3). I installed the nightly version and it came with 6.3-20171130, and it worked! Thanks @facchinm for your comment. It lead me in the write direction! |
Sorry for the confusion. I happened to be using the hourly build of the Arduino IDE. The avrdude version can be specified in the JSON file used for Boards Manager installation of SparkFun Boards. So, as long as the user installs via Boards Manager (which is the only method described in the readme and the guide on the SparkFun website, we can be sure they will always be using the version of avrdude that supports the linuxspi programmer type. I did a bit of research on the
but I really like the current very minimal implementation. The script workaround would require adding a new tool to platform.txt that would be used only for the Pi_Grammer programmer so it's kind of messy. So I'd prefer to find a solution using the existing avrdude tool definition but I'm also stumped. |
@per1234 Thanks for looking further into this.
Interesting. Where does/would it install this on the pi? I was searching around the packages folder (/home/pi/.arduino15/packages/SparkFun/hardware/avr/1.1.10) and couldn't see it anywhere. I'm new to all this, and it seems a little tricky to keep track of where all the actual avrdude versions and settings files live (programmers.txt, avrdude.conf, etc.) I will ask around here at SparkFun to see if anyone knows more about this gpio issue. Really appreciate your help so far! |
Just an FYI here, I have been testing this out with a little custom programming HAT (which include level shifters), and it is working well on a 5V/16MHz board (The SparkFun Redboard). |
It would be installed to /home/pi/.arduino15/packages/tools/avrdude/6.3.0-arduino14
Great! Hopefully someone with some more RPi experience than I can point us in the right direction.
I really enjoyed reading your article about the RPi standalone programmer. |
I found the solution to the It turned out someone had submitted a patch to the linuxspi author two years ago for this: I improved the patch a bit, applied it to the latest Arduino version of avrdude: You can download the modified avrdude here: https://github.com/per1234/Arduino_Boards/files/2226696/avrdude.zip or build it from my source if you prefer: https://github.com/per1234/avrdude/tree/linuxspi-retry (here's the build script that applies Arduino's patches: https://github.com/arduino/avrdude-build-script/tree/staging). Then just replace {Arduino IDE installation folder}/hardware/avr/bin/avrdude with the modified version. I find that Burn Bootloader works fine now so I don't think any modifications need to be made to deal with the current back to back avrdude commands. It would be great if others would give it a try and let me know how it works for them. So now the question of how to proceed? I'm going to submit a PR (kcuzner/avrdude#17) to kcuzner/avrdude and would appreciate any feedback on that code as I have no prior experience with this. After that is requesting Arduino to update their AVRDUDE code according to the updated patch. If SparkFun wants to proceed with this project, it's not actually necessary to wait on any of that since they have the option of simply distributing their own version of the AVRDUDE tool via the Boards Manager installation. |
I'm trying to follow the breadcrumb trail to get my pi zero working as a programmer today. It appears that kcuzner/avrdude#17 was merged, so if there's no more action to be taken, I'd like to see this PR closed so no future person tries to follow it. |
What is the harm in someone following it? |
🤷🏻♂️ if it's not abandoned work, nothing's wrong. Looked like you solved the issue elsewhere though. |
It's not abandoned. I would like to see this programmer made easily accessible for people to use via the Arduino IDE. It is true that I don't know when I'll have time to move forward with this. I had planned to make a 3rd party platform that would allow people to install support for the programmer via Boards Manager. I had to wait for my patch to AVRDUDE to be merged, and for Arduino to release a version of AVRDUDE that contained that patch. That took a long time. By the time it did happen, health issues and the associated ongoing medical expenses have made it so that I now have very little time for volunteer work. Now, Arduino has made a change to the Arduino IDE that means 3rd party programmer platforms will no longer be possible: arduino/Arduino#9900 So the only path forward is to submit a pull request to Arduino AVR Boards and any major 3rd party AVR-based platforms that don't reference the arduino core. This PR shows what would be needed to do that, so it's very much still relevant. The intent of this PR was to demonstrate the necessary changes and provide a place for me to discuss them with lewispg228. For the actual PR, I would change the programmer name to something standardized like
The sub-issue of the bug in AVRDUDE has been solved, at least in Arduino's fork. But the AVRDUDE issue was only a blocker for the real goal of this project: to make the linuxspi programmer available for use via the Arduino IDE. That is very much not solved yet. |
I'll share an update: the The implementation is a little bit different from the original. The good news is that it is not affected by kcuzner/avrdude#10. The bad news is that the port name format is different. So the The Other than that, I have found the official linuxspi to work perfectly. |
This adds a Tools > Programmer > Pi_grammer menu selection after installing SparkFun AVR Boards, which allows the SPI pins of a Raspberry Pi to be used as an ISP programmer. More info here.
Installation instructions:
add-pi_grammer
branch).Usage
Powering a 16 MHz board at 3.3 V is out of spec and may lead to unstable operation. Connecting the RPi GPIO pins directly to a board running at 5 V can damage the RPi so you should use level shifters.
https://learn.sparkfun.com/tutorials/raspberry-pi-spi-and-i2c-tutorial#spi-on-pi
Note that I found the menu path to be a little different using the latest version of Raspian.
I've tested this working (every other time, see (1) below) with the SparkFun Digital Sandbox. I haven't tested the 16 MHz boards because I don't have level shifters to safely use my Raspberry Pi with boards running at 5 V.
To do:
Every other upload fails:(fixed by https://github.com/per1234/avrdude/commit/1b673007e0382564f50aedad8875036ca48de27c)avrdude: linuxspi_gpio_op_wr(): Unable to open file /sys/class/gpio/gpio26/direction
.The SparkFun pi_program.sh script used for programming their products does a reset of the target between setting fuses and flashing (https://github.com/sparkfun/SparkFun_Pi_AVR_Programmer_HAT/blob/master/pi_program.sh#L29-L33). Due to (1) I have not been able to complete a Burn Bootloader to see if this is necessary. The alternative is to simply set fuses and burn bootloader in a single avrdude command. The two avrdude commands back to back have historically caused problems with the AVRISP mkII ((Doesn't appear to be necessary)https://github.com/arduino/Arduino/issues/2986
) and reportedly continue to do so for the AVR Dragon (https://github.com/arduino/ArduinoCore-avr/issues/9
).https://github.com/sparkfun/Arduino_Boards/issues/21
, this is an outdated version of that file and so this avrdude.conf will need to be updated in order to ensure support for all newer programmers and parts. The current version of the file should be fine for any testing of the Pi_grammer programmer.Reference:
https://github.com/arduino/Arduino/issues/7795