Thursday, January 12, 2017

Integration of Arduino IDE and Geany on Linux to build arduino projects (amake)


I love the whole Arduino project idea, but happens that I use Linux OS as my only OS and I hate the lack of modern functions in the IDE.

Some users have my same ideas some reasons and they brought to life the Ino project software to make this easy; and then when this go deprecated the Arturo project took the lead with a folk of Ino into modern waters.

I has been using both projects since ever, the idea and software are good, but they has different file structures from the Arduino IDE standard, and this bug me a lot.

Then I saw it, a note on the release notes of the Arduino IDE version 1.8.0: now you can build from the command line without the whole IDE apparatus (you don't need a X installed) and this bit me. (Actually it has been on the Arduino IDE since 1.6.x as I can tell, but I don’t know it was the tool I was looking for)

Having a way to build the arduino projects with the arduino tools in the command line will help me integrate it to Geany IDE (my default IDE), plus I keep the WHOLE compatibility of the project: wow!

Taking a peek into the arduino-builder tool I noted that this is still very complicated to configure all the parameters and so, after a few minutes I noted a pattern and started to make a simple bash script to automate this.

That’s how the amake script born.

Being an arduino tool under the hood, full compatibility is expected and maintained in your project, same folder structure, same tricks, same everything.

Now let’s get our hands dirty,to configure it you need to download the lastest amake utility from the above link, and of course the Arduino IDE software for Linux in a version equal or greater than 1.8.0, you can get it from the official Arduino Site please download the file and extract it, put the folder where you like, but take note of the place (full path starting from /).

If you don't have preferences just put it right in your home folder.

Then you need to move the amake file inside the amake-master.zip you just downloaded to a folder named "bin" in you home folder (you must create it if not there already) once you have the file in place open it for edition with your simple text tool (gedit in Gnome, leafpad in LXDE, kedit in KDE, etc.) then locate a line like this:


APATH="~/Documentos/Programación/Arduino/arduino-1.8.0"


Then put the path you take note in the previous steps (where you put the arduino IDE folder) in this line between the "" with no leading or trailing spaces.

Now you need to make the amake file executable, you can use your graphic interface tool (right click > properties > make executable) or using the basic command line, like this:


chmod +x ~/bin/amake


Now you need to configure your IDE build commands, in Geany you can take note of three:

Build


cd %d ; amake uno %f


Take a peek on the Geany help, the %d is swapped by the actual file path and the %f is swapped with the filename at run time.

'uno' is the board name (you can get details running 'amake list')

Download


cd %d ; amake uno %f arduino /dev/ttyUSB1


In this case the new parameters are the word 'arduino' that is the programmer type, in this case we are using an Arduino Uno R3 via USB (you can get more details by runing 'amake prog')

The '/dev/ttyUSB1' is the USB port in which the arduino is connected in my case.

Clean

Some times you may need to clean you build environment, this common task if set by a command like this:


cd %d ; amake clean %f


Other IDE tools may need to switch parameters names but the ones showed here are very common ones and I know you can adapt it to your preferred IDE tool.

In this early developing stage there is limited board support (to the boards I have at hand), if you know bash you can hack the code to ad your board (don't forget to notify the working changes to me to include in the code) or simply write and email to me and I will work with you to get your board supported.

Code hacks and pull request in the github page are always welcomed and appreciated, if you can't code and what to keep this project on going take a peek at the Donations_funding.md file for details.

Happy Ardunio coding (now better under GNU/Linux, of course)

1 comment:

  1. hola desde ciego jeje no muy lejos de camaguey, bueno ley un post suyo en foro.frcuba.cu y me interesa mucho el tema de arduino y las amplias posibilidades que brinda, pero bueno, desconozco como poder comprarlo desde china, si puede expliqueme como lo hace usted y si se lo envian directo desde la tienda, si puede revise su correo gmail que le escribi ahi para aclarar unas dudad. saludos

    ReplyDelete