Skip to content

Commit 344632c

Browse files
ESP32: Add support for ESP32-P4 (project-chip#36312)
* ESP32: Add support for ESP32-P4 * Restyled by clang-format * Restyled by prettier-yaml --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 22fb834 commit 344632c

File tree

8 files changed

+104
-17
lines changed

8 files changed

+104
-17
lines changed

config/esp32/components/chip/CMakeLists.txt

+10-3
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,8 @@ if(CONFIG_BT_ENABLED)
428428
idf_component_get_property(bt_dir bt COMPONENT_DIR)
429429
list(APPEND chip_libraries $<TARGET_FILE:${bt_lib}>)
430430
list(APPEND chip_libraries "${bt_dir}/controller/lib_${target_name}/${target_name}-bt-lib/libble_app.a")
431+
elseif(target_name STREQUAL "esp32p4")
432+
list(APPEND chip_libraries $<TARGET_FILE:${bt_lib}>)
431433
else()
432434
list(APPEND chip_libraries $<TARGET_FILE:${bt_lib}> -lbtdm_app)
433435
endif()
@@ -507,10 +509,10 @@ idf_component_get_property(lwip_lib lwip COMPONENT_LIB)
507509
list(APPEND chip_libraries $<TARGET_FILE:${lwip_lib}>)
508510

509511

512+
idf_component_get_property(esp_wifi_lib esp_wifi COMPONENT_LIB)
513+
list(APPEND chip_libraries $<TARGET_FILE:${esp_wifi_lib}>)
510514
if (CONFIG_ESP32_WIFI_ENABLED)
511-
idf_component_get_property(esp_wifi_lib esp_wifi COMPONENT_LIB)
512515
idf_component_get_property(esp_wifi_dir esp_wifi COMPONENT_DIR)
513-
list(APPEND chip_libraries $<TARGET_FILE:${esp_wifi_lib}>)
514516
if (CONFIG_IDF_TARGET_ESP32C2)
515517
set(blobs core net80211 pp)
516518
else()
@@ -536,6 +538,7 @@ list(APPEND chip_libraries $<TARGET_FILE:${esp_netif_lib}>)
536538
idf_component_get_property(esp_hw_support_lib esp_hw_support COMPONENT_LIB)
537539
list(APPEND chip_libraries $<TARGET_FILE:${esp_hw_support_lib}>)
538540

541+
if (NOT CONFIG_IDF_TARGET_ESP32P4)
539542
idf_component_get_property(esp_phy_lib esp_phy COMPONENT_LIB)
540543
idf_component_get_property(esp_phy_dir esp_phy COMPONENT_DIR)
541544
list(APPEND chip_libraries $<TARGET_FILE:${esp_phy_lib}>)
@@ -550,8 +553,12 @@ endif()
550553
foreach(phy_blob ${phy_blobs})
551554
list(APPEND chip_libraries "${esp_phy_dir}/lib/${target_name}/lib${phy_blob}.a")
552555
endforeach()
556+
endif()
553557

554-
set(components_to_link esp_event hal esp_system soc efuse vfs driver esp_coex freertos esp_timer)
558+
set(components_to_link esp_event hal esp_system soc efuse vfs driver freertos esp_timer)
559+
if (NOT CONFIG_IDF_TARGET_ESP32P4)
560+
list(APPEND components_to_link esp_coex)
561+
endif()
555562
idf_build_get_property(build_components BUILD_COMPONENTS)
556563
foreach(component ${components_to_link})
557564
# Some of the components are not present in IDF v4.x

config/esp32/components/chip/idf_component.yml

+5
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,8 @@ dependencies:
3636
require: public
3737
rules:
3838
- if: "idf_version >=4.3"
39+
40+
espressif/esp_wifi_remote:
41+
version: ">=0.1.12"
42+
rules:
43+
- if: "target in [esp32p4]"

examples/all-clusters-app/esp32/main/Kconfig.projbuild

+6-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ menu "Demo"
2626
default DEVICE_TYPE_ESP32_C3_DEVKITM if IDF_TARGET_ESP32C3
2727
default DEVICE_TYPE_ESP32_C2_DEVKITM if IDF_TARGET_ESP32C2
2828
default DEVICE_TYPE_ESP32_C6_DEVKITC if IDF_TARGET_ESP32C6
29+
default DEVICE_TYPE_ESP32_P4_FUNCTION_EV_BOARD if IDF_TARGET_ESP32P4
2930
help
3031
Specifies the type of ESP32 device.
3132

@@ -57,6 +58,9 @@ menu "Demo"
5758
config DEVICE_TYPE_ESP32_H2_DEVKITM
5859
bool "ESP32H2-DevKitM"
5960
depends on IDF_TARGET_ESP32H2
61+
config DEVICE_TYPE_ESP32_P4_FUNCTION_EV_BOARD
62+
bool "ESP32P4 Function EV Board"
63+
depends on IDF_TARGET_ESP32P4
6064
endchoice
6165

6266
choice
@@ -87,7 +91,7 @@ menu "Demo"
8791
config TFT_PREDEFINED_DISPLAY_TYPE
8892
int
8993
range 0 5
90-
default 0 if DEVICE_TYPE_ESP32_DEVKITC || DEVICE_TYPE_ESP32_H2_DEVKITM
94+
default 0 if DEVICE_TYPE_ESP32_DEVKITC || DEVICE_TYPE_ESP32_H2_DEVKITM || DEVICE_TYPE_ESP32_P4_FUNCTION_EV_BOARD
9195
default 0 if DEVICE_TYPE_ESP32_C3_DEVKITM || DEVICE_TYPE_ESP32_C2_DEVKITM || DEVICE_TYPE_ESP32_C6_DEVKITC
9296
default 3 if DEVICE_TYPE_M5STACK
9397
default 4 if DEVICE_TYPE_ESP32_WROVER_KIT
@@ -118,7 +122,7 @@ menu "Demo"
118122
range 0 40
119123
default 2 if DEVICE_TYPE_ESP32_DEVKITC #Use LED1 (blue LED) as status LED on DevKitC
120124
default 2 if DEVICE_TYPE_ESP32_ETHERNET_KIT
121-
default 8 if DEVICE_TYPE_ESP32_C3_DEVKITM || DEVICE_TYPE_ESP32_C2_DEVKITM || DEVICE_TYPE_ESP32_C6_DEVKITC || DEVICE_TYPE_ESP32_H2_DEVKITM
125+
default 8 if DEVICE_TYPE_ESP32_C3_DEVKITM || DEVICE_TYPE_ESP32_C2_DEVKITM || DEVICE_TYPE_ESP32_C6_DEVKITC || DEVICE_TYPE_ESP32_H2_DEVKITM || DEVICE_TYPE_ESP32_P4_FUNCTION_EV_BOARD
122126
default 26 if DEVICE_TYPE_ESP32_WROVER_KIT
123127
default 40 if DEVICE_TYPE_M5STACK
124128
help
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
CONFIG_IDF_TARGET="esp32p4"
2+
3+
# Flash size and partition
4+
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
5+
CONFIG_PARTITION_TABLE_CUSTOM=y
6+
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
7+
8+
# Enable BLE Host but use remote controller
9+
CONFIG_BT_ENABLED=y
10+
CONFIG_BT_NIMBLE_ENABLED=y
11+
CONFIG_BT_NIMBLE_TRANSPORT_UART=n
12+
CONFIG_ESP_ENABLE_BT=y
13+
14+
# Increase main task stack size
15+
CONFIG_ESP_MAIN_TASK_STACK_SIZE=4096
16+
17+
# Disable Wi-Fi Soft AP
18+
CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n
19+
20+
# LwIP
21+
CONFIG_LWIP_IPV6_AUTOCONFIG=y
22+
CONFIG_LWIP_IPV6_NUM_ADDRESSES=6
23+
24+
# mbedtls
25+
CONFIG_MBEDTLS_HKDF_C=y
26+
27+
# Matter shell
28+
CONFIG_ENABLE_CHIP_SHELL=y
29+
30+
# OTA requestor
31+
CONFIG_ENABLE_OTA_REQUESTOR=y
32+
33+
# Do not deinit BLE after commissioning
34+
CONFIG_USE_BLE_ONLY_FOR_COMMISSIONING=n
35+
36+
# ESP32-P4 Function EV Board use ESP32C6 as slave device
37+
CONFIG_SLAVE_IDF_TARGET_ESP32C6=y
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
CONFIG_IDF_TARGET="esp32p4"
2+
3+
# Flash size and partition
4+
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
5+
CONFIG_PARTITION_TABLE_CUSTOM=y
6+
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
7+
8+
# Enable BLE Host but use remote controller
9+
CONFIG_BT_ENABLED=y
10+
CONFIG_BT_NIMBLE_ENABLED=y
11+
CONFIG_BT_NIMBLE_TRANSPORT_UART=n
12+
CONFIG_ESP_ENABLE_BT=y
13+
14+
# Increase main task stack size
15+
CONFIG_ESP_MAIN_TASK_STACK_SIZE=4096
16+
17+
# Disable Wi-Fi Soft AP
18+
CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n
19+
20+
# LwIP
21+
CONFIG_LWIP_IPV6_AUTOCONFIG=y
22+
CONFIG_LWIP_IPV6_NUM_ADDRESSES=6
23+
24+
# mbedtls
25+
CONFIG_MBEDTLS_HKDF_C=y
26+
27+
# Matter shell
28+
CONFIG_ENABLE_CHIP_SHELL=y
29+
30+
# OTA requestor
31+
CONFIG_ENABLE_OTA_REQUESTOR=y
32+
33+
# Do not deinit BLE after commissioning
34+
CONFIG_USE_BLE_ONLY_FOR_COMMISSIONING=n
35+
36+
# ESP32-P4 Function EV Board use ESP32C6 as slave device
37+
CONFIG_SLAVE_IDF_TARGET_ESP32C6=y

examples/platform/esp32/common/Esp32AppServer.cpp

-12
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,6 @@
4040
#include <app/clusters/device-energy-management-server/DeviceEnergyManagementTestEventTriggerHandler.h>
4141
#endif
4242

43-
#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
44-
#if CONFIG_BT_ENABLED
45-
#include "esp_bt.h"
46-
#if CONFIG_BT_NIMBLE_ENABLED
47-
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
48-
#include "esp_nimble_hci.h"
49-
#endif // ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
50-
#include "nimble/nimble_port.h"
51-
#endif // CONFIG_BT_NIMBLE_ENABLED
52-
#endif // CONFIG_BT_ENABLED
53-
#endif // CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
54-
5543
#ifdef CONFIG_ENABLE_CHIP_SHELL
5644
#include <lib/shell/commands/WiFi.h>
5745
#endif

src/platform/ESP32/ConfigurationManagerImpl.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
#include "esp_mac.h"
3737
#endif
3838
#include "esp_ota_ops.h"
39+
#ifndef CONFIG_IDF_TARGET_ESP32P4
3940
#include "esp_phy_init.h"
41+
#endif
4042
#include "esp_wifi.h"
4143
#include "nvs.h"
4244
#include "nvs_flash.h"

src/platform/ESP32/nimble/BLEManagerImpl.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@
4848
#include <setup_payload/AdditionalDataPayloadGenerator.h>
4949
#include <system/SystemTimer.h>
5050

51+
#ifndef CONFIG_IDF_TARGET_ESP32P4
5152
#include "esp_bt.h"
53+
#endif
5254
#include "esp_log.h"
5355

5456
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
@@ -1021,6 +1023,11 @@ CHIP_ERROR BLEManagerImpl::DeinitBLE()
10211023
return MapBLEError(err);
10221024
}
10231025

1026+
#ifdef CONFIG_IDF_TARGET_ESP32P4
1027+
// Stub function to avoid link error
1028+
extern "C" void ble_transport_ll_deinit(void) {}
1029+
#endif
1030+
10241031
CHIP_ERROR BLEManagerImpl::ConfigureAdvertisingData(void)
10251032
{
10261033
CHIP_ERROR err;

0 commit comments

Comments
 (0)