Skip to content

Commit

Permalink
bump all to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
gdamjan committed May 18, 2024
1 parent 5e44b00 commit ab6d85f
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 90 deletions.
42 changes: 12 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,21 @@
name: ci

on: [push]
on:
push:
branches: [main]
pull_request:

jobs:
compile:
build:
runs-on: ubuntu-latest

strategy:
matrix:
include:
- rust: stable
# - rust: nightly

steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
components: llvm-tools-preview

- name: install cargo-binutils
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-binutils
toolchain: ${{ matrix.rust }}
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo install cargo-binutils

- name: program size
uses: actions-rs/cargo@v1
with:
command: size
args: --release
toolchain: ${{ matrix.rust }}
- run: cargo build
- run: cargo size

- name: lint
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Annotate commit with clippy warnings
uses: giraffate/clippy-action@v1
69 changes: 46 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ version = "0.1.0"
authors = ["Damjan Georgievski <[email protected]>"]

[dependencies]
cortex-m-rt = "0.6.15" # can't upgrade higher until g0xx-hal catches up
stm32g0xx-hal = { version = "0.1.2", features = ["stm32g031", "rt"] }
rtt-target = { version = "0.3.1", features = ["cortex-m"] }
stm32g0xx-hal = { version = "0.2", features = ["stm32g031", "rt"] }
cortex-m-rt = "0.7.4"
panic-halt = "0.2.0"
rtt-target = "0.5.0"

[profile.release]
debug = true # "true" is ok, symbols reside on the host, not the target
Expand Down
3 changes: 3 additions & 0 deletions Embed.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
[default.general]
chip = "STM32G031J6Mx"

[default.rtt]
enabled = true
18 changes: 4 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,14 @@ a quite small 8pin mcu, which has only 8KB ram and 32KB flash.

### Setup tooling:

- install cortex-m0 support for rust: `rustup target add thumbv6m-none-eabi`

- install [cargo-flash](https://probe.rs/docs/tools/cargo-flash/):
`cargo install cargo-flash`

- on Linux make sure udev rules allow non-root access, see
[probe setup](https://probe.rs/docs/getting-started/probe-setup/).

- `arm-none-eabi-binutils` and `arm-none-eabi-gdb` are recommended, but not
mandatory

- optional, for advanced debugging with RTT see [cargo embed](https://probe.rs/docs/tools/cargo-embed/)
and/or the [vscode extension](https://probe.rs/docs/tools/vscode/).
- [`rustup`](https://rustup.rs/) - is recommended to install rust and its components
- `cargo install cargo-binutils` - for `cargo size` and `cargo objdump -- --disassemble`, etc…
- `cargo install cargo-embed` - flash and debug using the [`probe-rs project`](https://probe.rs/)

### Compile and flash:

```
cargo flash --release --chip stm32g031j6mx
cargo embed --release
```

## Notes:
Expand Down
2 changes: 2 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
[toolchain]
channel = "stable"
targets = ["thumbv6m-none-eabi"]
components = [ "rust-src", "rustfmt", "llvm-tools" ]
31 changes: 11 additions & 20 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,29 @@
#![no_main]
#![no_std]

use core::panic::PanicInfo;
use rtt_target::{rprintln, rtt_init_print};

use panic_halt as _;
use stm32g0xx_hal as hal;

use hal::prelude::*;
use hal::rcc::Config;
use hal::stm32;

use rtt_target::{rprintln, rtt_init_print};

#[cortex_m_rt::entry]
fn main() -> ! {
rtt_init_print!();
rprintln!("Hello, world!");

let dp = stm32::Peripherals::take().expect("cannot take peripherals");
let mut rcc = dp.RCC.freeze(Config::lsi()); // configure clocks
let mut delay = dp.TIM16.delay(&mut rcc); // and now we can have a working delay
let mut rcc = dp.RCC.freeze(Config::lsi());
let mut delay = dp.TIM16.delay(&mut rcc);

let gpioa = dp.GPIOA.split(&mut rcc); // get gpio port A
let mut led = gpioa.pa12.into_push_pull_output(); // the led is on 12th pin
let gpioa = dp.GPIOA.split(&mut rcc);
let mut led = gpioa.pa5.into_push_pull_output();

rprintln!("Hello, world!");
loop {
// led.toggle().unwrap();
led.set_high().unwrap();
delay.delay(150.ms());
led.set_low().unwrap();
delay.delay(850.ms());
led.toggle().unwrap();
delay.delay(500.millis());
}
}

#[inline(never)]
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
rprintln!("{}", info);
loop {}
}

0 comments on commit ab6d85f

Please sign in to comment.