I2C inconsistency between online mbed compiler & Platformio - Toolchain related?

Hi,

I’m encoutering a strange behavior when using the platformio and some code using the mbed I2C, and I’m wondering if you might help.
Mainly, i’m using the frdm_k64f as platform, and in this particular case, i’m trying to communicate with the BMP085 sensor.

When using the mbed compiler online, my code works perfectly, but when using the platformio, the I2C can’t seems to be properly working, and the problem seems to be the restart condition during the I2C transaction.

This problem appears with my code, but also many other code available such as https://mbed.arm.com/components/Barometric-Pressure-Sensor-BMP085/ for exemple. Working perfectly from the online, but not on platformio.

Therefore, I’m thinking maybe I missed something, a build flag that is needed, or a toolchain configuration or something. I can’t really get why there would be this difference from the 2 compilation envirronment, and maybe you would have an idea?

Sincerely,
Robin

Hi, Robin!
Indeed, PlatformIO and mbed use two different toolchains for compiling - GCC and ARMCC but this shouldn’t be a problem. Could I ask you to compile and upload to your board a simple program (which does not work correctly with PlatformIO) exported as a GCC (ARM Embedded) project from the mbed online compiler?

Hi Valeros,

Thanks for the quick answer.

I exported the simple program linkedin my first post, as GCC arm embedded, then compiled it and run the bin into the frdm_k64f.

The program works as intended.

Unfortunately, I don’t have frdm_k64f board at the moment, but my nucleo_f401re works perfectly with BMP180. Which GCC did you use for compiling?

Hi Valeros,

When compiling directly from the cmd line, I’m using the classical gnu arm embedded toolchain ( gcc-none-eabi).
And this works, I get the data from the sensor.

This is what bugs me, can’t really explain why the .bin from the platformio build does not work as intended.

Hi again,
Not entirely sure if this is the cause of my issue, and if so how to resolve it, but I noticed that the files downloaded from platformio directly ( In the folder .pioenvs/frdm_k64f/FrameworkMbedInc-*****/ where ** is a number), more specifically the ones related to the platform, are quite different from the one that are provided by the online compiler.
I made 2 screencaptures to emphasis if i’m searching for MK64F files : The first one is on the Platformio env,

And the second one, in the folder provided by the online compiler when I export the files.

NB: the list of files related to MK64F is longer, but I thought it was not neccesarilly to print them all

We can clearly see that the online compiler provides more files regarding the board, and therefore the lack of some of those files is the cause of the I2C disfunction when using the .bin generated by platformio?

@rdoume thanks for the info!
The main reason why files may be different is the version of mbed framework, but I’ve just exported a simple project for frdm_k64f from the online compiler and I don’t see MK64F12_* header files. For all peripherals, mbed uses NXP Kinetis SDK(fsl_*.h).

Could you please provide your project with these files here?

@valeros Here’s the raw file exported directly from the online compiler.
I put it on google drive:
https://drive.google.com/open?id=0B9xOrMa5vQm6eFdEZE1NVjNCcGs

Thanks, you have quite outdated mbed library in your project:
mbed.h:19: #define MBED_LIBRARY_VERSION 88
Currently, we use v.121 in PlatformIO. Could you update your mbed library in the online compiler to this version and try to build and run firmware from exported project?

Thanks!

My bad there, it seems indeed that using the v121 from the online
compiler leads to the same issues as with Platformio ( both from online
.bin file & the file generated through gcc).

So it seems that older version of Mbed works for me using Frdmk64f, but not newer then. Is it possible to use an older version through platformio?

Is it possible to use an older version through platformio?

Hmm, it’s not a simple question mainly because we have a little bit tricky build process for mbed framework. I will check such possibility and report you back.
Sorry for the inconvenience!

Perfect ! Thanks you for the quick answers and support, it’s very much appreciated !

I’ve created the mbed library with version 88 for your board. Could you please try to replace folder C:\Users\user\.platformio\packages\framework-mbed\variant\K64F with this one? Any changes?

Hi @Valeros,

This seems to be working just fine now with your folder !

Nice, but keep in mind that this folder will be overwritten with next framework-mbed update.