Skip to content

Zephyr setup failure #4

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

Closed
wants to merge 5 commits into from
Closed
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
59 changes: 59 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Copyright (c) 2024 Linaro LTD
# SPDX-License-Identifier: Apache-2.0

name: Build

# Build the rust samples and tests using the current Zephyr.

on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: "0 0 * * *"

jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: zephyr-rust-lang

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11

- name: Setup Zephyr project
uses: zephyrproject-rtos/action-zephyr-setup@v1
with:
app-path: zephyr-rust-lang
manifest-file-name: ci-manifest.yml
toolchains: arm-zephyr-eabi:riscv64-zephyr-elf

- name: Install Rust Targets
shell: bash
run: |
rustup target add riscv32i-unknown-none-elf
rustup target add riscv64imac-unknown-none-elf
rustup target add thumbv6m-none-eabi
rustup target add thumbv7em-none-eabi
rustup target add thumbv7m-none-eabi
rustup target add thumbv8m.main-none-eabi

- name: Build firmware
working-directory: zephyr-rust-lang
shell: bash
run: |
cargo --version

west twister -T samples -v --inline-logs --integration
65 changes: 65 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Generate and Preview Rust Docs

on:
pull_request:
branches:
- main # Only generate docs for PRs targeting main
push:
branches:
- main
workflow_dispatch:

jobs:
generate-docs:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: zephyr-rust-lang

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11

- name: Setup Zephyr project
uses: zephyrproject-rtos/action-zephyr-setup@v1
with:
app-path: zephyr-rust-lang
manifest-file-name: ci-manifest.yml
toolchains: arm-zephyr-eabi

- name: Install Rust Targets
shell: bash
run: |
rustup target add thumbv7em-none-eabi
rustup target add thumbv7m-none-eabi

- name: Setup cargo build
working-directory: zephyr-rust-lang
run: |
west build -b nrf52840dk/nrf52840 --cmake-only docgen
find . -type d -ls

# - name: Build Rust documentation
# run: cargo doc --no-deps

# - name: Deploy docs to GitHub Pages for pull requests
# if: github.event_name == 'pull_request'
# uses: peaceiris/actions-gh-pages@v3
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# publish_dir: ./target/doc
# publish_branch: gh-pages
# publish_dir: ./target/doc
# destination_dir: pr-${{ github.event.number }}
#
# - name: Deploy docs to GitHub Pages for push to main
# if: github.event_name == 'push'
# uses: peaceiris/actions-gh-pages@v3
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# publish_dir: ./target/doc
# publish_branch: gh-pages
22 changes: 22 additions & 0 deletions ci-manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright (c) 2021 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

# Although this normally lives as a module, the local CI uses action-zephyr-setup which wants the
# application to have a manifest.

manifest:
remotes:
- name: zephyrproject-rtos
url-base: https://github.com/zephyrproject-rtos

projects:
- name: zephyr
remote: zephyrproject-rtos
revision: main
import:
# By using name-allowlist we can clone only the modules that are
# strictly needed by the application.
name-allowlist:
- cmsis # required by the ARM port
- hal_nordic # required by the custom_plank board (Nordic based)
- hal_stm32 # required by the nucleo_f302r8 board (STM32 based)
8 changes: 8 additions & 0 deletions docgen/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(hello_rust_world)
rust_cargo_application()
16 changes: 16 additions & 0 deletions docgen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 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 = "0.1.0"
4 changes: 4 additions & 0 deletions docgen/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (c) 2024 Linaro LTD
# SPDX-License-Identifier: Apache-2.0

CONFIG_RUST=y
16 changes: 16 additions & 0 deletions docgen/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) 2024 Linaro LTD
// SPDX-License-Identifier: Apache-2.0

#![no_std]

use zephyr::printkln;

// Reference the Zephyr crate so that the panic handler gets used. This is only needed if no
// symbols from the crate are directly used.
extern crate zephyr;

#[no_mangle]
extern "C" fn rust_main() {
printkln!("Hello world from Rust on {}",
zephyr::kconfig::CONFIG_BOARD);
}