Skip to content

Commit ab7f19c

Browse files
committed
Merge branch 'feat/basic_br_esp32p4' into 'main'
feat(br): support esp32p4 for basic_thread_border_router example See merge request espressif/esp-thread-br!166
2 parents a203af0 + 3512245 commit ab7f19c

File tree

8 files changed

+161
-4
lines changed

8 files changed

+161
-4
lines changed

examples/basic_thread_border_router/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ If the `OPENTHREAD_BR_AUTO_START` option is enabled, the device will connect to
4141

4242
If the `OPENTHREAD_BR_START_WEB` option is enabled, [ESP Thread Border Router Web Server](../../components/esp_ot_br_server/README.md) will be provided to configure and query Thread network via a Web GUI.
4343

44+
The `ESP_CONSOLE_USB_SERIAL_JTAG` option is enabled by default for ESP Thread Border Router Hardware. If you are using other hardware, you may enable `ESP_CONSOLE_UART_DEFAULT` if you wish to use the UART port for serial communication instead. In either case, `OPENTHREAD_CONSOLE_TYPE_USB_SERIAL_JTAG` or `OPENTHREAD_CONSOLE_TYPE_UART` will be selected accordingly. If you enable `ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG`, please manually specify which `OPENTHREAD_CONSOLE_TYPE` you would like to use.
45+
4446
### Create the RCP firmware image
4547

