Skip to content

Commit 8d2b2ee

Browse files
committed
[ci] run-make/thumb-none-qemu: add example crate.
1 parent a4faa5e commit 8d2b2ee

File tree

5 files changed

+79
-8
lines changed

5 files changed

+79
-8
lines changed

src/test/run-make/thumb-none-qemu/Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,21 @@ ifneq (,$(filter $(TARGET),thumbv6m-none-eabi thumbv7m-none-eabi))
88

99
# For cargo setting
1010
export RUSTC := $(RUSTC_ORIGINAL)
11-
LD_LIBRARY_PATH := $(HOST_RPATH_DIR)
11+
export LD_LIBRARY_PATH := $(HOST_RPATH_DIR)
1212
# We need to be outside of 'src' dir in order to run cargo
1313
export WORK_DIR := $(TMPDIR)
1414
export HERE := $(shell pwd)
1515

16+
## clean up unused env variables which might cause harm.
17+
# unexport RUSTC_LINKER
18+
# unexport RUSTC_BOOTSTRAP
19+
# unexport RUST_BUILD_STAGE
20+
# unexport RUST_TEST_THREADS
21+
# unexport RUST_TEST_TMPDIR
22+
# unexport AR
23+
# unexport CC
24+
# unexport CXX
25+
1626
all:
1727
bash script.sh
1828
else
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[package]
2+
name = "example"
3+
version = "0.1.0"
4+
authors = ["Hideki Sekine <sekineh@me.com>"]
5+
# edition = "2018"
6+
7+
[dependencies]
8+
cortex-m = "0.5.4"
9+
cortex-m-rt = "=0.5.4"
10+
panic-halt = "0.2.0"
11+
cortex-m-semihosting = "0.3.1"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* Device specific memory layout */
2+
3+
/* This file is used to build the cortex-m-rt examples,
4+
but not other applications using cortex-m-rt. */
5+
6+
MEMORY
7+
{
8+
/* FLASH and RAM are mandatory memory regions */
9+
/* Update examples/data_overflow.rs if you change these sizes. */
10+
FLASH : ORIGIN = 0x00000000, LENGTH = 256K
11+
RAM : ORIGIN = 0x20000000, LENGTH = 64K
12+
13+
/* More memory regions can declared: for example this is a second RAM region */
14+
/* CCRAM : ORIGIN = 0x10000000, LENGTH = 8K */
15+
}
16+
17+
/* The location of the stack can be overridden using the `_stack_start` symbol.
18+
By default it will be placed at the end of the RAM region */
19+
/* _stack_start = ORIGIN(CCRAM) + LENGTH(CCRAM); */
20+
21+
/* The location of the .text section can be overridden using the `_stext` symbol.
22+
By default it will place after .vector_table */
23+
/* _stext = ORIGIN(FLASH) + 0x40c; */
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// #![feature(stdsimd)]
2+
#![no_main]
3+
#![no_std]
4+
5+
extern crate cortex_m;
6+
7+
extern crate cortex_m_rt as rt;
8+
extern crate cortex_m_semihosting as semihosting;
9+
extern crate panic_halt;
10+
11+
use core::fmt::Write;
12+
use cortex_m::asm;
13+
use rt::entry;
14+
15+
entry!(main);
16+
17+
fn main() -> ! {
18+
let x = 42;
19+
20+
loop {
21+
asm::nop();
22+
23+
// write something through semihosting interface
24+
let mut hstdout = semihosting::hio::hstdout().unwrap();
25+
write!(hstdout, "x = {}\n", x);
26+
27+
// exit from qemu
28+
semihosting::debug::exit(semihosting::debug::EXIT_SUCCESS);
29+
}
30+
}
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
set -exuo pipefail
22

3-
CRATE=cortex-m-rt
4-
CRATE_URL=https://github.com/rust-embedded/cortex-m-rt
5-
CRATE_SHA1=62972c8a89ff54b76f9ef0d600c1fcf7a233aabd
3+
CRATE=example
64

75
env | sort
86
mkdir -p $WORK_DIR
97
pushd $WORK_DIR
108
rm -rf $CRATE || echo OK
11-
bash -x $HERE/../git_clone_sha1.sh $CRATE $CRATE_URL $CRATE_SHA1
9+
cp -a $HERE/example .
1210
pushd $CRATE
13-
$CARGO run --target $TARGET --example qemu | grep "x = 42"
14-
$CARGO run --target $TARGET --example qemu --release | grep "x = 42"
11+
$CARGO run --target $TARGET
1512
popd
16-
popd
13+
popd

0 commit comments

Comments
 (0)