Skip to content

Initial support for using Embassy with Rust on Zephyr #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions samples/embassy/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})

project(embassy_on_zephyr)
rust_cargo_application()
63 changes: 63 additions & 0 deletions samples/embassy/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Copyright (c) 2024 Linaro LTD
# SPDX-License-Identifier: Apache-2.0

[package]
# This must be rustapp for now.
name = "rustapp"
version = "0.1.0"
edition = "2021"
description = "A sample hello world application in Rust"
license = "Apache-2.0 or MIT"

[lib]
crate-type = ["staticlib"]

[dependencies]
zephyr = { version = "0.1.0", features = ["time-driver"] }
log = "0.4.22"
static_cell = "2.1"
heapless = "0.8"

[dependencies.embassy-executor]
version = "0.7.0"
# path = "../../embassy/embassy-executor"
features = [
"log",
"task-arena-size-2048",
]

[dependencies.embassy-futures]
version = "0.1.1"
# path = "../../embassy/embassy-futures"

[dependencies.embassy-sync]
version = "0.6.2"
# path = "../../embassy/embassy-sync"

[dependencies.embassy-time]
version = "0.4.0"
# path = "../../embassy/embassy-time"
# This is board specific.
features = ["tick-hz-10_000"]

[dependencies.critical-section]
version = "1.2"

[features]
# default = ["executor-thread"]
default = ["executor-zephyr"]

executor-thread = [
"embassy-executor/arch-cortex-m",
"embassy-executor/executor-thread",
]

executor-zephyr = [
"zephyr/executor-zephyr",
]

[profile.dev]
opt-level = 1

[profile.release]
debug = true
7 changes: 7 additions & 0 deletions samples/embassy/pimoroni_tiny_2040.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright (c) 2024 Linaro LTD
# SPDX-License-Identifier: Apache-2.0

# This board doesn't have a serial console, so use RTT.
CONFIG_UART_CONSOLE=n
CONFIG_RTT_CONSOLE=y
CONFIG_USE_SEGGER_RTT=y
14 changes: 14 additions & 0 deletions samples/embassy/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright (c) 2024 Linaro LTD
# SPDX-License-Identifier: Apache-2.0

CONFIG_DEBUG=y

# The default 1k stack isn't large enough for rust string formatting with logging.
CONFIG_MAIN_STACK_SIZE=4096

CONFIG_RUST=y

CONFIG_RUST_ALLOC=y
# CONFIG_LOG=y

CONFIG_LOG_BACKEND_RTT=n
7 changes: 7 additions & 0 deletions samples/embassy/rpi_pico.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright (c) 2024 Linaro LTD
# SPDX-License-Identifier: Apache-2.0

# This board doesn't have a serial console, so use RTT.
CONFIG_UART_CONSOLE=n
CONFIG_RTT_CONSOLE=y
CONFIG_USE_SEGGER_RTT=y
20 changes: 20 additions & 0 deletions samples/embassy/sample.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
sample:
description: Embassy Hello
name: hello and basics from Embassy
common:
harness: console
harness_config:
type: one_line
regex:
- "Embassy tests passed"
tags: rust
filter: CONFIG_RUST_SUPPORTED
platform_allow:
- qemu_cortex_m0
- qemu_cortex_m3
- qemu_riscv32
- qemu_riscv64
- nrf52840dk/nrf52840
tests:
sample.rust.embassyhello:
tags: introduction
Loading