Skip to content

Commit

Permalink
Merge pull request #14 from iqlusioninc/drop-xargo
Browse files Browse the repository at this point in the history
drop cargo-xbuild build dependency
  • Loading branch information
japaric authored Jan 27, 2020
2 parents 8970b4b + 44b7fc1 commit 5b5de61
Show file tree
Hide file tree
Showing 25 changed files with 107 additions and 173 deletions.
96 changes: 26 additions & 70 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
name: Rust

jobs:
# TODO switch to beta and then to stable
check:
name: Check firmware
runs-on: ubuntu-latest
Expand All @@ -18,32 +19,14 @@ jobs:
- name: Install nightly toolchain
uses: actions-rs/toolchain@v1
with:
components: rust-src # needed by cargo-xbuild
target: armv7a-none-eabi
toolchain: nightly
override: true

- name: Cache cargo installs
id: cache-cargo-bin
uses: actions/cache@v1
with:
path: ~/.cargo/bin
key: ${{ runner.os }}-cargo-bin-${{ hashFiles('dev-dependencies.txt') }}

- name: Install dev-dependencies
# NOTE we need this check because the cache action won't restore `.cargo/.{crates2.json,.crates.toml}`
if: steps.cache-cargo-bin.outputs.cache-hit != 'true'
# FIXME `cache-hit` is not being set when the cache is found
# (is it because there's a permission error when un-tar-ing it?)
run: |
which cargo-audit || cargo install `cat dev-dependencies.txt`
- name: Set environment for cargo-xbuild
run: echo ::set-env name=RUST_TARGET_PATH::$(echo ${GITHUB_WORKSPACE}/firmware )

- name: Run cargo xcheck
- name: Run cargo check
working-directory: ./firmware
run: |
cargo xcheck
cargo check
# NOTE the `common` directory is currently empty so this is a no-op
# host-test:
Expand Down Expand Up @@ -110,35 +93,25 @@ jobs:
# - name: Install nightly toolchain
# uses: actions-rs/toolchain@v1
# with:
# components: rust-src # needed by cargo-xbuild
# target: armv7a-none-eabi
# toolchain: nightly
# override: true

# - name: Cache cargo installs
# id: cache-cargo-bin
# uses: actions/cache@v1
# with:
# path: ~/.cargo/bin
# key: ${{ runner.os }}-cargo-bin-${{ hashFiles('dev-dependencies.txt') }}

# - name: Install QEMU
# run: |
# sudo apt update
# sudo apt install qemu-system-arm

# - name: Install dev-dependencies
# if: steps.cache-cargo-bin.outputs.cache-hit != 'true'
# - name: Install flip-lld
# run: |
# cargo install `cat dev-dependencies.txt`

# - name: Set environment for cargo-xbuild
# run: echo ::set-env name=RUST_TARGET_PATH::$(echo ${GITHUB_WORKSPACE}/firmware )
# cargo install --git https://github.com/japaric/flip-lld

# - name: Run examples
# working-directory: ./firmware/usbarmory
# run: |
# cargo xrun --example qemu-hello --release
# cargo run --example qemu-hello --release

# TODO switch to beta and then to stable
# test that all our examples link
it_links:
name: Check that all examples link in dev and release mode
Expand All @@ -150,39 +123,36 @@ jobs:
- name: Install nightly toolchain
uses: actions-rs/toolchain@v1
with:
components: rust-src # needed by cargo-xbuild
target: armv7a-none-eabi
toolchain: nightly
override: true

- name: Cache cargo installs
id: cache-cargo-bin
uses: actions/cache@v1
with:
path: ~/.cargo/bin
key: ${{ runner.os }}-cargo-bin-${{ hashFiles('dev-dependencies.txt') }}
# - name: Cache cargo installs
# id: cache-cargo-bin
# uses: actions/cache@v1
# with:
# path: ~/.cargo/bin
# key: ${{ runner.os }}-cargo-bin-${{ hashFiles('dev-dependencies.txt') }}

- name: Install dev-dependencies
if: steps.cache-cargo-bin.outputs.cache-hit != 'true'
run: |
which cargo-audit || cargo install `cat dev-dependencies.txt`
# - name: Install dev-dependencies
# if: steps.cache-cargo-bin.outputs.cache-hit != 'true'
# run: |
# which flip-lld || cargo install `cat dev-dependencies.txt`

