Merge branch 'feature/gateway_support_c6' into 'master'

zigbee: zigbee gateway support for single chip esp32-c6 solution

See merge request espressif/esp-idf!23061
This commit is contained in:
Shu Chen 2023-04-07 17:08:38 +08:00
commit d6767c22f5
14 changed files with 86 additions and 44 deletions

View File

@ -18,13 +18,13 @@ The ESP Thread Border Router SDK provides extra components and examples for putt
#### **Wi-Fi based Thread Border Router** #### **Wi-Fi based Thread Border Router**
By default, two SoCs are required to run this example: By default, two SoCs are required to run this example:
* An ESP32 series Wi-Fi SoC (ESP32, ESP32-C, ESP32-S, etc) loaded with this ot_br example. * An ESP32 series Wi-Fi SoC (ESP32, ESP32-C, ESP32-S, etc) loaded with this ot_br example.
* An ESP32-H4 802.15.4 SoC loaded with [ot_rcp](../ot_rcp) example. * An ESP32-H2 802.15.4 SoC loaded with [ot_rcp](../ot_rcp) example.
* Another ESP32-H4 SoC loaded with [ot_cli](../ot_cli) example. * Another ESP32-H2 SoC loaded with [ot_cli](../ot_cli) example.
Connect the two SoCs via UART, below is an example setup with ESP32 DevKitC and ESP32-H4 DevKitC: Connect the two SoCs via UART, below is an example setup with ESP32 DevKitC and ESP32-H2 DevKitC:
![thread_br](image/thread-border-router-esp32-esp32h4.jpg) ![thread_br](image/thread-border-router-esp32-esp32h2.jpg)
ESP32 pin | ESP32-H4 pin ESP32 pin | ESP32-H2 pin
----------|------------- ----------|-------------
GND | G GND | G
GPIO4 | TX GPIO4 | TX

View File

Before

Width:  |  Height:  |  Size: 331 KiB

After

Width:  |  Height:  |  Size: 331 KiB

View File

@ -9,7 +9,7 @@ This example demonstrates an [OpenThread CLI](https://github.com/openthread/open
### Hardware Required ### Hardware Required
To run this example, an ESP32-H4 board is required. To run this example, an ESP32-H2 board is required.
### Configure the project ### Configure the project
@ -63,7 +63,7 @@ factoryreset
## Set Up Network ## Set Up Network
To run this example, at least two ESP32-H4 boards flashed with this ot_cli example are required. To run this example, at least two ESP32-H2 boards flashed with this ot_cli example are required.
On the first device, run the following commands: On the first device, run the following commands:
```bash ```bash

View File

@ -13,11 +13,11 @@ OpenThread RCP doesn't function alone, it needs to work together with a Host and
### Hardware Required ### Hardware Required
To run this example, an ESP32-H4 board is required. To run this example, an ESP32-H2 board is required.
### Configure the project ### Configure the project
The default communication interface is port 0 of ESP32-H4 UART running at 115200 baud, change the configuration in [esp_ot_config.h](main/esp_ot_config.h) if you want to use another interface or need different communication parameters. The default communication interface is port 0 of ESP32-H2 UART running at 460800 baud, change the configuration in [esp_ot_config.h](main/esp_ot_config.h) if you want to use another interface or need different communication parameters.
### Build and Flash ### Build and Flash

View File

@ -2,16 +2,16 @@
examples/zigbee/esp_zigbee_gateway: examples/zigbee/esp_zigbee_gateway:
disable: disable:
- if: IDF_TARGET in ["esp32c2", "esp32c6", "esp32h2"] - if: IDF_TARGET in ["esp32c2", "esp32h2"]
temporary: true temporary: true
reason: target(s) not supported yet reason: target(s) not supported yet
examples/zigbee/esp_zigbee_rcp: examples/zigbee/esp_zigbee_rcp:
enable: enable:
- if: IDF_TARGET in ["esp32h4", "esp32c6", "esp32h2"] - if: IDF_TARGET in ["esp32c6", "esp32h2"]
reason: should able to run on esp32h4 esp32h2 and esp32c6 reason: should able to run on esp32h2 and esp32c6
examples/zigbee/light_sample: examples/zigbee/light_sample:
enable: enable:
- if: IDF_TARGET in ["esp32h4", "esp32c6", "esp32h2"] - if: IDF_TARGET in ["esp32c6", "esp32h2"]
reason: should able to run on esp32h4 esp32h2 and esp32c6 reason: should able to run on esp32h2 and esp32c6

View File

@ -3,5 +3,6 @@
# The following five lines of boilerplate have to be in your project's # The following five lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly # CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.16) cmake_minimum_required(VERSION 3.16)
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common)
include($ENV{IDF_PATH}/tools/cmake/project.cmake) include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(esp_zigbee_gateway) project(esp_zigbee_gateway)

