Skip to content

Conversation

@maje-emb
Copy link
Contributor

@maje-emb maje-emb commented Nov 7, 2025

  • Improved esb_suspend to suspend the protocol.
  • Changed esb_flush_tx to allow clearing the FIFO queue when ESB is in the IDLE state.
  • Fixed esb_pop_tx to use the correct pointer.
  • Renamed tx_fifo_remove_last to tx_fifo_remove_first

- Improved `esb_suspend` to suspend the protocol.
- Changed `esb_flush_tx` to allow clearing the FIFO queue
  when ESB is in the IDLE state.
- Fixed `esb_pop_tx` to use the correct pointer.
- Renamed `tx_fifo_remove_last` to `tx_fifo_remove_first`

Ref: NCSDK-36153

Signed-off-by: Marcin Jelinski <marcin.jelinski@nordicsemi.no>
@maje-emb maje-emb requested review from a team as code owners November 7, 2025 13:21
Copilot AI review requested due to automatic review settings November 7, 2025 13:21
@NordicBuilder NordicBuilder added the changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. label Nov 7, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the ESB (Enhanced ShockBurst) protocol implementation with critical bug fixes and improvements. The changes focus on properly suspending the protocol, fixing FIFO queue operations, and ensuring complete peripheral disconnection.

Key changes:

  • Enhanced esb_suspend() to properly stop radio and timer peripherals before transitioning to IDLE state
  • Fixed esb_pop_tx() to use the correct FIFO pointer (front instead of back)
  • Renamed tx_fifo_remove_last() to tx_fifo_remove_first() for clarity

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
subsys/esb/esb.c Core ESB implementation with improved suspend logic, fixed FIFO operations, and renamed internal function
subsys/esb/esb_ppi.c Added complete PPI endpoint cleanup to fully disconnect peripherals during suspend
subsys/esb/esb_dppi.c Added complete DPPI publish/subscribe clearing to fully disconnect peripherals during suspend
include/esb.h Updated documentation for esb_flush_tx() to clarify radio state requirements and return values

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

nrf_dppi_channels_disable(ESB_DPPIC, channels_mask);

/* Clear all publish/subscribe connections to fully disconnect peripherals */

Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Remove this empty line to maintain consistent code style.

Suggested change

Copilot uses AI. Check for mistakes.
Comment on lines +305 to +308

/* Clear Radio */
nrf_radio_publish_clear(NRF_RADIO, NRF_RADIO_EVENT_ADDRESS);
nrf_radio_publish_clear(NRF_RADIO, NRF_RADIO_EVENT_DISABLED);
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Remove this empty line to maintain consistent code style.

Suggested change
/* Clear Radio */
nrf_radio_publish_clear(NRF_RADIO, NRF_RADIO_EVENT_ADDRESS);
nrf_radio_publish_clear(NRF_RADIO, NRF_RADIO_EVENT_DISABLED);
/* Clear Radio */
nrf_radio_publish_clear(NRF_RADIO, NRF_RADIO_EVENT_ADDRESS);
nrf_radio_publish_clear(NRF_RADIO, NRF_RADIO_EVENT_DISABLED);
nrf_radio_publish_clear(NRF_RADIO, NRF_RADIO_EVENT_DISABLED);

Copilot uses AI. Check for mistakes.
nrf_radio_subscribe_clear(NRF_RADIO, NRF_RADIO_TASK_RXEN);
nrf_radio_subscribe_clear(NRF_RADIO, NRF_RADIO_TASK_TXEN);
nrf_radio_subscribe_clear(NRF_RADIO, NRF_RADIO_TASK_DISABLE);

Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Remove this empty line to maintain consistent code style.

Suggested change

Copilot uses AI. Check for mistakes.
nrf_timer_publish_clear(ESB_NRF_TIMER_INSTANCE, NRF_TIMER_EVENT_COMPARE1);
nrf_timer_subscribe_clear(ESB_NRF_TIMER_INSTANCE, NRF_TIMER_TASK_START);
nrf_timer_subscribe_clear(ESB_NRF_TIMER_INSTANCE, NRF_TIMER_TASK_STOP);

Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Remove this empty line to maintain consistent code style.

Suggested change

