Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
217ebb3a79 | ||
|
|
5063e90960 | ||
|
|
73ced50a21 | ||
|
|
b89c76e3fc | ||
|
|
7bb74b2123 | ||
|
|
0eaa0de3c6 | ||
|
|
3e39a0b927 | ||
|
|
a79ea9bee7 | ||
|
|
34d34975c3 | ||
|
|
72e914069c | ||
|
|
014dab642a |
@@ -1,27 +1,56 @@
|
|||||||
[target.thumbv6m-none-eabi]
|
[target.thumbv6m-none-eabi]
|
||||||
runner = 'arm-none-eabi-gdb'
|
runner = 'arm-none-eabi-gdb'
|
||||||
rustflags = [
|
rustflags = [
|
||||||
"-C", "link-arg=-Wl,-Tlink.x",
|
# LLD (shipped with the Rust toolchain) is used as the default linker
|
||||||
"-C", "link-arg=-nostartfiles",
|
"-C", "link-arg=-Tlink.x",
|
||||||
|
|
||||||
|
# if you run into problems with LLD switch to the GNU linker by commenting out
|
||||||
|
# this line
|
||||||
|
# "-C", "linker=arm-none-eabi-ld",
|
||||||
|
|
||||||
|
# if you need to link to pre-compiled C libraries provided by a C toolchain
|
||||||
|
# use GCC as the linker by commenting out both lines above and then
|
||||||
|
# uncommenting the three lines below
|
||||||
|
# "-C", "linker=arm-none-eabi-gcc",
|
||||||
|
# "-C", "link-arg=-Wl,-Tlink.x",
|
||||||
|
# "-C", "link-arg=-nostartfiles",
|
||||||
]
|
]
|
||||||
|
|
||||||
[target.thumbv7m-none-eabi]
|
[target.thumbv7m-none-eabi]
|
||||||
runner = 'arm-none-eabi-gdb'
|
runner = 'arm-none-eabi-gdb'
|
||||||
rustflags = [
|
rustflags = [
|
||||||
"-C", "link-arg=-Wl,-Tlink.x",
|
# the comments under `[target.thumbv6m-none-eabi]` also apply here
|
||||||
"-C", "link-arg=-nostartfiles",
|
"-C", "link-arg=-Tlink.x",
|
||||||
|
|
||||||
|
# "-C", "linker=arm-none-eabi-ld",
|
||||||
|
|
||||||
|
# "-C", "linker=arm-none-eabi-gcc",
|
||||||
|
# "-C", "link-arg=-Wl,-Tlink.x",
|
||||||
|
# "-C", "link-arg=-nostartfiles",
|
||||||
]
|
]
|
||||||
|
|
||||||
[target.thumbv7em-none-eabi]
|
[target.thumbv7em-none-eabi]
|
||||||
runner = 'arm-none-eabi-gdb'
|
runner = 'arm-none-eabi-gdb'
|
||||||
rustflags = [
|
rustflags = [
|
||||||
"-C", "link-arg=-Wl,-Tlink.x",
|
# the comments under `[target.thumbv6m-none-eabi]` also apply here
|
||||||
"-C", "link-arg=-nostartfiles",
|
"-C", "link-arg=-Tlink.x",
|
||||||
|
|
||||||
|
# "-C", "linker=arm-none-eabi-ld",
|
||||||
|
|
||||||
|
# "-C", "linker=arm-none-eabi-gcc",
|
||||||
|
# "-C", "link-arg=-Wl,-Tlink.x",
|
||||||
|
# "-C", "link-arg=-nostartfiles",
|
||||||
]
|
]
|
||||||
|
|
||||||
[target.thumbv7em-none-eabihf]
|
[target.thumbv7em-none-eabihf]
|
||||||
runner = 'arm-none-eabi-gdb'
|
runner = 'arm-none-eabi-gdb'
|
||||||
rustflags = [
|
rustflags = [
|
||||||
"-C", "link-arg=-Wl,-Tlink.x",
|
# the comments under `[target.thumbv6m-none-eabi]` also apply here
|
||||||
"-C", "link-arg=-nostartfiles",
|
"-C", "link-arg=-Tlink.x",
|
||||||
|
|
||||||
|
# "-C", "linker=arm-none-eabi-ld",
|
||||||
|
|
||||||
|
# "-C", "linker=arm-none-eabi-gcc",
|
||||||
|
# "-C", "link-arg=-Wl,-Tlink.x",
|
||||||
|
# "-C", "link-arg=-nostartfiles",
|
||||||
]
|
]
|
||||||
|
|||||||
1
bors.toml → .github/bors.toml
vendored
1
bors.toml → .github/bors.toml
vendored
@@ -1,3 +1,4 @@
|
|||||||
|
block_labels = ["needs-decision"]
|
||||||
delete_merged_branches = true
|
delete_merged_branches = true
|
||||||
required_approvals = 1
|
required_approvals = 1
|
||||||
status = ["continuous-integration/travis-ci/push"]
|
status = ["continuous-integration/travis-ci/push"]
|
||||||
23
.travis.yml
23
.travis.yml
@@ -2,36 +2,24 @@ language: rust
|
|||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
|
- env: TARGET=x86_64-unknown-linux-gnu
|
||||||
|
rust: nightly
|
||||||
|
if: branch = master AND type != pull_request
|
||||||
|
|
||||||
- env: TARGET=thumbv6m-none-eabi
|
- env: TARGET=thumbv6m-none-eabi
|
||||||
rust: nightly
|
rust: nightly
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- gcc-arm-none-eabi
|
|
||||||
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)
|
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)
|
||||||
|
|
||||||
- env: TARGET=thumbv7m-none-eabi
|
- env: TARGET=thumbv7m-none-eabi
|
||||||
rust: nightly
|
rust: nightly
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- gcc-arm-none-eabi
|
|
||||||
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)
|
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)
|
||||||
|
|
||||||
- env: TARGET=thumbv7em-none-eabi
|
- env: TARGET=thumbv7em-none-eabi
|
||||||
rust: nightly
|
rust: nightly
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- gcc-arm-none-eabi
|
|
||||||
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)
|
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)
|
||||||
|
|
||||||
- env: TARGET=thumbv7em-none-eabihf
|
- env: TARGET=thumbv7em-none-eabihf
|
||||||
rust: nightly
|
rust: nightly
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- gcc-arm-none-eabi
|
|
||||||
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)
|
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)
|
||||||
|
|
||||||
before_install: set -e
|
before_install: set -e
|
||||||
@@ -42,6 +30,9 @@ install:
|
|||||||
script:
|
script:
|
||||||
- bash ci/script.sh
|
- bash ci/script.sh
|
||||||
|
|
||||||
|
after_success:
|
||||||
|
- bash ci/after-success.sh
|
||||||
|
|
||||||
after_script: set +e
|
after_script: set +e
|
||||||
|
|
||||||
cache: cargo
|
cache: cargo
|
||||||
|
|||||||
@@ -2,16 +2,17 @@
|
|||||||
authors = ["Jorge Aparicio <jorge@japaric.io>"]
|
authors = ["Jorge Aparicio <jorge@japaric.io>"]
|
||||||
categories = ["embedded", "no-std"]
|
categories = ["embedded", "no-std"]
|
||||||
description = "A template for building applications for ARM Cortex-M microcontrollers"
|
description = "A template for building applications for ARM Cortex-M microcontrollers"
|
||||||
|
documentation = "https://rust-embedded.github.io/cortex-m-quickstart/cortex_m_quickstart"
|
||||||
keywords = ["arm", "cortex-m", "template"]
|
keywords = ["arm", "cortex-m", "template"]
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
name = "cortex-m-quickstart"
|
name = "cortex-m-quickstart"
|
||||||
repository = "https://github.com/japaric/cortex-m-quickstart"
|
repository = "https://github.com/japaric/cortex-m-quickstart"
|
||||||
version = "0.3.3"
|
version = "0.3.4"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cortex-m = "0.5.0"
|
cortex-m = "0.5.6"
|
||||||
cortex-m-rt = "0.5.0"
|
cortex-m-rt = "0.5.3"
|
||||||
cortex-m-semihosting = "0.3.0"
|
cortex-m-semihosting = "0.3.1"
|
||||||
panic-semihosting = "0.3.0"
|
panic-semihosting = "0.3.0"
|
||||||
|
|
||||||
# Uncomment for the panic example.
|
# Uncomment for the panic example.
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
This project is developed and maintained by the [Cortex-M team][team].
|
This project is developed and maintained by the [Cortex-M team][team].
|
||||||
|
|
||||||
# [Documentation](https://docs.rs/cortex-m-quickstart)
|
# [Documentation](https://rust-embedded.github.io/cortex-m-quickstart/cortex_m_quickstart)
|
||||||
|
|
||||||
# License
|
# License
|
||||||
|
|
||||||
|
|||||||
20
ci/after-success.sh
Normal file
20
ci/after-success.sh
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
set -euxo pipefail
|
||||||
|
|
||||||
|
main() {
|
||||||
|
cargo doc
|
||||||
|
|
||||||
|
mkdir ghp-import
|
||||||
|
|
||||||
|
curl -Ls https://github.com/davisp/ghp-import/archive/master.tar.gz |
|
||||||
|
tar --strip-components 1 -C ghp-import -xz
|
||||||
|
|
||||||
|
./ghp-import/ghp_import.py target/doc
|
||||||
|
|
||||||
|
set +x
|
||||||
|
git push -fq https://$GH_TOKEN@github.com/$TRAVIS_REPO_SLUG.git gh-pages && echo OK
|
||||||
|
}
|
||||||
|
|
||||||
|
# only publish on successful merges to master
|
||||||
|
if [ $TRAVIS_BRANCH = master ] && [ $TRAVIS_PULL_REQUEST = false ] && [ $TARGET = x86_64-unknown-linux-gnu ]; then
|
||||||
|
main
|
||||||
|
fi
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
set -euxo pipefail
|
set -euxo pipefail
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
rustup target add $TARGET
|
if [ $TARGET != x86_64-unknown-linux-gnu ]; then
|
||||||
|
rustup target add $TARGET
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
main
|
main
|
||||||
|
|||||||
@@ -61,10 +61,12 @@ EOF
|
|||||||
examples+=( $ex )
|
examples+=( $ex )
|
||||||
fi
|
fi
|
||||||
|
|
||||||
IFS=,;eval arm-none-eabi-size target/$TARGET/release/examples/"{${examples[*]}}"
|
IFS=,;eval size target/$TARGET/release/examples/"{${examples[*]}}"
|
||||||
|
|
||||||
popd
|
popd
|
||||||
rm -rf $td
|
rm -rf $td
|
||||||
}
|
}
|
||||||
|
|
||||||
main
|
if [ $TARGET != x86_64-unknown-linux-gnu ]; then
|
||||||
|
main
|
||||||
|
fi
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
#![feature(alloc)]
|
#![feature(alloc)]
|
||||||
#![feature(alloc_error_handler)]
|
#![feature(alloc_error_handler)]
|
||||||
#![feature(global_allocator)]
|
|
||||||
#![feature(lang_items)]
|
#![feature(lang_items)]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
@@ -58,7 +57,7 @@ fn main() -> ! {
|
|||||||
// define what happens in an Out Of Memory (OOM) condition
|
// define what happens in an Out Of Memory (OOM) condition
|
||||||
#[alloc_error_handler]
|
#[alloc_error_handler]
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub fn alloc_error(layout: Layout) -> ! {
|
pub fn alloc_error(_layout: Layout) -> ! {
|
||||||
asm::bkpt();
|
asm::bkpt();
|
||||||
|
|
||||||
loop {}
|
loop {}
|
||||||
|
|||||||
@@ -15,28 +15,19 @@
|
|||||||
//! define a panicking behavior is to link to a [panic handler crate][0]
|
//! define a panicking behavior is to link to a [panic handler crate][0]
|
||||||
//!
|
//!
|
||||||
//! [0]: https://crates.io/keywords/panic-impl
|
//! [0]: https://crates.io/keywords/panic-impl
|
||||||
//!
|
|
||||||
//! - Define the `HardFault` handler using the [`exception!`] macro. This handler (function) is
|
|
||||||
//! called when a hard fault exception is raised by the hardware.
|
|
||||||
//!
|
|
||||||
//! [`exception!`]: https://docs.rs/cortex-m-rt/~0.5/cortex_m_rt/macro..html
|
|
||||||
//!
|
|
||||||
//! - Define a default handler using the [`exception!`] macro. This function will be used to handle
|
|
||||||
//! all interrupts and exceptions which have not been assigned a specific handler.
|
|
||||||
|
|
||||||
#![no_main] // <- IMPORTANT!
|
#![no_main] // <- IMPORTANT!
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
extern crate cortex_m;
|
extern crate cortex_m;
|
||||||
|
|
||||||
#[macro_use(entry, exception)]
|
#[macro_use(entry)]
|
||||||
extern crate cortex_m_rt as rt;
|
extern crate cortex_m_rt as rt;
|
||||||
|
|
||||||
// makes `panic!` print messages to the host stderr using semihosting
|
// makes `panic!` print messages to the host stderr using semihosting
|
||||||
extern crate panic_semihosting;
|
extern crate panic_semihosting;
|
||||||
|
|
||||||
use cortex_m::asm;
|
use cortex_m::asm;
|
||||||
use rt::ExceptionFrame;
|
|
||||||
|
|
||||||
// the program entry point is ...
|
// the program entry point is ...
|
||||||
entry!(main);
|
entry!(main);
|
||||||
@@ -47,17 +38,3 @@ fn main() -> ! {
|
|||||||
asm::bkpt();
|
asm::bkpt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// define the hard fault handler
|
|
||||||
exception!(HardFault, hard_fault);
|
|
||||||
|
|
||||||
fn hard_fault(ef: &ExceptionFrame) -> ! {
|
|
||||||
panic!("HardFault at {:#?}", ef);
|
|
||||||
}
|
|
||||||
|
|
||||||
// define the default exception handler
|
|
||||||
exception!(*, default_handler);
|
|
||||||
|
|
||||||
fn default_handler(irqn: i16) {
|
|
||||||
panic!("Unhandled exception (IRQn = {})", irqn);
|
|
||||||
}
|
|
||||||
|
|||||||
36
src/lib.rs
36
src/lib.rs
@@ -2,9 +2,8 @@
|
|||||||
//!
|
//!
|
||||||
//! # Dependencies
|
//! # Dependencies
|
||||||
//!
|
//!
|
||||||
//! - Nightly Rust toolchain newer than `nightly-2018-04-08`: `rustup default nightly`
|
//! - Nightly Rust toolchain from 2018-08-28 or newer: `rustup default nightly`
|
||||||
//! - Cargo `clone` subcommand: `cargo install cargo-clone`
|
//! - Cargo `clone` subcommand: `cargo install cargo-clone`
|
||||||
//! - ARM toolchain: `sudo apt-get install gcc-arm-none-eabi` (on Ubuntu)
|
|
||||||
//! - GDB: `sudo apt-get install gdb-arm-none-eabi` (on Ubuntu)
|
//! - GDB: `sudo apt-get install gdb-arm-none-eabi` (on Ubuntu)
|
||||||
//! - OpenOCD: `sudo apt-get install OpenOCD` (on Ubuntu)
|
//! - OpenOCD: `sudo apt-get install OpenOCD` (on Ubuntu)
|
||||||
//! - [Optional] Cargo `add` subcommand: `cargo install cargo-edit`
|
//! - [Optional] Cargo `add` subcommand: `cargo install cargo-edit`
|
||||||
@@ -27,7 +26,7 @@
|
|||||||
//! 2) Clone this crate
|
//! 2) Clone this crate
|
||||||
//!
|
//!
|
||||||
//! ``` text
|
//! ``` text
|
||||||
//! $ cargo clone cortex-m-quickstart --vers 0.3.0
|
//! $ cargo clone cortex-m-quickstart --vers 0.3.4
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! 3) Change the crate name, author and version
|
//! 3) Change the crate name, author and version
|
||||||
@@ -179,11 +178,13 @@
|
|||||||
//! ``` text
|
//! ``` text
|
||||||
//! $ cargo build
|
//! $ cargo build
|
||||||
//! Compiling demo v0.1.0 (file:///home/japaric/tmp/demo)
|
//! Compiling demo v0.1.0 (file:///home/japaric/tmp/demo)
|
||||||
//! error: linking with `arm-none-eabi-ld` failed: exit code: 1
|
//! error: linking with `rust-lld` failed: exit code: 1
|
||||||
//! |
|
//! |
|
||||||
//! = note: "arm-none-eabi-gcc" "-L" (..)
|
//! = note: "rust-lld" "-flavor" "gnu" "-L" (..)
|
||||||
|
//! (..)
|
||||||
|
//! = note: rust-lld: error: section '.vector_table' will not fit in region 'FLASH': overflowed by X bytes
|
||||||
|
//! rust-lld: error: section '.vector_table' will not fit in region 'FLASH': overflowed by Y bytes
|
||||||
//! (..)
|
//! (..)
|
||||||
//! (..)/ld: region `FLASH' overflowed by XXX bytes
|
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! Solution: Specify your device memory layout in the `memory.x` linker script. See [Usage]
|
//! Solution: Specify your device memory layout in the `memory.x` linker script. See [Usage]
|
||||||
@@ -206,24 +207,15 @@
|
|||||||
//!
|
//!
|
||||||
//! ## Overwrote the original `.cargo/config` file
|
//! ## Overwrote the original `.cargo/config` file
|
||||||
//!
|
//!
|
||||||
//! Error message:
|
//! You won't get an error message but the output binary will be empty
|
||||||
//!
|
//!
|
||||||
//! ``` text
|
//! ``` text
|
||||||
//! error: linking with `arm-none-eabi-gcc` failed: exit code: 1
|
//! $ cargo build && echo OK
|
||||||
//! |
|
//! OK
|
||||||
//! = note: (..)
|
//!
|
||||||
//! (..)
|
//! $ size target/thumbv7m-none-eabi/debug/app
|
||||||
//! (..)/crt0.o: In function `_start':
|
//! text data bss dec hex filename
|
||||||
//! (.text+0x90): undefined reference to `memset'
|
//! 0 0 0 0 0 target/thumbv7m-none-eabi/debug/app
|
||||||
//! (..)/crt0.o: In function `_start':
|
|
||||||
//! (.text+0xd0): undefined reference to `atexit'
|
|
||||||
//! (..)/crt0.o: In function `_start':
|
|
||||||
//! (.text+0xd4): undefined reference to `__libc_init_array'
|
|
||||||
//! (..)/crt0.o: In function `_start':
|
|
||||||
//! (.text+0xe4): undefined reference to `exit'
|
|
||||||
//! (..)/crt0.o: In function `_start':
|
|
||||||
//! (.text+0x100): undefined reference to `__libc_fini_array'
|
|
||||||
//! collect2: error: ld returned 1 exit status
|
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! Solution: You probably overwrote the original `.cargo/config` instead of appending the default
|
//! Solution: You probably overwrote the original `.cargo/config` instead of appending the default
|
||||||
|
|||||||
Reference in New Issue
Block a user