View File

@ -1,21 +1,24 @@
| Supported Targets | ESP32 | ESP32-C3 | ESP32-S2 | ESP32-S3 | | Supported Targets | ESP32 | ESP32-C3 | ESP32-C6 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | | ----------------- | ----- | -------- | -------- | -------- | -------- |
# Gateway Example # Gateway Example
This example demonstrates how to build a Zigbee Gateway device. It runs on a Wi-Fi SoC such as ESP32, ESP32-C3 and ESP32-S3, with an 802.15.4 SoC like ESP32-H4 running [esp_zigbee_rcp](../esp_zigbee_rcp) to provide 802.15.4 radio. This example demonstrates how to build a Zigbee Gateway device.
The ESP Zigbee SDK provides more examples and tools for productization:
* [ESP Zigbee SDK Docs](https://docs.espressif.com/projects/esp-zigbee-sdk)
* [ESP Zigbee SDK Repo](https://github.com/espressif/esp-zigbee-sdk)
## Hardware Required ## Hardware Required
* One development board with ESP32 or ESP32-S3 SoC acting as Zigbee gateway (loaded with esp_zigbee_gateway example) By default, two SoCs are required to run this example:
* A USB cable for power supply and programming * An ESP32 series Wi-Fi SoC (ESP32, ESP32-C, ESP32-S, etc) loaded with this esp_zigbee_gateway example.
* Three jumper wires for UART (TX, RX and GND) * An ESP32-H2 802.15.4 SoC loaded with [esp_zigbee_rcp](../esp_zigbee_rcp) example
* Gateway doesn't function alone. Choose ESP32-H4 as Zigbee rcp (see [esp_zigbee_rcp example](../esp_zigbee_rcp))
* **Flash** Zigbee rcp on the ESP32-H4 DevKitC first **before** connecting to Zigbee gateway
* Connect the two SoCs via UART, below is an example setup with ESP32-DevKitC and ESP32-H4-DevKitC:
![Zigbee_gateway](../../openthread/ot_br/image/thread-border-router-esp32-esp32h4.jpg)
ESP32 pin | ESP32-H4 pin Connect the two SoCs via UART, below is an example setup with ESP32-DevKitC and ESP32-H2-DevKitC:
![Zigbee_gateway](../../openthread/ot_br/image/thread-border-router-esp32-esp32h2.jpg)
ESP32 pin | ESP32-H2 pin
------------- |------------- ------------- |-------------
GND | G GND | G
GPIO4 (RX) | TX GPIO4 (RX) | TX
@ -23,9 +26,13 @@ ESP32 pin | ESP32-H4 pin
* TX, RX pin can be also configured by user in esp_zigbee_gateway.h * TX, RX pin can be also configured by user in esp_zigbee_gateway.h
The example could also run on a single SoC which supports both Wi-Fi and Zigbee (e.g., ESP32-C6), but since there is only one RF path in ESP32-C6, which means Wi-Fi and Zigbee can't receive simultaneously, it has a significant impact on performance. Hence the two SoCs solution is recommended.
## Configure the project ## Configure the project
Before project configuration and build, make sure to set the correct chip target using `idf.py set-target esp32` or `idf.py set-target esp32s3` Before project configuration and build, make sure to set the correct chip target using `idf.py set-target <chip_name>`.
In order to run the example on single SoC which supports both Wi-Fi and Thread, the option `CONFIG_ESP_COEX_SW_COEXIST_ENABLE` and option `CONFIG_ZB_RADIO_NATIVE` should be enabled. The two options are enabled by default for ESP32-C6 target.
## Erase the NVRAM ## Erase the NVRAM

View File

@ -38,6 +38,12 @@
#include "esp_log.h" #include "esp_log.h"
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/task.h" #include "freertos/task.h"
#include "esp_netif.h"
#include "esp_vfs_eventfd.h"
#include "esp_wifi.h"
#include "nvs_flash.h"
#include "protocol_examples_common.h"
#include "esp_coexist_internal.h"
#include "esp_zigbee_gateway.h" #include "esp_zigbee_gateway.h"
#if (!defined ZB_MACSPLIT_HOST && defined ZB_MACSPLIT_DEVICE) #if (!defined ZB_MACSPLIT_HOST && defined ZB_MACSPLIT_DEVICE)
@ -127,5 +133,18 @@ void app_main(void)
}; };
/* load Zigbee gateway platform config to initialization */ /* load Zigbee gateway platform config to initialization */
ESP_ERROR_CHECK(esp_zb_platform_config(&config)); ESP_ERROR_CHECK(esp_zb_platform_config(&config));
ESP_ERROR_CHECK(nvs_flash_init());
ESP_ERROR_CHECK(esp_netif_init());
ESP_ERROR_CHECK(esp_event_loop_create_default());
#if CONFIG_EXAMPLE_CONNECT_WIFI
ESP_ERROR_CHECK(example_connect());
#if CONFIG_ESP_COEX_SW_COEXIST_ENABLE
ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_MIN_MODEM));
coex_enable();
coex_schm_status_bit_set(1, 1);
#else
ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_NONE));
#endif
#endif
xTaskCreate(esp_zb_task, "Zigbee_main", 4096, NULL, 5, NULL); xTaskCreate(esp_zb_task, "Zigbee_main", 4096, NULL, 5, NULL);
} }

