Skip to content

Minimal Async: Basic #13

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

Merged
merged 25 commits into from
Apr 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1182374
Added minimal async basic project
coder137 Apr 5, 2023
65f1593
Added l2 cooperative library for async utilities
coder137 Apr 6, 2023
1421601
Updated application example
coder137 Apr 6, 2023
533edf9
Added l2 unit test (add more)
coder137 Apr 6, 2023
84abe5e
Minor update to button lib
coder137 Apr 6, 2023
da3f6a8
Added simple executor module
coder137 Apr 6, 2023
ec7e4b4
Updated main example
coder137 Apr 6, 2023
2e96290
Updated unit tests
coder137 Apr 6, 2023
2c86f41
Added SysTick implementation to compute Duration
coder137 Apr 7, 2023
106aa8b
Added additional files to cooperative l2 in rust
coder137 Apr 7, 2023
bf8b393
Added async timer and sleep implementation
coder137 Apr 7, 2023
c9c9cb3
Updated application example
coder137 Apr 7, 2023
25b8e13
Updated makefile (added flash_release) to check performance
coder137 Apr 7, 2023
76f4cab
Updated application example with async blink led
coder137 Apr 7, 2023
2a2ca50
Removed safe poll function
coder137 Apr 7, 2023
7d78202
Updated conditional compiling for std tests
coder137 Apr 7, 2023
2ee7306
Added unit tests for AsyncTimer
coder137 Apr 8, 2023
11e6f5e
Added wait_until API.
coder137 Apr 8, 2023
c8b4c58
Updated wait implementation
coder137 Apr 8, 2023
b88bca7
Added unit test for wait_until
coder137 Apr 8, 2023
5c1b1cc
Updated async mutex implementation
coder137 Apr 9, 2023
b58ce0d
Added unit tests for async mutex
coder137 Apr 9, 2023
7ee1c00
Added README changes
coder137 Apr 9, 2023
a55b7ae
Added TODO statements for later implementations
coder137 Apr 9, 2023
93a3deb
Updated CI/CD
coder137 Apr 9, 2023
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
7 changes: 7 additions & 0 deletions .github/workflows/rust_all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,10 @@ jobs:
cargo make ci_debug
cargo make ci_release
cargo doc

- name: Minimal Async Basic
working-directory: ${{github.workspace}}/minimal_async_basic
run: |
cargo make ci_debug
cargo make ci_release
cargo doc
99 changes: 94 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Rust on microcontrollers

# Projects
# Base Projects

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

# Async Rust

- Minimal Async Basic
- Forked from `Minimal Interrupt`
- Configure Interrupts and main loop with rust cooperative async/await
- No executor/waker implementation. Just basic polling functionality

# Roadmap

## Libraries
## Supported Architecture

- [x] ARM Cortex M4

> TODO, Add more eventually

## Supported Chips

- [x] STM32L475xx
- [ ] LPC4078xx

## Supported Development platforms

