Skip to content

Commit

Permalink
Merge pull request #10 from ferrous-systems/add-cortex-r
Browse files Browse the repository at this point in the history
Add ThreadX on Cortex-R demo
  • Loading branch information
miguelraz authored Jul 23, 2024
2 parents 42e744b + cb78435 commit 6eef99f
Show file tree
Hide file tree
Showing 34 changed files with 1,895 additions and 59 deletions.
55 changes: 47 additions & 8 deletions .github/workflows/build-ferrocene.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: workflow-build-everything-ferrocene
run-name: Build Everything with Ferrocene
on: [push]
jobs:
job-build-demo-app:
job-build-nrf52-app:
runs-on: ubuntu-latest
steps:
- name: Install Arm C compiler
Expand All @@ -27,23 +27,62 @@ jobs:
slug=$(./describe.sh "${GITHUB_REF}")
echo "Building with slug '${slug}'"
echo "BUILD_SLUG=${slug}" >> "${GITHUB_ENV}"
- name: Check Demo App
- name: Check nRF52 App
run: |
cd demo-app
cd nrf52-app
rustc --version
cargo --version
cargo check --target=thumbv7em-none-eabi
- name: Build Demo App
- name: Build nRF52 App
run: |
cd demo-app
cd nrf52-app
rustc --version
cargo --version
cargo build --target=thumbv7em-none-eabi --release
- name: Upload demo-app
- name: Upload nrf52-app
uses: actions/upload-artifact@master
with:
name: demo-app
path: demo-app/target/thumbv7em-none-eabi/release/demo-app
name: nrf52-app
path: nrf52-app/target/thumbv7em-none-eabi/release/nrf52-app
job-build-qemu-cortex-r5-app:
runs-on: ubuntu-latest
steps:
- name: Install Arm C compiler
run: |
sudo apt-get update -y && sudo apt-get -y install gcc-arm-none-eabi
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/ferrocene/criticalup/releases/download/v1.0.1/criticalup-installer.sh | sh
- name: Checkout repo
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Install Ferrocene
env:
CRITICALUP_TOKEN: ${{ secrets.CRITICALUP_TOKEN }}
run: |
criticalup install
echo "$HOME/.local/share/criticalup/bin" >> $GITHUB_PATH
- name: Find slug name
run: |
slug=$(./describe.sh "${GITHUB_REF}")
echo "Building with slug '${slug}'"
echo "BUILD_SLUG=${slug}" >> "${GITHUB_ENV}"
- name: Check QEMU Cortex-R5 App
run: |
cd qemu-cortex-r5-app
rustc --version
cargo --version
cargo check --target=armv7r-none-eabihf
- name: Build QEMU Cortex-R5 App
run: |
cd qemu-cortex-r5-app
rustc --version
cargo --version
cargo build --target=armv7r-none-eabihf --release
- name: Upload QEMU Cortex-R5 App
uses: actions/upload-artifact@master
with:
name: qemu-cortex-r5-app
path: qemu-cortex-r5-app/target/armv7r-none-eabihf/release/qemu-cortex-r5-app
job-build-threadx-sys:
runs-on: ubuntu-latest
steps:
Expand Down
47 changes: 39 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: workflow-build-everything
run-name: Build Everything
on: [push]
jobs:
job-build-demo-app:
job-build-nrf52-app:
runs-on: ubuntu-latest
steps:
- name: Install Arm C compiler
Expand All @@ -27,19 +27,50 @@ jobs:
slug=$(./describe.sh "${GITHUB_REF}")
echo "Building with slug '${slug}'"
echo "BUILD_SLUG=${slug}" >> "${GITHUB_ENV}"
- name: Check Demo App
- name: Check nRF52 App
run: |
cd demo-app
cd nrf52-app
cargo check --target=thumbv7em-none-eabi
- name: Build Demo App
- name: Build nRF52 App
run: |
cd demo-app
cd nrf52-app
cargo build --target=thumbv7em-none-eabi --release
- name: Upload demo-app
- name: Upload nrf52-app
uses: actions/upload-artifact@master
with:
name: demo-app
path: demo-app/target/thumbv7em-none-eabi/release/demo-app
name: nrf52-app
path: nrf52-app/target/thumbv7em-none-eabi/release/nrf52-app
job-build-qemu-cortex-r5-app:
runs-on: ubuntu-latest
steps:
- name: Install Arm C compiler
run: |
sudo apt-get update -y && sudo apt-get -y install gcc-arm-none-eabi
- name: Checkout repo
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Add rustup target
run: |
rustup target add armv7r-none-eabihf
- name: Find slug name
run: |
slug=$(./describe.sh "${GITHUB_REF}")
echo "Building with slug '${slug}'"
echo "BUILD_SLUG=${slug}" >> "${GITHUB_ENV}"
- name: Check QEMU Cortex-R5 App
run: |
cd qemu-cortex-r5-app
cargo check --target=armv7r-none-eabihf
- name: Build QEMU Cortex-R5 App
run: |
cd qemu-cortex-r5-app
cargo build --target=armv7r-none-eabihf --release
- name: Upload qemu-cortex-r5-app
uses: actions/upload-artifact@master
with:
name: qemu-cortex-r5-app
path: qemu-cortex-r5-app/target/armv7r-none-eabihf/release/qemu-cortex-r5-app
job-build-threadx-sys:
runs-on: ubuntu-latest
steps:
Expand Down
25 changes: 22 additions & 3 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: workflow-code-analysis
run-name: Run code analysis
on: [push]
jobs:
job-clippy-demo-app:
job-clippy-nrf52-app:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
Expand All @@ -18,11 +18,30 @@ jobs:
- name: Add rustup target
run: |
rustup target add thumbv7em-none-eabi
- name: Check Clippy on Demo App
- name: Check Clippy on nRF52 App
env:
RUSTFLAGS: "-Dwarnings"
run: |
cd demo-app
cd nrf52-app
cargo clippy --all-features
job-clippy-qemu-cortex-r5-app:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Install tools
run: |
sudo apt-get update -y && sudo apt-get -y install gcc-arm-none-eabi
- name: Add rustup target
run: |
rustup target add armv7r-none-eabihf
- name: Check Clippy on QEMU Cortex-R5 App
env:
RUSTFLAGS: "-Dwarnings"
run: |
cd qemu-cortex-r5-app
cargo clippy --all-features
job-clippy-threadx-sys:
runs-on: ubuntu-latest
Expand Down
15 changes: 12 additions & 3 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,23 @@ name: workflow-code-format
run-name: Check code formatting
on: [push]
jobs:
job-format-demo-app:
job-format-nrf52-app:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Check Formatting
- name: Check Formatting on nRF52 App
run: |
cd nrf52-app
cargo fmt -- --check
job-format-qemu-cortex-r5-app:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Check Formatting on QEMU Cortex-R5 App
run: |
cd demo-app
cd qemu-cortex-r5-app
cargo fmt -- --check
job-format-threadx-sys:
runs-on: ubuntu-latest
Expand Down
6 changes: 5 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

