openthread: enable ot_cli on esp32h2

This commit is contained in:
Shu Chen 2021-07-09 12:18:41 +08:00
parent bdaeeb3169
commit 8e56ecc656
12 changed files with 132 additions and 16 deletions

View File

@ -28,3 +28,4 @@ PROVIDE ( GPSPI4 = 0x60037000 );
PROVIDE ( APB_SARADC = 0x60040000 );
PROVIDE ( USB_SERIAL_JTAG = 0x60043000 );
PROVIDE ( GDMA = 0x6003F000 );
PROVIDE ( IEEE802154 = 0x60047000 );

@ -1 +1 @@
Subproject commit 6def308291aaba24a2baaa27fe2a4d50c79420cc
Subproject commit 8b1137c35cc3d2b1085e7f857c2530efb115d3a3

@ -1 +1 @@
Subproject commit f4cdc78bb198414ad1e1962b3c044305bbcf62a8
Subproject commit 46396c46bd3c4d459b194e0e9273ff004158b993

View File

@ -69,7 +69,7 @@ idf_component_register(SRC_DIRS "${src_dirs}"
EXCLUDE_SRCS "${exclude_srcs}"
INCLUDE_DIRS "${public_include_dirs}"
PRIV_INCLUDE_DIRS "${private_include_dirs}"
REQUIRES mbedtls)
REQUIRES mbedtls ieee802154)
if(CONFIG_OPENTHREAD_ENABLED)
target_compile_definitions(

View File

@ -6,6 +6,25 @@ menu "OpenThread"
help
Select this option to enable OpenThread and show the submenu with OpenThread configuration choices.
choice OPENTHREAD_RADIO_TYPE
prompt "Config the Thread radio type"
depends on OPENTHREAD_ENABLED
default OPENTHREAD_RADIO_NATIVE if IDF_TARGET_ESP32H2
default OPENTHREAD_RADIO_SPINEL_UART
help
Configure how OpenThread connects to the 15.4 radio
config OPENTHREAD_RADIO_NATIVE
bool "Native 15.4 radio"
help
Select this to use the native 15.4 radio.
config OPENTHREAD_RADIO_SPINEL_UART
bool "Connect via UART"
help
Select this to connect to a Radio Co-Processor via UART.
endchoice
choice OPENTHREAD_DEVICE_TYPE
prompt "Config the Thread device type"
depends on OPENTHREAD_ENABLED

View File

@ -72,7 +72,9 @@ typedef struct {
*
*/
typedef enum {
RADIO_MODE_UART_RCP = 0x0, /*!< UART connection to a 15.4 capable radio co-processor(RCP)*/
RADIO_MODE_NATIVE = 0x0, /*!< Use the native 15.4 radio*/
RADIO_MODE_UART_RCP = 0x1, /*!< UART connection to a 15.4 capable radio co-processor (RCP)*/
RADIO_MODE_SPI_RCP = 0x2, /*!< SPI connection to a 15.4 capable radio co-processor (RCP)*/
} esp_openthread_radio_mode_t;
/**

@ -1 +1 @@
Subproject commit 3a3009e7a1d9a89f2a06453eb299d6c1a9ee7cad
Subproject commit d84f8967f8ce14490e19433b85c8c363d424f4c1

View File

@ -24,10 +24,10 @@
#include "esp_netif_net_stack.h"
#include "esp_openthread.h"
#include "esp_openthread_border_router.h"
#include "esp_openthread_defaults.h"
#include "esp_openthread_lock.h"
#include "esp_openthread_netif_glue.h"
#include "esp_openthread_types.h"
#include "esp_ot_config.h"
#include "esp_vfs_eventfd.h"
#include "esp_wifi.h"
#include "nvs_flash.h"
@ -143,8 +143,8 @@ static void create_config_network(otInstance *instance)
static void ot_task_worker(void *aContext)
{
esp_openthread_platform_config_t config = {
.radio_config = ESP_OPENTHREAD_DEFAULT_RADIO_UART_RCP_CONFIG(4, 5),
.host_config = ESP_OPENTHREAD_DEFAULT_UART_HOST_CONFIG(),
.radio_config = ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG(),
.host_config = ESP_OPENTHREAD_DEFAULT_HOST_CONFIG(),
.port_config = ESP_OPENTHREAD_DEFAULT_PORT_CONFIG(),
};

View File

@ -16,7 +16,7 @@
#include "esp_openthread_types.h"
#define ESP_OPENTHREAD_DEFAULT_RADIO_UART_RCP_CONFIG(pin_rx, pin_tx) \
#define ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG() \
{ \
.radio_mode = RADIO_MODE_UART_RCP, \
.radio_uart_config = { \
@ -31,12 +31,12 @@
.rx_flow_ctrl_thresh = 0, \
.source_clk = UART_SCLK_APB, \
}, \
.rx_pin = pin_rx, \
.tx_pin = pin_tx, \
.rx_pin = 4, \
.tx_pin = 5, \
}, \
}
#define ESP_OPENTHREAD_DEFAULT_UART_HOST_CONFIG() \
#define ESP_OPENTHREAD_DEFAULT_HOST_CONFIG() \
{ \
.host_connection_mode = HOST_CONNECTION_MODE_UART, \
.host_uart_config = { \

View File

@ -21,10 +21,10 @@
#include "esp_netif.h"
#include "esp_netif_types.h"
#include "esp_openthread.h"
#include "esp_openthread_defaults.h"
#include "esp_openthread_lock.h"
#include "esp_openthread_netif_glue.h"
#include "esp_openthread_types.h"
#include "esp_ot_config.h"
#include "esp_vfs_eventfd.h"
#include "driver/uart.h"
#include "freertos/FreeRTOS.h"
@ -56,8 +56,8 @@ static esp_netif_t *init_openthread_netif(const esp_openthread_platform_config_t
static void ot_task_worker(void *aContext)
{
esp_openthread_platform_config_t config = {
.radio_config = ESP_OPENTHREAD_DEFAULT_RADIO_UART_RCP_CONFIG(4, 5),
.host_config = ESP_OPENTHREAD_DEFAULT_UART_HOST_CONFIG(),
.radio_config = ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG(),
.host_config = ESP_OPENTHREAD_DEFAULT_HOST_CONFIG(),
.port_config = ESP_OPENTHREAD_DEFAULT_PORT_CONFIG(),
};
esp_netif_t *openthread_netif;
@ -89,9 +89,10 @@ void app_main(void)
{
// Used eventfds:
// * netif
// * ot task queue
// * radio driver
esp_vfs_eventfd_config_t eventfd_config = {
.max_fds = 2,
.max_fds = 3,
};
ESP_ERROR_CHECK(esp_event_loop_create_default());

View File

@ -0,0 +1,72 @@
// 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
#pragma once
#include "esp_openthread_types.h"
#if CONFIG_IDF_TARGET_ESP32H2
#define ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG() \
{ \
.radio_mode = RADIO_MODE_NATIVE, \
}
#else
#define ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG() \
{ \
.radio_mode = RADIO_MODE_UART_RCP, \
.radio_uart_config = { \
.port = 1, \
.uart_config = \
{ \
.baud_rate = 115200, \
.data_bits = UART_DATA_8_BITS, \
.parity = UART_PARITY_DISABLE, \
.stop_bits = UART_STOP_BITS_1, \
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE, \
.rx_flow_ctrl_thresh = 0, \
.source_clk = UART_SCLK_APB, \
}, \
.rx_pin = 4, \
.tx_pin = 5, \
}, \
}
#endif
#define ESP_OPENTHREAD_DEFAULT_HOST_CONFIG() \
{ \
.host_connection_mode = HOST_CONNECTION_MODE_UART, \
.host_uart_config = { \
.port = 0, \
.uart_config = \
{ \
.baud_rate = 115200, \
.data_bits = UART_DATA_8_BITS, \
.parity = UART_PARITY_DISABLE, \
.stop_bits = UART_STOP_BITS_1, \
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE, \
.rx_flow_ctrl_thresh = 0, \
.source_clk = UART_SCLK_APB, \
}, \
.rx_pin = UART_PIN_NO_CHANGE, \
.tx_pin = UART_PIN_NO_CHANGE, \
}, \
}
#define ESP_OPENTHREAD_DEFAULT_PORT_CONFIG() \
{ \
.storage_partition_name = "ot_storage", \
.netif_queue_size = 10, \
.task_queue_size = 10, \
}

View File

@ -0,0 +1,21 @@
#
# mbedTLS
#
# ESP32H2-TODO: enable HW acceleration
CONFIG_MBEDTLS_HARDWARE_AES=n
CONFIG_MBEDTLS_HARDWARE_MPI=n
CONFIG_MBEDTLS_HARDWARE_SHA=n
# end of mbedTLS
#
# OpenThread
#
CONFIG_OPENTHREAD_BORDER_ROUTER=n
# end of OpenThread
#
# IEEE 802.15.4
#
CONFIG_IEEE802154_ENABLED=y
# end of IEEE 802.15.4