Quellcode durchsuchen

Merge branch 'feature/add_openthread_and_i154_lib_for_c6' into 'master'

openthread: add 802.15.4 and Thread support for ESP32-C6

See merge request espressif/esp-idf!21780
Shu Chen vor 3 Jahren
Ursprung
Commit
2ce330bd34

+ 1 - 1
components/ieee802154/lib

@@ -1 +1 @@
-Subproject commit 7c691d705b491c1dbb53fa6a15e23b1c4ccb287f
+Subproject commit 6ddc1b2d80d7db565f144f76e60f77a0f98a2cbd

+ 10 - 0
components/openthread/CMakeLists.txt

@@ -203,6 +203,16 @@ if(CONFIG_OPENTHREAD_ENABLED)
                     "${CMAKE_CURRENT_SOURCE_DIR}/lib/${idf_target}/rev2/libopenthread_port.a"
                     "${CMAKE_CURRENT_SOURCE_DIR}/lib/${idf_target}/rev2/libopenthread_port.a"
                     REQUIRES openthread)
                     REQUIRES openthread)
             endif()
             endif()
+        elseif(IDF_TARGET STREQUAL "esp32c6")
+            if(CONFIG_OPENTHREAD_BORDER_ROUTER)
+                add_prebuilt_library(openthread_port
+                    "${CMAKE_CURRENT_SOURCE_DIR}/lib/${idf_target}/br/libopenthread_port.a"
+                    REQUIRES openthread)
+            else()
+                add_prebuilt_library(openthread_port
+                    "${CMAKE_CURRENT_SOURCE_DIR}/lib/${idf_target}/cli/libopenthread_port.a"
+                    REQUIRES openthread)
+            endif()
         else()
         else()
             add_prebuilt_library(openthread_port "${CMAKE_CURRENT_SOURCE_DIR}/lib/${idf_target}/libopenthread_port.a"
             add_prebuilt_library(openthread_port "${CMAKE_CURRENT_SOURCE_DIR}/lib/${idf_target}/libopenthread_port.a"
                                 REQUIRES openthread)
                                 REQUIRES openthread)

+ 1 - 1
components/openthread/Kconfig

@@ -47,7 +47,7 @@ menu "OpenThread"
     choice OPENTHREAD_RADIO_TYPE
     choice OPENTHREAD_RADIO_TYPE
         prompt "Config the Thread radio type"
         prompt "Config the Thread radio type"
         depends on OPENTHREAD_ENABLED
         depends on OPENTHREAD_ENABLED
-        default OPENTHREAD_RADIO_NATIVE if IDF_TARGET_ESP32H4
+        default OPENTHREAD_RADIO_NATIVE if SOC_IEEE802154_SUPPORTED
         default OPENTHREAD_RADIO_SPINEL_UART
         default OPENTHREAD_RADIO_SPINEL_UART
         help
         help
             Configure how OpenThread connects to the 15.4 radio
             Configure how OpenThread connects to the 15.4 radio

+ 28 - 14
components/openthread/include/esp_openthread_lock.h

@@ -1,16 +1,8 @@
-// Copyright 2021 Espressif Systems (Shanghai) CO LTD
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License
+/*
+ * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
 
 
 #pragma once
 #pragma once
 
 
@@ -41,7 +33,7 @@ esp_err_t esp_openthread_lock_init(void);
 void esp_openthread_lock_deinit(void);
 void esp_openthread_lock_deinit(void);
 
 
 /**
 /**
- * @brief This functions acquires the OpenThread API lock.
+ * @brief This function acquires the OpenThread API lock.
  *
  *
  * @note Every OT APIs that takes an otInstance argument MUST be protected with this API lock
  * @note Every OT APIs that takes an otInstance argument MUST be protected with this API lock
  *       except that the call site is in OT callbacks.
  *       except that the call site is in OT callbacks.
@@ -61,6 +53,28 @@ bool esp_openthread_lock_acquire(TickType_t block_ticks);
  */
  */
 void esp_openthread_lock_release(void);
 void esp_openthread_lock_release(void);
 
 
