From 5b1443a91c4293d4b0c4fb956d67cf1b03a00906 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Wed, 28 Jun 2023 14:48:17 +1000 Subject: [PATCH] hashes/embedded: Add script dir and README To help folk work out how to run the `hashes/embedded` test crate copy over the `script` directory and an updated version of the `README` from `embedded/bitcoin`. --- hashes/embedded/README.md | 30 ++++++++++++++++++++++++++++ hashes/embedded/scripts/env.sh | 2 ++ hashes/embedded/scripts/install-deps | 3 +++ 3 files changed, 35 insertions(+) create mode 100644 hashes/embedded/README.md create mode 100644 hashes/embedded/scripts/env.sh create mode 100755 hashes/embedded/scripts/install-deps diff --git a/hashes/embedded/README.md b/hashes/embedded/README.md new file mode 100644 index 00000000..60e4e1a1 --- /dev/null +++ b/hashes/embedded/README.md @@ -0,0 +1,30 @@ +# Running + +To run the embedded test, first prepare your environment: + +```shell +sudo ./scripts/install-deps +rustup +nightly target add thumbv7m-none-eabi +``` + +Then: + +```shell +source ./scripts/env.sh && cargo +nightly run --target thumbv7m-none-eabi +``` + +Output should be something like: + +```text +hash:ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad hash_check:ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad +hash:ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad hash_check:ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad +``` + +## Cleanup + +After sourcing `scripts/env.sh` and _before_ building again using another target +you'll want to unset `RUSTFLAGS` otherwise you'll get linker errors. + +```shell +unset RUSTFLAGS +``` diff --git a/hashes/embedded/scripts/env.sh b/hashes/embedded/scripts/env.sh new file mode 100644 index 00000000..125162b6 --- /dev/null +++ b/hashes/embedded/scripts/env.sh @@ -0,0 +1,2 @@ +export RUSTFLAGS="-C link-arg=-Tlink.x" +export CARGO_TARGET_THUMBV7M_NONE_EABI_RUNNER="qemu-system-arm -cpu cortex-m3 -machine mps2-an385 -nographic -semihosting-config enable=on,target=native -kernel" diff --git a/hashes/embedded/scripts/install-deps b/hashes/embedded/scripts/install-deps new file mode 100755 index 00000000..d22806dd --- /dev/null +++ b/hashes/embedded/scripts/install-deps @@ -0,0 +1,3 @@ +#!/bin/sh + +apt install gcc-arm-none-eabi qemu-system-arm gdb-multiarch