My board is an esp32-s3 board, let the generic_gpio for example:.
If you using platformio compile the example rountine in you esp32-idf project directly, there are always some errors occured which caused by undefined macro definitions, as the picture shows above.
By many test, I find there are two solutions below to solve the errors, share them for the people who needed.
One solution: using the Kconfig.projbuild file to generate the macro definitions into sdkconfig.h automatically
step1: Create a new esp32s3 idf project using vscode-platformio, but do not compile.
gpio_example_main.c file and Kconfig.projbuild file in
folder to your project path of src folder, such as
step3: Delete main.c, and rename gpio_example_main.c to main.c.
step4: Copy Kconfig.projbuild file to your project path of config folder, such as
step5: Compile the project, then the errors occured by the undefined macro definitions of
CONFIG_GPIO_OUTPUT_0, CONFIG_GPIO_OUTPUT_1, CONFIG_GPIO_INPUT_0, CONFIG_GPIO_INPUT_1
After compiling, if you open the sdkconfig.h file in
you can find that the macro definitions which needed has been created in sdkconfig.h automatically :
- I don’t know why must copy the Kconfig.projbuild file into the src folder and the config folder before first compiling, but if I do not do this, the errors shows in the top picture occured.
- If I compile the project first, then copy the Kconfig.projbuild file into the src folder and the config folder, and compile the project again, the errors can not solve.
- So, the operate order can not change, you must copy first, compile second, don’t reverse.
Another solution: using build_flags in platformio.ini file
Refer to this post: ESP32: blink - won't compile under pio
Add the defines in platformio.ini:
The values are refered to Kconfig.projbuild: