Skip to content

Commit

Permalink
Merge branch 'backport/openthread_related_mr_v51' into 'release/v5.1'
Browse files Browse the repository at this point in the history
Backport openthread fix to v5.1

See merge request espressif/esp-idf!28819
  • Loading branch information
jack0c committed Feb 5, 2024
2 parents 7cbee80 + 5c74483 commit eb4fa72
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 8 deletions.
2 changes: 2 additions & 0 deletions components/hal/include/hal/ieee802154_common_ll.h
Expand Up @@ -89,6 +89,7 @@ typedef enum {
} ieee802154_ll_rx_abort_reason_t;

typedef uint32_t ieee802154_ll_rx_abort_events;
#define IEEE802154_RX_ABORT_ALL 0x7fffffff

/**
* @brief IEEE802154 transmission failed reason.
Expand All @@ -112,6 +113,7 @@ typedef enum {
} ieee802154_ll_tx_abort_reason_t;

typedef uint32_t ieee802154_ll_tx_abort_events;
#define IEEE802154_TX_ABORT_ALL 0x7fffffff

/**
* @brief IEEE802154 CCA mode.
Expand Down
15 changes: 11 additions & 4 deletions components/ieee802154/driver/esp_ieee802154_dev.c
Expand Up @@ -351,6 +351,8 @@ static IRAM_ATTR void next_operation(void)
{
#if !CONFIG_IEEE802154_TEST
if (s_pending_tx.frame) {
// Here the driver needs to recover the setting of rx aborts, see function `ieee802154_transmit`.
ieee802154_ll_enable_rx_abort_events(BIT(IEEE802154_RX_ABORT_BY_TX_ACK_TIMEOUT - 1) | BIT(IEEE802154_RX_ABORT_BY_TX_ACK_COEX_BREAK - 1));
ieee802154_transmit_internal(s_pending_tx.frame, s_pending_tx.cca);
s_pending_tx.frame = NULL;
} else
Expand Down Expand Up @@ -482,18 +484,18 @@ static IRAM_ATTR void isr_handle_rx_abort(void)
IEEE802154_ASSERT(s_ieee802154_state == IEEE802154_STATE_RX);
#if CONFIG_IEEE802154_TEST
esp_ieee802154_receive_failed(rx_status);
next_operation();
#endif
break;
case IEEE802154_RX_ABORT_BY_COEX_BREAK:
IEEE802154_ASSERT(s_ieee802154_state == IEEE802154_STATE_RX);
#if CONFIG_IEEE802154_TEST
esp_ieee802154_receive_failed(rx_status);
#endif
break;
case IEEE802154_RX_ABORT_BY_ED_ABORT:
case IEEE802154_RX_ABORT_BY_ED_COEX_REJECT:
IEEE802154_ASSERT(s_ieee802154_state == IEEE802154_STATE_ED || s_ieee802154_state == IEEE802154_STATE_CCA);
esp_ieee802154_ed_failed(rx_status);
next_operation();
break;
case IEEE802154_RX_ABORT_BY_TX_ACK_TIMEOUT:
case IEEE802154_RX_ABORT_BY_TX_ACK_COEX_BREAK:
Expand All @@ -503,7 +505,6 @@ static IRAM_ATTR void isr_handle_rx_abort(void)
#else
esp_ieee802154_receive_failed(rx_status);
#endif
next_operation();
break;
case IEEE802154_RX_ABORT_BY_ENHACK_SECURITY_ERROR:
IEEE802154_ASSERT(s_ieee802154_state == IEEE802154_STATE_TX_ENH_ACK);
Expand All @@ -512,11 +513,11 @@ static IRAM_ATTR void isr_handle_rx_abort(void)
#else
esp_ieee802154_receive_failed(rx_status);
#endif
next_operation();
break;
default:
IEEE802154_ASSERT(false);
}
next_operation();
}

static IRAM_ATTR void isr_handle_tx_abort(void)
Expand Down Expand Up @@ -816,6 +817,7 @@ static inline esp_err_t ieee802154_transmit_internal(const uint8_t *frame, bool
esp_err_t ieee802154_transmit(const uint8_t *frame, bool cca)
{
#if !CONFIG_IEEE802154_TEST
ieee802154_enter_critical();
if ((s_ieee802154_state == IEEE802154_STATE_RX && ieee802154_ll_is_current_rx_frame())
|| s_ieee802154_state == IEEE802154_STATE_TX_ACK || s_ieee802154_state == IEEE802154_STATE_TX_ENH_ACK) {
// If the current radio is processing an RX frame or sending an ACK, do not shut down the ongoing process.
Expand All @@ -824,8 +826,13 @@ esp_err_t ieee802154_transmit(const uint8_t *frame, bool cca)
s_pending_tx.frame = frame;
s_pending_tx.cca = cca;
IEEE802154_TX_DEFERRED_NUMS_UPDATE();
// Here we enable all rx interrupts due to the driver needs to know when the current RX has finished.
// Will recover the setting of rx abort in function `next_operation`.
ieee802154_ll_enable_rx_abort_events(IEEE802154_RX_ABORT_ALL);
ieee802154_exit_critical();
return ESP_OK;
}
ieee802154_exit_critical();
#endif
return ieee802154_transmit_internal(frame, cca);
}
Expand Down
13 changes: 12 additions & 1 deletion components/openthread/Kconfig
Expand Up @@ -114,6 +114,7 @@ menu "OpenThread"
Select this to use the native 15.4 radio.

config OPENTHREAD_RADIO_SPINEL_UART
select UART_ISR_IN_IRAM
bool "Connect via UART"
help
Select this to connect to a Radio Co-Processor via UART.
Expand Down Expand Up @@ -157,6 +158,7 @@ menu "OpenThread"
default OPENTHREAD_RCP_UART

config OPENTHREAD_RCP_UART
select UART_ISR_IN_IRAM
bool "UART RCP"
help
Select this to enable UART connection to host.
Expand Down Expand Up @@ -293,7 +295,7 @@ menu "OpenThread"
config OPENTHREAD_UART_BUFFER_SIZE
int "The uart received buffer size of openthread"
depends on OPENTHREAD_ENABLED
default 256
default 768
range 128 1024
help
Set the OpenThread UART buffer size.
Expand Down Expand Up @@ -374,6 +376,15 @@ menu "OpenThread"
default n
help
Select this option to enable the OpenThread Radio Spinel for external protocol stack, such as Zigbee.

config OPENTHREAD_RX_ON_WHEN_IDLE
bool "Enable OpenThread radio capibility rx on when idle"
default y if !ESP_COEX_SW_COEXIST_ENABLE
default n if ESP_COEX_SW_COEXIST_ENABLE
help
Select this option to enable OpenThread radio capibility rx on when idle. Do not support this feature when
SW coexistence is enabled.

menu "Thread Address Query Config"
config OPENTHREAD_ADDRESS_QUERY_TIMEOUT
int "Timeout value (in seconds) for a address notification response after sending an address query."
Expand Down
2 changes: 1 addition & 1 deletion components/openthread/lib
2 changes: 1 addition & 1 deletion components/openthread/openthread
Submodule openthread updated 285 files
8 changes: 7 additions & 1 deletion components/openthread/src/port/esp_openthread_radio.c
Expand Up @@ -343,7 +343,11 @@ int8_t otPlatRadioGetRssi(otInstance *aInstance)

otRadioCaps otPlatRadioGetCaps(otInstance *aInstance)
{
return (otRadioCaps)(OT_RADIO_CAPS_ENERGY_SCAN | OT_RADIO_CAPS_RX_ON_WHEN_IDLE |
// FIXME: Remove `CONFIG_OPENTHREAD_RX_ON_WHEN_IDLE` when JIRA: TZ-609 fixed.
return (otRadioCaps)(OT_RADIO_CAPS_ENERGY_SCAN |
#if CONFIG_OPENTHREAD_RX_ON_WHEN_IDLE
OT_RADIO_CAPS_RX_ON_WHEN_IDLE |
#endif
OT_RADIO_CAPS_TRANSMIT_SEC | OT_RADIO_CAPS_RECEIVE_TIMING | OT_RADIO_CAPS_TRANSMIT_TIMING |
OT_RADIO_CAPS_ACK_TIMEOUT | OT_RADIO_CAPS_SLEEP_TO_TX);
}
Expand Down Expand Up @@ -771,8 +775,10 @@ otError otPlatRadioSetChannelMaxTransmitPower(otInstance *aInstance, uint8_t aCh
return OT_ERROR_NONE;
}

#if CONFIG_OPENTHREAD_RX_ON_WHEN_IDLE
void otPlatRadioSetRxOnWhenIdle(otInstance *aInstance, bool aEnable)
{
OT_UNUSED_VARIABLE(aInstance);
esp_ieee802154_set_rx_when_idle(aEnable);
}
#endif
Expand Up @@ -6,6 +6,7 @@

#include "esp_openthread_radio.h"

#include "sdkconfig.h"
#include "esp_check.h"
#include "esp_err.h"
#include "esp_openthread_border_router.h"
Expand Down Expand Up @@ -413,7 +414,9 @@ otError otPlatRadioConfigureEnhAckProbing(otInstance *aInstance, otLinkMetrics a
}
#endif

#if CONFIG_OPENTHREAD_RX_ON_WHEN_IDLE
void otPlatRadioSetRxOnWhenIdle(otInstance *aInstance, bool aEnable)
{
s_radio.SetRxOnWhenIdle(aEnable);
}
#endif

0 comments on commit eb4fa72

Please sign in to comment.