Skip to content

Add new programmer class - for remote upload #2047

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
tchilton opened this issue May 3, 2014 · 9 comments
Closed

Add new programmer class - for remote upload #2047

tchilton opened this issue May 3, 2014 · 9 comments

Comments

@tchilton
Copy link

tchilton commented May 3, 2014

As its easier and faster to develop on a desktop PC, yet many embedded systems end up in hard to access places, it would be really helpful if there was a two-staged programming option for example :

  1. Develop on PC - full size screen, plenty of CPU, plenty of RAM
  2. Compile - as above
  3. "Upload Using Programmer" by sending .hex files to intermediate small form factor raspberry Pi / equivalent over SCP. Remote machine just needs to be reachable on the network wireless, wired, etc.
  4. Initiate a script on the remote system (over SSH ?) that includes execution of AVRDUDE on raspberry PI to program Arduino
  5. Report results back to IDE, so everything is Integrated, like it should be.

I note that the Yun has a SSH / SCP capability. Could this be expanded to make it more general ?

This would also allow for increased flexibility such as SPI programming of remote systems. Conversely, remote serial port redirection to support upload is far harder to do in such situations.

Alternately, could the programmers.txt file be enhanced to allow for a call-out to an OS script file that could do whatever the programmer requires to upload - Just pass it the argument of the .hex file and similar.

@matthijskooijman
Copy link
Collaborator

Sounds like you can already do something like this, just define a new tool in platform.txt that sets tool.xxx.cmd.path to your script and passes your arguments? Then you can refer to that tool using xxx.program.tool in programmers.txt, or xxx.upload.tool in boards.txt?

Having native support for a setup like this in the IDE is unlikely to ever make it, I expect. It is a complicated setup, that requires some fairly advanced know-how (setting up SSH, installing avrdude, connecting everything correctly), while the IDE primarily focuses on novice users. Having said that, perhaps we can tweak the IDE so an advanced user can set this up a custom script for this if he wants to (but perhaps you already can, like I suggested above). Disclaimer: I'm not an official developer, so this is just a personal opinion.

@tchilton
Copy link
Author

tchilton commented May 4, 2014

Thanks for the pointer Matthijs. I had missed platform.txt (I know its in the same folder ... didn't get its purpose on first look)

I now have working remote upload capability - develop on Windows PC, script that SCP's to Raspberry Pi, then SSH's into Pi and run script that runs a modified (kcuzner) version of avrdude that completes the task.

All with the output logged to the IDE's output window.
I need to tidy this up, but once done I'll release it for others to re-use

@matthijskooijman
Copy link
Collaborator

Cool!

@Lauszus
Copy link
Contributor

Lauszus commented May 31, 2014

@tchilton have you released you script anywhere yet? I looking into doing something similar myself for an upcoming project.

@tchilton
Copy link
Author

Hi Lauszus,

I have it mostly 95% working. The scripting side of things is working fine, I can write code on my Windows PC, compile and send to the remote system over a wireless network link to a Raspberry Pi, the Pi has a script that programs the Arduino using a local version of AVRDUDE and all the screen output goes back to my PC's text window in the Arduino IDE.

I hit a couple of problems, they are:

  1. I needed to upgrade to the 1.5 version of the Arduino IDE, since this makes the interfaces I need available to define the new programmers. So far the 1.5 IDE has been OK..
  2. The Arduino configuration files are not sensible about path names and mix both forward and backslashes in the same pathname. I've logged this as a bug, see Path names problem in 1.5 IDE's platforms.txt #2052 (comment), but I've worked around this for my use.
  3. The Raspberry Pi version of the AVRDUDE I use remotely had a bug with inverted reset not being supported - assuming you drive reset with an open collector transistor, so I've submitted a fix for this - see https://github.com/kcuzner/avrdude
  4. I have found a problem with the first run of this configuration, where it seems that the /sys/class/gpio interface is a little slow in exporting the new control interface files when you first call it, so it fails with a file IO error. I know what's causing this but have not had time to fix it yet. Will submit a bugfix into the above AVRDUDE fork to fix it shortly. In the interim, just run it twice and it will be OK
  5. I hit a noise problem with my SPI hardware interface which bricked a Mega, so I had to build a high voltage recovery board and use this. What makes this harder is that 4 of the pins you need are not pinned out by default and a clamp diode needs removing to make it work, but its recovered now and fully working again. To help others, when avrdude asks if you want to program fuses, say no .. unless you are REALLY sure. Also keep a couple of spare Arduino's kicking around.. Always handy for when you get problems.

My outstanding problem is a noisy SPI bus - even with 50R resistors in series, per other articles, it works 50% of the time, but not always and its re-bricks the mega again a couple of times. I could do remote USB over Serial programming but I want the serial port free in my design as I also SSH into the Raspberry Pi and connect over the USB to serial interface to get the Arduino console output.

Due to some time pressures, I've reverted back to standard USB upload from the PC to allow me to move my project forward, but I will fix the issue in the next couple of weeks.

If you want the pre-release versions of the script, then I'll make them available on the project web site http://www.chicken-pi.co.uk in the next couple of days. I just need to find some time to upload them there too. Why do these projects always take longer than you expect :-)

@Lauszus
Copy link
Contributor

Lauszus commented Jun 1, 2014

@tchilton I won't be uploading via SPI anyway, as it will just be temporarily while I work on the project :)

Just let me know when you have uploaded the code - I would really appreciate it.
Have you considered uploading it to Github?

@tchilton
Copy link
Author

Hi Lauszus

I have finally found some time to write up the scripts and make them available for others. You can obtain them on Github as the farduino project. Here's the link.https://github.com/tchilton/farduino

@Lauszus
Copy link
Contributor

Lauszus commented Jul 26, 2015

Thanks @tchilton, I will take a look :)

@sandeepmistry
Copy link
Contributor

I believe #4107 resolves this, but let me know if it doesn't we can re-open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants