Rewrite & Redesign uefi firmware in Rust - shijunjing/edk2 GitHub Wiki

Why?

  • Modern firmware need modern programming language.
  • Modern firmware != simply adopt Linuxboot/Coreboot/Uboot etc. Linux-based solutions also have inherent drawbacks

First Goal

  • Enable the Rust build tool-chain and necessary libraries (memory safe + unsafe) in edk2 for single Rust module interoperability.

Long time Goal

  • Complete Uefi Rust core/library for uncompromising memory safety
  • Introduce fearless concurrency in Uefi Rust firmware
  • Binary package management, distribution and Rust firmware update

Rust background and useful links:

Working notes

20190601

jshi19@ub2-uefi-b01:~$ curl https://sh.rustup.rs -sSf | sh
Need exit and login again to update PATH env
jshi19@ub2-uefi-b01:~$ cargo install cargo-binutils

Try to build a Rust embedded project: https://github.com/ah-/anne-key, but fail as below:

jshi19@ub2-uefi-b01:~/wksp_efi/Rust$ git clone https://github.com/ah-/anne-key.git
jshi19@ub2-uefi-b01:~/wksp_efi/Rust/anne-key$ make dfu
rustup component add llvm-tools-preview
info: component 'llvm-tools-preview' for target 'x86_64-unknown-linux-gnu' is up to date
rustup target add thumbv7m-none-eabi
info: component 'rust-std' for target 'thumbv7m-none-eabi' is up to date
cargo build --release
    Updating git repository `https://github.com/hdhoang/cortex-m`
warning: spurious network error (2 tries remaining): failed to receive HTTP 200 response: got 401; class=Net (12)
warning: spurious network error (1 tries remaining): failed to receive HTTP 200 response: got 401; class=Net (12)
error: failed to resolve patches for `https://github.com/rust-lang/crates.io-index`

Caused by:
  failed to load source for a dependency on `cortex-m`

Caused by:
  Unable to update https://github.com/hdhoang/cortex-m?branch=static-system_reset2#3605ad2e

Caused by:
  failed to fetch into /home/jshi19/.cargo/git/db/cortex-m-9b34e66755859cca

Caused by:
  failed to receive HTTP 200 response: got 401; class=Net (12)
Makefile:7: recipe for target 'build' failed
make: *** [build] Error 101

Try to add the Rust proxy as below, but build still fail with same error. Need further investigation.

jshi19@ub2-uefi-b01:~/wksp_efi/Rust/anne-key$ vim ~/.cargo/config
jshi19@ub2-uefi-b01:~/wksp_efi/Rust/anne-key$ cat ~/.cargo/config
[https]
  proxy = "jshi19:Q5432*[email protected]:913"
[http]
  proxy = "jshi19:Q5432*[email protected]:913"

20190603

Successfully build the doc and code samples of the book Tao of Rust

C:\Users\jshi19\RustWorkspace>set http_proxy=...
C:\Users\jshi19\RustWorkspace>set https_proxy=...
C:\Users\jshi19\RustWorkspace>git clone https://github.com/ZhangHanDong/tao-of-rust-codes.git
C:\Users\jshi19\RustWorkspace>cd tao-of-rust-codes
Add [http] and check-revoke = false as below in Cargo.toml
C:\Users\jshi19\RustWorkspace\tao-of-rust-codes>git diff
diff --git a/Cargo.toml b/Cargo.toml
@@ -14,3 +14,6 @@ readme = "README.md"
 [dependencies]
 failures_crate = { version = "0.1", path = "./src/ch09/failures_crate" }
 csv_challenge = { version = "0.1", path = "./src/ch10/csv_challenge" }
+
+[http]
+check-revoke = false               # Indicates whether SSL certs are checked for revocation
\ No newline at end of file
C:\Users\jshi19\RustWorkspace\tao-of-rust-codes>cargo doc
    Finished dev [unoptimized + debuginfo] target(s) in 7m 15s

Change the default rustc to nightly then build all samples

C:\Users\jshi19\RustWorkspace\tao-of-rust-codes>rustup default nightly
  nightly-x86_64-pc-windows-msvc installed - rustc 1.37.0-nightly (627486af1 2019-06-02)
C:\Users\jshi19\RustWorkspace\tao-of-rust-codes>cargo build
    Finished dev [unoptimized + debuginfo] target(s) in 1m 17s