Skip to content

Commit d20623c

Browse files
Merge pull request #23 from rust-embedded/use-windows-for-qemu
Use QEMU 9
2 parents ac3aa53 + 0963873 commit d20623c

9 files changed

+147
-26
lines changed

.cargo/config.toml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
[target.armv8r-none-eabihf]
22
# Note, this requires QEMU 9 or higher
3-
runner = "qemu-system-arm -machine mps3-an536 -cpu cortex-r52 -semihosting -nographic -kernel"
3+
runner = "qemu-system-arm -machine mps3-an536 -cpu cortex-r52 -semihosting -nographic -audio none -kernel"
44

55
[target.armv7r-none-eabihf]
6-
runner = "qemu-system-arm -machine versatileab -cpu cortex-r5f -semihosting -nographic -kernel"
6+
runner = "qemu-system-arm -machine versatileab -cpu cortex-r5f -semihosting -nographic -audio none -kernel"
77

88
[target.armv7r-none-eabi]
99
# change '-mcpu=cortex-r5' to '-mcpu=cortex-r5f' if you use eabi-fpu feature, otherwise
1010
# qemu-system-arm will lock up
11-
runner = "qemu-system-arm -machine versatileab -cpu cortex-r5 -semihosting -nographic -kernel"
11+
runner = "qemu-system-arm -machine versatileab -cpu cortex-r5 -semihosting -nographic -audio none -kernel"
1212

1313
[target.armv7a-none-eabihf]
14-
runner = "qemu-system-arm -machine versatileab -cpu cortex-a8 -semihosting -nographic -kernel"
14+
runner = "qemu-system-arm -machine versatileab -cpu cortex-a8 -semihosting -nographic -audio none -kernel"
1515

1616
[target.armv7a-none-eabi]
17-
runner = "qemu-system-arm -machine versatileab -cpu cortex-a8 -semihosting -nographic -kernel"
17+
runner = "qemu-system-arm -machine versatileab -cpu cortex-a8 -semihosting -nographic -audio none -kernel"
1818

1919
[unstable]
2020
build-std = ["core", "alloc"]

.github/workflows/build.yml

