Blog Image

Arduino blog

Arduino thinkering

This blog is about things I come by related to Arduino which I feel are inspiring/important/funny enough to write about.

V3 is coming the first of April: and it is cool

eclipse plugin Posted on Wed, March 09, 2016 20:13:51

We have come a long way with the Arduino eclipse plugin since it started in 2011.
What we now call V1 was based on the AVR plugin and used the Arduino IDE install. You may remember there was a project for each board you used and one for each sketch you had. It supported the Arduino IDE 0.X and 1.X versions. We were excited that it just worked in eclipse. Those days are long gone now.

V2 was a major improvement. We broke with the AVR plugin*. We also put the Arduino core and your sketch in 1 project. It was a huge improvement at the level of configuration and usability. We added lots of oher features to go from it works to it work nicely.

Now V3 (nicknamed toddler) is even going further.
No need for a Arduino IDE anymore for toddler. Install the toddler product; it will download the Arduino AVR boards and toolchains and you can run. Fully auto configured. And lots of other features that make the experience nice an easy.

Och I hear you think: “The Arduino AVR boards only?”
No no no. We have added a boardsmanager to the arduino eclipse plugin and tested it with a bunch of json files. Most of them compiled. Due to lack of hardware we could not test the upload. If it doesn’t work send us a issue on github and the hardware and we’ll fix it. If it works: let us know here or even better on twitter @Arduino_jantje.
The Arduino eclipse plugin -just like the Arduino IDE- is no longer a Arduino/Teensy only IDE. More and more people add json files for other hardware. As such the Arduino in Arduino eclipse plugin is more and more a misfit. But do we really want to change the name?

To get you started quickly with Toddler we made a couple of video’s to get you started.
Here is number one : New and noteworthy: “Single instal**”
Next week video number 2.
Best regards

*As such making it possible to run the AVR eclipse plugin next to the Arduino Eclipse plugin.
**instal=install in British English.

Presentation at t-dose

eclipse plugin Posted on Sun, November 29, 2015 19:41:08

I presented at t-dose today to demo the debug possibilities with arduino community supported hardware using the arduino eclipse plugin.
The speech was recorded and will be released later. For those interested here is the presentation I used.

Best regards

arduino boards.txt and platform.txt and trouble shooting

eclipse plugin Posted on Fri, November 20, 2015 14:25:10

Today I got this mail from a user of the plugin and I would like to use it to explain how the plugin works based on this trouble shooting instance.

the mail
Hi Jantje,

I just installed the Arduino 1.6.6 and updated the AVR to 1.6.9 and the SAM packages for Uno and Due. The Graph sample builds fine for both of them using the IDE.

But I’m having a problem with Eclipse. The call to the archiver (avr-ar) is not being passed the file output file, just empty quotes (“”). The AVR 1.6.8 files work fine. The makefile has the quotes in it: $(AR_OBJ)
@echo ‘Starting archiver’
“/home/rmerriam/Apps/arduino-1.6.6/hardware/tools/avr/bin/avr-ar” rcs “” $(AR_OBJ)
@echo ‘Finished building: $@’
@echo ‘ ‘

The makefile for the SAM is the same: $(AR_OBJ)
@echo ‘Starting archiver’
“/home/rmerriam/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-ar” rcs “” $(AR_OBJ)
@echo ‘Finished building: $@’
@echo ‘ ‘

I tried to track this back to the files you generate at the workspace root and other possible locations without any success.

The answer
Hi user

If you used the latest nightly you should have gotten a message that Arduino IDE 1.6.6 is not supported.
There is a regression in Arduino IDE 1.6.6. which is not so bad on linux but pretty bad on windows.
Though I’m not sure the regressions I’m aware of also match your case I do advice not to use Arduino IDE 1.6.6 (and later) for now.

If I had your environment at my fingertips I’d probably find out quickly what is wrong. Trying to recreate your environment here is a big unknown.
So best for me is that you (or “any plugin user”) would understand what arduino ide and the plugin do to make the compile commands. I have already written a blog to explain the basics on the plugin. You can find it here And here is the spec from arduino on the platform and boards.txt files

Here is my braindump (not cleaned up so you get an idea on how I got where I got)
My first guess is that there is something unexpected in the “platform.txt” which makes the plugin to do something “wrong”.
In this particular case I would check the link recipe in the platform.txt file. Look for how the files get introduced.
…… (light goes on)
I would remember that the plugin links in all the files at once (where the arduino ide does them file by file). Finding the files is done by cdt based on a keyword. Because I can not force arduino to use a specific name for the keyword the plugin has to introduce the keyword itself. The keyword is hardcoded in the plugin.xml.

