Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 12 additions & 7 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
runner = 'probe-rs run --chip STM32F405RGTx'
[target.thumbv8m.main-none-eabihf]
runner = 'probe-rs run --chip STM32H563ZITx'

[build]
target = "thumbv7em-none-eabi"
[target.thumbv7em-none-eabi]
runner = 'probe-rs run --chip STM32F405RGTx'

[env]
DEFMT_LOG = "info"
DEFMT_LOG = "warn"
PROBE_RS_EMBED_FILE = { value = "Embed.toml", relative = true }

# these are all so the workspace can work cohesively, and should not affect code stability

[resolver]
feature-unification = "package"

[unstable]
build-std-features = ["panic_immediate_abort"]
build-std = ["core"]
feature-unification = true # for having a variety of features, ex stm32-metapac we cannot enable two different stm32's
8 changes: 3 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"rust-analyzer.checkOnSave.allTargets": false,
"rust-analyzer.diagnostics.disabled": [
"trait-impl-incorrect-safety"
]
}
"rust-analyzer.cargo.target": "thumbv8m.main-none-eabihf",
"rust-analyzer.checkOnSave.allTargets": false,
}
12 changes: 12 additions & 0 deletions .zed/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"lsp": {
"rust-analyzer": {
"initialization_options": {
"cargo": {
"target": "thumbv8m.main-none-eabihf",
"allTargets": false
}
}
}
}
}
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[workspace]
members = ["msb-fw-rs","crates/*"]
members = ["projects/*","crates/drivers/*"]
resolver = "3"

[workspace.dependencies]
embassy-stm32 = { version = "0.6.0", features = ["defmt", "stm32f405rg", "unstable-pac", "memory-x", "time", "time-driver-any", "exti"] }
embassy-stm32 = { version = "0.6.0", features = ["defmt", "unstable-pac", "memory-x", "time", "time-driver-any", "exti"] }
embassy-sync = { version = "0.8.0", features = ["defmt"] }
embassy-executor = { version = "0.10.0", features = ["executor-thread", "executor-interrupt", "defmt", "embassy-time-driver", "platform-cortex-m"] }
embassy-time = { version = "0.5.1", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
Expand Down
56 changes: 25 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,48 @@
# MSB-FW.rs
Mechanical Sensor Board Firmware in Rust (experimental, not for usage on car)
# firmware-rs
NER Firmware in Rust (experimental, not for usage on car)


### Commands
## Setup

First, [get rustup](https://www.rust-lang.org/learn/get-started).
1. [get rustup](https://www.rust-lang.org/learn/get-started).
2. clone and open this root folder.
3. [get probe-rs](https://probe.rs/docs/getting-started/installation/).

Second, clone and open this root folder.

To build `msb-fw-rs`, just run `cargo build --release`. Note the first time you do this it will take a while, as `rustup` has to install the correct version of rust for this project.

To deploy onto an embedded chip locally connected, run `cargo run --release`.

To build a different project other than `msb-fw-rs` (of which none exist), cd into that directory and run build.

To format, run `cargo format`.

To lint and check stuff, run `cargo clippy`.

### On car stuff

To run a RTT terminal dedicated:
`cargo embed --release rtt`

To run a GDB terminal dedicated:
`cargo embed --release gdb`

To flash and leave code:
`cargo embed --release`
## Commands

- To enter a project: `cd ./projects/project-name`
- To build: `cargo build`
- To deploy onto an embedded chip locally connected, run `cargo run --release`.
- To format, run `cargo format`.
- To lint and check stuff, run `cargo clippy`.
- To run a RTT terminal dedicated: `cargo embed --release rtt`
- To run a GDB terminal dedicated: `cargo embed --release gdb`
- To flash and leave code: `cargo embed --release`

**At this time, many commands only work consistently inside the project (via `cd`)**
The workspace's only purpose is to organize dependencies and build artificats, especially for rust-analyzer.

### Coding tips and tricks

- Use defmt macros to print stuff
-

### IDE Stuff

There are currently custom rust-analyzer settings for VSCode and zed. Feel free to adapt them to your own liking.


### Repository structure
## Repository structure

This is a mega-repo configured as a normal embassy-styled project with multiple dependency crates and sub-projects.
This is a mono-repo configured as a normal embassy-styled project with multiple dependency crates and sub-projects.

Various files:

Top level `Cargo.toml`, `Embed.toml`, and `rust-toolchain.toml` define the various parts of the embassy project. See comments inside for how these were structure, but most follow embassy specification.
Top level `Cargo.toml` and `rust-toolchain.toml` define the various parts of the embassy project. See comments inside for how these were structure, but most follow embassy specification.

The `crates` folder defines drivers or other code shared between projects.

Top level folders like `msb-fw-rs`, and any other project, define projects which inherit explicity defined `Cargo.toml` dependencies and `Embed.toml` settings, and more. They can also depend on a crate in the `crates` folder.
The `projects` folder defines individual board-specific compilation units which inherit explicity defined `Cargo.toml` dependencies and `Embed.toml` settings, and more. They can also depend on a crate in the `crates` folder. Notably, they all may have individual `.config/cargo.toml` if they override anything.

This structure has multiple benefits, including:
- Static versioning of all embassy and other dependencies, eliminating version conflicts for in-tree code
Expand All @@ -57,7 +51,7 @@ This structure has multiple benefits, including:
- Other quirks, such as vscode `settings.json` and `config.toml`, are shared between projects


### Versioning
### Upgrades of Embassy/Dep versions

Updating versions is as follows

Expand Down
234 changes: 0 additions & 234 deletions cerberus/src/main.rs

This file was deleted.

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.
5 changes: 5 additions & 0 deletions projects/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This is the location of all of the board-specific and high level operating code.

Each folder is a project corresponding to ONE binary.

Feel free to depend on code inside of crates/drivers folder.
2 changes: 2 additions & 0 deletions projects/cerberus/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build]
target = "thumbv7em-none-eabi"
Loading