From fd05fa560f816057e0e29aee094e039d36558d23 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 8 Jun 2019 23:01:37 +0800 Subject: [PATCH] firmware: compile for riscv32i --- firmware/Cargo.lock | 24 ++++++++++++------------ firmware/Cargo.toml | 4 ++++ firmware/default.nix | 10 +++++++--- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/firmware/Cargo.lock b/firmware/Cargo.lock index d92775d..fdf9d1e 100644 --- a/firmware/Cargo.lock +++ b/firmware/Cargo.lock @@ -18,7 +18,7 @@ name = "helloworld" version = "0.0.0" dependencies = [ "panic-halt 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "riscv-rt 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "riscv-rt 0.5.0 (git+https://github.com/m-labs/riscv-rt)", ] [[package]] @@ -71,7 +71,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "riscv" version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/m-labs/riscv#f735652b622981df8850959645a8be6945da9029" dependencies = [ "bare-metal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "bit_field 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -80,22 +80,22 @@ dependencies = [ [[package]] name = "riscv-rt" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/m-labs/riscv-rt#e9ba6738a26f6e9e3b44b118dced942ad7b7e52c" dependencies = [ "r0 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "riscv 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "riscv-rt-macros 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "riscv 0.5.2 (git+https://github.com/m-labs/riscv)", + "riscv-rt-macros 0.1.5 (git+https://github.com/m-labs/riscv-rt)", ] [[package]] name = "riscv-rt-macros" version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/m-labs/riscv-rt#e9ba6738a26f6e9e3b44b118dced942ad7b7e52c" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -121,7 +121,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "syn" -version = "0.15.34" +version = "0.15.35" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", @@ -144,11 +144,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9" "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" "checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" -"checksum riscv 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "00f3ec73803f144a6474819070dfcf0b0d1662e1bd8845956850ee8f8cfbc69b" -"checksum riscv-rt 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "af8c51c09a5445950a53431d3f8ca9d90ba4062cd86b5407c3e16d8c2558c17d" -"checksum riscv-rt-macros 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e9ba967e1f2902cc37cc4722f7ef4dd5e08cec430c97586424d6f679eb51b695" +"checksum riscv 0.5.2 (git+https://github.com/m-labs/riscv)" = "" +"checksum riscv-rt 0.5.0 (git+https://github.com/m-labs/riscv-rt)" = "" +"checksum riscv-rt-macros 0.1.5 (git+https://github.com/m-labs/riscv-rt)" = "" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)" = "a1393e4a97a19c01e900df2aec855a29f71cf02c402e2f443b8d2747c25c5dbe" +"checksum syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)" = "641e117d55514d6d918490e47102f7e08d096fdde360247e4a10f7a91a8478d3" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" diff --git a/firmware/Cargo.toml b/firmware/Cargo.toml index f81b311..a239017 100644 --- a/firmware/Cargo.toml +++ b/firmware/Cargo.toml @@ -6,6 +6,10 @@ version = "0.0.0" panic-halt = "0.2.0" riscv-rt = "0.5.0" +[patch.crates-io] +riscv = { git = "https://github.com/m-labs/riscv" } +riscv-rt = { git = "https://github.com/m-labs/riscv-rt" } + [profile.release] codegen-units = 1 incremental = false diff --git a/firmware/default.nix b/firmware/default.nix index 2e457a9..c9bc25d 100644 --- a/firmware/default.nix +++ b/firmware/default.nix @@ -1,16 +1,20 @@ -{ rustPlatform, rust-riscv32i-crates, binutils-riscv32 }: +{ rustPlatform, rust-riscv32i-crates, binutils-riscv32, rustc, cargo }: rustPlatform.buildRustPackage rec { name = "helloworld"; version = "0.0.0"; src = ./.; - cargoSha256 = "1j8ipk7mwf6jqjnddpvkdydhgl7lfddxkv6p1vhzlfhqlf8am42j"; + cargoSha256 = "0kf2pnfylfmzm0qvi4jfci43qvrnj1v5f037sb9zpvfqyddhdffl"; + + # HACK - rustc overlay does not update rustPlatform. Find out why. + configurePhase = ''echo XXX ${rustPlatform.rust.rustc} ${rustPlatform.rust.cargo}''; buildPhase = '' export CARGO_HOME=$(mktemp -d cargo-home.XXX) export RUSTFLAGS="-L ${rust-riscv32i-crates}/lib/rustlib/riscv32i-unknown-none-elf/lib -C linker=${binutils-riscv32}/bin/riscv32-unknown-elf-ld -C link-arg=-Tlink.x" - cargo build --release --target riscv32imc-unknown-none-elf + export RUSTC=${rustc}/bin/rustc + ${cargo}/bin/cargo build --release --target riscv32i-unknown-none-elf ''; doCheck = false;