Copilot uses AI. Check for mistakes.
{
if (!esb_initialized) {
return -EACCES;
} else if (esb_state != ESB_STATE_IDLE) {
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Use separate if statements instead of else-if for better clarity and to avoid unnecessary coupling between unrelated error conditions.

Suggested change
} else if (esb_state != ESB_STATE_IDLE) {
}
if (esb_state != ESB_STATE_IDLE) {

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@NordicBuilder
Copy link
Contributor

NordicBuilder commented Nov 7, 2025

CI Information

To view the history of this post, click the 'edited' button above
Build number: 1

Inputs:

Sources:

sdk-nrf: PR head: a9b1965aa83de258a383907aefe8b016ac331b38

more details

sdk-nrf:

PR head: a9b1965aa83de258a383907aefe8b016ac331b38
merge base: ad7d9b915b4d543e00b23c7b9be6a20dad9c63fd
target head (main): 40aaea40b964dd5702c7a9ce13cbd37b086abc4a
Diff

Github labels

Enabled Name Description
ci-disabled Disable the ci execution
ci-all-test Run all of ci, no test spec filtering will be done
ci-force-downstream Force execution of downstream even if twister fails
ci-run-twister Force run twister
ci-run-zephyr-twister Force run zephyr twister
List of changed files detected by CI (4)
include
│  │ esb.h
subsys
│  ├── esb
│  │  ├── esb.c
│  │  ├── esb_dppi.c
│  │  │ esb_ppi.c

Outputs:

Toolchain

Version: df3cc9d822
Build docker image: docker-dtr.nordicsemi.no/sw-production/ncs-build:df3cc9d822_e595b21c39

Test Spec & Results: ✅ Success; ❌ Failure; 🟠 Queued; 🟡 Progress; ◻️ Skipped; ⚠️ Quarantine

  • ◻️ Toolchain - Skipped: existing toolchain is used
  • ✅ Build twister
    • sdk-nrf test count: 47
  • ✅ Integration tests
    • ⚠️ test-fw-nrfconnect-proprietary_esb
Disabled integration tests
    • test-fw-nrfconnect-nrf_lrcs_positioning
    • desktop52_verification
    • test_ble_nrf_config
    • test-fw-nrfconnect-apps
    • test-fw-nrfconnect-ble_mesh
    • test-fw-nrfconnect-ble_samples
    • test-fw-nrfconnect-chip
    • test-fw-nrfconnect-fem
    • test-fw-nrfconnect-nfc
    • test-fw-nrfconnect-nrf-iot_libmodem-nrf
    • test-fw-nrfconnect-nrf-iot_lwm2m
    • test-fw-nrfconnect-nrf-iot_samples
    • test-fw-nrfconnect-nrf-iot_thingy91
    • test-fw-nrfconnect-nrf-iot_zephyr_lwm2m
    • test-fw-nrfconnect-nrf_crypto
    • test-fw-nrfconnect-ps-main
    • test-fw-nrfconnect-rpc
    • test-fw-nrfconnect-rs
    • test-fw-nrfconnect-tfm
    • test-fw-nrfconnect-thread-main
    • test-low-level
    • test-sdk-audio
    • test-sdk-dfu
    • test-sdk-find-my
    • test-sdk-mcuboot
    • test-sdk-wifi
    • test-secdom-samples-public

Note: This message is automatically posted and updated by the CI

@github-actions
Copy link

github-actions bot commented Nov 7, 2025

You can find the documentation preview for this PR here.

Preview links for modified nRF Connect SDK documents:

https://ncsdoc.z6.web.core.windows.net/PR-25479/nrf/releases_and_maturity/software_maturity.html

Copy link
Member

@Szynkaa Szynkaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using esb_pop_tx can cause same corruption as esb_flush_tx

BIT(timer_compare0_radio_disable) |
BIT(radio_end_timer_start) |
(IS_ENABLED(CONFIG_ESB_NEVER_DISABLE_TX) ?
BIT(timer_compare1_radio_txen) : 0));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this 2 channels are swapped, radio_end_timer_start depends on CONFIG_ESB_NEVER_DISABLE_TX and timer_compare1_radio_txen is used as retx trigger

same thing is below in clearing endpoint

BIT(timer_compare0_radio_disable) |
BIT(radio_end_timer_start) |
(IS_ENABLED(CONFIG_ESB_NEVER_DISABLE_TX) ?
BIT(timer_compare1_radio_txen) : 0));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this 2 channels are swapped, radio_end_timer_start depends on CONFIG_ESB_NEVER_DISABLE_TX


/* Clear Radio */
nrf_radio_publish_clear(NRF_RADIO, NRF_RADIO_EVENT_ADDRESS);
nrf_radio_publish_clear(NRF_RADIO, NRF_RADIO_EVENT_DISABLED);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we cannot clear publish for NRF_RADIO_EVENT_DISABLED here, because it comes from ppi_init
also clear for ESB_RADIO_EVENT_END is problematic because on nrf54X it alias for NRF_RADIO_EVENT_PHYEND and it's set in ppi_init for CONFIG_ESB_FAST_SWITCHING

Comment on lines +2125 to +2128
nrf_timer_event_clear(esb_timer.p_reg, NRF_TIMER_EVENT_COMPARE0);
nrf_timer_event_clear(esb_timer.p_reg, NRF_TIMER_EVENT_COMPARE1);
nrf_timer_event_clear(esb_timer.p_reg, NRF_TIMER_EVENT_COMPARE2);
nrf_timer_event_clear(esb_timer.p_reg, NRF_TIMER_EVENT_COMPARE3);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is needed

}

/* Clear PPI */
nrf_radio_event_clear(NRF_RADIO, NRF_RADIO_EVENT_DISABLED);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is needed

Comment on lines +2130 to +2135
#if NRF_TIMER_HAS_SHUTDOWN
nrf_timer_task_trigger(esb_timer.p_reg, NRF_TIMER_TASK_SHUTDOWN);
#else
nrf_timer_task_trigger(esb_timer.p_reg, NRF_TIMER_TASK_STOP);
nrf_timer_task_trigger(esb_timer.p_reg, NRF_TIMER_TASK_CLEAR);
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

esb_fem_reset also do that

{
if (!esb_initialized) {
return -EACCES;
} else if (esb_state != ESB_STATE_IDLE) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants