Skip to content

Commit 4060c3d

Browse files
romancardenasAfoHT
andauthored
RISC-V support over CLINT (#815)
* Rebase to master * using interrupt_mod * bug fixes * fix other backends * Add changelog * forgot about rtic-macros * backend-specific configuration * core peripherals optional over macro argument * pre_init_preprocessing binding * CI for RISC-V (WIP) * separation of concerns * add targets for RISC-V examples * remove qemu feature * prepare examples folder * move examples all together * move ci out of examples * minor changes * add cortex-m * new xtask: proof of concept * fix build.yml * feature typo * clean rtic examples * reproduce weird issue * remove unsafe code in user app * update dependencies * allow builds on riscv32imc * let's fix QEMU * Update .github/workflows/build.yml Co-authored-by: Henrik Tjäder <[email protected]> * New build.rs * removing test features * adapt ui test to new version of clippy * add more examples to RISC-V backend * proper configuration of heapless for riscv32imc * opt-out examples for riscv32imc * point to new version of riscv-slic * adapt new macro bindings * adapt examples and CI to stable * fix cortex-m CI * Review --------- Co-authored-by: Henrik Tjäder <[email protected]>
1 parent 22ac33a commit 4060c3d

File tree

166 files changed

+2308
-301
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+2308
-301
lines changed

.github/workflows/build.yml

Lines changed: 113 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ jobs:
3131
- name: cargo xtask fmt
3232
run: cargo xtask --verbose fmt -c
3333

34-
# Compilation check
35-
check:
36-
name: check
34+
# Compilation check (lm3s6965)
35+
checklm3s6965:
36+
name: check (lm3s6965)
3737
runs-on: ubuntu-22.04
3838
strategy:
3939
matrix:
@@ -62,11 +62,14 @@ jobs:
6262
- name: Cache Dependencies
6363
uses: Swatinem/rust-cache@v2
6464

65-
- run: cargo xtask --deny-warnings --backend ${{ matrix.backend }} check
65+
- run: cargo xtask --deny-warnings --platform lm3s6965 --backend ${{ matrix.backend }} check
6666

67-
# Clippy
68-
clippy:
69-
name: clippy
67+
# Compilation check (hifive1) TODO
68+
# checkhifive1:
69+
70+
# Clippy (lm3s6965)
71+
clippylm3s6965:
72+
name: clippy (lm3s6965)
7073
runs-on: ubuntu-22.04
7174
strategy:
7275
matrix:
@@ -98,11 +101,14 @@ jobs:
98101
- name: Cache Dependencies
99102
uses: Swatinem/rust-cache@v2
100103

101-
- run: cargo xtask --deny-warnings --backend ${{ matrix.backend }} clippy
104+
- run: cargo xtask --deny-warnings --platform lm3s6965 --backend ${{ matrix.backend }} clippy
105+
106+
# Clippy (hifive1) TODO
107+
# clippyhifive1:
102108

103-
# Verify all examples, checks
104-
checkexamples:
105-
name: check examples
109+
# Platform lm3s6965: verify all examples, checks
110+
checkexampleslm3s6965:
111+
name: check examples (lm3s6965)
106112
runs-on: ubuntu-22.04
107113
strategy:
108114
matrix:
@@ -133,44 +139,46 @@ jobs:
133139

134140
- name: Check the examples
135141
if: ${{ matrix.backend == 'thumbv8-base' }}
136-
run: cargo xtask --backend ${{ matrix.backend }} --exampleexclude pool example-check
142+
run: cargo xtask --platform lm3s6965 --backend ${{ matrix.backend }} --exampleexclude pool example-check
137143

138144
- name: Check the examples
139145
if: ${{ matrix.backend != 'thumbv8-base' }}
140-
run: cargo xtask --backend ${{ matrix.backend }} example-check
141-
142-
# Check that the usage examples build
143-
usageexamples:
144-
name: Build usage examples
146+
run: cargo xtask --platform lm3s6965 --backend ${{ matrix.backend }} example-check
147+
148+
# Platform hifive1: verify all examples, checks
149+
checkexampleshifive1:
150+
name: check examples (hifive1)
145151
runs-on: ubuntu-22.04
146152
strategy:
147153
matrix:
154+
backend:
155+
- riscv32-imc-clint
156+
- riscv32-imac-clint
148157
toolchain:
149158
- stable
150159
steps:
151160
- name: Checkout
152161
uses: actions/checkout@v4
153162

154-
- name: Install rust ${{ matrix.toolchain }}
163+
- name: Install Rust ${{ matrix.toolchain }}
155164
run: |
156-
rustup set profile minimal
157165
rustup override set ${{ matrix.toolchain }}
158166
159-
- name: Configure rust target (v6, v7)
167+
- name: Configure Rust target
160168
run: |
161-
rustup target add thumbv7em-none-eabihf
162-
rustup target add thumbv7m-none-eabi
163-
rustup target add thumbv6m-none-eabi
164-
rustup component add rust-src
169+
rustup target add riscv32imac-unknown-none-elf
170+
rustup target add riscv32imc-unknown-none-elf
165171
166172
- name: Cache Dependencies
167173
uses: Swatinem/rust-cache@v2
168-
169-
- name: Install flip-link
170-
run: cargo install flip-link
174+
175+
- name: Check the examples
176+
if: ${{ matrix.backend == 'riscv32-imc-clint' }}
177+
run: cargo xtask --platform hifive1 --backend ${{ matrix.backend }} --exampleexclude static example-check
171178

172179
- name: Check the examples
173-
run: cargo xtask usage-example-build
180+
if: ${{ matrix.backend != 'riscv32-imc-clint' }}
181+
run: cargo xtask --platform hifive1 --backend ${{ matrix.backend }} example-check
174182

175183
buildqemu:
176184
name: Get modern QEMU, build and store
@@ -192,7 +200,7 @@ jobs:
192200
- name: Install QEMU to get dependencies
193201
run: |
194202
sudo apt update
195-
sudo apt install -y qemu-system-arm
203+
sudo apt install -y qemu-system-arm qemu-system-riscv32
196204
sudo apt-get install git libglib2.0-dev libfdt-dev libpixman-1-dev zlib1g-dev ninja-build
197205
198206
- if: ${{ steps.cache-qemu.outputs.cache-hit != 'true' }}
@@ -226,9 +234,9 @@ jobs:
226234
name: qemu
227235
path: qemu.tar
228236

229-
# Verify the example output with run-pass tests
230-
testexamples:
231-
name: QEMU run
237+
# Platform lm3s6965: verify the example output with run-pass tests
238+
testexampleslm3s6965:
239+
name: QEMU run (lm3s6965)
232240
needs: buildqemu
233241
runs-on: ubuntu-22.04
234242
strategy:
@@ -283,7 +291,71 @@ jobs:
283291
which qemu-system-riscv32
284292
285293
- name: Run-pass tests
286-
run: cargo xtask --deny-warnings --backend ${{ matrix.backend }} qemu
294+
run: cargo xtask --deny-warnings --platform lm3s6965 --backend ${{ matrix.backend }} qemu
295+
296+
# Platform hifive1: verify the example output with run-pass tests
297+
testexampleshifive1:
298+
name: QEMU run (hifive1)
299+
needs: buildqemu
300+
runs-on: ubuntu-22.04
301+
strategy:
302+
matrix:
303+
backend:
304+
- riscv32-imc-clint
305+
- riscv32-imac-clint
306+
toolchain:
307+
- stable
308+
steps:
309+
- name: Checkout
310+
uses: actions/checkout@v4
311+
312+
- name: Install Rust ${{ matrix.toolchain }}
313+
run: |
314+
rustup set profile minimal
315+
rustup override set ${{ matrix.toolchain }}
316+
317+
- name: Configure Rust target
318+
run: |
319+
rustup target add riscv32imac-unknown-none-elf
320+
rustup target add riscv32imc-unknown-none-elf
321+
322+
- name: Add Rust component llvm-tools-preview
323+
run: rustup component add llvm-tools-preview
324+
325+
# Use precompiled binutils
326+
- name: Install cargo-binutils
327+
uses: taiki-e/install-action@v2
328+
with:
329+
tool: cargo-binutils
330+
331+
- name: Cache Dependencies
332+
uses: Swatinem/rust-cache@v2
333+
334+
- name: Install QEMU to get dependencies
335+
run: |
336+
sudo apt update
337+
sudo apt install -y qemu-system-riscv32
338+
339+
- name: Download built QEMU
340+
uses: actions/download-artifact@v4
341+
with:
342+
name: qemu
343+
344+
- name: Extract QEMU into local path
345+
run: tar -xf qemu.tar -C /usr/local/bin
346+
347+
- name: Check which QEMU is used
348+
run: |
349+
which qemu-system-arm
350+
which qemu-system-riscv32
351+
352+
- name: Run-pass tests
353+
if: ${{ matrix.backend == 'riscv32-imc-clint' }}
354+
run: cargo xtask --deny-warnings --platform hifive1 --backend ${{ matrix.backend }} --exampleexclude static qemu
355+
356+
- name: Run-pass tests
357+
if: ${{ matrix.backend != 'riscv32-imc-clint' }}
358+
run: cargo xtask --deny-warnings --platform hifive1 --backend ${{ matrix.backend }} qemu
287359

288360
# Run test suite
289361
tests:
@@ -719,10 +791,14 @@ jobs:
719791
if: github.event_name == 'push' && success()
720792
needs:
721793
- formatcheck
722-
- check
723-
- clippy
724-
- checkexamples
725-
- testexamples
794+
- checklm3s6965
795+
# checkhifive1 TODO
796+
- clippylm3s6965
797+
# clippyhifive1 TODO
798+
- checkexampleslm3s6965
799+
- checkexampleshifive1
800+
- testexampleslm3s6965
801+
- testexampleshifive1
726802
- tests
727803
- docs
728804
- mdbook

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@
66
Cargo.lock
77
*.hex
88
book-target/
9+
10+
.DS_Store
11+
.vscode/
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[Idle]: Started
2+
[SoftMedium]: Started
3+
[SoftMedium]: Shared: 1
4+
[SoftHigh]: Started
5+
[SoftHigh]: Shared: 2
6+
[SoftHigh]: Finished
7+
[SoftMedium]: Finished
8+
[SoftLow1]: Started
9+
[SoftLow1]: Shared: 3
10+
[SoftLow1]: Yield
11+
[SoftLow2]: Started
12+
[SoftLow2]: Shared: 4
13+
[SoftLow2]: Yield
14+
[SoftLow1]: Finished
15+
[SoftLow2]: Finished
16+
[Idle]: Shared: 4
17+
[Idle]: Finished
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

ci/expected/lm3s6965/static.run

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
received message: 1
2+
received message: 2
3+
received message: 3
File renamed without changes.
File renamed without changes.
File renamed without changes.

ci/expected/lm3s6965/task.run

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
foo - start
2+
foo - middle
3+
baz
4+
foo - end
5+
bar
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
init
2+
hello from async
3+
hello from async2

examples/hifive1/.cargo/config.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[target.'cfg(all(target_arch = "riscv32", target_os = "none"))']
2+
runner = "qemu-system-riscv32 -machine sifive_e,revb=true -nographic -semihosting-config enable=on,target=native -kernel"
3+
# runner = "riscv64-unknown-elf-gdb -q -x gdb_init"
4+
rustflags = [
5+
"-C", "link-arg=-Thifive1-link.x",
6+
]
7+
8+
[build]
9+
# Pick ONE of these compilation targets
10+
# target = "riscv32imc-unknown-none-elf" # non-atomic support
11+
target = "riscv32imac-unknown-none-elf" # atomic support (partial)

0 commit comments

Comments
 (0)