platformio / platform-espressif32

Espressif 32: development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/espressif32
Apache License 2.0
922 stars 624 forks source link

Can't compile Arduino as an ESP-IDF component when using PIO release v5.3.0 #1031

Closed GKFernandes closed 1 year ago

GKFernandes commented 1 year ago

Hello everyone,

So, I've been trying to make a blank code example work using Arduino as an ESP-IDF Component inside Platformio.

I've followed the guidelines at: https://espressif-docs.readthedocs-hosted.com/projects/arduino-esp32/en/latest/esp-idf_component.html

I intend to build this project to work with ESP32-C3, I'll leave a picture of my platformio.ini file, as well as the current error message when trying to build.

inifile cmakefile1 errorcode1

Edit 1: I see now that Python dependencies may be an issue as well, I know that release 6.0 fixes that, but unfortunately I can't use release 6.0 with Arduino as a component.

Edit 2: Running Menuconfig for the project works fine.

Many thanks!

Jason2866 commented 1 year ago

Your setup is wrong

framework = arduino, espidf

You can look at the examples how it should look like https://github.com/platformio/platform-espressif32/tree/develop/examples

Platformio way is different to IDF. You can't use the documentation from IDF 1:1 with VSC/Platformio.

GKFernandes commented 1 year ago

Hello there @Jason2866 ,

Thank you for the response.

I've changed my setup, now it seems some Arduino function references are not being 'pulled' by the framework, Arduino setup() and loop() functions seem to not be found.

By the way, this same error was happening when using only framework = espidf

In my project, main.cpp includes the same files as the Blink.cpp in the examples, but without the rest of the code, only the includes.

main.zip

undef_reference

Jason2866 commented 1 year ago

In my project, main.cpp includes the same files as the Blink.cpp in the examples, but without the rest of the code, only the includes.

It is not the way it works. Look at the examples.

GKFernandes commented 1 year ago

In my project, main.cpp includes the same files as the Blink.cpp in the examples, but without the rest of the code, only the includes.

It is not the way it works. Look at the examples.

Sorry, which part doesn't work? The file is almost exactly the same as the blink example.

I've tried build the espidf-arduino-blink example using framework = arduino, espidf, it compiles just fine, but I see it does not add the components/arduino folder, like the ESP-IDF documentation mentions.

In a previous project, I managed to use arduino as a component by creating a component folder inside the project directory and placing the Arduino libraries inside the include folder, I was using release espressif32@3.2.1 at the time and framework = espidf.

Guess I will try to use some IDF functions/properties and menuconfig to see if it works.

valeros commented 1 year ago

I've tried build the espidf-arduino-blink example using framework = arduino, espidf, it compiles just fine, but I see it does not add the components/arduino folder, like the ESP-IDF documentation mentions.

The Arduino component is added automatically when you specify framework = arduino, espidf.

In a previous project, I managed to use arduino as a component by creating a component folder inside the project directory and placing the Arduino libraries inside the include folder, I was using release espressif32@3.2.1 at the time and framework = espidf.

Again, PlatformIO handles downloading and importing Arduino core as an IDF component when you specify framework = arduino, espidf in your platformio.ini. Your previous approach is completely possible, but in that case you're on your own as we cannot help debug your custom setup.

The recommendation here is to build your project on the basis of available examples.

DrakoPOD commented 1 week ago

@Jason2866 I have a problem when add arduino to framework, I use an idf components "REQUIRES esp_driver_i2c" results in an error

fatal: not a git repository (or any of the parent directories): .git
CMake Error at C:/Users/<userName>/.platformio/packages/framework-espidf@3.40407.240606/tools/cmake/build.cmake:201 (message):
  Failed to resolve component 'esp_driver_i2c'.

My CMakeList is:

FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/src/*.*)

idf_component_register(
  SRCS ${app_sources}
  REQUIRES esp_driver_i2c
)

Removing arduino, removes the error

Jason2866 commented 1 week ago

Your setup needs the IDF component esp_driver_i2c which is not found. I don't see this driver in IDF 4.4.x so the error is as expected Using Arduino as an component switches in actual Platformio to IDF 4.4.x and Arduino core 2.0.17. Official Platformio does not support actual Arduino core 3.x.x