+/**
+ * @brief This function acquires the OpenThread API task switching lock.
+ *
+ * @note In OpenThread API context, it waits for some actions to be done in other tasks (like lwip),
+ *       after task switching, it needs to call OpenThread API again. Normally it's not allowed,
+ *       since the previous OpenThread API lock is not released yet. This task_switching lock allows
+ *       the OpenThread API can be called in this case.
+ *
+ * @note Please use esp_openthread_lock_acquire() for normal cases.
+ *
+ * @return
+ *      - True on lock acquired
+ *      - False on failing to acquire the lock with the timeout.
+ *
+ */
+bool esp_openthread_task_switching_lock_acquire(void);
+
+/**
+ * @brief This function releases the OpenThread API task switching lock.
+ *
+ */
+void esp_openthread_task_switching_lock_release(void);
 
 
 #ifdef __cplusplus
 #ifdef __cplusplus
 }
 }

+ 1 - 1
components/openthread/lib

@@ -1 +1 @@
-Subproject commit d1cf81e6b04828a7480d43bbaf73bb6b5b154e9d
+Subproject commit 009faca9f091a1dec4508dbaaff95fa01a1abc2f

+ 1 - 1
components/openthread/openthread

@@ -1 +1 @@
-Subproject commit 507d1b79712bba1ea3033fa4116577f668818e80
+Subproject commit 19e18753c1ca97ffc68566f4852444f341e0319c

+ 9 - 3
examples/openthread/.build-test-rules.yml

@@ -6,16 +6,22 @@ examples/openthread/ot_br:
       temporary: true
       temporary: true
       reason: target(s) not supported yet
       reason: target(s) not supported yet
   disable_test:
   disable_test:
-    - if: IDF_TARGET in ["esp32", "esp32c3", "esp32s2"]
+    - if: IDF_TARGET in ["esp32", "esp32c3", "esp32s2", "esp32c6"]
       temporary: true
       temporary: true
       reason: only test on esp32s3
       reason: only test on esp32s3
 
 
 examples/openthread/ot_cli:
 examples/openthread/ot_cli:
   enable:
   enable:
-    - if: IDF_TARGET == "esp32h4"
+    - if: IDF_TARGET in ["esp32h4", "esp32c6"]
+  disable_test:
+    - if: IDF_TARGET == "esp32c6"
+      temporary: true
       reason: only test on esp32h4
       reason: only test on esp32h4
 
 
 examples/openthread/ot_rcp:
 examples/openthread/ot_rcp:
   enable:
   enable:
-    - if: IDF_TARGET == "esp32h4"
+    - if: IDF_TARGET in ["esp32h4", "esp32c6"]
+  disable_test:
+    - if: IDF_TARGET == "esp32c6"
+      temporary: true
       reason: only test on esp32h4
       reason: only test on esp32h4

+ 2 - 2
examples/openthread/ot_cli/README.md

@@ -1,5 +1,5 @@
-| Supported Targets | ESP32-H4 |
-| ----------------- | -------- |
+| Supported Targets | ESP32-C6 | ESP32-H4 |
+| ----------------- | -------- | -------- |
 
 
 # OpenThread Command Line Example
 # OpenThread Command Line Example
 
 

+ 2 - 0
examples/openthread/ot_cli/main/esp_ot_cli.c

@@ -32,6 +32,7 @@
 #include "freertos/FreeRTOS.h"
 #include "freertos/FreeRTOS.h"
 #include "freertos/task.h"
 #include "freertos/task.h"
 #include "hal/uart_types.h"
 #include "hal/uart_types.h"
+#include "nvs_flash.h"
 #include "openthread/cli.h"
 #include "openthread/cli.h"
 #include "openthread/instance.h"
 #include "openthread/instance.h"
 #include "openthread/logging.h"
 #include "openthread/logging.h"
@@ -101,6 +102,7 @@ void app_main(void)
         .max_fds = 3,
         .max_fds = 3,
     };
     };
 
 
+    ESP_ERROR_CHECK(nvs_flash_init());
     ESP_ERROR_CHECK(esp_event_loop_create_default());
     ESP_ERROR_CHECK(esp_event_loop_create_default());
     ESP_ERROR_CHECK(esp_netif_init());
     ESP_ERROR_CHECK(esp_netif_init());
     ESP_ERROR_CHECK(esp_vfs_eventfd_register(&eventfd_config));
     ESP_ERROR_CHECK(esp_vfs_eventfd_register(&eventfd_config));

+ 1 - 1
examples/openthread/ot_cli/main/esp_ot_config.h

