From 87771282d1b87d1a1b40e18f9c8f829ad01a6e7f Mon Sep 17 00:00:00 2001 From: Hideki Sekine Date: Wed, 19 Sep 2018 10:17:29 +0900 Subject: [rust/ci/qemu] main for qemu run. - taken from japaric/lm3s6965evb --- cortex-m-rt/examples/qemu.rs | 53 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 cortex-m-rt/examples/qemu.rs (limited to 'cortex-m-rt/examples/qemu.rs') diff --git a/cortex-m-rt/examples/qemu.rs b/cortex-m-rt/examples/qemu.rs new file mode 100644 index 0000000..f3850d5 --- /dev/null +++ b/cortex-m-rt/examples/qemu.rs @@ -0,0 +1,53 @@ +#![feature(stdsimd)] +#![no_main] +#![no_std] + +extern crate cortex_m; + +#[macro_use(entry, exception)] +extern crate cortex_m_rt as rt; +extern crate cortex_m_semihosting as semihosting; +extern crate panic_abort; +extern crate unreachable; + +use core::arch::arm; +use core::fmt::Write; +use rt::ExceptionFrame; + +entry!(main); + +fn main() -> ! { + let x = 42; + + loop { + unsafe { arm::__NOP() } + + // write something through semihosting interface + let mut hstdout = semihosting::hio::hstdout().unwrap(); + write!(hstdout, "x = {}\n", x); + + // exit from qemu + semihosting::debug::exit(semihosting::debug::EXIT_SUCCESS); + + // hint to the optimizer that any code path which calls this function is statically unreachable + unsafe { + unreachable::unreachable(); + } + } +} + +// define the hard fault handler +exception!(HardFault, hard_fault); + +#[inline(always)] +fn hard_fault(_ef: &ExceptionFrame) -> ! { + loop { + unsafe { arm::__NOP() } + } +} + +// define the default exception handler +exception!(*, default_handler); + +#[inline(always)] +fn default_handler(_irqn: i16) {} -- cgit v1.2.3 From b20f27d983624478a956d70e113c82138dea3ed8 Mon Sep 17 00:00:00 2001 From: Hideki Sekine Date: Fri, 21 Sep 2018 02:01:39 +0900 Subject: make build pass. --- cortex-m-rt/.cargo/config | 3 +++ cortex-m-rt/Cargo.toml | 3 +++ cortex-m-rt/examples/qemu.rs | 36 +++++++++++++++++++----------------- 3 files changed, 25 insertions(+), 17 deletions(-) create mode 100644 cortex-m-rt/.cargo/config (limited to 'cortex-m-rt/examples/qemu.rs') diff --git a/cortex-m-rt/.cargo/config b/cortex-m-rt/.cargo/config new file mode 100644 index 0000000..837eee1 --- /dev/null +++ b/cortex-m-rt/.cargo/config @@ -0,0 +1,3 @@ +[target.thumbv7m-none-eabi] +# uncomment this to make `cargo run` execute programs on QEMU +runner = "qemu-system-arm -cpu cortex-m3 -machine lm3s6965evb -semihosting-config enable=on,target=native -nographic -kernel" diff --git a/cortex-m-rt/Cargo.toml b/cortex-m-rt/Cargo.toml index ae72260..19e29e5 100644 --- a/cortex-m-rt/Cargo.toml +++ b/cortex-m-rt/Cargo.toml @@ -17,6 +17,9 @@ cortex-m-rt-macros = { path = "macros", version = "0.1.1" } [dev-dependencies] cortex-m = "0.5.4" panic-halt = "0.2.0" +panic-semihosting = "0.5.0" +cortex-m-semihosting = "0.3.1" +unreachable = "1.0.0" [dev-dependencies.rand] default-features = false diff --git a/cortex-m-rt/examples/qemu.rs b/cortex-m-rt/examples/qemu.rs index f3850d5..0bae8e7 100644 --- a/cortex-m-rt/examples/qemu.rs +++ b/cortex-m-rt/examples/qemu.rs @@ -1,31 +1,31 @@ -#![feature(stdsimd)] +// #![feature(stdsimd)] #![no_main] #![no_std] extern crate cortex_m; -#[macro_use(entry, exception)] extern crate cortex_m_rt as rt; extern crate cortex_m_semihosting as semihosting; -extern crate panic_abort; +extern crate panic_semihosting; extern crate unreachable; -use core::arch::arm; use core::fmt::Write; -use rt::ExceptionFrame; - -entry!(main); +use cortex_m::asm; +use rt::{entry, exception, ExceptionFrame}; +#[entry] fn main() -> ! { let x = 42; loop { - unsafe { arm::__NOP() } + asm::nop(); // write something through semihosting interface let mut hstdout = semihosting::hio::hstdout().unwrap(); write!(hstdout, "x = {}\n", x); + asm::nop(); + // exit from qemu semihosting::debug::exit(semihosting::debug::EXIT_SUCCESS); @@ -36,18 +36,20 @@ fn main() -> ! { } } -// define the hard fault handler -exception!(HardFault, hard_fault); - +#[exception] #[inline(always)] -fn hard_fault(_ef: &ExceptionFrame) -> ! { +fn HardFault(_ef: &ExceptionFrame) -> ! { loop { - unsafe { arm::__NOP() } + asm::nop() } } -// define the default exception handler -exception!(*, default_handler); - +#[exception] #[inline(always)] -fn default_handler(_irqn: i16) {} +fn DefaultHandler(_irqn: i16) {} + +// use core::panic::PanicInfo; +// #[panic_handler] +// fn panic(_info: &PanicInfo) -> ! {{ +// semihosting::debug::exit(semihosting::debug::EXIT_SUCCESS)} +// } -- cgit v1.2.3 From 70cacc499c0a5cc3a56841591b4955ec45b18010 Mon Sep 17 00:00:00 2001 From: Hideki Sekine Date: Fri, 21 Sep 2018 02:42:41 +0900 Subject: remove unneeded code and dependencies. --- cortex-m-rt/Cargo.toml | 2 -- cortex-m-rt/examples/qemu.rs | 30 ++---------------------------- 2 files changed, 2 insertions(+), 30 deletions(-) (limited to 'cortex-m-rt/examples/qemu.rs') diff --git a/cortex-m-rt/Cargo.toml b/cortex-m-rt/Cargo.toml index 19e29e5..fdee9bb 100644 --- a/cortex-m-rt/Cargo.toml +++ b/cortex-m-rt/Cargo.toml @@ -17,9 +17,7 @@ cortex-m-rt-macros = { path = "macros", version = "0.1.1" } [dev-dependencies] cortex-m = "0.5.4" panic-halt = "0.2.0" -panic-semihosting = "0.5.0" cortex-m-semihosting = "0.3.1" -unreachable = "1.0.0" [dev-dependencies.rand] default-features = false diff --git a/cortex-m-rt/examples/qemu.rs b/cortex-m-rt/examples/qemu.rs index 0bae8e7..e2cd895 100644 --- a/cortex-m-rt/examples/qemu.rs +++ b/cortex-m-rt/examples/qemu.rs @@ -6,12 +6,11 @@ extern crate cortex_m; extern crate cortex_m_rt as rt; extern crate cortex_m_semihosting as semihosting; -extern crate panic_semihosting; -extern crate unreachable; +extern crate panic_halt; use core::fmt::Write; use cortex_m::asm; -use rt::{entry, exception, ExceptionFrame}; +use rt::entry; #[entry] fn main() -> ! { @@ -24,32 +23,7 @@ fn main() -> ! { let mut hstdout = semihosting::hio::hstdout().unwrap(); write!(hstdout, "x = {}\n", x); - asm::nop(); - // exit from qemu semihosting::debug::exit(semihosting::debug::EXIT_SUCCESS); - - // hint to the optimizer that any code path which calls this function is statically unreachable - unsafe { - unreachable::unreachable(); - } } } - -#[exception] -#[inline(always)] -fn HardFault(_ef: &ExceptionFrame) -> ! { - loop { - asm::nop() - } -} - -#[exception] -#[inline(always)] -fn DefaultHandler(_irqn: i16) {} - -// use core::panic::PanicInfo; -// #[panic_handler] -// fn panic(_info: &PanicInfo) -> ! {{ -// semihosting::debug::exit(semihosting::debug::EXIT_SUCCESS)} -// } -- cgit v1.2.3 From bb25ff4507f72859b4b6f09a0b81632873053abf Mon Sep 17 00:00:00 2001 From: Jonathan 'theJPster' Pallant Date: Sat, 16 Mar 2019 22:46:18 +0000 Subject: Bump cortex-m dev-dep to 0.6 (it's only a dev-dep and so doesn't affect other packages) Disable the semihosting test on thumbv8, as it's currently unsupported in cortex-m-semihosting --- cortex-m-rt/Cargo.toml | 15 +++++++++++++-- cortex-m-rt/examples/qemu.rs | 19 +++++++++++++++---- 2 files changed, 28 insertions(+), 6 deletions(-) (limited to 'cortex-m-rt/examples/qemu.rs') diff --git a/cortex-m-rt/Cargo.toml b/cortex-m-rt/Cargo.toml index 949bdad..29310d7 100644 --- a/cortex-m-rt/Cargo.toml +++ b/cortex-m-rt/Cargo.toml @@ -19,10 +19,21 @@ autoexamples = true r0 = "0.2.2" cortex-m-rt-macros = { path = "macros", version = "0.1.5" } +[target.thumbv7em-none-eabihf.dev-dependencies] +cortex-m-semihosting = "0.3.1" + +[target.thumbv7em-none-eabi.dev-dependencies] +cortex-m-semihosting = "0.3.1" + +[target.thumbv7m-none-eabi.dev-dependencies] +cortex-m-semihosting = "0.3.1" + +[target.thumbv6m-none-eabi.dev-dependencies] +cortex-m-semihosting = "0.3.1" + [dev-dependencies] -cortex-m = ">= 0.5.7, <0.7" +cortex-m = "0.6" panic-halt = "0.2.0" -cortex-m-semihosting = "0.3.1" [dev-dependencies.rand] default-features = false diff --git a/cortex-m-rt/examples/qemu.rs b/cortex-m-rt/examples/qemu.rs index e2cd895..7553e70 100644 --- a/cortex-m-rt/examples/qemu.rs +++ b/cortex-m-rt/examples/qemu.rs @@ -2,18 +2,22 @@ #![no_main] #![no_std] -extern crate cortex_m; +extern crate cortex_m; extern crate cortex_m_rt as rt; + +#[cfg(not(armv8m))] extern crate cortex_m_semihosting as semihosting; + extern crate panic_halt; -use core::fmt::Write; use cortex_m::asm; use rt::entry; +#[cfg(not(armv8m))] #[entry] fn main() -> ! { + use core::fmt::Write; let x = 42; loop { @@ -21,9 +25,16 @@ fn main() -> ! { // write something through semihosting interface let mut hstdout = semihosting::hio::hstdout().unwrap(); - write!(hstdout, "x = {}\n", x); - + write!(hstdout, "x = {}\n", x).unwrap(); // exit from qemu semihosting::debug::exit(semihosting::debug::EXIT_SUCCESS); } } + +#[cfg(armv8m)] +#[entry] +fn main() -> ! { + loop { + asm::nop(); + } +} -- cgit v1.2.3 From 0aa5b90ed378fb881de1b3333c5a252ff97d8f4d Mon Sep 17 00:00:00 2001 From: Aurabindo Jayamohanan Date: Mon, 19 Aug 2019 12:30:04 +0530 Subject: Enable building semihosting for Armv8m Semihosting protocol has not changed for Arvmv8m and hence it need not be disabled for this architecture. Signed-off-by: Aurabindo Jayamohanan --- cortex-m-rt/Cargo.toml | 13 +------------ cortex-m-rt/examples/qemu.rs | 12 ------------ 2 files changed, 1 insertion(+), 24 deletions(-) (limited to 'cortex-m-rt/examples/qemu.rs') diff --git a/cortex-m-rt/Cargo.toml b/cortex-m-rt/Cargo.toml index 9b44a15..4b5faee 100644 --- a/cortex-m-rt/Cargo.toml +++ b/cortex-m-rt/Cargo.toml @@ -19,21 +19,10 @@ autoexamples = true r0 = "0.2.2" cortex-m-rt-macros = { path = "macros", version = "0.1.5" } -[target.thumbv7em-none-eabihf.dev-dependencies] -cortex-m-semihosting = "0.3.1" - -[target.thumbv7em-none-eabi.dev-dependencies] -cortex-m-semihosting = "0.3.1" - -[target.thumbv7m-none-eabi.dev-dependencies] -cortex-m-semihosting = "0.3.1" - -[target.thumbv6m-none-eabi.dev-dependencies] -cortex-m-semihosting = "0.3.1" - [dev-dependencies] cortex-m = "0.6" panic-halt = "0.2.0" +cortex-m-semihosting = "0.3" [dev-dependencies.rand] default-features = false diff --git a/cortex-m-rt/examples/qemu.rs b/cortex-m-rt/examples/qemu.rs index 7553e70..e903404 100644 --- a/cortex-m-rt/examples/qemu.rs +++ b/cortex-m-rt/examples/qemu.rs @@ -2,11 +2,8 @@ #![no_main] #![no_std] - extern crate cortex_m; extern crate cortex_m_rt as rt; - -#[cfg(not(armv8m))] extern crate cortex_m_semihosting as semihosting; extern crate panic_halt; @@ -14,7 +11,6 @@ extern crate panic_halt; use cortex_m::asm; use rt::entry; -#[cfg(not(armv8m))] #[entry] fn main() -> ! { use core::fmt::Write; @@ -30,11 +26,3 @@ fn main() -> ! { semihosting::debug::exit(semihosting::debug::EXIT_SUCCESS); } } - -#[cfg(armv8m)] -#[entry] -fn main() -> ! { - loop { - asm::nop(); - } -} -- cgit v1.2.3