+14-3
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,10 @@ jobs:
102102
cargo build
103103
104104
# Build the workspace for the target architecture but using nightly to compile libcore
105+
# Technically it doens't need 'setup' but it makes the graph look nicer
105106
build-tier3:
106107
runs-on: ubuntu-24.04
108+
needs: setup
107109
strategy:
108110
matrix:
109111
target:
@@ -292,15 +294,24 @@ jobs:
292294
run: |
293295
cargo test --manifest-path cortex-ar/Cargo.toml
294296
295-
# Run some programs in QEMU
297+
# Run some programs in QEMU 9
296298
qemu-test:
297299
runs-on: ubuntu-24.04
298300
needs: [build-all]
299301
steps:
300-
- run: sudo apt-get -y update && sudo apt-get -y install qemu-system-arm
301302
- name: Checkout
302303
uses: actions/checkout@v4
303-
- run: ./tests.sh
304+
- name: Install Dependencies
305+
run: |
306+
sudo apt-get -y update
307+
sudo apt-get -y install libpixman-1-0 libfdt1 libglib2.0-0t64
308+
- name: Install custom QEMU into /opt
309+
run: |
310+
curl -sSL https://github.com/jonathanpallant/qemu9-for-ubuntu-2404/releases/download/qemu-9.2.3%2Bbuild0/qemu-9.2.3-ubuntu-24.04.tar.gz | sudo tar xvzf - -C /
311+
- name: Run tests in QEMU
312+
run: |
313+
export PATH=/opt/qemu/bin:$PATH
314+
./tests.sh
304315
305316
# Gather all the above xxx-all jobs together for the purposes of getting an overall pass-fail
306317
all:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
cntfrq = 62.500 MHz
2+
Using physical timer ************************
3+
Print five, every 100ms...
4+
i = 0
5+
i = 1
6+
i = 2
7+
i = 3
8+
i = 4
9+
Waiting for 31250000 physical ticks to count up...
10+
Matched! physical
11+
Waiting for 31250000 physical ticks to count down...
12+
physical countdown hit zero!
13+
Using virtual timer ************************
14+
Print five, every 100ms...
15+
i = 0
16+
i = 1
17+
i = 2
18+
i = 3
19+
i = 4
20+
Waiting for 31250000 virtual ticks to count up...
21+
Matched! virtual
22+
Waiting for 31250000 virtual ticks to count down...
23+
virtual countdown hit zero!
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Found PERIPHBASE 0xf0000000
2+
Creating GIC driver @ 0xf0000000 / 0xf0100000
3+
Calling git.setup(0)
4+
Configure SGI...
5+
gic.enable_interrupt()
6+
Enabling interrupts...
7+
CPSR: CPSR { N=0 Z=1 C=1 V=0 Q=0 J=0 E=0 A=0 I=1 F=1 T=0 MODE=Ok(Sys) }
8+
CPSR: CPSR { N=0 Z=1 C=1 V=0 Q=0 J=0 E=0 A=0 I=0 F=1 T=0 MODE=Ok(Sys) }
9+
Send SGI
10+
> IRQ
11+
- IRQ handle SGI 3
12+
< IRQ
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Hello, this is semihosting! x = 1.000, y = 2.000
2+
PANIC: PanicInfo {
3+
message: I am an example panic,
4+
location: Location {
5+
file: "src/bin/hello.rs",
6+
line: 26,
7+
col: 5,
8+
},
9+
can_unwind: true,
10+
force_no_backtrace: false,
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
MIDR { implementer=0x41 variant=0x1 arch=0xf part_no=0xd13 rev=0x3 }
2+
CPSR { N=0 Z=1 C=1 V=0 Q=0 J=0 E=0 A=0 I=1 F=1 T=0 MODE=Ok(Sys) }
3+
IMP_CBAR { 0xf0000000 }
4+
VBAR { 0x08000000 }
5+
PMSA-v8 MPUIR: Mpuir { iregions: 0, dregions: 16, non_unified: false }
6+
Region 0: Region { range: 0x0..=0x3f, shareability: NonShareable, access: ReadWriteNoEL0, no_exec: false, mair: 0, enable: false }
7+
Region 1: Region { range: 0x0..=0x3f, shareability: NonShareable, access: ReadWriteNoEL0, no_exec: false, mair: 0, enable: false }
8+
Region 2: Region { range: 0x0..=0x3f, shareability: NonShareable, access: ReadWriteNoEL0, no_exec: false, mair: 0, enable: false }
9+
Region 3: Region { range: 0x0..=0x3f, shareability: NonShareable, access: ReadWriteNoEL0, no_exec: false, mair: 0, enable: false }
10+
Region 4: Region { range: 0x0..=0x3f, shareability: NonShareable, access: ReadWriteNoEL0, no_exec: false, mair: 0, enable: false }
11+
Region 5: Region { range: 0x0..=0x3f, shareability: NonShareable, access: ReadWriteNoEL0, no_exec: false, mair: 0, enable: false }
12+
Region 6: Region { range: 0x0..=0x3f, shareability: NonShareable, access: ReadWriteNoEL0, no_exec: false, mair: 0, enable: false }
13+
Region 7: Region { range: 0x0..=0x3f, shareability: NonShareable, access: ReadWriteNoEL0, no_exec: false, mair: 0, enable: false }
14+
Region 8: Region { range: 0x0..=0x3f, shareability: NonShareable, access: ReadWriteNoEL0, no_exec: false, mair: 0, enable: false }
15+
Region 9: Region { range: 0x0..=0x3f, shareability: NonShareable, access: ReadWriteNoEL0, no_exec: false, mair: 0, enable: false }
16+
Region 10: Region { range: 0x0..=0x3f, shareability: NonShareable, access: ReadWriteNoEL0, no_exec: false, mair: 0, enable: false }
17+
Region 11: Region { range: 0x0..=0x3f, shareability: NonShareable, access: ReadWriteNoEL0, no_exec: false, mair: 0, enable: false }
18+
Region 12: Region { range: 0x0..=0x3f, shareability: NonShareable, access: ReadWriteNoEL0, no_exec: false, mair: 0, enable: false }
19+
Region 13: Region { range: 0x0..=0x3f, shareability: NonShareable, access: ReadWriteNoEL0, no_exec: false, mair: 0, enable: false }
20+
Region 14: Region { range: 0x0..=0x3f, shareability: NonShareable, access: ReadWriteNoEL0, no_exec: false, mair: 0, enable: false }
21+
Region 15: Region { range: 0x0..=0x3f, shareability: NonShareable, access: ReadWriteNoEL0, no_exec: false, mair: 0, enable: false }
22+
Region 0: Region { range: 0x0..=0x3fffffff, shareability: OuterShareable, access: ReadWrite, no_exec: true, mair: 0, enable: true }
23+
Region 1: Region { range: 0x0..=0x3f, shareability: NonShareable, access: ReadWriteNoEL0, no_exec: false, mair: 0, enable: false }
24+
Region 2: Region { range: 0x0..=0x3f, shareability: NonShareable, access: ReadWriteNoEL0, no_exec: false, mair: 0, enable: false }
25+
Region 3: Region { range: 0x0..=0x3f, shareability: NonShareable, access: ReadWriteNoEL0, no_exec: false, mair: 0, enable: false }
26+
Region 4: Region { range: 0x0..=0x3f, shareability: NonShareable, access: ReadWriteNoEL0, no_exec: false, mair: 0, enable: false }
27+
Region 5: Region { range: 0x0..=0x3f, shareability: NonShareable, access: ReadWriteNoEL0, no_exec: false, mair: 0, enable: false }
28+
Region 6: Region { range: 0x0..=0x3f, shareability: NonShareable, access: ReadWriteNoEL0, no_exec: false, mair: 0, enable: false }
29+
Region 7: Region { range: 0x0..=0x3f, shareability: NonShareable, access: ReadWriteNoEL0, no_exec: false, mair: 0, enable: false }
30+
Region 8: Region { range: 0x0..=0x3f, shareability: NonShareable, access: ReadWriteNoEL0, no_exec: false, mair: 0, enable: false }
31+
Region 9: Region { range: 0x0..=0x3f, shareability: NonShareable, access: ReadWriteNoEL0, no_exec: false, mair: 0, enable: false }
32+
Region 10: Region { range: 0x0..=0x3f, shareability: NonShareable, access: ReadWriteNoEL0, no_exec: false, mair: 0, enable: false }
33+
Region 11: Region { range: 0x0..=0x3f, shareability: NonShareable, access: ReadWriteNoEL0, no_exec: false, mair: 0, enable: false }
34+
Region 12: Region { range: 0x0..=0x3f, shareability: NonShareable, access: ReadWriteNoEL0, no_exec: false, mair: 0, enable: false }
35+
Region 13: Region { range: 0x0..=0x3f, shareability: NonShareable, access: ReadWriteNoEL0, no_exec: false, mair: 0, enable: false }
36+
Region 14: Region { range: 0x0..=0x3f, shareability: NonShareable, access: ReadWriteNoEL0, no_exec: false, mair: 0, enable: false }
37+
Region 15: Region { range: 0x0..=0x3f, shareability: NonShareable, access: ReadWriteNoEL0, no_exec: false, mair: 0, enable: false }
38+
SCTLR { IE=0 TE=0 NMFI=0 EE=0 U=1 FI=0 DZ=1 BR=1 RR=0 V=0 I=0 Z=1 SW=0 C=0 A=0 M=0 } before setting C, I and Z
39+
SCTLR { IE=0 TE=0 NMFI=0 EE=0 U=1 FI=0 DZ=1 BR=1 RR=0 V=0 I=1 Z=1 SW=0 C=1 A=0 M=0 } after
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
x = 1, y = 2, z = 3.000
2+
In _svc_handler, with arg=0xabcdef
3+
In _svc_handler, with arg=0x456789
4+
x = 1, y = 2, z = 3.000
5+
PANIC: PanicInfo {
6+
message: I am an example panic,
7+
location: Location {
8+
file: "src/bin/svc.rs",
9+
line: 29,
10+
col: 5,
11+
},
12+
can_unwind: true,
13+
force_no_backtrace: false,
14+
}

examples/mps3-an536/src/bin/generic_timer.rs

+5-10
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn main() {
2323
let cntfrq = cortex_ar::register::Cntfrq::read().0;
2424
println!("cntfrq = {:.03} MHz", cntfrq as f32 / 1_000_000.0);
2525

26-
let delay_ticks = cntfrq * 2;
26+
let delay_ticks = cntfrq / 2;
2727

2828
let mut pgt = unsafe { El1PhysicalTimer::new() };
2929
let mut vgt = unsafe { El1VirtualTimer::new() };
@@ -34,21 +34,20 @@ fn main() {
3434
for (timer, name) in [(pgt_ref, "physical"), (vgt_ref, "virtual")] {
3535
println!("Using {} timer ************************", name);
3636

37-
println!("Print five, one per second...");
37+
println!("Print five, every 100ms...");
3838
for i in 0..5 {
3939
println!("i = {}", i);
40-
timer.delay_ms(1000);
40+
timer.delay_ms(100);
4141
}
4242

4343
let now = timer.counter();
44-
println!("{} is now: {}", name, now);
4544
println!("Waiting for {} {} ticks to count up...", delay_ticks, name);
4645
timer.counter_compare_set(now + delay_ticks as u64);
4746
timer.enable(true);
4847
while !timer.interrupt_status() {
4948
core::hint::spin_loop();
5049
}
51-
println!("Matched! {} count now {}", name, timer.counter());
50+
println!("Matched! {}", name);
5251

5352
println!(
5453
"Waiting for {} {} ticks to count down...",
@@ -58,10 +57,6 @@ fn main() {
5857
while !timer.interrupt_status() {
5958
core::hint::spin_loop();
6059
}
61-
println!(
62-
"{} countdown hit zero! (and is now {})",
63-
name,
64-
timer.countdown() as i32
65-
);
60+
println!("{} countdown hit zero!", name,);
6661
}
6762
}

tests.sh

+24-8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
rustup target add armv7r-none-eabi
77
rustup target add armv7r-none-eabihf
88
rustup target add armv7a-none-eabi
9+
rustup toolchain add nightly
10+
rustup component add rust-src --toolchain=nightly
911

1012
FAILURE=0
1113

@@ -19,31 +21,45 @@ fail() {
1921
mkdir -p ./target
2022

2123
versatile_ab_cargo="--manifest-path examples/versatileab/Cargo.toml"
24+
mps3_an536_cargo="--manifest-path examples/mps3-an536/Cargo.toml"
25+
26+
my_diff() {
27+
file_a=$1
28+
file_b=$2
29+
# - Fix Windows path separators (\\) to look like UNIX ones (/) in the QEMU
30+
# output
31+
# - Fix the CRLF line endings in the files on disk, because git adds them to
32+
# text files.
33+
diff <(cat $file_a | tr -d '\r') <(cat $file_b | sed 's~\\\\~/~g')
34+
}
2235

2336
# armv7r-none-eabi tests
2437
for binary in hello registers svc; do
2538
cargo run ${versatile_ab_cargo} --target=armv7r-none-eabi --bin $binary | tee ./target/$binary-armv7r-none-eabi.out
26-
diff ./examples/versatileab/reference/$binary-armv7r-none-eabi.out ./target/$binary-armv7r-none-eabi.out || fail $binary "armv7r-none-eabi"
39+
my_diff ./examples/versatileab/reference/$binary-armv7r-none-eabi.out ./target/$binary-armv7r-none-eabi.out || fail $binary "armv7r-none-eabi"
2740
done
2841

2942
# armv7r-none-eabihf tests
3043
for binary in hello registers svc undef-exception prefetch-exception abt-exception; do
3144
cargo run ${versatile_ab_cargo} --target=armv7r-none-eabihf --bin $binary | tee ./target/$binary-armv7r-none-eabihf.out
32-
diff ./examples/versatileab/reference/$binary-armv7r-none-eabihf.out ./target/$binary-armv7r-none-eabihf.out || fail $binary "armv7r-none-eabihf"
45+
my_diff ./examples/versatileab/reference/$binary-armv7r-none-eabihf.out ./target/$binary-armv7r-none-eabihf.out || fail $binary "armv7r-none-eabihf"
3346
done
3447

3548
# armv7a-none-eabi tests
3649
for binary in hello registers svc undef-exception prefetch-exception abt-exception; do
3750
cargo run ${versatile_ab_cargo} --target=armv7a-none-eabi --bin $binary | tee ./target/$binary-armv7a-none-eabi.out
38-
diff ./examples/versatileab/reference/$binary-armv7a-none-eabi.out ./target/$binary-armv7a-none-eabi.out || fail $binary "armv7a-none-eabi"
51+
my_diff ./examples/versatileab/reference/$binary-armv7a-none-eabi.out ./target/$binary-armv7a-none-eabi.out || fail $binary "armv7a-none-eabi"
3952
done
4053

54+
# These tests only run on QEMU 9 or higher.
4155
# Ubuntu 24.04 supplies QEMU 8, which doesn't support the machine we have configured for this target
42-
# # armv8r-none-eabihf tests
43-
# for binary in hello registers svc gic; do
44-
# cargo +nightly run --target=armv8r-none-eabihf --bin $binary --features=gic -Zbuild-std=core | tee ./target/$binary-armv8r-none-eabihf.out
45-
# diff ./cortex-r-examples/reference/$binary-armv8r-none-eabihf.out ./target/$binary-armv8r-none-eabihf.out || fail $binary "armv8r-none-eabihf"
46-
# done
56+
if qemu-system-arm --version | grep "version 9"; then
57+
# armv8r-none-eabihf tests
58+
for binary in hello registers svc gic generic_timer; do
59+
cargo +nightly run ${mps3_an536_cargo} --target=armv8r-none-eabihf --bin $binary --features=gic -Zbuild-std=core | tee ./target/$binary-armv8r-none-eabihf.out
60+
my_diff ./examples/mps3-an536/reference/$binary-armv8r-none-eabihf.out ./target/$binary-armv8r-none-eabihf.out || fail $binary "armv8r-none-eabihf"
61+
done
62+
fi
4763

4864
if [ "$FAILURE" == "1" ]; then
4965
echo "***************************************************"

0 commit comments

Comments
 (0)