Can't compile Arduino as a component code for ESP32-P4

Hi,

I successfuly compiled and run Arduino as component code for ESP32-S3.
Unfortunately, there are still errors when I’m trying to compile it for ESP32-P4.

Here are the files I’m using:

Platformio.ini

[esp32p4]
    board_build.partitions = boards/dev-16MB.csv   ; 16MB Flash
    board = ESP32-P4-DevKitC-1-NRW32 ; 16 MB Flash, has PSRAM
;

[env]
    platform = https://github.com/pioarduino/platform-espressif32.git#develop

    build_flags     = ${common.build_flags}
    monitor_speed   = ${common.monitor_speed}
    monitor_filters = esp32_exception_decoder, send_on_enter, log2file
    upload_speed    = 921600  ; 921600, 512000, 460800, 256000, 115200

    custom_component_remove = espressif/esp_hosted
                              espressif/esp_wifi_remote
                              espressif/esp-dsp
                              espressif/esp32-camera
                              espressif/libsodium
                              espressif/esp-modbus
                              espressif/qrcode
                              espressif/esp_insights
                              espressif/esp_diag_data_store
                              espressif/esp_diagnostics
                              espressif/esp_rainmaker
                              espressif/rmaker_common


[env:esp32p4]
    board = ${esp32p4.board}
    board_build.partitions = ${esp32p4.board_build.partitions}
    framework = arduino, espidf

Main.cpp

#include "Arduino.h"
#include "WiFi.h"

String ssid =     "******";
String password = "******";

void setup() {
    Serial.begin(115200);
    
    WiFi.begin(ssid.c_str(), password.c_str());
    while (WiFi.status() != WL_CONNECTED) delay(1500);
    }

void loop() {
    
    vTaskDelay(1);
}

And finally, here are errors I’m getting:

(...)
src/main.cpp: In function 'void setup()':
src/main.cpp:15:5: error: 'WiFi' was not declared in this scope
   15 |     WiFi.begin(ssid.c_str(), password.c_str());
      |     ^~~~
src/main.cpp:16:29: error: 'WL_CONNECTED' was not declared in this scope
   16 |     while (WiFi.status() != WL_CONNECTED) delay(1500);
      |                             ^~~~~~~~~~~~
Compiling .pio\build\esp32p4\driver\deprecated\adc_legacy.c.o
Archiving .pio\build\esp32p4\esp-idf\cmock\libcmock.a
Archiving .pio\build\esp32p4\esp-idf\bootloader_support\libbootloader_support.a
Archiving .pio\build\esp32p4\esp-idf\chmorgan__esp-libhelix-mp3\libchmorgan__esp-libhelix-mp3.a
Compiling .pio\build\esp32p4\driver\deprecated\adc_dma_legacy.c.o
*** [.pio\build\esp32p4\src\main.cpp.o] Error 1

Are there any problems with pioarduino library for P4?

PS. The code compiles perfectly fine for the arduino framework.

The ESP32-P4 has no WiFi at all.

See ESP SoCs | Espressif Systems

That’s weird, https://github.com/espressif/arduino-esp32/issues/10278 says the porting status for the WiFi library is “OK”, with “Bluetooth: To be added”

It was a bug in Platformio espidf.py. I have it fixed in latest pioarduino develop branches. BT works well via hosted. Tested and verified working with NimBLE (tested with an early P4 Tasmota build)

P4-Function-EV-Board it utilizes ESP32-C6 for wifi operations.
WiFi.h works seamlessly in the Arduino IDE as well as in Platformio with Arduino framework. The problem is with framework = arduino, espidf configuration…

As written before, bug is fixed. You have to use latest develop branch.

Thx Jason.

I use platform = https://github.com/pioarduino/platform-espressif32.git#develop in my platformi.ini.

I’ve deleted all C:\Users\XXX\ .platformio\ folder, Platformio downloaded all necessary files, but the problem still exists. Should I do anything else?

Try PlatformIO core cli

pio pkg update -g -p espressif32

or

pio pkg update -g -p https://github.com/pioarduino/platform-espressif32.git#develop
PS D:\Dane\Platformio_Projekty\Test> pio pkg update -g -p https://github.com/pioarduino/platform-espressif32.git#develop
Platform Manager: espressif32@54.3.20+develop.sha.37eac4f is already up-to-date
Tool Manager: framework-arduinoespressif32@3.2.0 is already up-to-date
Tool Manager: framework-espidf@3.50402.0 is already up-to-date
Tool Manager: tl-install@5.0.0 is already up-to-date
Tool Manager: tool-esptoolpy@5.0.0 is already up-to-date
Tool Manager: tool-scons@4.40801.0 is already up-to-date

How can I check whether I have the latest dev version?

Mhm. 37eac4f is the latest version of the develop branch according to https://github.com/pioarduino/platform-espressif32/commits/develop. Maybe the fix wasn’t pushed yet or needs a different fix?

The fix is Fix IDF managed component compile · pioarduino/platform-espressif32@f68effb · GitHub and I can compile espidf and HybridCompile projects with hosted mcu fine for the P4

Well this is needed for P4

custom_component_remove = espressif/esp_hosted
                              espressif/esp_wifi_remote

do not remove for P4 or better do not remove anything you don’t know about

1 Like

Now works!
Thx Jason - you’re the Man:)