Skip to content
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

add qemu-run #12

Merged
merged 2 commits into from
Jul 30, 2020
Merged

add qemu-run #12

merged 2 commits into from
Jul 30, 2020

Conversation

japaric
Copy link
Member

@japaric japaric commented Jul 30, 2020

this lets us test binfmt end-to-end (encoder + decoder + singleton) on an
emulated microcontroller

To use:

$ cargo install --path qemu-run
$ cd firmware
$ cargo run --bin log
0.000000 INFO Hello!
0.000001 INFO World!
0.000002 INFO The answer is 42
0.000003 INFO S { x: 1, y: 256 }
0.000004 INFO X { y: Y { z: 42 } }

this lets us test binfmt end-to-end (encoder + decoder + singleton) on an
emulated microcontroller
@@ -12,9 +13,25 @@ fn main() -> ! {
binfmt::info!("World!");
binfmt::info!("The answer is {:u8}", 42);

// HACK cortex-m-semihosting and/or QEMU does not flush until it sees a newline :sad:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wasn't needed when piping QEMU's output (I guess the usual difference in line buffering between terminal output and process pipes)

@@ -1,5 +1,6 @@
[target.thumbv7m-none-eabi]
runner = "qemu-system-arm -cpu cortex-m3 -machine lm3s6965evb -nographic -semihosting-config enable=on,target=native -kernel"
# runner = "qemu-system-arm -cpu cortex-m3 -machine lm3s6965evb -nographic -semihosting-config enable=on,target=native -kernel"
runner = "qemu-run"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This requires installing qemu-run first, right? You could also use "cargo run --bin qemu-run" instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this gets invoked within a workspace where the default compilation target is not host that approach requires passing --target $HOST to cargo-run. Hardcoding HOST=Linux means that it won't work on macOS or Windows.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right. That's unfortunate.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could remove the default target, other than that I don't have any better suggestion. I do think not having to install part of the package can be helpful at times (it ensures that the newest version of qemu-run is automatically built and used), but if you think otherwise we can merge this as-is.

@japaric
Copy link
Member Author

japaric commented Jul 30, 2020

removed the default compilation target, set cargo run as the runner and added some Cargo aliases to avoid typing out the --target flag

@japaric japaric merged commit 6ece3ea into main Jul 30, 2020
@jonas-schievink jonas-schievink deleted the qemu-run branch October 19, 2020 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants