diff --git a/.github/bors.toml b/.github/bors.toml index ca42be0..f7fd9f6 100644 --- a/.github/bors.toml +++ b/.github/bors.toml @@ -1,4 +1,7 @@ block_labels = ["needs-decision"] delete_merged_branches = true required_approvals = 1 -status = ["continuous-integration/travis-ci/push"] +status = [ + "build (stable)", + "build (1.51.0)", +] diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..037725f --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,116 @@ +name: CI + +on: + push: + branches: [master, staging, trying] + pull_request: + +jobs: + build: + runs-on: ubuntu-20.04 + + continue-on-error: ${{ matrix.experimental || false }} + + strategy: + matrix: + rust: + - stable + - beta + - nightly + - 1.51.0 # Minimum supported rust version (MSRV) + include: + - rust: nightly + experimental: true + + steps: + - uses: actions/checkout@v2 + + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: ${{ matrix.rust }} + override: true + components: rustfmt, clippy, llvm-tools-preview + target: thumbv7m-none-eabi + + - name: Install Python dependencies + run: | + pip3 install --user python-dateutil linkchecker + + - name: Cache installed binaries + uses: actions/cache@v1 + id: cache-bin + with: + path: ~/cache-bin + key: cache-bin + + - name: Install mdbook + if: steps.cache-bin.outputs.cache-hit != 'true' + uses: actions-rs/install@v0.1 + with: + crate: mdbook + version: latest + + - name: Install cargo-binutils + if: steps.cache-bin.outputs.cache-hit != 'true' + uses: actions-rs/install@v0.1 + with: + crate: cargo-binutils + version: latest + + - name: Install arm-none-eabi-gcc and qemu + if: steps.cache-bin.outputs.cache-hit != 'true' + run: | + mkdir -p ~/cache-bin/arm_gcc + curl -L https://developer.arm.com/-/media/Files/downloads/gnu-rm/10.3-2021.07/gcc-arm-none-eabi-10.3-2021.07-x86_64-linux.tar.bz2 \ + | tar --strip-components=1 -C ~/cache-bin/arm_gcc -xj + + curl -L https://github.com/japaric/qemu-bin/raw/master/14.04/qemu-system-arm-2.12.0 \ + > ~/cache-bin/qemu-system-arm + chmod a+x ~/cache-bin/qemu-system-arm + + - name: Copy installed binaries to cache directory + if: steps.cache-bin.outputs.cache-hit != 'true' + run: | + cp ~/.cargo/bin/* ~/cache-bin + + - name: Put new bin directory into path + run: | + echo "$HOME/cache-bin" >> $GITHUB_PATH + echo "$HOME/cache-bin/arm_gcc/bin" >> $GITHUB_PATH + + - name: Test + run: bash ci/script.sh + env: + RUST_VERSION: ${{ matrix.rust }} + + deploy: + runs-on: ubuntu-20.04 + + needs: [build] + + if: github.event_name == 'push' && github.ref == 'refs/heads/master' + + steps: + - uses: actions/checkout@v2 + + - name: Cache installed binaries + uses: actions/cache@v1 + id: cache-bin + with: + path: ~/cache-bin + key: cache-bin + + - name: Put new bin directory into path + run: echo "$HOME/cache-bin" >> $GITHUB_PATH + + - name: Build the book + run: mdbook build + + - name: Deploy book + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: book + force_orphan: true diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7a3cf01..0000000 --- a/.travis.yml +++ /dev/null @@ -1,30 +0,0 @@ -language: rust - -matrix: - include: - - rust: stable - - rust: beta - - rust: nightly - allow_failures: - - rust: nightly - -install: - - bash ci/install.sh - - export PATH="$PATH:$PWD/gcc/bin:$PWD/qemu" - -script: - - bash ci/script.sh - -after_success: - - set -e - - bash ci/after-success.sh - -branches: - only: - - master - - staging - - trying - -notifications: - email: - on_success: never diff --git a/ci/asm/app/release.objdump b/ci/asm/app/release.objdump index c98c9ee..afdbd99 100644 --- a/ci/asm/app/release.objdump +++ b/ci/asm/app/release.objdump @@ -1,27 +1,24 @@ -app: file format ELF32-arm-little +app: file format elf32-littlearm Disassembly of section .text: -HardFault: +: b #-0x4 -main: - trap +
: + b #-0x4
-Reset: +: push {r7, lr} mov r7, sp bl #-0xa trap -DefaultExceptionHandler: - b #-0x4 - -UsageFault: - +: + b #-0x4 -HardFaultTrampoline: +: mrs r0, msp b #-0x18 diff --git a/ci/asm/app/release.vector_table b/ci/asm/app/release.vector_table index fe5a9fa..95ecd2b 100644 --- a/ci/asm/app/release.vector_table +++ b/ci/asm/app/release.vector_table @@ -1,5 +1,5 @@ -app: file format ELF32-arm-little +app: file format elf32-littlearm Contents of section .vector_table: 0000 00000120 45000000 4f000000 51000000 ... E...O...Q... diff --git a/ci/exceptions/app/app.objdump b/ci/exceptions/app/app.objdump index 2dd5057..4d0c042 100644 --- a/ci/exceptions/app/app.objdump +++ b/ci/exceptions/app/app.objdump @@ -1,120 +1,133 @@ -app: file format ELF32-arm-little +app: file format elf32-littlearm Disassembly of section .text: -main: +
: trap trap -Reset: +: + push {r7, lr} + mov r7, sp movw r1, #0x0 movw r0, #0x0 movt r1, #0x2000 movt r0, #0x2000 subs r1, r1, r0 - bl #0xe2 + bl #0x34 movw r1, #0x0 movw r0, #0x0 movt r1, #0x2000 movt r0, #0x2000 subs r2, r1, r0 - movw r1, #0x142 + movw r1, #0x16c movt r1, #0x0 bl #0x8 - bl #-0x3c + bl #-0x40 trap -DefaultExceptionHandler: - b #-0x4 +: + b #-0x4 -UsageFault: - blo.w #0x2756a <_sidata+0x274ab> +<__aeabi_memcpy>: + b.w #0x10 -__aeabi_memcpy: +<__aeabi_memset>: + mov r3, r1 + mov r1, r2 + mov r2, r3 + b.w #0x84 + +<__aeabi_memclr>: + movs r2, #0x0 + b.w #-0x10 <__aeabi_memset> + +: push {r4, r5, r6, r7, lr} - cbz r2, #0x60 + add r7, sp, #0xc + str r8, [sp, #-4]! + cbz r2, #0x10 subs r3, r2, #0x1 and r12, r2, #0x3 cmp r3, #0x3 - bhs #0x8 <__aeabi_memcpy+0x18> + bhs #0xc movs r2, #0x0 cmp.w r12, #0x0 - bne #0x32 <__aeabi_memcpy+0x4a> - b #0x4c <__aeabi_memcpy+0x66> - sub.w lr, r12, r2 - adds r3, r1, #0x1 - adds r4, r0, #0x1 + bne #0x3e + ldr r8, [sp], #4 + pop {r4, r5, r6, r7, pc} + bic r2, r2, #0x3 + add.w lr, r0, #0x1 + rsbs r4, r2, #0 + add.w r8, r1, #0x1 mvn r2, #0x3 - adds r6, r3, r2 - adds r5, r4, r2 - adds r2, #0x4 - ldrb r7, [r6, #0x3] - strb r7, [r5, #0x3] - ldrb r7, [r6, #0x4] - strb r7, [r5, #0x4] - ldrb r7, [r6, #0x5] - strb r7, [r5, #0x5] - ldrb r6, [r6, #0x6] - strb r6, [r5, #0x6] + add.w r6, r8, r2 add.w r5, lr, r2 - adds r5, #0x4 - bne #-0x20 <__aeabi_memcpy+0x24> + adds r2, #0x4 + ldrb r3, [r6, #0x3] + strb r3, [r5, #0x3] + ldrb r3, [r6, #0x4] + strb r3, [r5, #0x4] + ldrb r3, [r6, #0x5] + strb r3, [r5, #0x5] + ldrb r3, [r6, #0x6] + strb r3, [r5, #0x6] + adds r3, r4, r2 + adds r3, #0x4 + bne #-0x22 adds r2, #0x4 cmp.w r12, #0x0 - beq #0x1a <__aeabi_memcpy+0x66> + beq #-0x42 ldrb r3, [r1, r2] cmp.w r12, #0x1 strb r3, [r0, r2] - beq #0x10 <__aeabi_memcpy+0x66> + beq #-0x4c adds r3, r2, #0x1 cmp.w r12, #0x2 - ldrb r7, [r1, r3] - strb r7, [r0, r3] - beq #0x4 <__aeabi_memcpy+0x66> + ldrb r6, [r1, r3] + strb r6, [r0, r3] + beq #-0x58 adds r2, #0x2 ldrb r1, [r1, r2] strb r1, [r0, r2] + ldr r8, [sp], #4 pop {r4, r5, r6, r7, pc} -__aeabi_memset: - push {r4, lr} - cmp r1, #0x0 - it eq - popeq {r4, pc} - subs r3, r1, #0x1 - and r12, r1, #0x3 +: + push {r4, r6, r7, lr} + add r7, sp, #0x8 + cbz r2, #0x3e + subs r3, r2, #0x1 + and r12, r2, #0x3 cmp r3, #0x3 - bhs #0x2 <__aeabi_memset+0x16> - movs r1, #0x0 - b #0x1e <__aeabi_memset+0x36> - sub.w lr, r12, r1 - adds r1, r0, #0x1 - mvn r3, #0x3 - adds r4, r1, r3 - adds r3, #0x4 - strb r2, [r4, #0x6] - strb r2, [r4, #0x5] - strb r2, [r4, #0x4] - strb r2, [r4, #0x3] - add.w r4, lr, r3 + bhs #0x2 + movs r2, #0x0 + b #0x22 + bic r2, r2, #0x3 + add.w lr, r0, #0x1 + rsbs r3, r2, #0 + mvn r2, #0x3 + add.w r4, lr, r2 + adds r2, #0x4 + strb r1, [r4, #0x6] + strb r1, [r4, #0x5] + strb r1, [r4, #0x4] + strb r1, [r4, #0x3] + adds r4, r3, r2 adds r4, #0x4 - bne #-0x16 <__aeabi_memset+0x20> - adds r1, r3, #0x4 + bne #-0x16 + adds r2, #0x4 cmp.w r12, #0x0 itt ne - strbne r2, [r0, r1] + strbne r1, [r0, r2] cmpne.w r12, #0x1 - bne #0x0 <__aeabi_memset+0x46> - pop {r4, pc} - add r0, r1 + bne #0x0 + pop {r4, r6, r7, pc} + add r2, r0 cmp.w r12, #0x2 - strb r2, [r0, #0x1] + strb r1, [r2, #0x1] it ne - strbne r2, [r0, #0x2] - pop {r4, pc} - -__aeabi_memclr: - movs r2, #0x0 - b.w #-0x5a <__aeabi_memset> + strbne r1, [r2, #0x2] + pop {r4, r6, r7, pc} diff --git a/ci/exceptions/app/app.vector_table.objdump b/ci/exceptions/app/app.vector_table.objdump index 313fc25..4b18b35 100644 --- a/ci/exceptions/app/app.vector_table.objdump +++ b/ci/exceptions/app/app.vector_table.objdump @@ -1,8 +1,8 @@ -app: file format ELF32-arm-little +app: file format elf32-littlearm Contents of section .vector_table: - 0000 00000120 45000000 7f000000 7f000000 ... E........... - 0010 7f000000 7f000000 7f000000 00000000 ................ - 0020 00000000 00000000 00000000 7f000000 ................ - 0030 00000000 00000000 7f000000 7f000000 ................ + 0000 00000120 45000000 83000000 83000000 ... E........... + 0010 83000000 83000000 83000000 00000000 ................ + 0020 00000000 00000000 00000000 83000000 ................ + 0030 00000000 00000000 83000000 83000000 ................ diff --git a/ci/exceptions/app/src/main.rs b/ci/exceptions/app/src/main.rs index d4ca74e..c669e44 100644 --- a/ci/exceptions/app/src/main.rs +++ b/ci/exceptions/app/src/main.rs @@ -10,5 +10,5 @@ entry!(main); fn main() -> ! { // this executes the undefined instruction (UDF) and causes a HardFault exception - unsafe { intrinsics::abort() } + intrinsics::abort() } diff --git a/ci/exceptions/app2/src/main.rs b/ci/exceptions/app2/src/main.rs index 16148e0..8b10a07 100644 --- a/ci/exceptions/app2/src/main.rs +++ b/ci/exceptions/app2/src/main.rs @@ -9,7 +9,7 @@ use rt::entry; entry!(main); fn main() -> ! { - unsafe { intrinsics::abort() } + intrinsics::abort() } #[no_mangle] diff --git a/ci/install.sh b/ci/install.sh deleted file mode 100644 index c27a6d5..0000000 --- a/ci/install.sh +++ /dev/null @@ -1,32 +0,0 @@ -set -euxo pipefail - -main() { - local tag=$(git ls-remote --tags --refs --exit-code https://github.com/rust-lang-nursery/mdbook \ - | cut -d/ -f3 \ - | grep -E '^v[0-9.]+$' \ - | sort --version-sort \ - | tail -n1) - - curl -LSfs https://japaric.github.io/trust/install.sh | \ - sh -s -- --git rust-lang-nursery/mdbook --tag $tag - - rustup target add thumbv7m-none-eabi - - # install arm-none-eabi-gcc - mkdir gcc - - curl -L https://developer.arm.com/-/media/Files/downloads/gnu-rm/7-2018q2/gcc-arm-none-eabi-7-2018-q2-update-linux.tar.bz2?revision=bc2c96c0-14b5-4bb4-9f18-bceb4050fee7?product=GNU%20Arm%20Embedded%20Toolchain,64-bit,,Linux,7-2018-q2-update | tar --strip-components=1 -C gcc -xj - - mkdir qemu - curl -L https://github.com/japaric/qemu-bin/raw/master/14.04/qemu-system-arm-2.12.0 > qemu/qemu-system-arm - chmod +x qemu/qemu-system-arm - - rustup component add llvm-tools-preview - - curl -LSfs https://japaric.github.io/trust/install.sh | \ - sh -s -- --git rust-embedded/cargo-binutils --tag v0.1.4 - - pip install linkchecker --user -} - -main diff --git a/ci/logging/app4/dev.objdump b/ci/logging/app4/dev.objdump index ed7fe8a..ef77e12 100644 --- a/ci/logging/app4/dev.objdump +++ b/ci/logging/app4/dev.objdump @@ -1,3 +1,3 @@ 00000000 g O .log 00000001 Goodbye 00000001 g O .log 00000001 Hello, world! -00000001 .log 00000000 __log_warning_start__ +00000001 g .log 00000000 __log_warning_start__ diff --git a/ci/main/app/app.objdump b/ci/main/app/app.objdump index f9f8df2..b04d83a 100644 --- a/ci/main/app/app.objdump +++ b/ci/main/app/app.objdump @@ -1,17 +1,17 @@ -app: file format ELF32-arm-little +app: file format elf32-littlearm Disassembly of section .text: -main: +
: sub sp, #4 movs r0, #42 str r0, [sp] b #-2 b #-4 -Reset: +: push {r7, lr} mov r7, sp bl #-18 diff --git a/ci/main/app4/src/main.rs b/ci/main/app4/src/main.rs index 89dcf58..2c1cb09 100644 --- a/ci/main/app4/src/main.rs +++ b/ci/main/app4/src/main.rs @@ -15,7 +15,7 @@ fn main() -> ! { // check that DATA is properly initialized if ptr::read_volatile(&DATA) != 1 { // this makes QEMU crash - asm!("BKPT" :::: "volatile"); + asm!("BKPT"); } } diff --git a/ci/memory-layout/app.text.objdump b/ci/memory-layout/app.text.objdump index 423e462..77a3a6b 100644 --- a/ci/memory-layout/app.text.objdump +++ b/ci/memory-layout/app.text.objdump @@ -1,10 +1,10 @@ -app: file format ELF32-arm-little +app: file format elf32-littlearm Disassembly of section .text: -Reset: +: sub sp, #4 movs r0, #42 str r0, [sp] diff --git a/ci/memory-layout/app.vector_table.objdump b/ci/memory-layout/app.vector_table.objdump index 025bffb..2191658 100644 --- a/ci/memory-layout/app.vector_table.objdump +++ b/ci/memory-layout/app.vector_table.objdump @@ -1,5 +1,5 @@ -app: file format ELF32-arm-little +app: file format elf32-littlearm Contents of section .vector_table: 0000 00000120 09000000 ... .... diff --git a/ci/script.sh b/ci/script.sh index dafb7be..7d3d959 100644 --- a/ci/script.sh +++ b/ci/script.sh @@ -40,7 +40,7 @@ main() { # check presence of the `rust_begin_unwind` symbol diff app.o.nm \ - <(cargo nm -- target/thumbv7m-none-eabi/debug/deps/app-*.o | grep '[0-9]* [^N] ') + <(cargo nm -- $(pwd)/target/thumbv7m-none-eabi/debug/deps/app-*.o | grep '[0-9]* [^N] ') edition_check @@ -51,11 +51,11 @@ main() { # check that the Reset symbol is there diff -b app.text.objdump \ - <(cargo objdump --bin app -- -d -no-show-raw-insn -no-leading-addr) + <(cargo objdump --bin app -- -d --no-show-raw-insn --no-leading-addr) # check that the reset vector is there and has the right address diff -b app.vector_table.objdump \ - <(cargo objdump --bin app -- -s -section .vector_table) + <(cargo objdump --bin app -- -s --section .vector_table) qemu_check target/thumbv7m-none-eabi/debug/app @@ -69,7 +69,7 @@ main() { # check that the disassembly matches pushd app diff -b app.objdump \ - <(cargo objdump --bin app -- -d -no-show-raw-insn -no-leading-addr) + <(cargo objdump --bin app -- -d --no-show-raw-insn --no-leading-addr) # disabled because of rust-lang/rust#53964 # edition_check popd @@ -86,7 +86,7 @@ main() { popd # NOTE(nightly) this will require nightly until core::arch::arm::udf is stabilized - if [ $TRAVIS_RUST_VERSION = nightly ]; then + if [ $RUST_VERSION = nightly ]; then pushd app4 cargo build qemu_check target/thumbv7m-none-eabi/debug/app @@ -98,13 +98,13 @@ main() { # # exception handling # NOTE(nightly) this will require nightly until core::arch::arm::udf is stabilized - if [ $TRAVIS_RUST_VERSION = nightly ]; then + if [ $RUST_VERSION = nightly ]; then pushd exceptions # check that the disassembly matches pushd app diff -b app.objdump \ - <(cargo objdump --bin app --release -- -d -no-show-raw-insn -print-imm-hex -no-leading-addr) + <(cargo objdump --bin app --release -- -d --no-show-raw-insn --print-imm-hex --no-leading-addr) diff -b app.vector_table.objdump \ <(cargo objdump --bin app --release -- -s -j .vector_table) edition_check @@ -125,7 +125,7 @@ main() { # check that the disassembly matches pushd app diff -b release.objdump \ - <(cargo objdump --bin app --release -- -d -no-show-raw-insn -print-imm-hex -no-leading-addr) + <(cargo objdump --bin app --release -- -d --no-show-raw-insn --print-imm-hex --no-leading-addr) diff release.vector_table \ <(cargo objdump --bin app --release -- -s -j .vector_table) edition_check @@ -142,7 +142,7 @@ main() { # check that the disassembly matches pushd app2 diff -b release.objdump \ - <(cargo objdump --bin app --release -- -d -no-show-raw-insn -print-imm-hex -no-leading-addr) + <(cargo objdump --bin app --release -- -d --no-show-raw-insn --print-imm-hex --no-leading-addr) diff release.vector_table \ <(cargo objdump --bin app --release -- -s -j .vector_table) edition_check @@ -231,7 +231,7 @@ main() { # # DMA # NOTE(nightly) this will require nightly until core::pin is stabilized (1.33) - if [ $TRAVIS_RUST_VERSION = nightly ]; then + if [ $RUST_VERSION = nightly ]; then pushd dma cargo build --examples popd @@ -260,7 +260,4 @@ qemu_check() { rm .stdout .stderr } -# don't run this on successful merges -if [[ $TRAVIS_BRANCH != main || $TRAVIS_PULL_REQUEST != false ]]; then - main -fi +main