Arduino blog

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.

arduino boards.txt and platform.txt

eclipse pluginPosted by Jan 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 files.

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
Jantje





  • Comments(10)//blog.baeyens.it/#post22