Skip to content

Commit

Permalink
Merge pull request #9 from ferrous-systems/remove-cmake
Browse files Browse the repository at this point in the history
No longer requires cmake or ninja.
  • Loading branch information
miguelraz committed Jul 23, 2024
2 parents 20d0caa + 0d4e931 commit 42e744b
Show file tree
Hide file tree
Showing 8 changed files with 301 additions and 125 deletions.
30 changes: 2 additions & 28 deletions .github/workflows/build-ferrocene.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,19 @@ name: workflow-build-everything-ferrocene
run-name: Build Everything with Ferrocene
on: [push]
jobs:
job-build-threadx-staticlib:
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 cmake gcc gcc-arm-none-eabi build-essential ninja-build
- name: Compile ThreadX for Cortex-M4
run: |
cd threadx
cmake -Bbuild_m4 -GNinja -DCMAKE_TOOLCHAIN_FILE=cmake/cortex_m4.cmake
cmake --build ./build_m4
- name: Upload staticlib
uses: actions/upload-artifact@master
with:
name: threadx-cm4
path: threadx/build_m4/libthreadx.a
job-build-demo-app:
runs-on: ubuntu-latest
needs: job-build-threadx-staticlib
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.0-prerelease.1/criticalup-installer.sh | sh
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: Download staticlib
uses: actions/download-artifact@master
with:
name: threadx-cm4
path: threadx/build # Where build.rs expects it
- name: Install Ferrocene
env: # Or as an environment variable
env:
CRITICALUP_TOKEN: ${{ secrets.CRITICALUP_TOKEN }}
run: |
criticalup install
Expand Down
26 changes: 0 additions & 26 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,8 @@ name: workflow-build-everything
run-name: Build Everything
on: [push]
jobs:
job-build-threadx-staticlib:
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 cmake gcc gcc-arm-none-eabi build-essential ninja-build
- name: Compile ThreadX for Cortex-M4
run: |
cd threadx
cmake -Bbuild_m4 -GNinja -DCMAKE_TOOLCHAIN_FILE=cmake/cortex_m4.cmake
cmake --build ./build_m4
- name: Upload staticlib
uses: actions/upload-artifact@master
with:
name: threadx-cm4
path: threadx/build_m4/libthreadx.a
job-build-demo-app:
runs-on: ubuntu-latest
needs: job-build-threadx-staticlib
steps:
- name: Install Arm C compiler
run: |
Expand All @@ -40,11 +19,6 @@ jobs:
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Download staticlib
uses: actions/download-artifact@master
with:
name: threadx-cm4
path: threadx/build # Where build.rs expects it
- name: Add rustup target
run: |
rustup target add thumbv7em-none-eabi
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
This repository shows how to compile a Rust application which runs on the
ThreadX RTOS.

Note this project uses Git submodules, so you should run:

```bash
git submodule update --init
```

## Licence

* Copyright (c) 2023 Ferrous Systems
* Copyright (c) 2024 Ferrous Systems
* SPDX-License-Identifier: MIT OR Apache-2.0
10 changes: 2 additions & 8 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
#!/bin/bash

# Builds the Cortex-M4 version of ThreadX, then builds a Rust
# application that links to it.
# Builds the various ThreadX demo apps.

# SPDX-FileCopyrightText: Copyright (c) 2023 Ferrous Systems
# SPDX-FileCopyrightText: Copyright (c) 2024 Ferrous Systems
# SPDX-License-Identifier: MIT OR Apache-2.0

set -euo pipefail

pushd threadx
cmake -Bbuild -GNinja -DCMAKE_TOOLCHAIN_FILE=cmake/cortex_m4.cmake .
cmake --build ./build
popd

pushd demo-app
cargo build --release
popd
50 changes: 50 additions & 0 deletions demo-app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Rust on ThreadX on nRF52 Example Binary

This is a Rust application which uses ThreadX and runs on an nRF52840-DK board.

You can compile it with Rust, or with Ferrocene. You will need
`arm-none-eabi-gcc` installed to compile ThreadX, which this application does
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)
Finished `dev` profile [optimized + debuginfo] target(s) in 4.81s
Running `probe-rs run --chip nRF52840_xxAA target/thumbv7em-none-eabi/debug/demo-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
<lvl> Entering ThreadX kernel...
└─ demo_app::__cortex_m_rt_main @ src/main.rs:186
<lvl> In tx_application_define()...
└─ demo_app::tx_application_define @ src/main.rs:26
<lvl> Stack allocated @ 0x20037444
└─ demo_app::tx_application_define @ src/main.rs:59
<lvl> Thread spawned (entry=12345678) @ 0x2003f440
└─ demo_app::tx_application_define @ src/main.rs:85
<lvl> Stack allocated @ 0x2003944c
└─ demo_app::tx_application_define @ src/main.rs:102
<lvl> Thread spawned (entry=aabbccdd) @ 0x2003f4f8
└─ demo_app::tx_application_define @ src/main.rs:128
<lvl> I am my_thread(12345678)
└─ demo_app::my_thread @ src/main.rs:136
<lvl> I am my_thread(aabbccdd)
└─ demo_app::my_thread @ src/main.rs:136
<lvl> I am my_thread(12345678), count = 1
└─ demo_app::my_thread @ src/main.rs:145
<lvl> I am my_thread(aabbccdd), count = 1
└─ demo_app::my_thread @ src/main.rs:145
<lvl> I am my_thread(12345678), count = 2
└─ demo_app::my_thread @ src/main.rs:145
<lvl> I am my_thread(aabbccdd), count = 2
└─ demo_app::my_thread @ src/main.rs:145
<lvl> I am my_thread(12345678), count = 3
└─ demo_app::my_thread @ src/main.rs:145
...
```

## Licence

* Copyright (c) 2024 Ferrous Systems
* SPDX-License-Identifier: MIT OR Apache-2.0
Loading

0 comments on commit 42e744b

Please sign in to comment.