- [Bitflags](https://crates.io/crates/bitflags): Rust macros to generate bitflags
- [Heapless](https://crates.io/crates/heapless): Stack allocated data structures
**See CI/CD**

- [x] Windows
- [x] Linux
- [x] Mac

## Async Rust

- [x] Basic Async Rust
- Polling support
- [ ] Efficient Async Rust
- Waker support
- Interrupt support

## RTOS

### C based

- [ ] FreeRTOS
- [ ] Zephyr RTOS

### Rust based

- [ ] RTIC

## Debugging

## Tooling
- [x] OpenOCD
- [ ] Semihosting

## Mocking

- [ ] Mockall

## Buildsystem

- [x] Cargo
- [x] Cargo Make
- [ ] Cargo features
- Conditional compiling for additional platforms

## Code coverage

- [ ] Grcov
- Rust based code coverage
- [ ] Lcov
- Stable code coverage tool
- [ ] Codecov
- Web based code coverage
- [ ] Coveralls
- Web based code coverage

## FFI compat with C

- [x] Bindgen
- Use C in Rust
- [ ] CBindgen
- Use Rust in C

## Crates.io Libraries

- [x] [Bitflags](https://crates.io/crates/bitflags)
- Rust macros to generate bitflags
- [x] [Heapless](https://crates.io/crates/heapless)
- Stack allocated data structures

## Rust integrated tooling

- [x] Unit testing
- [ ] Clippy
- Linting
- [x] Cargofmt
- Integrated in VSCode
- [ ] Documentation

## External tooling

- [x] Continuous Integration
- [x] Github Actions
43 changes: 43 additions & 0 deletions minimal_async_basic/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[target.thumbv7em-none-eabihf]
# uncomment this to make `cargo run` execute programs on QEMU
# runner = "qemu-system-arm -cpu cortex-m3 -machine lm3s6965evb -nographic -semihosting-config enable=on,target=native -kernel"

[target.'cfg(all(target_arch = "arm", target_os = "none"))']
# uncomment ONE of these three option to make `cargo run` start a GDB session
# which option to pick depends on your system
# runner = "arm-none-eabi-gdb -q -x openocd.gdb"
# runner = "gdb-multiarch -q -x openocd.gdb"
# runner = "gdb -q -x openocd.gdb"
rustflags = [
# This is needed if your flash or ram addresses are not aligned to 0x10000 in memory.x
# See https://github.com/rust-embedded/cortex-m-quickstart/pull/95
# "-C", "link-arg=--nmagic",

# LLD (shipped with the Rust toolchain) is used as the default linker
# "-C", "link-arg=-Tgcc_arm.ld",

# Generate a .map file
# "-C", "link-args=-Map=application.map",

# if you run into problems with LLD switch to the GNU linker by commenting out
# this line
"-C", "linker=arm-none-eabi-ld",

# if you need to link to pre-compiled C libraries provided by a C toolchain
# use GCC as the linker by commenting out both lines above and then
# uncommenting the three lines below
"-C", "linker=arm-none-eabi-gcc",
"-C", "link-arg=-Wl,-Tgcc_arm.ld",
"-C", "link-arg=-Wl,-Map,application.map",
"-C", "link-arg=-nostartfiles",
]

[build]
# Pick ONE of these compilation targets
# target = "thumbv6m-none-eabi" # Cortex-M0 and Cortex-M0+
# target = "thumbv7m-none-eabi" # Cortex-M3
# target = "thumbv7em-none-eabi" # Cortex-M4 and Cortex-M7 (no FPU)
target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU)
# target = "thumbv8m.base-none-eabi" # Cortex-M23
# target = "thumbv8m.main-none-eabi" # Cortex-M33 (no FPU)
# target = "thumbv8m.main-none-eabihf" # Cortex-M33 (with FPU)
6 changes: 6 additions & 0 deletions minimal_async_basic/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Files
*.map
.vscode/.cortex-debug.*

# Folders
target
36 changes: 36 additions & 0 deletions minimal_async_basic/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"configurations": [
{
"cwd": "${workspaceFolder}",
"executable": "target/thumbv7em-none-eabihf/debug/application",
"configFiles": [
"stm32l4discovery.cfg"
],
"postLaunchCommands": [
"load",
"monitor arm semihosting enable",
],
"name": "Rust Debug",
"request": "launch",
"type": "cortex-debug",
"servertype": "openocd",
"svdFile": "l0/svd/STM32L4x5.svd",
"svdPath": "l0/svd/STM32L4x5.svd"
},
{
"cwd": "${workspaceFolder}",
"executable": "target/thumbv7em-none-eabihf/release/application",
"configFiles": [
"stm32l4discovery.cfg"
],
"postLaunchCommands": [
"load",
"monitor arm semihosting enable",
],
"name": "Rust Release",
"request": "launch",
"type": "cortex-debug",
"servertype": "openocd"
}
]
}
12 changes: 12 additions & 0 deletions minimal_async_basic/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"rust-analyzer.cargo.target": "thumbv7em-none-eabihf",
"rust-analyzer.check.allTargets": false,
"rust-analyzer.imports.prefer.no.std": true,
"rust-analyzer.cargo.unsetTest": [
"core",
"l0",
"l3",
"l5",
"application",
],
}
7 changes: 7 additions & 0 deletions minimal_async_basic/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[workspace]
members = [
"l0",
"l3",
"l4",
"l5"
]
94 changes: 94 additions & 0 deletions minimal_async_basic/Makefile.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
[config]
default_to_workspace = false

# Duckscript is used here to convert \ to / for binary output path
[tasks.build_debug]
script_runner = "@duckscript"
script = '''
output = set ${CARGO_MAKE_CRATE_CUSTOM_TRIPLE_TARGET_DIRECTORY}/debug/application
echo OUTPUT: ${output}
output = replace ${output} \\ /
set_env OUTPUT ${output}
exec cargo build
'''

# Duckscript is used here to convert \ to / for binary output path
[tasks.build_release]
script_runner = "@duckscript"
script = '''
output = set ${CARGO_MAKE_CRATE_CUSTOM_TRIPLE_TARGET_DIRECTORY}/release/application
output = replace ${output} \\ /
set_env OUTPUT ${output}
exec cargo build --release
'''

[tasks.test]
command = "cargo"
args = ["test", "--target", "${CARGO_MAKE_RUST_TARGET_TRIPLE}"]

[tasks.flash_debug]
script_runner = "@shell"
script = '''
openocd -f board/stm32l4discovery.cfg -c "program ${OUTPUT} verify reset exit"
'''
dependencies = ["build_debug"]

[tasks.flash_release]
script_runner = "@shell"
script = '''
openocd -f board/stm32l4discovery.cfg -c "program ${OUTPUT} verify reset exit"
'''
dependencies = ["build_release"]

[tasks.ci_debug]
dependencies = [
"build_debug",
"test",
"objcopy_to_binary",
"objcopy_to_hex",
"objdump",
"size",
]

[tasks.ci_release]
dependencies = [
"build_release",
"test",
"objcopy_to_binary",
"objcopy_to_hex",
"objdump",
"size",
]

# Private Tasks

# Requires
# arm-none-eabi-size executable (ARM GCC toolchain)
# OUTPUT env variable (Set by build_*)
[tasks.size]
private = true
command = "arm-none-eabi-size"
args = ["${OUTPUT}"]

# arm-none-eabi-objcopy executable (ARM GCC toolchain)
# OUTPUT env variable (Set by build_*)
[tasks.objcopy_to_binary]
private = true
command = "arm-none-eabi-objcopy"
args = ["-O", "binary", "${OUTPUT}", "${OUTPUT}.bin"]

# arm-none-eabi-objcopy executable (ARM GCC toolchain)
# OUTPUT env variable (Set by build_*)
[tasks.objcopy_to_hex]
private = true
command = "arm-none-eabi-objcopy"
args = ["-O", "ihex", "${OUTPUT}", "${OUTPUT}.hex"]

# arm-none-eabi-objdump executable (ARM GCC toolchain)
# OUTPUT env variable (Set by build_*)
[tasks.objdump]
private = true
script_runner = "@shell"
script = '''
arm-none-eabi-objdump --source --all-headers --demangle --line-numbers --wide ${OUTPUT} > ${OUTPUT}.lst
'''
Loading