-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic hello world example that runs on the metro m0 express
- Loading branch information
Showing
9 changed files
with
110 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# samd21 is a Cortex-M0 and thus thumbv6m | ||
|
||
[build] | ||
target = "thumbv6m-none-eabi" | ||
|
||
[target.thumbv6m-none-eabi] | ||
runner = 'arm-none-eabi-gdb' | ||
rustflags = [ | ||
"-C", "link-arg=-Tlink.x", | ||
"-C", "linker=arm-none-eabi-ld", | ||
"-Z", "linker-flavor=ld", | ||
"-Z", "thinlto=no", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# print demangled symbols by default | ||
set print asm-demangle on | ||
|
||
# JLink | ||
target extended-remote :2331 | ||
monitor flash breakpoints 1 | ||
# allow hprints to show up in gdb | ||
monitor semihosting enable | ||
monitor semihosting IOClient 3 | ||
|
||
monitor reset | ||
load | ||
|
||
# OpenOCD | ||
#target extended-remote :3333 | ||
#monitor arm semihosting enable | ||
#load | ||
#step |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
[._]*.sw[a-p] | ||
/target | ||
Cargo.lock | ||
/.gdb_history |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,28 @@ | ||
[workspace] | ||
members = ["atsamd21g18a"] | ||
|
||
[package] | ||
name = "samd21" | ||
version = "0.0.0" | ||
|
||
[dependencies] | ||
cortex-m = "0.4.3" | ||
cortex-m-semihosting = "0.2.0" | ||
|
||
[dependencies.cortex-m-rt] | ||
version = "0.3.13" | ||
features = ["abort-on-panic"] | ||
|
||
[dependencies.atsamd21g18a] | ||
path = "atsamd21g18a" | ||
features = ["rt"] | ||
|
||
# disable both incremental compilation and parallel codegen to | ||
# reduce the chances of running into rust-lang/rust#47074 | ||
[profile.dev] | ||
codegen-units = 1 | ||
incremental = false | ||
|
||
[profile.release] | ||
debug = true | ||
lto = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[dependencies.core] | ||
stage = 0 | ||
|
||
# [dependencies.alloc] # Uncomment for the alloc example. | ||
# stage = 0 | ||
|
||
[dependencies.compiler_builtins] | ||
features = ["mem"] | ||
stage = 1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use std::env; | ||
use std::fs::File; | ||
use std::io::Write; | ||
use std::path::PathBuf; | ||
|
||
fn main() { | ||
// Put the linker script somewhere the linker can find it | ||
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); | ||
File::create(out.join("memory.x")) | ||
.unwrap() | ||
.write_all(include_bytes!("memory.x")) | ||
.unwrap(); | ||
println!("cargo:rustc-link-search={}", out.display()); | ||
|
||
println!("cargo:rerun-if-changed=build.rs"); | ||
println!("cargo:rerun-if-changed=memory.x"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
MEMORY | ||
{ | ||
// Leave 8k for the default bootloader on the Metro M0 | ||
FLASH (rx) : ORIGIN = 0x00000000 + 8K, LENGTH = 256K - 8K | ||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K | ||
} | ||
_stack_start = ORIGIN(RAM) + LENGTH(RAM); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#![feature(used)] | ||
#![no_std] | ||
|
||
extern crate atsamd21g18a; | ||
extern crate cortex_m; | ||
extern crate cortex_m_rt; | ||
extern crate cortex_m_semihosting; | ||
|
||
use core::fmt::Write; | ||
use cortex_m_semihosting::hio; | ||
|
||
fn main() { | ||
let mut stdout = hio::hstdout().unwrap(); | ||
writeln!(stdout, "Hello, world!").unwrap(); | ||
} |