PlatformIO Review and First Thoughts

I was introduced to PlatformIO by my friend Steven, as we were planning to do an ESP8266 project at a hackathon. Despite being a regular hackaday reader and someone who thinks he’s got his finger on the pulse of the embedded maker community, I’d never heard of it before. It’s a cross-platform environment that supports development across a wide range of microcontrollers and platforms, like ESP, Arduino, and others. It’s got a sweet Atom-based IDE, which is what the focus of this article will be.


I’m interested in it primarily for AVR and Tiva (TI’s ARM chips) parts, as I’m moving away from using Arduino in my projects to improve my firmware skills. Of course, these parts can be programmed using the manufacturer’s solutions, like Code Composer for TI and AVR Studio. Being a mac user however, embedded development has been a hassle, as I’d normally have to virtualize Windows to run Code Composer or AVR Studio. To run under native OSX, I’ve set up the AVR toolchain under eclipse, which was not a pleasant experience. PlatformIO appears to streamline the toolchain setup process by integrating a bunch of open source packages and simplifying project configuration. In short, it appears that they’ve fixed the nightmare that is an embedded toolchain, and they’ve even integrated a serial monitor in the IDE! Let’s go through the installation process and get to programming some AVRs and Tivas.


The first thing you’ll need to do is install the PlatformIO package using pip, Python’s package installer.

sudo easy_install pip
sudo pip install platformio


Assuming everything went well, you should have PlatformIO now, and you can proceed to installing the IDE. Nowhere in my quick glance of the IDE’s documentation did it mention that you need to install PlatformIO and the IDE separately. Maybe to some people it’s obvious, but I think it’s a pretty big documentation oversight that’ll catch a lot of beginners. I caught on quickly, as the IDE installer threw me an error that caused me to remember installing PlatformIO previously via the command line on my laptop. Since the IDE installed smoothly on my laptop, I figured lack of PlatformIO was the issue, and I tracked down the documentation I’d used previously, which is here.


Now you can download the IDE here.


I had to install the latest version of clang, which does code completion.


“sudo clang” did the trick, after accepting some license agreements. This is OS dependent, so look at the link provided in the error message.


Now it looks like we’re good to go. Head over to the PlatformIO menu and select “Initialize new PlatformIO project or update existing.” Specify a directory and select the correct board (I picked my launchpad).


Screen Shot 2016-03-11 at 10.19.40 PM



Finding the correct documentation and sample code was a little confusing the first time around. This seems to be a consistent theme throughout PlatformIO, I think their documentation and example code needs to be a little more cohesive. You end up clicking links and poking around GitHub pages, and the readme files aren’t very well fleshed out.


Eventually I ran across the PlatformIO GitHub page, and there is example code in the “examples/titiva” directory. Within, there are three projects; energia, native, and opencm3. I went for the native example. Turns out, it uses the same TivaWare functions that we’re used to seeing in my other tutorials.


To get this going, I grabbed the code out of the main.c file right off GitHub, and pasted it into a main.c file I already created in my project in the PlatformIO IDE. That goes in the /src folder, naturally. You will also want to ensure that your platformio.ini file matches that of the example, or at least has the section covering your specific microcontroller. Under the PlatformIO menu, click build, cross your fingers, and it should all build successfully. If not, I’ve found the error messages to be quite specific and detailed. Nice! Plug in your LaunchPad and click “upload” under the same menu. Hopefully, after a couple of seconds you’ll have a blinking LED!



Well, I had a blinking LED and I didn’t need to touch flash compiler installation, dependencies, build variables, or anything else that needs to be set up when doing the same process under Code Composer (CC). Given that CC comes from TI and PlatformIO comes from the open source community, I’d call that a huge success. Hands down, it was the fastest I’ve ever gotten an LED blinking, with the exception of Arduino. While looking for example code and documentation will lead you along a twisting path of GitHub and PlatformIO pages, the reference material I’ve found worked the first time. That almost never happens, so that’s pretty good!


Is this Energia?

Energia is TI’s environment for the LaunchPad boards that lets them use standard Arduino syntax and libraries. Two things led me to wonder if there is some element of Energia hanging around in what is supposedly a native development platform.


First, there is a setup() and loop() function in the main.c demo code. This is classic arduino stuff. When I tried pasting in some code I’d written under CC that only had a main() function with a while loop in it, I got an error upon building. The error is below, and says that main() is already defined in energia.a.


Screen Shot 2016-03-11 at 11.03.33 PM


This seems weird, since according to the example, we’re developing with the native framework. Interestingly, the TivaWare functions are working correctly. So is this Energia or not?


The answer to this can be found in the platformio.ini file. Here, we see “framework = energia.” Code completion tells us that “native” is definitely not an option here, but “libopencm3” certainly is.


So we can conclude that we’re developing with the vestiges of Energia, but TivaWare functions work as expected. I think it’s pretty strange, and I’m definitely going to figure out how to get a native framework working without Energia, so that code can work with the standard main() and not the arduino-style setup() and loop(), however convenient they may be. The issue here is keeping compatibility with standard embedded practices so that code is portable. If PlatformIO is really as “professional” as they claim, I’m of the opinion that standard professional practices should be upheld, and hobby style code should be wiped out.


