platform-espressif32 icon indicating copy to clipboard operation
platform-espressif32 copied to clipboard

motor controller code that works from Arduino IDE but not from PIO; possibly an ESPIDF / Arduino include ordering problem?

Open hamishcunningham opened this issue 4 years ago • 1 comments

Hi,

I'm using IDF + the arduino layer with a .platformio like the example here: https://github.com/platformio/platform-espressif32/blob/develop/examples/espidf-arduino-blink/platformio.ini

The code (a simple motor controller demo) works when I compile from the Arduino IDE, but not from PlatformIO. (I can upload successfully, and serial monitoring works as expected, but I2C commands sent to the motor controller board don't work as expected. The ESP32 board is an Adafruit Huzzah 32 with a motor controller featherwing attached.)

I think the problem is caused by some difference between the compiler flags used by the Arduino IDE and by PIO.

One difference is that the IDF version is reported as 4.0.1 when build with Arduino, but 4.0.0 when built with PIO. I think this may be because of the ordering of -I include flags, which is picking up the ESP IDF headers before the Arduino core headers. Both the IDF framework and the Arduino core contain a file esp_idf_version.h, which defines the version:

~/.platformio $ pwd
/home/hamish/.platformio
~/.platformio $ !find
find |grep esp_idf_version.h
./packages/framework-arduinoespressif32/tools/sdk/include/esp_common/esp_idf_version.h
./packages/framework-espidf/components/esp_common/include/esp_idf_version.h
~/.platformio $ grep 'define ESP_IDF_VERSION' `!find `
grep 'define ESP_IDF_VERSION' `find |grep esp_idf_version.h `
./packages/framework-arduinoespressif32/tools/sdk/include/esp_common/esp_idf_version.h:#define ESP_IDF_VERSION_MAJOR   4
./packages/framework-arduinoespressif32/tools/sdk/include/esp_common/esp_idf_version.h:#define ESP_IDF_VERSION_MINOR   0
./packages/framework-arduinoespressif32/tools/sdk/include/esp_common/esp_idf_version.h:#define ESP_IDF_VERSION_PATCH   1
./packages/framework-espidf/components/esp_common/include/esp_idf_version.h:#define ESP_IDF_VERSION_MAJOR   4
./packages/framework-espidf/components/esp_common/include/esp_idf_version.h:#define ESP_IDF_VERSION_MINOR   0
./packages/framework-espidf/components/esp_common/include/esp_idf_version.h:#define ESP_IDF_VERSION_PATCH   0

~/.platformio $ 

The code for the PIO compile is here: https://gitlab.com/hamishcunningham/unphone/-/tree/master/examples/DCMotorTestPIO And the Arduino IDE compile is here: https://gitlab.com/hamishcunningham/unphone/-/tree/master/examples/DCMotorTest

Is there a way I can control the ordering of the compiler flags, or something else I might try?

Thanks!

hamishcunningham avatar Sep 23 '20 14:09 hamishcunningham

This issue has been automatically marked as stale because it has not had recent activity. Please provide more details or it will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jul 31 '22 21:07 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. Please provide more details or it will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Sep 08 '22 22:09 stale[bot]

Closing this as the versions used are no longer current.

hamishcunningham avatar Sep 09 '22 05:09 hamishcunningham