12 Commits

Author SHA1 Message Date
Jorge Aparicio
55e61c3291 bump dependencies 2018-11-10 00:04:28 +01:00
Jorge Aparicio
e64e690512 use NVIC::pend
instead of the deprecated NVIC.set_pending
2018-11-10 00:02:00 +01:00
Jorge Aparicio
f7a943f480 fix the allocator example
importing alloc is a bit weird
2018-11-10 00:01:25 +01:00
Jorge Aparicio
9c6b290e12 use hprint macros 2018-11-10 00:00:57 +01:00
Emil Fresk
7e2bec66b7 Merge pull request #54 from Nicoretti/toml
Add additional meta data to improve crate experience
2018-10-28 23:48:50 +01:00
Emil Fresk
4295bccf0e Merge pull request #51 from rust-embedded/therealprof-extended-remote
Default to extended-remote instead of remote mode
2018-10-28 23:48:32 +01:00
Nicola Coretti
8f292e0f07 Add additional meta data to improve crate experience
* Add readme setting, so README.md is shown on https://crates.io/
2018-10-26 15:54:27 +02:00
Jonathan 'theJPster' Pallant
76d2e947a5 Merge pull request #53 from birkenfeld/patch-1
Add example moving .bss data into custom memory
2018-10-22 19:18:17 -07:00
Georg Brandl
76cdd6a95b fix example 2018-10-21 17:27:47 +02:00
Georg Brandl
314e48537c Add example moving .bss data into custom memory
We're using a STM32F429 and wanted to move stuff around in memory, notably put stack+data into CPU coupled memory, and put framebuffers for the integrated LCD controller into the normal SRAM.

Getting this right while not completely overriding the default `link.x` was quite tricky (especially finding the `INSERT AFTER` life-saver...) so I thought an example would not hurt here.

It should probably also be mentioned in other places (book/...)?
2018-10-21 13:04:40 +02:00
Daniel Egger
d5abcf6d2a Merge pull request #52 from jannic/patch-1
Update rust version requirements in README.md
2018-10-13 21:40:23 +02:00
Jan Niehusmann
b02a67b5f9 Update rust version requirements in README.md
As Cargo.toml now includes edition = "2018", it won't build with rust 1.30-stable. 1.31-stable will be the first stable version to have the edition feature enabled. (See https://internals.rust-lang.org/t/rust-2018-release-schedule-and-extended-beta/8076 for details.)

At the same time, remove the remark about 1.30-beta not being out yet, as it's out by now.
2018-10-13 21:37:17 +02:00
7 changed files with 37 additions and 43 deletions

View File

@@ -1,13 +1,14 @@
[package]
authors = ["{{authors}}"]
edition = "2018"
readme = "README.md"
name = "{{project-name}}"
version = "0.1.0"
[dependencies]
cortex-m = "0.5.7"
cortex-m-rt = "0.6.3"
cortex-m-semihosting = "0.3.1"
cortex-m = "0.5.8"
cortex-m-rt = "0.6.5"
cortex-m-semihosting = "0.3.2"
panic-halt = "0.2.0"
# Uncomment for the panic example.

View File