This is visible in your project properties->C/C++ Build->settings->tool settings(tab)->Arduino archiver->command line pattern. It should be exactly the same as in the plugin.xml

Then I would check the makefile.
The keys ${A.RECIPE.AR.PATTERN.1} ${FLAGS} ${INPUTS} ${A.RECIPE.AR.PATTERN.2} ${A.RECIPE.AR.PATTERN.3} should be extended and $(AR_OBJ) should be added.
Extended mean “recursively replaced with the environment variables” as found in project properties->C/C++ Build->Environment.
…/(light goes on)
why is $(AR_OBJ) not extended? I mean $(AR_OBJ) means replace with all object files that should go to the archiver. It simply has not been replaced.
Secondly the archive file is not there. In my case ${A.RECIPE.AR.PATTERN.1} looks like:
Looking at the command you see in your console and you posted above
“/home/rmerriam/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-ar” rcs “”
“${A.COMPILER.PATH}${A.COMPILER.AR.CMD}” =”/home/rmerriam/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-ar”
I guess the / makes “the double quote part of the string” (instead of “end of string”) which makes $(AR_OBJ) part of the string which makes it is not replaced by the input files. BINGO smiley

So I think we can safely conclude that the root cause of problem is that

For those who have not read the blog mentioned before
${A.BUILD.PATH} in an environment variable means replace with the content of the environment variable A.BUILD.PATH
My naming convention for environment variables states
A.XXX is environment variable provided by arduino or to make the environment variables of arduino work.
on my system
Which is provided by the plugin. Why it is not provided on your system … I don’t know.
Which is provided by the plugin. Why it is not provided on your system … I don’t know.

lets have a look on how we can know where A.BUILD.PATH should be set
All string (should) be defined in We find A.BUILD.PATH here
The eclipse call hierarchy tells us this variable is only used in the method setTheEnvironmentVariablesSetTheDefaults
The method name setTheEnvironmentVariablesSetTheDefaults speaks for itself. As you can see in the code the variable is always set.
If it is missing something went wrong. To fix it it should be sufficient to go to project properties->arduino and select apply. If this is not sufficient there is something wrong in your environment (like arduino ide 1.6.6???, defining BUILD.PATH and ARCHIVE_FILE as empty strings overwriting the defaults?)

I hope this case explain better how the plugin works in regards to the platform.txt and boards.txt file and how one can do in depth trouble shooting.

Best regards


PS I prefer that you create github issues because other people may find the same issues and it is easier for me to keep track of all possible issues.

Debugging and unit testing Arduino (Part 3) Setting it up and debugging

eclipse plugin Posted on Thu, July 02, 2015 00:00:38

EDIT for this to work you need to have a gcc compiler in your path capable of making local executables.

(This post assumes you know how to setup and use the arduino eclipse plugin)
For the sake of this post we will now create a new project based on the uno.
Use the create new sketch wizard to create a new sketch called debugDemo as follows:
Make sure you have selected the correct boards file!!
Lets take a blank ino file
click finisch

open debugDemo.ino and paste following code in the ino file.

