-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
128: Add qemu example and run in CI r=japaric a=sekineh As @japaric has suggested I ported `lm3s6965evb/src/main.rs` into `example/qemu.rs`. All errors were fixed, ~but qemu never exits automatically~ `qemu` prints text and exits. ``` sekineh@sekineh-VirtualBox:~/cortex-m-rt_me$ cargo run --example qemu --target thumbv7m-none-eabi Compiling cortex-m-rt v0.6.3 (file:///home/sekineh/cortex-m-rt_me) Finished dev [unoptimized + debuginfo] target(s) in 0.17s Running `qemu-system-arm -cpu cortex-m3 -machine lm3s6965evb -nographic -semihosting-config enable=on,target=native -kernel target/thumbv7m-none-eabi/debug/examples/qemu` x = 42 sekineh@sekineh-VirtualBox:~/cortex-m-rt_me$ ``` ## supported targets - thumbv6m-none-eabi - thumbv7m-none-eabi ## code size ~code size is 0, which is apparently wrong:~ ``` sekineh@sekineh-VirtualBox:~/cortex-m-rt_me$ size target/thumbv7m-none-eabi/debug/examples/qemu text data bss dec hex filename 10776 0 0 10776 2a18 target/thumbv7m-none-eabi/debug/examples/qemu ``` ## code size (original) (deleted; different compiler version) Co-authored-by: Hideki Sekine <[email protected]>
- Loading branch information
Showing
7 changed files
with
94 additions
and
31 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,31 @@ | ||
[target.thumbv7m-none-eabi] | ||
# uncomment this to make `cargo run` execute programs on QEMU | ||
runner = "qemu-system-arm -cpu cortex-m3 -machine lm3s6965evb -nographic -semihosting-config enable=on,target=native -kernel" | ||
|
||
[target.thumbv6m-none-eabi] | ||
# uncomment this to make `cargo run` execute programs on QEMU | ||
# For now, we use cortex-m3 instead of cortex-m0 which are not supported by QEMU | ||
runner = "qemu-system-arm -cpu cortex-m3 -machine lm3s6965evb -nographic -semihosting-config enable=on,target=native -kernel" | ||
|
||
[target.'cfg(all(target_arch = "arm", target_os = "none"))'] | ||
# uncomment ONE of these three option to make `cargo run` start a GDB session | ||
# which option to pick depends on your system | ||
# runner = "arm-none-eabi-gdb -q -x openocd.gdb" | ||
# runner = "gdb-multiarch -q -x openocd.gdb" | ||
# runner = "gdb -q -x openocd.gdb" | ||
|
||
rustflags = [ | ||
# LLD (shipped with the Rust toolchain) is used as the default linker | ||
"-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", | ||
] |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[package] | ||
authors = ["Jorge Aparicio <[email protected]>"] | ||
authors = ["Jorge Aparicio <[email protected]>", "Hideki Sekine <[email protected]>"] | ||
categories = ["embedded", "no-std"] | ||
description = "Minimal runtime / startup for Cortex-M microcontrollers" | ||
documentation = "https://rust-embedded.github.io/cortex-m-rt/" | ||
|
@@ -17,6 +17,7 @@ cortex-m-rt-macros = { path = "macros", version = "0.1.1" } | |
[dev-dependencies] | ||
cortex-m = "0.5.4" | ||
panic-halt = "0.2.0" | ||
cortex-m-semihosting = "0.3.1" | ||
|
||
[dev-dependencies.rand] | ||
default-features = false | ||
|
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
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,29 @@ | ||
// #![feature(stdsimd)] | ||
#![no_main] | ||
#![no_std] | ||
|
||
extern crate cortex_m; | ||
|
||
extern crate cortex_m_rt as rt; | ||
extern crate cortex_m_semihosting as semihosting; | ||
extern crate panic_halt; | ||
|
||
use core::fmt::Write; | ||
use cortex_m::asm; | ||
use rt::entry; | ||
|
||
#[entry] | ||
fn main() -> ! { | ||
let x = 42; | ||
|
||
loop { | ||
asm::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); | ||
} | ||
} |
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