diff --git a/.cargo/config b/.cargo/config new file mode 100644 index 0000000..b10f29d --- /dev/null +++ b/.cargo/config @@ -0,0 +1,2 @@ +[build] +target = "thumbv6m-none-eabi" diff --git a/.gitignore b/.gitignore index ea8c4bf..2c96eb1 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -/target +target/ +Cargo.lock diff --git a/Cargo.toml b/Cargo.toml index 6349e44..26c73fa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,3 +6,5 @@ edition = "2018" readme = "README.md" [dependencies] +cortex-m-rt = "0.6.13" +panic-halt = "0.2.0" diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..3fb1eed --- /dev/null +++ b/build.rs @@ -0,0 +1,15 @@ +use std::env; +use std::fs; +use std::io::Write; +use std::path::PathBuf; + +fn main() { + let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); + fs::File::create(out_dir.join("memory.x")) + .unwrap() + .write_all(include_bytes!("memory.x")) + .unwrap(); + + println!("cargo:rustc-link-search={}", out_dir.display()); + println!("cargo:rerun-if-changed=memory.x"); +} diff --git a/memory.x b/memory.x new file mode 100644 index 0000000..07c05e5 --- /dev/null +++ b/memory.x @@ -0,0 +1,6 @@ +/* STM32F072CxT6 */ +MEMORY +{ + FLASH : ORIGIN = 0x08000000, LENGTH = 64K /* change length to 128K for STM32F072CBT6 */ + RAM : ORIGIN = 0x20000000, LENGTH = 16K +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..7a23af4 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,28 @@ +/* + * any key firmware + * Copyright (C) 2020 Luca Schmid + + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#![no_std] +#![no_main] + +use cortex_m_rt::entry; +use panic_halt as _; + +#[entry] +fn main() -> ! { + loop {} +}