In the meantime, before a true native framework is figured out, I will use the energia framework as if it were native. That is, nothing will go in setup(), and loop() will be structured with inits at the top, followed by a while(1), as would normally appear in main(). This way, code that works under this framework will adhere to standard embedded practice by simply renaming loop() to main().


IDE Thoughts

Man, the IDE is slick! I’ve barely scratched the surface of what it can do, but already, the console window, code highlighting and file navigation are impressive. Tabs work with the keyboard shortcuts you’d expect from a web browser (I think there’s some Chrome behind this, it seems very browser-y). I also love the dark theme, and the collapsible panels have obvious buttons and collapse/expand properly. Very nice UI, it absolutely destroys the awkward Eclipse-based stuff out there.


PlatformIO Thoughts

As I mentioned, this has been the smoothest toolchain installation I’ve ever done. That’s one of the main features of PlatformIO, and it delivers. The documentation is a little convoluted and needs to be a bit more cohesive, but that should improve as the community develops and more people start adopting the platform. I plan to offer a series of videos about it. At the time of this writing, there is only one video, and it doesn’t involve the IDE.


I can’t stress enough how nice it is to have the libraries and toolchain taken care of automatically. It feels more robust than CC, for example, where it feels like the entire toolchain could implode on itself with the wrong click of some box buried deep in a preference pane. However, it is nice to know where things like the TivaWare library are actually located, since you put them there. This is a sense you don’t get with PlatformIO abstracting everything away from you. I certainly plan to dig around in the environment config files to get an understanding of where it is pulling libraries from. That sense of knowing where my files are is important to me, and it is a little weird developing and including things without that. Do I have this library? I don’t know, because I didn’t put it there.


Overall though, I look forward to giving PlatformIO a further test run. I think my nervousness about where it keeps the framework files will be alleviated after digging around, and the issue of energia vs. native development is something I’ll be able to fix and ideally bring back to the community. I’m excited to be using an open source tool chain, and this really feels like we’re on the cusp of something that’s going to be the new standard in the maker community. Hopefully it’ll bleed over into startups and into the professional space. With that kind of adoption, I can see a lot less wrangling with toolchain issues, and a lot of happy firmware devs!

5 thoughts on “PlatformIO Review and First Thoughts

  1. Thank you for the great review. We could attribute main with __attribute__((weak)) so that you can write your own main() in Energia and platformio.

  2. Dear Richard,

    Thanks a lot for great review!!! We will try to answer on your questions and make some corrections.

    1. “The first thing you’ll need to do is install the PlatformIO package using pip”
    This is useless step because PlatformIO IDE contains pre-built version of the latest PlatformIO CLI. We have just made these corrections it in the different places:

    Just “Download & Use” 🙂

    2. “I think their documentation and example code needs to be a little more cohesive.”
    How about?
    Of course, that is our problem if user has problems with our documentation. Do you have any propositions/ideas which parts/pages of our docs should be improved?

    3. “So we can conclude that we’re developing with the vestiges of Energia, but TivaWare functions work as expected. … If PlatformIO is really as “professional” as they claim, I’m of the opinion that standard professional practices should be upheld, and hobby style code should be wiped out.”

    Energia is used in native as example as the source for TI’s driver lib. If you don’t use code from Energia Wiring-based Framework, then the linker will ignore it. You can check it by firmware size.
    Of course, this is really unprofessional approach. The problem here is linked with integration TI’s development platforms to PlatformIO. We made it experimental and don’t update these TI’s platforms/frameworks for more than 1 year. Here are a few reasons:

    * Currently we have very huge community within PlatformIO ecosystem. We are trying to improve and support the most popular development platforms/frameworks/SDKs.
    * Maybe the problem is hidden in small TI community within PlatformIO. We don’t have professional support for their products/boards/frameworks and people don’t use it.
    * What is interesting, that we have contacted with TI a few times and asked to help us. However, we have not received any answers yet. I understand that PlatformIO looks for TI like a “toy”, but this is a big mistake because other corporations/vendors have found how to build success community around PlatformIO. We are open for all and we don’t have any influence from the other vendors/corporations. Our ecosystem and instruments are totally FREE for ALL even for commercial using.


    This is the one of the best review about PlatformIO which I’ve ever seen. Thanks!!!
    Maybe it sounds stupid, but I really like sharp criticism. The key problems were mentioned in this review, such as: messed documentation and bad integration with TI products.

    Nevertheless, people should understand that we are not huge corporation with thousands employees. We are small team(3 very professional guys) which really love what they do and understand how to make customers happy and how to improve embedded world.

    Ivan Kravets and The PlatformIO Team

    P.S: Stay tuned with us on @PlatformIO_Org. We have a lot of interesting suprizes for 2016…

    1. Thanks for the detailed reply, Ivan. I look forward to checking out your recommendations and writing some tutorials in the future! I’ll definitely post an update to this article once I work through some of the issues I was having.

Leave a Reply

Your email address will not be published. Required fields are marked *