Skip to content

Commit e19a9e8

Browse files
authored
Minimal Async: Basic (#13)
1 parent ce9bdaf commit e19a9e8

Some content is hidden

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

59 files changed

+83864
-5
lines changed

.github/workflows/rust_all.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,10 @@ jobs:
7575
cargo make ci_debug
7676
cargo make ci_release
7777
cargo doc
78+
79+
- name: Minimal Async Basic
80+
working-directory: ${{github.workspace}}/minimal_async_basic
81+
run: |
82+
cargo make ci_debug
83+
cargo make ci_release
84+
cargo doc

README.md

Lines changed: 94 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Rust on microcontrollers
44

5-
# Projects
5+
# Base Projects
66

77
- Minimal blinky
88
- Barebones blinky example i.e linker script to main
@@ -25,15 +25,104 @@ Rust on microcontrollers
2525
- Added **heapless** library to `l2`
2626
- Added USART buffered traits to `l3`
2727

28+
# Async Rust
29+
30+
- Minimal Async Basic
31+
- Forked from `Minimal Interrupt`
32+
- Configure Interrupts and main loop with rust cooperative async/await
33+
- No executor/waker implementation. Just basic polling functionality
34+
2835
# Roadmap
2936

30-
## Libraries
37+
## Supported Architecture
38+
39+
- [x] ARM Cortex M4
40+
41+
> TODO, Add more eventually
42+
43+
## Supported Chips
44+
45+
- [x] STM32L475xx
46+
- [ ] LPC4078xx
47+
48+
## Supported Development platforms
3149

32-
- [Bitflags](https://crates.io/crates/bitflags): Rust macros to generate bitflags
33-
- [Heapless](https://crates.io/crates/heapless): Stack allocated data structures
50+
**See CI/CD**
51+
52+
- [x] Windows
53+
- [x] Linux
54+
- [x] Mac
55+
56+
## Async Rust
57+
58+
- [x] Basic Async Rust
59+
- Polling support
60+
- [ ] Efficient Async Rust
61+
- Waker support
62+
- Interrupt support
3463

3564
## RTOS
3665

66+
### C based
67+
68+
- [ ] FreeRTOS
69+
- [ ] Zephyr RTOS
70+
71+
### Rust based
72+
73+
- [ ] RTIC
74+
3775
## Debugging
3876

39-
## Tooling
77+
- [x] OpenOCD
78+
- [ ] Semihosting
79+
80+
## Mocking
81+
82+
- [ ] Mockall
83+
84+
## Buildsystem
85+
86+
- [x] Cargo
87+
- [x] Cargo Make
88+
- [ ] Cargo features
89+
- Conditional compiling for additional platforms
90+
91+
## Code coverage
92+
93+
- [ ] Grcov
94+
- Rust based code coverage
95+
- [ ] Lcov
96+
- Stable code coverage tool
97+
- [ ] Codecov
98+
- Web based code coverage
99+
- [ ] Coveralls
100+
- Web based code coverage
101+
102+
## FFI compat with C
103+
104+
- [x] Bindgen
105+
- Use C in Rust
106+
- [ ] CBindgen
107+
- Use Rust in C
108+
109+
## Crates.io Libraries
110+
111+
- [x] [Bitflags](https://crates.io/crates/bitflags)
112+
- Rust macros to generate bitflags
113+
- [x] [Heapless](https://crates.io/crates/heapless)
114+
- Stack allocated data structures
115+
116+
## Rust integrated tooling
117+
118+
- [x] Unit testing
119+
- [ ] Clippy
120+
- Linting
121+
- [x] Cargofmt
122+
- Integrated in VSCode
123+
- [ ] Documentation
124+
125+
## External tooling
126+
127+
- [x] Continuous Integration
128+
- [x] Github Actions
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
[target.thumbv7em-none-eabihf]
2+
# uncomment this to make `cargo run` execute programs on QEMU
3+
# runner = "qemu-system-arm -cpu cortex-m3 -machine lm3s6965evb -nographic -semihosting-config enable=on,target=native -kernel"
4+
5+
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
6+
# uncomment ONE of these three option to make `cargo run` start a GDB session
7+
# which option to pick depends on your system
8+
# runner = "arm-none-eabi-gdb -q -x openocd.gdb"
9+
# runner = "gdb-multiarch -q -x openocd.gdb"
10+
# runner = "gdb -q -x openocd.gdb"
11+
rustflags = [
12+
# This is needed if your flash or ram addresses are not aligned to 0x10000 in memory.x
13+
# See https://github.com/rust-embedded/cortex-m-quickstart/pull/95
14+
# "-C", "link-arg=--nmagic",
15+
16+
# LLD (shipped with the Rust toolchain) is used as the default linker
17+
# "-C", "link-arg=-Tgcc_arm.ld",
18+
19+
# Generate a .map file
20+
# "-C", "link-args=-Map=application.map",
21+
22+
# if you run into problems with LLD switch to the GNU linker by commenting out
23+
# this line
24+
"-C", "linker=arm-none-eabi-ld",
25+
26+
# if you need to link to pre-compiled C libraries provided by a C toolchain
27+
# use GCC as the linker by commenting out both lines above and then
28+
# uncommenting the three lines below
29+
"-C", "linker=arm-none-eabi-gcc",
30+
"-C", "link-arg=-Wl,-Tgcc_arm.ld",
31+
"-C", "link-arg=-Wl,-Map,application.map",
32+
"-C", "link-arg=-nostartfiles",
33+
]
34+
35+
[build]
36+
# Pick ONE of these compilation targets
37+
# target = "thumbv6m-none-eabi" # Cortex-M0 and Cortex-M0+
38+
# target = "thumbv7m-none-eabi" # Cortex-M3
39+
# target = "thumbv7em-none-eabi" # Cortex-M4 and Cortex-M7 (no FPU)
40+
target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU)
41+
# target = "thumbv8m.base-none-eabi" # Cortex-M23
42+
# target = "thumbv8m.main-none-eabi" # Cortex-M33 (no FPU)
43+
# target = "thumbv8m.main-none-eabihf" # Cortex-M33 (with FPU)

minimal_async_basic/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Files
2+
*.map
3+
.vscode/.cortex-debug.*
4+
5+
# Folders
6+
target
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"configurations": [
3+
{
4+
"cwd": "${workspaceFolder}",
5+
"executable": "target/thumbv7em-none-eabihf/debug/application",
6+
"configFiles": [
7+
"stm32l4discovery.cfg"
8+
],
9+
"postLaunchCommands": [
10+
"load",
11+
"monitor arm semihosting enable",
12+
],
13+
"name": "Rust Debug",
14+
"request": "launch",
15+
"type": "cortex-debug",
16+
"servertype": "openocd",
17+
"svdFile": "l0/svd/STM32L4x5.svd",
18+
"svdPath": "l0/svd/STM32L4x5.svd"
19+
},
20+
{
21+
"cwd": "${workspaceFolder}",
22+
"executable": "target/thumbv7em-none-eabihf/release/application",
23+
"configFiles": [
24+
"stm32l4discovery.cfg"
25+
],
26+
"postLaunchCommands": [
27+
"load",
28+
"monitor arm semihosting enable",
29+
],
30+
"name": "Rust Release",
31+
"request": "launch",
32+
"type": "cortex-debug",
33+
"servertype": "openocd"
34+
}
35+
]
36+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"rust-analyzer.cargo.target": "thumbv7em-none-eabihf",
3+
"rust-analyzer.check.allTargets": false,
4+
"rust-analyzer.imports.prefer.no.std": true,
5+
"rust-analyzer.cargo.unsetTest": [
6+
"core",
7+
"l0",
8+
"l3",
9+
"l5",
10+
"application",
11+
],
12+
}

minimal_async_basic/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[workspace]
2+
members = [
3+
"l0",
4+
"l3",
5+
"l4",
6+
"l5"
7+
]

minimal_async_basic/Makefile.toml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
[config]
2+
default_to_workspace = false
3+
4+
# Duckscript is used here to convert \ to / for binary output path
5+
[tasks.build_debug]
6+
script_runner = "@duckscript"
7+
script = '''
8+
output = set ${CARGO_MAKE_CRATE_CUSTOM_TRIPLE_TARGET_DIRECTORY}/debug/application
9+
echo OUTPUT: ${output}
10+
output = replace ${output} \\ /
11+
set_env OUTPUT ${output}
12+
exec cargo build
13+
'''
14+
15+
# Duckscript is used here to convert \ to / for binary output path
16+
[tasks.build_release]
17+
script_runner = "@duckscript"
18+
script = '''
19+
output = set ${CARGO_MAKE_CRATE_CUSTOM_TRIPLE_TARGET_DIRECTORY}/release/application
20+
output = replace ${output} \\ /
21+
set_env OUTPUT ${output}
22+
exec cargo build --release
23+
'''
24+
25+
[tasks.test]
26+
command = "cargo"
27+
args = ["test", "--target", "${CARGO_MAKE_RUST_TARGET_TRIPLE}"]
28+
29+
[tasks.flash_debug]
30+
script_runner = "@shell"
31+
script = '''
32+
openocd -f board/stm32l4discovery.cfg -c "program ${OUTPUT} verify reset exit"
33+
'''
34+
dependencies = ["build_debug"]
35+
36+
[tasks.flash_release]
37+
script_runner = "@shell"
38+
script = '''
39+
openocd -f board/stm32l4discovery.cfg -c "program ${OUTPUT} verify reset exit"
40+
'''
41+
dependencies = ["build_release"]
42+
43+
[tasks.ci_debug]
44+
dependencies = [
45+
"build_debug",
46+
"test",
47+
"objcopy_to_binary",
48+
"objcopy_to_hex",
49+
"objdump",
50+
"size",
51+
]
52+
53+
[tasks.ci_release]
54+
dependencies = [
55+
"build_release",
56+
"test",
57+
"objcopy_to_binary",
58+
"objcopy_to_hex",
59+
"objdump",
60+
"size",
61+
]
62+
63+
# Private Tasks
64+
65+
# Requires
66+
# arm-none-eabi-size executable (ARM GCC toolchain)
67+
# OUTPUT env variable (Set by build_*)
68+
[tasks.size]
69+
private = true
70+
command = "arm-none-eabi-size"
71+
args = ["${OUTPUT}"]
72+
73+
# arm-none-eabi-objcopy executable (ARM GCC toolchain)
74+
# OUTPUT env variable (Set by build_*)
75+
[tasks.objcopy_to_binary]
76+
private = true
77+
command = "arm-none-eabi-objcopy"
78+
args = ["-O", "binary", "${OUTPUT}", "${OUTPUT}.bin"]
79+
80+
# arm-none-eabi-objcopy executable (ARM GCC toolchain)
81+
# OUTPUT env variable (Set by build_*)
82+
[tasks.objcopy_to_hex]
83+
private = true
84+
command = "arm-none-eabi-objcopy"
85+
args = ["-O", "ihex", "${OUTPUT}", "${OUTPUT}.hex"]
86+
87+
# arm-none-eabi-objdump executable (ARM GCC toolchain)
88+
# OUTPUT env variable (Set by build_*)
89+
[tasks.objdump]
90+
private = true
91+
script_runner = "@shell"
92+
script = '''
93+
arm-none-eabi-objdump --source --all-headers --demangle --line-numbers --wide ${OUTPUT} > ${OUTPUT}.lst
94+
'''

0 commit comments

Comments
 (0)