# TODO cache in dev-dependencies.txt when available on crates.io
- name: Install flip-lld
run: |
cargo install --git https://github.com/japaric/flip-lld
- name: Set environment for cargo-xbuild
run: echo ::set-env name=RUST_TARGET_PATH::$(echo ${GITHUB_WORKSPACE}/firmware )

- name: Build examples using the dev profile
working-directory: ./firmware/usbarmory
run: |
cargo xbuild --examples
cargo build --examples
- name: Build examples using the release profile
working-directory: ./firmware/usbarmory
run: |
cargo xbuild --examples --release
cargo build --examples --release
fmt:
name: Rustfmt
Expand All @@ -205,39 +175,25 @@ jobs:
run: |
cargo fmt --all -- --check
# TODO switch to beta and then to stable
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install stable toolchain
- name: Install nightly toolchain
uses: actions-rs/toolchain@v1
with:
components: rust-src # needed by cargo-xbuild
target: armv7a-none-eabi
toolchain: nightly
override: true

- name: Cache cargo installs
id: cache-cargo-bin
uses: actions/cache@v1
with:
path: ~/.cargo/bin
key: ${{ runner.os }}-cargo-bin-${{ hashFiles('dev-dependencies.txt') }}

- name: Install dev-dependencies
if: steps.cache-cargo-bin.outputs.cache-hit != 'true'
run: |
which cargo-audit || cargo install `cat dev-dependencies.txt`
- name: Install clippy
run: rustup component add clippy

- name: Set environment for cargo-xbuild
run: echo ::set-env name=RUST_TARGET_PATH::$(echo ${GITHUB_WORKSPACE}/firmware )

- name: Run cargo clippy
working-directory: ./firmware
run: |
cargo xclippy -- -D warnings
cargo clippy -- -D warnings
2 changes: 1 addition & 1 deletion dev-dependencies.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
cargo-audit cargo-xbuild
cargo-audit
4 changes: 2 additions & 2 deletions firmware/.cargo/config
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build]
target = "armv7-none-eabi" # soft float ABI, emulated float operations
# target = "armv7-none-eabihf" # hard float ABI, float operations on hardware
target = "armv7a-none-eabi" # soft float ABI, emulated float operations
# target = "armv7a-none-eabihf" # hard float ABI, float operations on hardware
6 changes: 3 additions & 3 deletions firmware/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions firmware/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ Cortex-A7.
There are two compilation targets (see `--target` in `rustc -h`) for this
embedded target:

- armv7-none-eabihf, hard float ABI; float operations are performed on the
- armv7a-none-eabihf, hard float ABI; float operations are performed on the
hardware FPU. NOTE: currently untested

- armv7-none-eabi, soft float ABI; float operations are emulated
- armv7a-none-eabi, soft float ABI; float operations are emulated

The default compilation target for the whole directory is currently set to the
most compatible soft float target. If you need to use the hard float target
modify `.cargo/config`, or pass `--target armv7-none-eabihf` to Xargo.

*NOTE* all the code under this directory needs Rust nightly and Xargo. See the
README in the [`usbarmory`](usbarmory) directory for more information.
modify `.cargo/config`, or pass `--target armv7a-none-eabihf` to Cargo.
27 changes: 0 additions & 27 deletions firmware/armv7-none-eabi.json

This file was deleted.

27 changes: 0 additions & 27 deletions firmware/armv7-none-eabihf.json

This file was deleted.

5 changes: 5 additions & 0 deletions firmware/cortex-a/asm.s
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,8 @@ __isb:
__wfi:
wfi
bx lr

