Skip to content

Conversation

Trond-F-Christiansen
Copy link

This PR introduces multi-domain support for ZBus, enabling message forwarding between domains.

  • Shadow Channels:
    A reserved channel type used for observing channels originating in other domains.
  • Proxy Agents:
    Background processes that forward messages between domains. Handles message forwarding, receiving, acknowledgments, and publishing to shadow channels.
    • IPC backend: For multi domain between cores.
    • UART backend: For multi domain between devices.

Fixes #94857

Copy link

Hello @Trond-F-Christiansen, and thank you very much for your first pull request to the Zephyr project!
Our Continuous Integration pipeline will execute a series of checks on your Pull Request commit messages and code, and you are expected to address any failures by updating the PR. Please take a look at our commit message guidelines to find out how to format your commit messages, and at our contribution workflow to understand how to update your Pull Request. If you haven't already, please make sure to review the project's Contributor Expectations and update (by amending and force-pushing the commits) your pull request if necessary.
If you are stuck or need help please join us on Discord and ask your question there. Additionally, you can escalate the review when applicable. 😊

@Trond-F-Christiansen Trond-F-Christiansen force-pushed the shaddow_channels branch 2 times, most recently from 3bf34bd to eea4c3f Compare September 18, 2025 15:27
@Trond-F-Christiansen Trond-F-Christiansen force-pushed the shaddow_channels branch 2 times, most recently from ab3bc41 to 1f20007 Compare October 2, 2025 07:42
@Trond-F-Christiansen Trond-F-Christiansen marked this pull request as ready for review October 2, 2025 08:25
@zephyrbot zephyrbot added area: Zbus area: Samples Samples area: Tests Issues related to a particular existing or missing test labels Oct 2, 2025
@Trond-F-Christiansen Trond-F-Christiansen force-pushed the shaddow_channels branch 2 times, most recently from 5f866d1 to 36e4902 Compare October 6, 2025 14:33
Add a new API function zbus_chan_from_name() that allows retrieving a
zbus channel by its name string. This complements the existing
zbus_chan_from_id() function and provides more flexibility for channel
lookup operations.

The function performs a linear search through all channels using
STRUCT_SECTION_FOREACH and compares channel names using strcmp(). It
returns NULL if no matching channel is found, maintaining consistency
with the existing zbus_chan_from_id() API.

The implementation is conditionally compiled when CONFIG_ZBUS_CHANNEL_NAME
is enabled, ensuring it's only available when channel names are configured
in the system.

Signed-off-by: Trond F. Christiansen <trond.christiansen@nordicsemi.no>
Add core multidomain support to ZBus, enabling communication between
separate domains. This includes:

- New shadow channel concept with is_shadow_channel flag
- ZBUS_SHADOW_CHAN_DEFINE macros for defining shadow channels
- ZBUS_MULTIDOMAIN_CHAN_DEFINE for conditional channel definitions
- ZBUS_CHANNEL_IS_SHADOW macro for checking shadow status
- ZBUS_CHANNEL_IS_MASTER macro for checking master status
- zbus_chan_pub_shadow() for internal shadow channel publishing
- Protection against publishing to shadow channels from application code
- Configuration options for multidomain support

Shadow channels represent channels defined in other domains, allowing
observation without direct publishing. The multidomain macros enable
shared channel definitions that create master channels in one domain
and shadow channels in others.

Signed-off-by: Trond F. Christiansen <trond.christiansen@nordicsemi.no>
Add the type definitions and API framework for ZBus multidomain
proxy agents. This provides the foundation for backend-agnostic
communication between domains.

- Define zbus_multidomain_type enum for different backends
- Add zbus_proxy_agent_msg structure for inter-domain messages
- Create zbus_proxy_agent_api for backend abstraction
- Add zbus_proxy_agent_config for agent configuration
- Implement core proxy agent functions (init, send, thread)
- Add retransmission logic
- Add macro system for backend-specific configuration generation

The proxy agent framework allows different communication backends
(UART, IPC, etc.) to be plugged in using a common API interface.

Signed-off-by: Trond F. Christiansen <trond.christiansen@nordicsemi.no>
Implement UART backend for ZBus multidomain communication, enabling
message forwarding between domains over UART connections.

- UART-specific configuration structure with async buffers
- Error handling and UART recovery mechanisms
- Integration with proxy agent framework via API structure
- Configurable buffer count for UART operations
- Schedule ACK sending as work to avoid blocking RX callback

The UART backend uses async UART APIs for non-blocking communication
and implements proper buffer cycling for continuous reception.

