Skip to content

Commit

Permalink
Merge pull request #51 from absw/staging
Browse files Browse the repository at this point in the history
Sprint 4 release
  • Loading branch information
PabloMansanet authored Feb 2, 2021
2 parents 01fed2a + 613bf30 commit 80e43a9
Show file tree
Hide file tree
Showing 65 changed files with 839 additions and 5,177 deletions.
6 changes: 4 additions & 2 deletions .cargo/config
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ rustflags = [
]

[alias]
b = "build --release --bin loadstone --target thumbv7em-none-eabihf"
rb = "run --release --bin loadstone --target thumbv7em-none-eabihf"
b = "build --release --target thumbv7em-none-eabihf --bin"
rb = "run --release --target thumbv7em-none-eabihf --bin"
sz = "size --release --bin loadstone --target thumbv7em-none-eabihf"
gen_blinky = "objcopy --bin blinky --release --target thumbv7em-none-eabihf --features stm32f412 -- -O binary blinky.bin"
gen_demo_app = "objcopy --bin demo_app --release --target thumbv7em-none-eabihf --features stm32f412 -- -O binary demo_app.bin"
gen_loadstone = "objcopy --bin loadstone --release --target thumbv7em-none-eabihf --features stm32f412 -- -O binary loadstone.bin"
st = "strip --bin loadstone --release --target thumbv7em-none-eabihf"
d = "doc --release --target thumbv7em-none-eabihf"
dop = "doc --release --target thumbv7em-none-eabihf --open"
bl = "bloat --release --bin loadstone --target thumbv7em-none-eabihf"
37 changes: 37 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: actions
on: [push]
jobs:
build-loadstone:
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Authentication
uses: webfactory/[email protected]
with:
ssh-private-key: |
${{ secrets.PATHFINDERDELL_PRIVATE_KEY }}
- name: Cargo initialisation
run: |
~/.cargo/bin/rustup default nightly
~/.cargo/bin/rustup update
~/.cargo/bin/rustup component add llvm-tools-preview
~/.cargo/bin/rustup target add thumbv7em-none-eabihf
~/.cargo/bin/cargo install cargo-binutils
- name: Documentation
run: ~/.cargo/bin/cargo d

- name: Tests
run: ~/.cargo/bin/cargo test --release

- name: Building
run: ~/.cargo/bin/cargo gen_loadstone

- name: Upload loadstone
uses: actions/upload-artifact@v2
with:
name: loadstone
path: loadstone.bin
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.gdb_history
Cargo.lock
target/
blue_hal/
*.bin

# editor files
Expand Down
4 changes: 0 additions & 4 deletions .vim/coc-settings.json

This file was deleted.

36 changes: 16 additions & 20 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,36 @@ default = [
"stm32f412_discovery",
"defmt-default",
]
stm32f412_discovery = ["blue_hal/stm32f412_discovery", "stm32f412"]
stm32f429 = ["stm32f4_any"]
stm32f469 = ["stm32f4_any"]
stm32f407 = ["stm32f4_any"]
stm32f412 = ["stm32f4_any"]
stm32f4_any = ["stm32_any"]
stm32_any = ["cortex_m_any"]
cortex_m_any = []
defmt-default = []
defmt-trace = []
defmt-debug = []
defmt-info = []
defmt-warn = []
defmt-error = []
stm32f412_discovery = ["stm32f412"]
stm32f429 = ["stm32f4/stm32f429", "stm32f4_any"]
stm32f469 = ["stm32f4/stm32f469", "stm32f4_any"]
stm32f407 = ["stm32f4/stm32f407", "stm32f4_any"]
stm32f412 = ["stm32f4/stm32f412", "stm32f4_any"]
stm32f4_any = ["stm32_any"]
stm32_any = ["cortex_m_any"]
cortex_m_any = []

