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)

Fill in only if you are not real





The following XHTML tags are allowed: <b>, <br/>, <em>, <i>, <strong>, <u>. CSS styles and Javascript are not permitted.
Posted by Kees Bakker Sun, July 05, 2015 23:23:08

In case you want have a look:

https://github.com/keestux/arduino-eclipse-plugin/tree/try_arduino_arduino

Posted by Kees Bakker Sun, July 05, 2015 21:02:23

Just to let you know.
I'm making some progress. What I first want to do is to let the plugin recognize the arduino:arduino syntax, and that it strips the first part, if it is "arduino".

Furthermore, I had to create a few symlinks in my ~/.arduino15 tree, but now I can build and upload a sketch.

For the symlinks I have no solution yet, so maybe I have to package up the whole tool section with our board config. It is ugly and it is exactly what Arduino IDE was trying to avoid.

Posted by Jan Thu, July 02, 2015 23:23:31

smiley

Posted by Kees Bakker Thu, July 02, 2015 23:02:54

Thanks.

I found out that I cannot take a shortcut with platform.txt. Arduino IDE knows how to fall back to the standard arduino platform.txt, but our plugin doesn't.
As a work-around I have copied all of arduino-1.6.5/hardware/arduino/avr/platform.txt into ours (except name and version). Now I'm able to build a sketch.

One step forward

Posted by Jan Wed, July 01, 2015 23:20:02

Look at setTheEnvironmentVariablesPostProcessing A.RECIPE.CPP.O.PATTERN gets cut into pieces.
Also look at project properties->c/c++ build->settings->tool settings->arduino C++ compiler-> command line pattern. This goes to the makefile.

Posted by Kees Bakker Wed, July 01, 2015 22:03:48

Hey Jan,

Any hint about the following would be helpful. Somehow the compiler argv0 is empty in the generated makefile (subdir.mk). I've looked at A.COMPILER.PATH and A.RECIPE.CPP.O.PATTERN. But I'm really clueless.

This is what I see:

make all
Building file: ../.ino.cpp
/bin/sh: 1: I/home/kees/.arduino15/packages/SODAQ/hardware/avr/1.0.0/cores/arduino: not found
Starting C++ compile
make: [.ino.cpp.o] Error 127 (ignored)
I"/home/kees/.arduino15/packages/SODAQ/hardware/avr/1.0.0/cores/arduino" -I"/home/kees/.arduino15/packages/SODAQ/hardware/avr/1.0.0/variants/mbili" -MMD -MP -MF".ino.cpp.d" -MT".ino.cpp.o" -D__IN_ECLIPSE__=1 -x c++ "../.ino.cpp" ".ino.cpp.o" -Wall
subdir.mk:24: recipe for target '.ino.cpp.o' failed

Posted by Jan Wed, July 01, 2015 20:55:11

I mean that the keys need to be made uppercase in the value and in the key.
for instance
build.core.path={runtime.platform.path}/cores/{build.core}

becomes

A.BUILD.CORE.PATH=${A.RUNTIME.PLATFORM.PATH}/cores/${A.BUILD.CORE}

PS I forgot to mention the addition of the $ to have cdt recognize it as a environment variable

Posted by Kees Bakker Wed, July 01, 2015 20:28:12

"Also all keys (both in values and key) are upgraded to upper-case"
I think (hope) that you meant to say: both in boards.txt and platform.txt
The values are not converted to uppercase, as far as I can see.

Posted by Jan Wed, July 01, 2015 20:25:25

@Kees
If something is not clear please tell me what. So I can elaborate.
Best regards
Jantje

Posted by Kees Bakker Wed, July 01, 2015 19:20:28

Thanks for writing this down. I'll make an attempt. But it will take time to digest what you just wrote.