set -euo pipefail

pushd demo-app
pushd nrf52-app
cargo build --release
popd

pushd qemu-cortex-r5-app
cargo build --release
popd
1 change: 1 addition & 0 deletions criticalup.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ packages = [
"flip-link-${rustc-host}",
"llvm-tools-${rustc-host}",
"rust-std-thumbv7em-none-eabi",
"rust-std-armv7r-none-eabihf",
]
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// SPDX-License-Identifier: MIT OR Apache-2.0

{
// Use `nc localhost 8765 | defmt-print -e ./target/thumbv7em-none-eabihf/release/demo-app` to print the defmt output
// Use `nc localhost 8765 | defmt-print -e ./target/thumbv7em-none-eabihf/release/nrf52-app` to print the defmt output
"version": "0.2.0",
"configurations": [
{
"cwd": "${workspaceRoot}",
"executable": "./target/thumbv7em-none-eabihf/release/demo-app",
"executable": "./target/thumbv7em-none-eabihf/release/nrf52-app",
"name": "Debug Microcontroller (launch)",
"request": "launch",
"preLaunchTask": "rust: cargo build release",
Expand Down
File renamed without changes.
File renamed without changes.
34 changes: 17 additions & 17 deletions demo-app/Cargo.lock → nrf52-app/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
2 changes: 1 addition & 1 deletion demo-app/Cargo.toml → nrf52-app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
authors = ["Jonathan Pallant <[email protected]>"]
edition = "2021"
license = "MIT OR Apache-2.0"
name = "demo-app"
name = "nrf52-app"
version = "0.0.0"
description = "Rust ThreadX demo on nRF52840"

Expand Down
32 changes: 16 additions & 16 deletions demo-app/README.md → nrf52-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,39 @@ automatically. You will also need `probe-rs` from <https://probe.rs>.

```console
$ cargo run --release
Compiling demo-app v0.0.0 (/Users/jonathan/Documents/ferrous-systems/threadx-experiments/demo-app)
Compiling nrf52-app v0.0.0 (/Users/jonathan/Documents/ferrous-systems/threadx-experiments/nrf52-app)
Finished `dev` profile [optimized + debuginfo] target(s) in 4.81s
Running `probe-rs run --chip nRF52840_xxAA target/thumbv7em-none-eabi/debug/demo-app`
Running `probe-rs run --chip nRF52840_xxAA target/thumbv7em-none-eabi/debug/nrf52-app`
Erasing ✔ [00:00:00] [####################################] 12.00 KiB/12.00 KiB @ 33.03 KiB/s (eta 0s )
Programming ✔ [00:00:00] [####################################] 12.00 KiB/12.00 KiB @ 42.84 KiB/s (eta 0s ) Finished in 0.661s
<lvl> Hello, this is version unknown!
└─ demo_app::__cortex_m_rt_main @ src/main.rs:151
└─ nrf52_app::__cortex_m_rt_main @ src/main.rs:151
<lvl> Entering ThreadX kernel...
└─ demo_app::__cortex_m_rt_main @ src/main.rs:186
└─ nrf52_app::__cortex_m_rt_main @ src/main.rs:186
<lvl> In tx_application_define()...
└─ demo_app::tx_application_define @ src/main.rs:26
└─ nrf52_app::tx_application_define @ src/main.rs:26
<lvl> Stack allocated @ 0x20037444
└─ demo_app::tx_application_define @ src/main.rs:59
└─ nrf52_app::tx_application_define @ src/main.rs:59
<lvl> Thread spawned (entry=12345678) @ 0x2003f440
└─ demo_app::tx_application_define @ src/main.rs:85
└─ nrf52_app::tx_application_define @ src/main.rs:85
<lvl> Stack allocated @ 0x2003944c
└─ demo_app::tx_application_define @ src/main.rs:102
└─ nrf52_app::tx_application_define @ src/main.rs:102
<lvl> Thread spawned (entry=aabbccdd) @ 0x2003f4f8
└─ demo_app::tx_application_define @ src/main.rs:128
└─ nrf52_app::tx_application_define @ src/main.rs:128
<lvl> I am my_thread(12345678)
└─ demo_app::my_thread @ src/main.rs:136
└─ nrf52_app::my_thread @ src/main.rs:136
<lvl> I am my_thread(aabbccdd)
└─ demo_app::my_thread @ src/main.rs:136
└─ nrf52_app::my_thread @ src/main.rs:136
<lvl> I am my_thread(12345678), count = 1
└─ demo_app::my_thread @ src/main.rs:145
└─ nrf52_app::my_thread @ src/main.rs:145
<lvl> I am my_thread(aabbccdd), count = 1
└─ demo_app::my_thread @ src/main.rs:145
└─ nrf52_app::my_thread @ src/main.rs:145
<lvl> I am my_thread(12345678), count = 2
└─ demo_app::my_thread @ src/main.rs:145
└─ nrf52_app::my_thread @ src/main.rs:145
<lvl> I am my_thread(aabbccdd), count = 2
└─ demo_app::my_thread @ src/main.rs:145
└─ nrf52_app::my_thread @ src/main.rs:145
<lvl> I am my_thread(12345678), count = 3
└─ demo_app::my_thread @ src/main.rs:145
└─ nrf52_app::my_thread @ src/main.rs:145
...
```

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions qemu-cortex-r5-app/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-FileCopyrightText: Copyright (c) 2024 Ferrous Systems
# SPDX-License-Identifier: MIT OR Apache-2.0

[target.armv7r-none-eabihf]
rustflags = [
"-Clink-arg=-Tlinker.ld",
"-Ctarget-cpu=cortex-r5",
]
runner = "qemu-system-arm -machine versatileab -cpu cortex-r5f -semihosting -nographic -kernel"

[build]
target = ["armv7r-none-eabihf"]
4 changes: 4 additions & 0 deletions qemu-cortex-r5-app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# SPDX-FileCopyrightText: Copyright (c) 2024 Ferrous Systems
# SPDX-License-Identifier: CC0-1.0

/target
Loading

0 comments on commit 6eef99f

Please sign in to comment.