-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[CI] Run a thumbv7m-none-eabi
binary using qemu-system-arm
[IRR-2018-embedded]
#53996
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
2747775
[ci] add qemu-system-arm in docker image
sekineh 502023a
[ci] thumbv7m-none-eabi: build lm3s6965evb and runon QEMU
sekineh 719a592
[ci] thumbv7m-none-eabi: add more variable.
sekineh a04754f
[ci] run-make/thumb-none-qemu: uses cortex-m-rt crate.
sekineh fdf4d6e
[ci] run-make/thumb-none-qemu: add thumbv6m-none-qemu
sekineh 5b0f486
[ci] run-make/thumb-none-qemu: transfer logic to script.sh
sekineh a4faa5e
[ci] run-make/thumb-none-qemu: transfer logic to script.sh (2)
sekineh 8d2b2ee
[ci] run-make/thumb-none-qemu: add example crate.
sekineh f40fd4b
[ci] run both debug and release
sekineh 3064e0a
[ci] fix tidy warning.
sekineh 06d0a71
[ci] clean up potentially harmful envs
sekineh 7cac7b6
[ci] run-make/thumb-none-qemu: use GNU LD.
sekineh 35bbcf1
[ci] fix tidy warning.
sekineh f872303
[ci] run-make/thumb-none-qemu: add .cargo/config
sekineh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,33 @@ | ||
-include ../../run-make-fulldeps/tools.mk | ||
|
||
# How to run this | ||
# $ ./x.py clean | ||
# $ ./x.py test --target thumbv7m-none-eabi src/test/run-make | ||
|
||
ifneq (,$(filter $(TARGET),thumbv6m-none-eabi thumbv7m-none-eabi)) | ||
|
||
# For cargo setting | ||
RUSTC := $(RUSTC_ORIGINAL) | ||
LD_LIBRARY_PATH := $(HOST_RPATH_DIR) | ||
# We need to be outside of 'src' dir in order to run cargo | ||
WORK_DIR := $(TMPDIR) | ||
HERE := $(shell pwd) | ||
|
||
|
||
# hint: we could set variables per $(TARGET) basis in order to support other targets. | ||
CRATE := cortex-m-rt | ||
CRATE_URL := https://github.com/rust-embedded/cortex-m-rt | ||
CRATE_SHA1 := 62972c8a89ff54b76f9ef0d600c1fcf7a233aabd | ||
|
||
all: | ||
env | ||
mkdir -p $(WORK_DIR) | ||
-cd $(WORK_DIR) && rm -rf $(CRATE) | ||
cd $(WORK_DIR) && bash -x $(HERE)/../git_clone_sha1.sh $(CRATE) $(CRATE_URL) $(CRATE_SHA1) | ||
cd $(WORK_DIR)/$(CRATE) && $(CARGO) run --target $(TARGET) --example qemu | grep "x = 42" | ||
cd $(WORK_DIR)/$(CRATE) && $(CARGO) run --target $(TARGET) --example qemu --release | grep "x = 42" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move logic l23-28 into separate file like script.sh? It will make error log clearer. |
||
else | ||
|
||
all: | ||
|
||
endif |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qemu-system-arm
only supports full system emulation of the LM3S6965 and LM3S811 microcontrollers. They are both Cortex-M3 microcontrollers so we can test thethumbv6m-none-eabi
andthumbv7m-none-eabi
targets with either QEMU target. Thethumbv7em-none-eabi
andthumbv7em-none-eabihf
targets have incompatible ISAs and they can crash QEMU.It would be great to also test the
thumbv6m-none-eabi
target here since it's an older ARM architecture. If you are up to it you can do that in a follow-up PR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahem, older... ;) Cortex-M0 is still very relevant, is there any support for a CM0 MCU in qemu?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@therealprof I've run 4 binaries on
qemu-system-arm
. As I remember, some worked in different board setting. My theory is if an ISA (thumbv6m-none-eabi
) is roughly a subset of another (thumbv7m-none-eabi
), and there's no harmful register changes, it has chance to run successfully. I'll try with existing qemu setting forthumbv6m
(Cortex-M0) also.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sekineh
thumbv6m-none-eabi
is indeed a subset ofthumbv7m-none-eabi
and code might run just fine on higher ISA versions. However to be on the safe(r) side you really want to test on a Cortex-M0(+) target or emulation.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@therealprof these are the Cortex CPUs QEMU 3.0.0 supports:
No
cortex-m0
orcortex-m4f
but you can run code compiled forthumbv6m-none-eabi
using-cpu cortex-m3
since the M0 ISA is a subset of the M3 ISA. We can't run code compiled for thethumbv7em-none-eabihf
though because the FPU instructions crash QEMU.I'm not entirely sure if
-machine
is completely orthogonal to-cpu
but I would prefer not to mix a Cortex-M3machine
with-cpu cortex-m4
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I successfully ran the
thumv6m-none-eabi
binary on qemu-cpu cortex-m3