4648
The border router supports updating the RCP upon boot.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# OpenThread Border Router Example for ESP32-P4
2+
3+
## Overview
4+
5+
There are 2 ways to run this example on the ESP32-P4:
6+
- [(Default): P4 main processor (Ethernet) + C6 Thread radio co-processor](#p4-main-processor-ethernet--c6-thread-radio-co-processor)
7+
- [(Wi-fi): P4 main processor + C6 Wi-Fi co-processor + External H2 Thread radio co-processor](#p4-main-processor--c6-wi-fi-co-processor--external-h2-thread-radio-co-processor)
8+
9+
## How to use example
10+
11+
### Hardware Required
12+
13+
The [ESP32-P4-Function-EV-Board](https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32p4/esp32-p4-function-ev-board/user_guide.html) is recommended for this example. If you wish to use standalone modules, you may refer to the [OpenThread Border Router Example](https://github.com/espressif/esp-idf/tree/master/examples/openthread/ot_br) in esp-idf.
14+
15+
### Set up ESP IDF
16+
17+
Refer to [ESP-IDF Get Started](https://docs.espressif.com/projects/esp-idf/en/latest/esp32p4/get-started/index.html).
18+
19+
Currently, it is recommended to use ESP-IDF [v5.4.2](https://github.com/espressif/esp-idf/tree/v5.4.2) release.
20+
21+
### P4 main processor (Ethernet) + C6 Thread radio co-processor
22+
23+
#### Configure the project
24+
25+
The default configurations in `sdkconfig.defaults.esp32p4` will be applied by using the command:
26+
27+
```
28+
idf.py set-target esp32p4
29+
```
30+
31+
#### Create the RCP firmware image
32+
33+
First build the [ot_rcp](https://github.com/espressif/esp-idf/tree/master/examples/openthread/ot_rcp) example in IDF **using the ESP32C6 target**. In the building process, the built RCP image will be automatically packed into the border router firmware.
34+
35+
> ⚠️ **Warning:** Using the default configurations for this example will flash the built-in C6 co-processor with the OT_RCP firmware, replacing the original ESP-Hosted slave firmware. If you wish to use this example with C6 running Wi-Fi, please refer to the [instructions for Wi-Fi](#configure-the-project-wi-fi).
36+
37+
The border router supports updating the C6 RCP upon boot, with the following header pin connections:
38+
39+
ESP32-P4 pin | ESP32-C6 pin
40+
--------------------|-------------
41+
GPIO4 (UART RX) | TX0
42+
GPIO5 (UART TX) | RX0
43+
GPIO7 | EN
44+
GPIO8 | BOOT
45+
46+
#### Build, Flash, and Run
47+
48+
> The `OPENTHREAD_BR_AUTO_START` option is enabled by default, you may choose to configure the `Thread Operational Dataset` options in menuconfig before building.
49+
50+
Build the project and flash it to the board, then run monitor tool to view serial output:
51+
52+
```
53+
idf.py -p PORT build erase-flash flash monitor
54+
```
55+
56+
### P4 main processor + C6 Wi-Fi co-processor + External H2 Thread radio co-processor
57+
58+
#### Configure the project
59+
60+
Add `esp_wifi_remote` and `esp_hosted` components to the project:
61+
62+
```
63+
idf.py add-dependency "espressif/esp_wifi_remote"
64+
idf.py add-dependency "espressif/esp_hosted"
65+
```
66+
67+
The default configurations in `sdkconfig.defaults.esp32p4` will be applied by using the command:
68+
69+
```
70+
idf.py -D "SDKCONFIG_DEFAULTS=sdkconfig.defaults;sdkconfig.wifi.esp32p4" set-target esp32p4
71+
```
72+
73+
#### Connect an ESP32-H2 RCP to an ESP32-P4 using UART:
74+
ESP32-P4 pin | ESP32-H2 pin
75+
--------------------|-------------
76+
GND | G
77+
5V | 5V
78+
GPIO4 (UART RX) | TX
79+
GPIO5 (UART TX) | RX
80+
GPIO7 | RST
81+
GPIO8 | GPIO9 (BOOT)
82+
83+
#### Flashing ESP32-C6 Wi-Fi Module (optional)
84+
85+
The ESP32-C6 module in the ESP32-P4-Function-EV-Board is pre-flashed with ESP-Hosted slave firmware, so there is no need to flash any additional firmware to the ESP32-C6. However, you may refer to [these instructions for flashing ESP32-C6](https://github.com/espressif/esp-hosted-mcu/blob/main/docs/esp32_p4_function_ev_board.md#5-flashing-esp32-c6) for more information if you wish to update to a newer version of ESP-Hosted slave firmware.
86+
87+
#### Build, Flash, and Run
88+
89+
Build the project and flash it to the board, then run monitor tool to view serial output:
90+
91+
```
92+
idf.py -p PORT build erase-flash flash monitor
93+
```

examples/basic_thread_border_router/main/esp_ot_config.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,21 @@
7272
#endif // CONFIG_OPENTHREAD_RADIO_SPINEL_UART OR CONFIG_OPENTHREAD_RADIO_SPINEL_SPI
7373

7474
#if CONFIG_AUTO_UPDATE_RCP
75+
76+
#if defined(CONFIG_ESP_BR_H2_TARGET)
77+
#define ESP_BR_RCP_TARGET_ID ESP32H2_CHIP
78+
#elif defined(CONFIG_ESP_BR_C6_TARGET)
79+
#define ESP_BR_RCP_TARGET_ID ESP32C6_CHIP
80+
#else
81+
#error RCP target type not supported.
82+
#endif
83+
7584
#define ESP_OPENTHREAD_RCP_UPDATE_CONFIG() \
7685
{ \
7786
.rcp_type = RCP_TYPE_UART, .uart_rx_pin = CONFIG_PIN_TO_RCP_TX, .uart_tx_pin = CONFIG_PIN_TO_RCP_RX, \
7887
.uart_port = 1, .uart_baudrate = 115200, .reset_pin = CONFIG_PIN_TO_RCP_RESET, \
7988
.boot_pin = CONFIG_PIN_TO_RCP_BOOT, .update_baudrate = 460800, \
80-
.firmware_dir = "/" CONFIG_RCP_PARTITION_NAME "/ot_rcp", .target_chip = ESP32H2_CHIP, \
89+
.firmware_dir = "/" CONFIG_RCP_PARTITION_NAME "/ot_rcp", .target_chip = ESP_BR_RCP_TARGET_ID \
8190
}
8291
#else
8392
#define ESP_OPENTHREAD_RCP_UPDATE_CONFIG() \

examples/basic_thread_border_router/main/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
dependencies:
33
espressif/mdns: "^1.0.0"
44
espressif/esp_ot_cli_extension:
5-
version: "~1.2.0"
5+
version: "~1.3.0"
66
espressif/esp_rcp_update:
77
version: "~1.4.0"
88
esp_br_http_ota:

examples/basic_thread_border_router/sdkconfig.defaults

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ CONFIG_OPENTHREAD_ENABLED=y
4646
CONFIG_OPENTHREAD_BORDER_ROUTER=y
4747
CONFIG_OPENTHREAD_CLI_OTA=y
4848
CONFIG_OPENTHREAD_RCP_COMMAND=y
49-
CONFIG_OPENTHREAD_CONSOLE_TYPE_USB_SERIAL_JTAG=y
5049
CONFIG_OPENTHREAD_RADIO_SPINEL_UART=y
5150
# end of OpenThread
5251

@@ -95,7 +94,7 @@ CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y
9594
# end of ESP Border Router Board Kit
9695

9796
#
98-
# Etherenet
97+
# Ethernet
9998
#
10099
CONFIG_EXAMPLE_USE_W5500=y
101100
CONFIG_EXAMPLE_ETH_SPI_HOST=2
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CONFIG_PIN_TO_RCP_TX=4
2+
CONFIG_PIN_TO_RCP_RX=5
3+
4+
CONFIG_ESP_BR_BOARD_STANDALONE=y
5+
CONFIG_ESP_CONSOLE_UART_DEFAULT=y
6+
7+
CONFIG_OPENTHREAD_BR_AUTO_START=y
8+
CONFIG_LWIP_PPP_SUPPORT=y
9+
CONFIG_LWIP_PPP_SERVER_SUPPORT=y
10+
11+
CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET=y
12+
CONFIG_ESP_BR_C6_TARGET=y
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#### Add Wi-Fi Remote config for better performance:
2+
CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=16
3+
CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM=64
4+
CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM=64
5+
CONFIG_ESP_WIFI_AMPDU_TX_ENABLED=y
6+
CONFIG_ESP_WIFI_TX_BA_WIN=32
7+
CONFIG_ESP_WIFI_AMPDU_RX_ENABLED=y
8+
CONFIG_ESP_WIFI_RX_BA_WIN=32
9+
10+
CONFIG_LWIP_TCP_SND_BUF_DEFAULT=65534
11+
CONFIG_LWIP_TCP_WND_DEFAULT=65534
12+
CONFIG_LWIP_TCP_RECVMBOX_SIZE=64
13+
CONFIG_LWIP_UDP_RECVMBOX_SIZE=64
14+
CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=64
15+
16+
CONFIG_LWIP_TCP_SACK_OUT=y
17+
18+
CONFIG_EXAMPLE_CONNECT_WIFI=y
19+
CONFIG_SLAVE_IDF_TARGET_ESP32C6=y
20+
CONFIG_PIN_TO_RCP_TX=4
21+
CONFIG_PIN_TO_RCP_RX=5
22+
23+
CONFIG_ESP_CONSOLE_UART_DEFAULT=y
24+
CONFIG_ESP_BR_H2_TARGET=y
25+
CONFIG_OPENTHREAD_BR_AUTO_START=n

examples/common/thread_border_router/Kconfig.projbuild

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,23 @@ menu "ESP Thread Border Router Example"
5555
default "11"
5656
endmenu
5757

58+
choice ESP_BR_RCP_TARGET
59+
prompt "Border router RCP target"
60+
default ESP_BR_H2_TARGET
61+
help
62+
The board running the Thread RCP.
63+
64+
config ESP_BR_H2_TARGET
65+
bool "ESP32-H2"
66+
help
67+
ESP32-H2 RCP
68+
69+
config ESP_BR_C6_TARGET
70+
bool "ESP32-C6"
71+
help
72+
ESP32-C6 RCP
73+
endchoice
74+
5875
config OPENTHREAD_BR_AUTO_START
5976
bool 'Enable the automatic start mode in Thread Border Router.'
6077
default n

0 commit comments

Comments
 (0)