Signed-off-by: Trond F. Christiansen <trond.christiansen@nordicsemi.no>
Add sample application demonstrating ZBus multidomain communication
over UART between two devices. Shows practical usage of shadow
channels and proxy agents for inter-domain message forwarding.

The sample consists of two devices:
- Device A: Acts as request publisher with master request_channel
- Device B: Acts as request listener/responder with shadow request_channel

Device A publishes periodic requests which are automatically forwarded
via UART to Device B. Device B processes requests and sends responses
back through the response_channel, demonstrating bidirectional
multidomain zbus communication.

Key features demonstrated:
- ZBUS_MULTIDOMAIN_CHAN_DEFINE for shared conditional channel definitions
- ZBUS_PROXY_AGENT_DEFINE for UART backend configuration
- Shadow vs master channel behavior
- Automatic message forwarding via proxy agents

Signed-off-by: Trond F. Christiansen <trond.christiansen@nordicsemi.no>
Implement IPC backend for ZBus multidomain communication, enabling
message forwarding between domains over IPC connections.

- IPC-spesific configuration structures
- Integration with proxy agent framework via API structure and macros
- Schedule ACK sending as work to avoid blocking in interrupt context

The IPC backend uses Zephyr's IPC service for inter-core communication
with async operation and proper endpoint binding using semaphore
synchronization for reliable zbus message forwarding.

Signed-off-by: Trond F. Christiansen <trond.christiansen@nordicsemi.no>
Add sample application demonstrating ZBus multidomain communication
over IPC between CPU cores. Shows practical usage of shadow channels
and proxy agents for inter-core message forwarding.

The sample consists of two applications:
- CPUAPP: Acts as request publisher with master request_channel
- CPURAD: Acts as request listener/responder with shadow request_channel

CPUAPP publishes periodic requests which are automatically forwarded
via IPC to CPURAD. CPURAD processes requests and sends responses back
through the response_channel, demonstrating bidirectional multidomain
zbus communication.

Key features demonstrated:
- ZBUS_MULTIDOMAIN_CHAN_DEFINE for shared conditional channel definitions
- ZBUS_PROXY_AGENT_DEFINE for IPC backend configuration
- Shadow vs master channel behavior across CPU cores
- Automatic message forwarding via proxy agents
- Sysbuild configuration for multi-core applications

Supports nRF5340DK and nRF54H20DK platforms with appropriate
device tree overlays for IPC configuration.

Signed-off-by: Trond F. Christiansen <trond.christiansen@nordicsemi.no>
Add tests to verify the zbus_chan_from_name() functionality when
CONFIG_ZBUS_CHANNEL_NAME is enabled.

Signed-off-by: Trond F. Christiansen <trond.christiansen@nordicsemi.no>
Add test suite to verify the shadow channel functionality when
CONFIG_ZBUS_MULTIDOMAIN is enabled.

Signed-off-by: Trond F. Christiansen <trond.christiansen@nordicsemi.no>
Add comprehensive test suite for the zbus multidomain proxy agent
functionality.
Implements a mock backend to enable isolated testing without requiring
actual hardware communication.

Signed-off-by: Trond F. Christiansen <trond.christiansen@nordicsemi.no>
Add comprehensive test suite for the zbus multidomain IPC backend.
The implementation includes a mock IPC backend to enable isolated testing
without requiring actual hardware communication between cores.

Signed-off-by: Trond F. Christiansen <trond.christiansen@nordicsemi.no>
Add comprehensive test suite for the zbus multidomain UART backend.
The implementation uses UART emulator devices to enable testing without
requiring physical UART hardware.

Signed-off-by: Trond F. Christiansen <trond.christiansen@nordicsemi.no>
Adds support for running the Zbus IPC forwarder sample on the nrf5340bsim
simulation platform to enable development and CI without physical hardware.

Signed-off-by: Trond F. Christiansen <trond.christiansen@nordicsemi.no>
Adds sample.yaml with test definitions for the IPC forwarder sample,
enabling testing using console harness with output validation.

Signed-off-by: Trond F. Christiansen <trond.christiansen@nordicsemi.no>
Add documentation for the multi-domain zbus feature, and multi-domain
zbus samples.

Signed-off-by: Trond F. Christiansen <trond.christiansen@nordicsemi.no>
Copy link

sonarqubecloud bot commented Oct 7, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Samples Samples area: Tests Issues related to a particular existing or missing test area: Zbus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ZBus multi-core support
3 participants