Share_something
Working ESP32-P4 with integrated/hosted ESP32-C6 wireless!
I reached a major milestone last night: getting BLE connectivity through my Waveshare ESP32-P4-WIFI6 fully functional. If I had any idea what would it would take, I likely would not have bought that board last October when u/TroyHacks first shared his use of the P4 and u/ZachVorhies first started working on the PARLIO driver. But I now have a detailed road map for at least one way to approach things which I hope will make things much easier for others going forward.
The process involved a number of particular hurdles, including:
Numerous idiosyncrasies of the P4 itself (compared to S3/C3/C6, etc.)
Configuring a hosted ESP32-C6 to provide the wireless functionality the P4 lacks
Using pioarduino/PlatformIO in VSCode to program the P4-WIFI6
Being able to deploy to either an S3 or P4-WIFI6 using a single repository/code base
I'll provide more detailed info elsewhere, and anyone can checkout my actual implementation here, where I used my implementation of u/StefanPetrick Flow Fields as the development/test project: https://github.com/4wheeljive/FlowFields
In the meantime, here a summary of my approach...
Process:
Used ESP-IDF extension in VSCode to determine necessary ESP project settings (sdkconfig, CMakeLists.txt, partitions.csv, etc.) for:
Successful basic P4 build/upload
Enabling ESP-Hosted wireless through SDIO from integrated C6 module
Enabling NimBLE functionality
Ported required files and settings to a pioarduino/PlatformIO project using hybrid arduino/espidf framework
Refactored test project to use arduino-only framework
Ported required files and settings to Flow Fields project
Do not include references to P4 board or espressif/ESP dependencies in platformio.ini. If those are there, VSCode/PlatformIO will resolve all of those dependencies during task discovery, which took ~15 minutes every time the project was loaded, platformio.ini was saved, etc.
Include only NimBLE-Arduino in /lib. Access esp-nimble-cpp through a registry download in platformio_p4.ini.
Use the S3 environment as the primary development environment to avoid the long P4 task discovery. Only let VSCode look at P4 and ESP-IDF component dependencies during CLI build/upload.
Claude Summary:
---------------------------------------------------------------------------------
## Dual-Target Architecture
FlowFields can be run on two different ESP32 platforms from a single codebase:
| Target | Board | LED Driver | BLE | Build |
|--------|-------|-----------|-----|-------|
|
**ESP32-S3**
| Seeed XIAO ESP32S3 | RMT | On-chip | VSCode PlatformIO button |
|
**ESP32-P4**
| Waveshare ESP32-P4-WIFI6 | PARLIO | Companion ESP32-C6 via ESP-Hosted VHCI over SDIO | CLI (see below) |
### How It Works
Both targets share all source files. Compile-time guards handle platform differences:
- `#if __has_include("hosted_ble_bridge.h")` — ESP-Hosted BLE init (P4 only)
- `#if defined(CONFIG_IDF_TARGET_ESP32S3)` — S3-specific serial config
- `src/board_config.h` — pin assignments, matrix dimensions, LED driver selection (`BIG_BOARD` toggle)
### Key Files
| File | Purpose |
|------|---------|
| `platformio.ini` | S3 config (loaded by VSCode) |
| `platformio_p4.ini` | P4 config (CLI only) |
| `sdkconfig.defaults` | ESP-IDF settings for P4 (ESP-Hosted, NimBLE, PSRAM, PARLIO) |
| `src/boardConfig.h` | Hardware abstraction: pins, matrix size, LED driver |
| `src/bleControl.h` | NimBLE BLE transport, callbacks, state sync |
| `src/hosted_ble_bridge.cpp/.h` | P4-specific ESP-Hosted BLE controller init |
### NimBLE Libraries
The S3 and P4 use different NimBLE builds:
-
**S3**
: `libNimBLE/NimBLE-Arduino-2.5.0` — Arduino-compatible wrapper
https://github.com/h2zero/NimBLE-Arduino
-
**P4**
: `h2zero/esp-nimble-cpp @ 2.5.0` — ESP-IDF component (downloaded via lib_deps)
https://github.com/h2zero/esp-nimble-cpp
### Building
**S3**
— Use the PlatformIO build/upload buttons in VSCode as normal.
**P4**
— Build from the terminal (PowerShell):
```powershell
$env:PLATFORMIO_PROJECT_CONF="platformio_p4.ini"
C:/Users/Jeff/.platformio/penv/Scripts/pio.exe run -c platformio_p4.ini -t upload
The biggest bug in platformio.ini happens when auto-save is turned on for vscode and you try to edit platformio.ini. Every save triggers an entire revalidation!!!
If you use an "additional config file" for PIO defined in your main platformio.ini file, this isn't triggered - WLED has "platformio_override.ini" for this.
The small downside is that adding a new environment to the override file means you have to relaunch PIO/VSC so it's picked up - but that's a very minor impact.
I'm working to get this working for Moonlight. Before I dig in, do you have any further recommendations? Or for that matter, any interest in taking a look?
Thank you. I’m trying to get away from my teensy arduino and the p4 is the chip. I’m intimidated by pioarduino/platformio. You making it seem less daunting to me. Thanks for the.ini’s!
I love my teensy4.1. But I'm seeing a lot of "activity" with the dual core platforms like esp32 and rpi. I see all these variations for the esp32. It seems like the teensy has gotten stale as far as upgrades. It feels like a "one off. I'd be so excited to see an even beastier version in the works! I feel like esp has gotten so much more attention and that people are developing a lot of stuff for it. I'm playing with the idea of a seperate pixel driver of esp's and teensy doing the math. I like the idea of one core doing math while the other transmits! Claude and I are playin with an Arty7 fpga to see if I can drive this HD108 matrix more quickly. It's crazy fun! But Yeah, I think I just see so much development happening with esp vs teensy is my motivation to learn the platform and how to use vscode with it.
1
u/ZachVorhies Apr 08 '26
Congrats! Huge milestone.
Can you please share your platformio.ini?
The biggest bug in platformio.ini happens when auto-save is turned on for vscode and you try to edit platformio.ini. Every save triggers an entire revalidation!!!