Friday, October 01, 2021

It's a good idea to update the Arduino IDE

There's some tribal knowledge around about Arduino IDE (and library) versions. I've heard from people that a certain version is the one that works and they don't want to update. Partly this is because they are using an old library and new code "breaks" the build.

Recently, I was talking with Paul, VK3HN, and he mentioned that he had a sketch that, when built for an Uno, was short of RAM.

Paul sent me the code, I compiled it, and didn't get the warning.

This was puzzling of course. I figured it could be one of two things:

  • One of the libraries had been improved to use less RAM
  • The gcc compiler bundled in the IDE had improved.
Here's the compile output from Paul:


Here's my output:


The figure is dynamic memory use:

Paul: 1539
Mine: 1132

Quite a big difference if you only have 2048 bytes of RAM.

It turned out that I was on a slightly later version of the IDE 1.8.15 (not even the latest) and Paul was on 1.8.12.

I tried the beta of Arduino IDE 2 and got the same memory use so I think the version of gcc bundled in it is the same. 

gcc has lots of options and, while I understand the Arduino IDE wants to keep thinks simple, it would be good if the compile options were exposed.

The lesson out of this is that the tools do get better and it's a good idea to upgrade.

4 comments:

  1. Hi Peter, an interesting result indeed. Have you tried any Teensy boards? They have comparatively huge ram and progmem spaces. And they are seriously fast.
    Cheers Richard

    ReplyDelete
  2. Richard,

    Yes, there are loads of boards with more RAM but the challenge is fitting into these tiny CPUs.

    It's great that gcc is being improved so much.

    73
    Peter

    ReplyDelete
  3. Note that the Flash usage increased by nearly the same amount the RAM decreased (with a discrepancy of only 128 bytes). Certainly looks like a case of libraries being improved with const'ing/PROGMEM'ing.

    A way to check is doing a "avr-size program.elf" (where the IDE leaves program.elf from the compiler is an exercise of the reader..) The BSS value, the in-RAM allocation for global variables, would be greatly reduced if the above is true...

    ReplyDelete
  4. Thanks for trying this. As a consequence I updated my IDE and libraries from NT7S (si5351 and JTEncide). It compiled. That gave me the impetus to resume work on the WSPR beacon s riot with GPS, and after a few days of part time play, I'm very happy with it. Thanks for testing on your system Peter.

    Paul VK3HN.

    ReplyDelete