@@ -8,12 +8,9 @@ This project is developed and maintained by the [Cortex-M team][team].
To build embedded programs using this template you'll need:
- Rust 1.30, 1.30-beta, nightly-2018-09-13 or a newer toolchain. e.g. `rustup
- Rust 1.31, 1.30-beta, nightly-2018-09-13 or a newer toolchain. e.g. `rustup
default beta`
> **NOTE**: 1.30-beta is not out yet so you'll have to use the nightly channel
> in the meantime.
- The `cargo generate` subcommand. [Installation
instructions](https://github.com/ashleygwilliams/cargo-generate#installation).

View File

@@ -14,16 +14,16 @@
#![no_main]
#![no_std]
extern crate alloc;
extern crate panic_halt;
use self::alloc::vec;
use core::alloc::Layout;
use core::fmt::Write;
use alloc::vec;
use alloc_cortex_m::CortexMHeap;
use cortex_m::asm;
use cortex_m_rt::entry;
use cortex_m_semihosting::hio;
use cortex_m_semihosting::hprintln;
// this is the allocator the application will use
#[global_allocator]
@@ -39,8 +39,11 @@ fn main() -> ! {
// Growable array allocated on the heap
let xs = vec![0, 1, 2];
let mut stdout = hio::hstdout().unwrap();
writeln!(stdout, "{:?}", xs).unwrap();
hprintln!("{:?}", xs).unwrap();
// exit QEMU
// NOTE do not run this on hardware; it can corrupt OpenOCD state
debug::exit(debug::EXIT_SUCCESS);
loop {}
}

View File

@@ -27,11 +27,9 @@
#[allow(unused_extern_crates)]
extern crate panic_halt;
use core::fmt::Write;
use cortex_m::peripheral::syst::SystClkSource;
use cortex_m_rt::entry;
use cortex_m_semihosting::hio::{self, HStdout};
use cortex_m_semihosting::hprint;
use stm32f30x::{interrupt, Interrupt};
#[entry]
@@ -53,19 +51,13 @@ fn main() -> ! {
while !syst.has_wrapped() {}
// trigger the `EXTI0` interrupt
nvic.set_pending(Interrupt::EXTI0);
NVIC::pend(Interrupt::EXTI0);
}
}
// try commenting out this line: you'll end in `default_handler` instead of in `exti0`
interrupt!(EXTI0, exti0, state: Option<HStdout> = None);
interrupt!(EXTI0, exti0);
fn exti0(state: &mut Option<HStdout>) {
if state.is_none() {
*state = Some(hio::hstdout().unwrap());
}
if let Some(hstdout) = state.as_mut() {
hstdout.write_str(".").unwrap();
}
fn exti0() {
hprint!(".").unwrap();
}

View File

@@ -12,12 +12,10 @@
extern crate panic_halt;
use core::fmt::Write;
use cortex_m::peripheral::syst::SystClkSource;
use cortex_m::Peripherals;
use cortex_m_rt::{entry, exception};
use cortex_m_semihosting::hio::{self, HStdout};
use cortex_m_semihosting::hprint;
#[entry]
fn main() -> ! {
@@ -35,13 +33,5 @@ fn main() -> ! {
#[exception]
fn SysTick() {
static mut STDOUT: Option<HStdout> = None;
if STDOUT.is_none() {
*STDOUT = Some(hio::hstdout().unwrap());
}
if let Some(hstdout) = STDOUT.as_mut() {
hstdout.write_str(".").unwrap();
}
hprint!(".").unwrap();
}

View File

@@ -5,17 +5,15 @@
extern crate panic_halt;
use core::fmt::Write;
use cortex_m_rt::entry;
use cortex_m_semihosting::{debug, hio};
use cortex_m_semihosting::{debug, hprintln};
#[entry]
fn main() -> ! {
let mut stdout = hio::hstdout().unwrap();
writeln!(stdout, "Hello, world!").unwrap();
hprintln!("Hello, world!").unwrap();
// exit QEMU or the debugger section
// exit QEMU
// NOTE do not run this on hardware; it can corrupt OpenOCD state
debug::exit(debug::EXIT_SUCCESS);
loop {}

View File

@@ -19,3 +19,16 @@ MEMORY
/* This is required only on microcontrollers that store some configuration right
after the vector table */
/* _stext = ORIGIN(FLASH) + 0x400; */
/* Example of putting non-initialized variables into custom RAM locations. */
/* This assumes you have defined a region RAM2 above, and in the Rust
sources added the attribute `#[link_section = ".ram2bss"]` to the data
you want to place there. */
/* Note that the section will not be zero-initialized by the runtime! */
/* SECTIONS {
.ram2bss (NOLOAD) : ALIGN(4) {
*(.ram2bss);
. = ALIGN(4);
} > RAM2
} INSERT AFTER .bss;
*/