View File

@ -51,6 +51,13 @@
.max_children = MAX_CHILDREN, \ .max_children = MAX_CHILDREN, \
}, \ }, \
} }
#if CONFIG_ZB_RADIO_NATIVE
#define ESP_ZB_DEFAULT_RADIO_CONFIG() \
{ \
.radio_mode = RADIO_MODE_NATIVE, \
}
#else
#define ESP_ZB_DEFAULT_RADIO_CONFIG() \ #define ESP_ZB_DEFAULT_RADIO_CONFIG() \
{ \ { \
.radio_mode = RADIO_MODE_UART_RCP, \ .radio_mode = RADIO_MODE_UART_RCP, \
@ -70,6 +77,7 @@
.tx_pin = 5, \ .tx_pin = 5, \
}, \ }, \
} }
#endif
#define ESP_ZB_DEFAULT_HOST_CONFIG() \ #define ESP_ZB_DEFAULT_HOST_CONFIG() \
{ \ { \

View File

@ -2,6 +2,6 @@
# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap # Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
nvs, data, nvs, 0x9000, 0x6000, nvs, data, nvs, 0x9000, 0x6000,
phy_init, data, phy, 0xf000, 0x1000, phy_init, data, phy, 0xf000, 0x1000,
factory, app, factory, 0x10000, 550K, factory, app, factory, 0x10000, 1150K,
zb_storage, data, fat, 0x9a000, 16K, zb_storage, data, fat, , 16K,
zb_fct, data, fat, 0x9e000, 1K, zb_fct, data, fat, , 1K,

1 # Name, Type, SubType, Offset, Size, Flags
2 # Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
3 nvs, data, nvs, 0x9000, 0x6000,
4 phy_init, data, phy, 0xf000, 0x1000,
5 factory, app, factory, 0x10000, 550K, factory, app, factory, 0x10000, 1150K,
6 zb_storage, data, fat, 0x9a000, 16K, zb_storage, data, fat, , 16K,
7 zb_fct, data, fat, 0x9e000, 1K, zb_fct, data, fat, , 1K,

View File

@ -30,6 +30,5 @@ CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1=n
# #
CONFIG_ZB_ENABLED=y CONFIG_ZB_ENABLED=y
CONFIG_ZB_ZCZR=y CONFIG_ZB_ZCZR=y
CONFIG_ZB_RADIO_MACSPLIT_UART=y
# end of Zboss # end of Zboss
# end of Component config # end of Component config

View File

@ -1,5 +1,5 @@
| Supported Targets | ESP32-C6 | ESP32-H2 | ESP32-H4 | | Supported Targets | ESP32-C6 | ESP32-H2 |
| ----------------- | -------- | -------- | -------- | | ----------------- | -------- | -------- |
# Rcp Example # Rcp Example
@ -7,7 +7,7 @@ This test code shows how to configure Zigbee rcp (radio co-processor) device. Rc
## Hardware Required ## Hardware Required
* One development board with ESP32-H4 SoC acting as Zigbee rcp (loaded with esp_zigbee_rcp example) * One development board with ESP32-H2 SoC acting as Zigbee rcp (loaded with esp_zigbee_rcp example)
* A USB cable for power supply and programming * A USB cable for power supply and programming
* Choose ESP32 or ESP32-S3 as Zigbee gateway. The connection and setup refer to the Zigbee gateway example for setup details (see [esp_zigbee_gateway example](../esp_zigbee_gateway)) * Choose ESP32 or ESP32-S3 as Zigbee gateway. The connection and setup refer to the Zigbee gateway example for setup details (see [esp_zigbee_gateway example](../esp_zigbee_gateway))
* TX, RX pin can be also configured by user in esp_zigbee_rcp.h * TX, RX pin can be also configured by user in esp_zigbee_rcp.h

View File

@ -1,15 +1,19 @@
| Supported Targets | ESP32-C6 | ESP32-H2 | ESP32-H4 | | Supported Targets | ESP32-C6 | ESP32-H2 |
| ----------------- | -------- | -------- | -------- | | ----------------- | -------- | -------- |
# Light Bulb Example # Light Bulb Example
This test code shows how to configure Zigbee end device and use it as HA on/off light bulb This test code shows how to configure Zigbee end device and use it as HA on/off light bulb.
The ESP Zigbee SDK provides more examples and tools for productization:
* [ESP Zigbee SDK Docs](https://docs.espressif.com/projects/esp-zigbee-sdk)
* [ESP Zigbee SDK Repo](https://github.com/espressif/esp-zigbee-sdk)
## Hardware Required ## Hardware Required
* One development board with ESP32-H4 SoC acting as Zigbee end device (loaded with HA_on_off_light example) * One development board with ESP32-H2 SoC acting as Zigbee end device (loaded with HA_on_off_light example)
* A USB cable for power supply and programming * A USB cable for power supply and programming
* Choose another ESP32-H4 as Zigbee coordinator (see [HA_on_off_switch example](../HA_on_off_switch)) * Choose another ESP32-H2 as Zigbee coordinator (see [HA_on_off_switch example](../HA_on_off_switch))
## Configure the project ## Configure the project
@ -45,7 +49,7 @@ I (9671) ESP_ZB_LIGHT: on/off light set to 0
## Light Control Functions ## Light Control Functions
* By toggling the switch button (BOOT) on the ESP32-H4 board loaded with the `HA_on_off_switch` example, the LED on this board loaded with `HA_on_off_light` example will be on and off. * By toggling the switch button (BOOT) on the ESP32-H2 board loaded with the `HA_on_off_switch` example, the LED on this board loaded with `HA_on_off_light` example will be on and off.
## Troubleshooting ## Troubleshooting

View File

@ -1,15 +1,19 @@
| Supported Targets | ESP32-C6 | ESP32-H2 | ESP32-H4 | | Supported Targets | ESP32-C6 | ESP32-H2 |
| ----------------- | -------- | -------- | -------- | | ----------------- | -------- | -------- |
# Light Switch Example # Light Switch Example
This test code shows how to configure Zigbee Coordinator and use it as an HA on/off_switch This test code shows how to configure Zigbee Coordinator and use it as an HA on/off_switch.
The ESP Zigbee SDK provides more examples and tools for productization:
* [ESP Zigbee SDK Docs](https://docs.espressif.com/projects/esp-zigbee-sdk)
* [ESP Zigbee SDK Repo](https://github.com/espressif/esp-zigbee-sdk)
## Hardware Required ## Hardware Required
* One development board with ESP32-H4 SoC acting as Zigbee Coordinator (loaded with HA_on_off_switch) * One development board with ESP32-H2 SoC acting as Zigbee Coordinator (loaded with HA_on_off_switch)
* A USB cable for power supply and programming * A USB cable for power supply and programming
* Choose another ESP32-H4 as Zigbee end-device (see [HA_on_off_light](../HA_on_off_light/)) * Choose another ESP32-H2 as Zigbee end-device (see [HA_on_off_light](../HA_on_off_light/))
## Configure the project ## Configure the project