Skip to content

Commit b166aab

Browse files
committed
Initial commit
0 parents  commit b166aab

File tree

11 files changed

+481
-0
lines changed

11 files changed

+481
-0
lines changed

.cargo/config

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[build]
2+
# target = "thumbv6m-none-eabi" # Cortex-M0 and Cortex-M0+
3+
# target = "thumbv7m-none-eabi" # Cortex-M3
4+
# target = "thumbv7em-none-eabi" # Cortex-M4 and Cortex-M7 (no FPU)
5+
target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU)
6+
7+
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
8+
runner = "arm-none-eabi-gdb -q -x openocd.gdb"
9+
10+
rustflags = [
11+
# LLD (shipped with the Rust toolchain) is used as the default linker
12+
"-C", "link-arg=-Tlink.x",
13+
14+
# if you run into problems with LLD switch to the GNU linker by commenting out
15+
# this line
16+
# "-C", "linker=arm-none-eabi-ld",
17+
18+
# if you need to link to pre-compiled C libraries provided by a C toolchain
19+
# use GCC as the linker by commenting out both lines above and then
20+
# uncommenting the three lines below
21+
# "-C", "linker=arm-none-eabi-gcc",
22+
# "-C", "link-arg=-Wl,-Tlink.x",
23+
# "-C", "link-arg=-nostartfiles",
24+
]

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
target/

Cargo.lock

Lines changed: 211 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[package]
2+
name = "flowdsp-blog"
3+
version = "0.1.0"
4+
authors = ["Antoine van Gelder <[email protected]>"]
5+
edition = "2018"
6+
7+
[dependencies]
8+
cortex-m = "0.5.8"
9+
cortex-m-rt = "0.6.7"
10+
cortex-m-semihosting = "0.3.2"
11+
panic-semihosting = "0.5.1"
12+
13+
[dependencies.lazy_static]
14+
features = ["spin_no_std"]
15+
version = "1.3.0"
16+
17+
[dependencies.stm32f30x]
18+
features = ["rt"]
19+
version = "0.8.0" # latest is 0.8.0!
20+
21+
[[bin]]
22+
name = "stm32f3-01-interrupts"
23+
path = "src/stm32f3-01-interrupts.rs"

Makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
deps:
2+
sudo port install arm-none-eabi-binutils arm-none-eabi-gcc arm-none-eabi-gdb
3+
sudo port install openocd +stlink
4+
rustup target add thumbv7em-none-eabihf
5+
cargo install itm --vers 0.3.1
6+
7+
deps-clean:
8+
sudo port uninstall arm-none-eabi-binutils arm-none-eabi-gcc arm-none-eabi-gdb isl libmpc mpfr
9+
sudo port uninstall openocd libusb
10+
11+
clean:
12+
find . -name "*.DS_Store" -exec rm '{}' ';'
13+
find . -name "*~" -exec rm '{}' ';'
14+
15+
distclean:
16+
cargo clean
17+
18+
openocd:
19+
openocd -f interface/stlink-v2-1.cfg -f target/stm32f3x.cfg

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Source code for https://blog.flowdsp.io/ articles
2+
3+
git clone https://github.com/antoinevg/stm32fx-examples.git
4+
cd stm32fx-examples
5+
make deps
6+
7+
# run in one terminal
8+
openocd -f openocd.cfg
9+
10+
# run in another terminal
11+
cargo run

build.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use std::env;
2+
use std::fs::File;
3+
use std::io::Write;
4+
use std::path::PathBuf;
5+
6+
fn main() {
7+
// Put the linker script somewhere the linker can find it
8+
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
9+
File::create(out.join("memory.x"))
10+
.unwrap()
11+
.write_all(include_bytes!("memory.x"))
12+
.unwrap();
13+
println!("cargo:rustc-link-search={}", out.display());
14+
15+
// Only re-run the build script when memory.x is changed,
16+
// instead of when any part of the source code changes.
17+
println!("cargo:rerun-if-changed=memory.x");
18+
}

memory.x

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/* Linker script for the STM32F303VCT6 */
2+
MEMORY
3+
{
4+
FLASH : ORIGIN = 0x08000000, LENGTH = 256K
5+
RAM : ORIGIN = 0x20000000, LENGTH = 40K
6+
}

openocd.cfg

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Sample OpenOCD configuration for the STM32F3DISCOVERY development board
2+
3+
# Depending on the hardware revision you got you'll have to pick ONE of these
4+
# interfaces. At any time only one interface should be commented out.
5+
6+
# Revision C (newer revision)
7+
source [find interface/stlink-v2-1.cfg]
8+
9+
# Revision A and B (older revisions)
10+
# source [find interface/stlink-v2.cfg]
11+
12+
source [find target/stm32f3x.cfg]

openocd.gdb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
target extended-remote :3333
2+
3+
# print demangled symbols
4+
set print asm-demangle on
5+
6+
# set backtrace limit to not have infinite backtrace loops
7+
set backtrace limit 32
8+
9+
# detect unhandled exceptions, hard faults and panics
10+
break DefaultHandler
11+
break HardFault
12+
break rust_begin_unwind
13+
14+
# *try* to stop at the user entry point (it might be gone due to inlining)
15+
# break main
16+
17+
monitor arm semihosting enable
18+
19+
# # send captured ITM to the file itm.fifo
20+
# # (the microcontroller SWO pin must be connected to the programmer SWO pin)
21+
# # 8000000 must match the core clock frequency
22+
monitor tpiu config internal /tmp/itm.txt uart off 8000000
23+
24+
# # OR: make the microcontroller SWO pin output compatible with UART (8N1)
25+
# # 8000000 must match the core clock frequency
26+
# # 2000000 is the frequency of the SWO pin
27+
#monitor tpiu config external uart off 8000000 2000000
28+
29+
# # enable ITM port 0
30+
monitor itm port 0 on
31+
32+
load
33+
34+
# start the process but immediately halt the processor
35+
# stepi
36+
37+
# start the process
38+
continue

0 commit comments

Comments
 (0)