@@ -16,7 +16,7 @@
 
 
 #include "esp_openthread_types.h"
 #include "esp_openthread_types.h"
 
 
-#if CONFIG_IDF_TARGET_ESP32H4
+#if SOC_IEEE802154_SUPPORTED
 #define ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG()              \
 #define ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG()              \
     {                                                      \
     {                                                      \
         .radio_mode = RADIO_MODE_NATIVE,                   \
         .radio_mode = RADIO_MODE_NATIVE,                   \

+ 0 - 1
examples/openthread/ot_cli/sdkconfig.defaults

@@ -1,4 +1,3 @@
-CONFIG_IDF_TARGET="esp32h4"
 #
 #
 # libsodium
 # libsodium
 #
 #

+ 2 - 2
examples/openthread/ot_rcp/README.md

@@ -1,5 +1,5 @@
-| Supported Targets | ESP32-H4 |
-| ----------------- | -------- |
+| Supported Targets | ESP32-C6 | ESP32-H4 |
+| ----------------- | -------- | -------- |
 
 
 # OpenThread Radio Co-Processor (RCP) Example
 # OpenThread Radio Co-Processor (RCP) Example
 
 

+ 4 - 2
examples/openthread/ot_rcp/main/esp_ot_rcp.c

@@ -16,13 +16,14 @@
 #include <unistd.h>
 #include <unistd.h>
 
 
 #include "esp_event.h"
 #include "esp_event.h"
+#include "nvs_flash.h"
 #include "esp_openthread.h"
 #include "esp_openthread.h"
 #include "esp_ot_config.h"
 #include "esp_ot_config.h"
 #include "esp_vfs_eventfd.h"
 #include "esp_vfs_eventfd.h"
 #include "driver/uart.h"
 #include "driver/uart.h"
 
 
-#if !CONFIG_IDF_TARGET_ESP32H4
-#error "RCP is only supported for esp32h4"
+#if !SOC_IEEE802154_SUPPORTED
+#error "RCP is only supported for the SoCs which have IEEE 802.15.4 module"
 #endif
 #endif
 
 
 #define TAG "ot_esp_rcp"
 #define TAG "ot_esp_rcp"
@@ -60,6 +61,7 @@ void app_main(void)
         .max_fds = 2,
         .max_fds = 2,
     };
     };
 
 
+    ESP_ERROR_CHECK(nvs_flash_init());
     ESP_ERROR_CHECK(esp_event_loop_create_default());
     ESP_ERROR_CHECK(esp_event_loop_create_default());
     ESP_ERROR_CHECK(esp_vfs_eventfd_register(&eventfd_config));
     ESP_ERROR_CHECK(esp_vfs_eventfd_register(&eventfd_config));
     xTaskCreate(ot_task_worker, "ot_rcp_main", 10240, xTaskGetCurrentTaskHandle(), 5, NULL);
     xTaskCreate(ot_task_worker, "ot_rcp_main", 10240, xTaskGetCurrentTaskHandle(), 5, NULL);

+ 0 - 1
examples/openthread/ot_rcp/sdkconfig.defaults

@@ -1,4 +1,3 @@
-CONFIG_IDF_TARGET="esp32h4"
 #
 #
 # libsodium
 # libsodium
 #
 #

+ 0 - 1
tools/ci/check_copyright_ignore.txt

@@ -813,7 +813,6 @@ components/nvs_flash/test_nvs_host/test_intrusive_list.cpp
 components/nvs_flash/test_nvs_host/test_nvs_cxx_api.cpp
 components/nvs_flash/test_nvs_host/test_nvs_cxx_api.cpp
 components/nvs_flash/test_nvs_host/test_nvs_initialization.cpp
 components/nvs_flash/test_nvs_host/test_nvs_initialization.cpp
 components/nvs_flash/test_nvs_host/test_nvs_storage.cpp
 components/nvs_flash/test_nvs_host/test_nvs_storage.cpp
-components/openthread/include/esp_openthread_lock.h
 components/protocomm/include/transports/protocomm_console.h
 components/protocomm/include/transports/protocomm_console.h
 components/protocomm/include/transports/protocomm_httpd.h
 components/protocomm/include/transports/protocomm_httpd.h
 components/pthread/pthread_cond_var.c
 components/pthread/pthread_cond_var.c