.global __udf
.section .text.__udf
__udf:
udf
4 changes: 2 additions & 2 deletions firmware/cortex-a/assemble.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ main() {

# NOTE: cflags taken from cc 1.0.49 / armv7-unknown-linux-gnueabi
arm-none-eabi-as -march=armv7-a asm.s -o bin/$pkg_name.o
ar crs bin/armv7-none-eabi.a bin/$pkg_name.o
ar crs bin/armv7a-none-eabi.a bin/$pkg_name.o

# cc uses the same flags for the gnueabihf variant
arm-none-eabi-as -march=armv7-a+vfpv3 asm.s -o bin/$pkg_name.o
ar crs bin/armv7-none-eabihf.a bin/$pkg_name.o
ar crs bin/armv7a-none-eabihf.a bin/$pkg_name.o

rm bin/*.o
}
Expand Down
Binary file removed firmware/cortex-a/bin/armv7-none-eabi.a
Binary file not shown.
Binary file removed firmware/cortex-a/bin/armv7-none-eabihf.a
Binary file not shown.
Binary file added firmware/cortex-a/bin/armv7a-none-eabi.a
Binary file not shown.
Binary file added firmware/cortex-a/bin/armv7a-none-eabihf.a
Binary file not shown.
13 changes: 11 additions & 2 deletions firmware/cortex-a/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//! Low level access to Cortex-A processors

// FIXME replace inline assembly with external assembly
#![feature(asm)]
#![no_std]
#![warn(missing_docs, rust_2018_idioms, unused_qualifications)]

Expand Down Expand Up @@ -110,3 +108,14 @@ pub fn wfi() {

unsafe { __wfi() }
}

/// UnDeFined instruction
///
/// Calling this will result in a `UndefinedInstrution` exception
pub fn udf() -> ! {
extern "C" {
fn __udf() -> !;
}

unsafe { __udf() }
}
1 change: 1 addition & 0 deletions firmware/cortex-a/src/register/cpsr.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Current Program Status Register

/// Reads the CPSR register
#[cfg(TODO = "external-assembly")]
pub fn read() -> u32 {
let cpsr: u32;
unsafe { asm!("mrs $0, cpsr" : "=r"(cpsr)) }
Expand Down
1 change: 1 addition & 0 deletions firmware/cortex-a/src/register/scr.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Security Control Register

/// Reads the SCR register
#[cfg(TODO = "external-assembly")]
pub fn read() -> u16 {
let scr;
unsafe { asm!("mrc p15, 0, $0, c1, c1, 0" : "=r"(scr)) }
Expand Down
1 change: 1 addition & 0 deletions firmware/cortex-a/src/register/sctlr.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! System Control Register

/// Reads the SCTLR register
#[cfg(TODO = "external-assembly")]
pub fn read() -> u32 {
let sctlr;
unsafe { asm!("mrc p15, 0, $0, c1, c1, 0" : "=r"(sctlr)) }
Expand Down
4 changes: 2 additions & 2 deletions firmware/usbarmory-rt/assemble.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ main() {
# NOTE: cflags taken from cc 1.0.49 / armv7-unknown-linux-gnueabi
arm-none-eabi-as -march=armv7-a asm-common.s -o bin/$crate-common.o
arm-none-eabi-as -march=armv7-a asm-no-vfp.s -o bin/$crate-no-vfp.o
ar crs bin/armv7-none-eabi.a bin/$crate-{common,no-vfp}.o
ar crs bin/armv7a-none-eabi.a bin/$crate-{common,no-vfp}.o

arm-none-eabi-as -march=armv7-a+vfpv3 asm-common.s -o bin/$crate-common.o
arm-none-eabi-as -march=armv7-a+vfpv3 asm-vfp.s -o bin/$crate-vfp.o
ar crs bin/armv7-none-eabihf.a bin/$crate-{common,vfp}.o
ar crs bin/armv7a-none-eabihf.a bin/$crate-{common,vfp}.o

rm bin/*.o
}
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions firmware/usbarmory/.cargo/config
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[target.armv7-none-eabi]
[target.armv7a-none-eabi]
runner = "qemu-system-arm -cpu cortex-a7 -machine mcimx6ul-evk -nographic -semihosting-config enable=on,target=native -kernel"
rustflags = [
"-C", "linker=flip-lld",
"-C", "link-arg=-Tlink.x",
]

[target.armv7-none-eabihf]
[target.armv7a-none-eabihf]
rustflags = [
"-C", "linker=flip-lld",
"-C", "link-arg=-Tlink.x",
]

[build]
target = "armv7-none-eabi"
target = "armv7a-none-eabi"
Loading

0 comments on commit 5b5de61

Please sign in to comment.