[dependencies]
cortex-m = "0.6.0"
cortex-m-rt = "0.6.10"
cortex-m-semihosting = "0.3.3"
bluefruit_rust_hal = { path = "bluefruit_rust_hal" }
panic-abort = "*"
nb = "*"
paste = "*"
panic-abort = "*"
static_assertions = "*"
defmt = { git = "https://github.com/knurling-rs/defmt.git", branch = "main" }
defmt-rtt = { git = "https://github.com/knurling-rs/defmt.git", branch = "main" }
defmt = "0.1"
defmt-rtt = "0.1"

[dependencies.nom]
version = "*"
default-features = false
[dependencies.blue_hal]
# Uncomment the next line and comment the next two lines to develop blue_hal locally in parallel
#path = "blue_hal"
git = "ssh://[email protected]/absw/blue_hal.git"
branch = "main"

[dependencies.ufmt]
version = "*"
Expand All @@ -53,10 +53,6 @@ default-features = false
version = "*"
default-features = false

[dependencies.stm32f4]
version = "*"
features = ["rt"]

[lib]
name = "loadstone_lib"
test = true
Expand Down
9 changes: 0 additions & 9 deletions bluefruit_rust_hal/Cargo.toml

This file was deleted.

3 changes: 0 additions & 3 deletions bluefruit_rust_hal/src/main.rs

This file was deleted.

34 changes: 0 additions & 34 deletions src/bin/blinky.rs

This file was deleted.

17 changes: 17 additions & 0 deletions src/bin/demo_app.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#![cfg_attr(test, allow(unused_attributes))]
#![cfg_attr(all(not(test), target_arch = "arm"), no_std)]
#![cfg_attr(target_arch = "arm", no_main)]

#[allow(unused_imports)]
use cortex_m_rt::{entry, exception};

#[cfg(target_arch = "arm")]
#[entry]
fn main() -> ! {
use loadstone_lib::devices::boot_manager;
let app = boot_manager::BootManager::new();
app.run();
}

#[cfg(not(target_arch = "arm"))]
fn main() {}
File renamed without changes.
66 changes: 66 additions & 0 deletions src/devices/boot_manager.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//! Fully CLI interactive boot manager for the demo application.
use super::{
cli::{file_transfer, Cli},
image,
};
use crate::error::Error;
use blue_hal::{
hal::{flash, serial},
stm32pac::SCB,
utilities::xmodem,
};

pub struct BootManager<EXTF, SRL>
where
EXTF: flash::ReadWrite,
Error: From<EXTF::Error>,
SRL: serial::ReadWrite + file_transfer::FileTransfer,
Error: From<<SRL as serial::Read>::Error>,
{
pub(crate) external_banks: &'static [image::Bank<<EXTF as flash::ReadWrite>::Address>],
pub(crate) external_flash: EXTF,
pub(crate) cli: Option<Cli<SRL>>,
}

impl<EXTF, SRL> BootManager<EXTF, SRL>
where
EXTF: flash::ReadWrite,
Error: From<EXTF::Error>,
SRL: serial::ReadWrite + file_transfer::FileTransfer,
Error: From<<SRL as serial::Read>::Error>,
{
/// Returns an iterator of all external flash banks.
pub fn external_banks(&self) -> impl Iterator<Item = image::Bank<EXTF::Address>> {
self.external_banks.iter().cloned()
}

/// Writes a firmware image to an external flash bank.
pub fn store_image<I>(
&mut self,
blocks: I,
bank: image::Bank<EXTF::Address>,
) -> Result<(), Error>
where
I: Iterator<Item = [u8; xmodem::PAYLOAD_SIZE]>,
{
for (i, block) in blocks.enumerate() {
nb::block!(self.external_flash.write(bank.location + block.len() * i, &block))?;
}
Ok(())
}

pub fn format_external(&mut self) -> Result<(), Error> {
nb::block!(self.external_flash.erase())?;
Ok(())
}

pub fn reset(&mut self) -> ! { SCB::sys_reset(); }

pub fn run(mut self) -> ! {
let mut cli = self.cli.take().unwrap();
loop {
cli.run(&mut self)
}
}
}
Loading

0 comments on commit 80e43a9

Please sign in to comment.