#include “Arduino.h”
void setup() {
// Add your initialization code here

void loop() {
static uint8_t ledState=LOW;
ledState = calcLedState(millis(), ledState);
digitalWrite(LED_BUILTIN, ledState);
#define INTERVAL 500
uint8_t calcLedState(uint32_t currentMillis, uint8_t ledState) {
static uint32_t previousMillis = 0;
if (currentMillis – previousMillis > INTERVAL) {
previousMillis = currentMillis;

if (ledState == LOW)
return HIGH;
return LOW;
return ledState;

Compile and upload to a uno to verify it is working. (you should get a blinking led on pin 13)
Untill now we have done nothing new. We have just uploaded a blink without delay sketch to the uno.

Now we’ll create a debug configuration for our debugDemo project using the “jantje hardware”.
To do so you first need to install the hardware found at my github repository.
Once the hardware is on your system right click the project in the project explorer and select project properties->arduino.
Press the button called “manage configurations”

Press the button new to create a new configuration called “Debug” based on “Release” as shown on the image below.

Press ok 2 times to get back to the arduino properties.
Select “Debug” in the configuration in the combo box.
In the boards.txt file select the one that ends with “/hardware/jantje/avr_local/boards.txt”
In debug or unit test fill in “debug”

Make sure you do not have selected “use alternative size command” in compile options.

Compile the project in the debug configuration (this is not strictly needed but it makes it easier to fill in the following forms)
Right click the project->build configurations->build all.
If the build fails probably something went wrong when setting up the environment (but try to build again before looking for the root cause).

Now we have our sketch build for running on arduino and build for debugging on our local machine. What needs to be done now is
Setting up a debug configuration.
Right click the project and select “debug as”->debug configurations.
Select C/C++ application and new.
Here you will have to experiment a bit with the settings. On my system I have to use the “legacy create process launcher”. I use the settings as shown below.

!!Note that forgetting to set the build configuration to Debug is a perfect way to increase your frustration level!!!!
Now click apply and then debug.
If all is well you should see eclipse compiling your project and eclipse may ask you to switch to debug perspective (click yes if he does).

The debugger breaks in the main function. Set a breakpoint where you want it and have a happy debugging session.
Best regards

arduino boards.txt and platform.txt

eclipse plugin Posted on Mon, June 29, 2015 16:49:51

As more and more board vendors create their boards.txt and platform.txt files to make their boards work under the arduino IDE I get more and more questions on how to do this with the arduino eclipse plugin.
Before going into the technicallities there are some practical things I’d like to share.
1) I do not get paid by Arduino (be it .org or .cc) to make this plugin.
2) Donations for the plugin are rare.
3) In other words at this time in my life I can not be bothered about the fact that your board doesn’t work with the arduino eclipse plugin.
Sorry for that.

I hope that with a better understanding of how the parsing of the boards.txt and platform.txt works these vendors/enthusiasts can do it themselves.

How the .txt files are processed.

Conceptually the plugin reads the txt files and makes environment variables from each line where the key is the string before the “=” and the value is the string after the “=”
I say conceptuallly because the key is actually “A.”the string in case of platform.txt.
This also means that the value is parsed to reference the “A.”
Also all keys (both in values and key) are upgraded to upper-case for otherwise: it doesn’t work on windows.

For boards.txt there are some extra rules. The first field must be equal to the selected board or the line gets ignored.
Also for boards.txt the first field+”.” (if equal to the board) will not be part of the key.

Because the .txt files are converted to environment variables only the last definition will remain.
There is a major difference here between the plugin and the arduino IDE that the boards.txt file is not filtered based on content. In other words any value set in platform.txt can also be set in boards.txt and visa versa.

The order of processing.
First there is a default file. Well actually there is no default file but the code adds some default values.
Than the platform.txt file is processed. Note that when you use Arduino IDE 1.6.5 or later it is not the platform.txt file but a generated file. See more below.

Then the boards.txt file is processed.

Then there is some specific post processing code to make things work.

Why do I need to add default values.
The arduino IDE has(and can) not externalized all its environment variables. Therefore the arduino eclipse plugin needed to create these. This is done in the method setTheEnvironmentVariablesSetTheDefaults.
Over time more functionality was placed in here but all with the idea of defaults that can be overruled.

Why do I need the post processing
The recipes as provided by the platform.txt are not ready to be processed by CDT. So I have to cut them in pieces to provide them to CDT. This is done in the method setTheEnvironmentVariablesPostProcessing

The boardsmanager situation.
The boards manager complicated stuff quite a bit.
First of all an extra location for hardware has been introduced.
Secondly new environment variables were introduced that could not be hard coded in the “set the defaults method”.
Basically the plugin was checkmate. The arduino core team made a method that “kind of outputs the platform.txt with these extra unknown variables”
Therefore now the plugin makes a file in the root of the workspace and this file is processed instead of the platform.txt file.

What is not supported.
Be aware that arduino:arduino does not work with the plugin.
Also platform.local.txt does not work with the plugin.

What does all the above mean for the boards.txt and platform.txt maker?
As you are in control of the platform.txt and the boards.txt there
should not be any need for defaults and extra post processing as these methods only
set environment variables as is done by the code processing the .txt

For debugging purposes it is very handy to look in the environment variables of the eclipse project. project properties->C/C++ build->Environment .
Together with the above description you should understand what is going on.

When you change your boards.txt file go to project properties->arduino and select apply. It may be that you have to close the project properties in between to see the changes.

I hope this helps you out.
Best regards

Support for the arduino IDE boards manager (testers wanted)

Arduino sketch experiances Posted on Sat, June 13, 2015 12:09:03

EDIT as Arduino IDE 1.6.5 is out use this one instead of the nightly

How we got here
As you may know the Arduino IDE introduced the boards manager in arduino IDE 1.6.2 which also introduced an incompatibility with the Arduino eclipse plugin.
Moreover the Arduino ide core team had to provide extra functionality to allow the Arduino eclipse plugin to continue working.
They did so in the current hourly so this will be part of the next arduino ide release (1.6.5). smiley This is cool as it shows the importance of the Arduino eclipse plugin in the Arduino community.
This also means that the current hourly build of the arduino IDE contains “untested” code and the arduino eclipse plugin also contains untested code in relation to the boards manager.

The current situation
I had made quite some changes to the arduino eclipse plugin so it is very likely that issues will appear. I’m currently using the hourly arduino IDE for my work under linux and I’m looking for tester/users to use the arduino IDE hourly together with the arduino eclipse plugin nightly.
!!!!Yes the Arduino IDE hourly. I do not support the Arduino hourly IDE so this is an exception case for testing only!!!!

I don’t expect windows and mac users will be able to get it running smiley so I would like some arduino eclipse plugin experienced users, who know how it should work and if possible can provide a pull request.

What needs to be done?
Due to the nature of the change testing is needed for boards installed via the boards manager (like the due) and boards installed with the Arduino IDE.
Both compilation and upload should be tested on all OS’es.
If you pla to use an existing workspace: do not forget to do the update procedure. Both the arduino IDE and project properties are needed.

reporting of failure is important but reporting of success is even more important.
In case of success please report as follows:
[OS] [os version] [BOARDS] compile and upload OK
The arduino IDE version and arduino eclipse plugin version are not relevant as it is hourly and nightly.
please report at this github issue
If it fails report as detailed as possible (most detailed = pull request) on the same github issue.

thanks jantje.

Debugging and unit testing Arduino (Part 2) Conceptually

eclipse plugin Posted on Sat, May 02, 2015 21:02:23

As explained in the previous post we focus on debugging/unit testing your code. However in most cases your code is mixed and mingled with library code and arduino code.
I know your code is not because you strictly separate them smiley but I also know that the first time you want to debug you’ll find some code that ……

To make this a bit real, lets look at the code of blink without delay
If we’d cut the code in your code and arduino code (as you always do smiley) the loop would look like

void loop()
ledState = calcLedState(millis(),ledState);
digitalWrite(ledPin, ledState);

And calcLedState would look like

uint8_t calcLedState(uint32_t currentMillis,uint8_t ledState)
if(currentMillis – previousMillis > interval) {
previousMillis = currentMillis;

if (ledState == LOW)
return HIGH;
return LOW;

The method calcLedState no longer contains any arduino calls. As such we can create a C/C++ project and dump the code in there to debug the method calcLedState. This can be done with the standard CDT debugging tools (see the CDT documentation o how to do so).

This way of working works fine but there are some major drawbacks.
First of all there is the code duplication. As you copy your code to debug you will have to copy your debugged code back to your Arduino project. Chances for mistakes are bug. (typo intended)
Secondly there is a whole lot of Arduino code that is so useful you’ll use it in your code. Think about constrain, map, max,…
The same counts for libraries; think about time, AES ….
All this code will force you to do more work to get your Arduino code to run in the new project.

So even-though this method works fine it turned out not to be practical enough to be usable.

To be usable you need an Arduino lookalike library/core that builds fine on your pc. It does not have to provide all the functionality but you need at least a function implementation for all Arduino methods.

I mean “delay” does not have to provide the functionality (wait number of millis, but the compiler and linker must be able to compile and link to enable debugging/unit testing.

On the other hand constraint, map, max … must be available and implemented properly. Because you use them in your code, remember?.

So I came up with the idea of porting the Arduino AVR boards to the PC. That would satisfy these needs so you don’t have to copy the code but only had to change the arduino board in the properties page of the project.

Again this worked fine (and lots better) but supporting multi configurations would make life even easier.
So I did that one to.smiley

The result is that I ended up with 1 project with 3 configurations. 1 configuration is used to compile and upload to Arduino; 1 is used to compile and debug locally and the last is used to unit test.

The next post will deal with how to set this up practically.

PS thanks for the comments. Keep me writing by keeping them coming 🙂

Debugging and unit testing Arduino (Part 1)

eclipse plugin Posted on Mon, April 27, 2015 00:25:54

Debugging and unit testing
with Arduino

I used many discussions
about debugging Arduino code, and frankly they almost always end with
“print statements and the serial monitor”.

Honestly I think that
whatever happens the serial monitor will be the king of the debugging
tools. That is so because debugging an Arduino program may seem
simple at first hand but it is actually a complex tasks.

If you look at the picture
below you’ll see all the involved components of an Arduino “end
product’”. I say end product because there are no “build tools”
or “debug tools”.

This series of posts is
only about the green part. Your code.

But if your code is only
such a small part of the whole project ….. why would you bother?

Look at the image below ….

As the image above shows:
“your code”, “your electronics” and “your mechanics” may
be the smallest part of the project but it is also the only non
debugged part. So errors are most likely in “your ***”.

The better each of “your
***” parts is debugged and understood the better chance your
project has to be a success.

This series ofpots wants
to show you a way to improve “your code” in ways you may not have
considered possible before. Namely debugging and unit testing.

If you want me to show you how … please post


Next »