From 48a41abe75c2ec5ab4e55af2af4114497ff120fe Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 10:06:50 +0000 Subject: [PATCH 01/25] Add tarpaulin --- .devcontainer/Dockerfile | 11 +++++++++-- .devcontainer/devcontainer.json | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 352df6e..a98bf73 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -49,6 +49,7 @@ RUN dnf update -y && \ make \ clang \ libusb1-devel \ + openssl-devel \ 'dnf-command(copr)' && \ dnf copr enable -y rleh/arm-none-eabi-gdb && \ dnf install -y --setopt=keepcache=0 arm-none-eabi-gdb && \ @@ -69,11 +70,12 @@ ENV LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64 # Set Rust environment variables ENV RUSTUP_HOME=/usr/local/rustup ENV CARGO_HOME=/usr/local/cargo +ENV KANI_HOME=/usr/local/kani ENV PATH="/usr/local/cargo/bin:${PATH}" # Create directories with world-writable permissions before switching to non-root user -RUN mkdir -p ${RUSTUP_HOME} ${CARGO_HOME} && \ - chmod 1777 ${RUSTUP_HOME} ${CARGO_HOME} +RUN mkdir -p ${RUSTUP_HOME} ${CARGO_HOME} ${KANI_HOME} && \ + chmod 1777 ${RUSTUP_HOME} ${CARGO_HOME} ${KANI_HOME} # The container now runs with a non-root user to avoid file permission issues ARG USERNAME=vscode @@ -91,6 +93,11 @@ RUN umask 0002 && \ cargo install cargo-binutils && \ rustup target add thumbv7em-none-eabihf thumbv7em-none-eabi +RUN cargo install --locked kani-verifier && \ + cargo kani setup +RUN cargo install --locked cargo-tarpaulin +RUN cargo install --locked cargo-watch + COPY --from=qemu-builder /usr/local/ /usr/local/ ENTRYPOINT ["/bin/bash"] diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 2ea96a9..3cf8a9b 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -3,7 +3,8 @@ "name": "Osiris Dev Container", "build": { "dockerfile": "Dockerfile", - "context": ".." + "context": "..", + "cacheFrom": "ghcr.io/osirisrtos/osiris/devcontainer:main-cache" }, "remoteUser": "vscode", "privileged": false, From 99311f8b332c46cfc99f08285a9387efc2db5026 Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 10:15:54 +0000 Subject: [PATCH 02/25] Also cache from main branch --- .github/workflows/ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2f79d5a..d482829 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,6 +42,7 @@ jobs: REPO=$(echo "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]') CONTAINER_NAME="ghcr.io/${REPO}/devcontainer:${BRANCH//\//-}" echo "container_name=$CONTAINER_NAME" >> $GITHUB_OUTPUT + echo "container_without_tag=ghcr.io/${REPO}/devcontainer" >> $GITHUB_OUTPUT - name: Build and push Docker image uses: docker/build-push-action@v2 @@ -50,7 +51,9 @@ jobs: file: .devcontainer/Dockerfile push: true tags: ${{ steps.set_output.outputs.container_name }} - cache-from: type=registry,ref=${{ steps.set_output.outputs.container_name }}-cache + cache-from: | + type=registry,ref=${{ steps.set_output.outputs.container_name }}-cache + type=registry,ref=${{ steps.set_output.outputs.container_without_tag }}:main-cache cache-to: type=registry,ref=${{ steps.set_output.outputs.container_name }}-cache,mode=max fmt: From 53314807dd3b386f7027e973704ca3ce0dc3a9d1 Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 11:19:04 +0000 Subject: [PATCH 03/25] Verification in CI --- .github/workflows/ci.yml | 31 +++++++++++++++++++++++++++++++ kernel | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d482829..f381e4f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -87,6 +87,37 @@ jobs: exit 1 fi + kani: + name: Kani verification + needs: [container] + runs-on: ubuntu-latest + container: + image: ${{ needs.container.outputs.container_name }} + options: --user root + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + + # This step is required to generate some Cargo.toml files + - name: Run CMake + run: cmake -B build + + - name: Run Kani + run: | + manifests=$(find . \( -path './build*' -o -path '*dep*' -o -path '*verus*' -o -path './target' \) -prune -false -o -name Cargo.toml) + failed=0 + for manifest in $manifests; do + echo "::group::Running kani for $manifest" + cargo kani --manifest-path="$manifest" || failed=1 + echo "::endgroup::" + done + if [ $failed -ne 0 ]; then + echo "Verification check failed for one or more manifests" + exit 1 + fi + build-stm32l4r5zi: name: Build for the STM32L4R5ZI needs: [container] diff --git a/kernel b/kernel index 70b39d0..66011e3 160000 --- a/kernel +++ b/kernel @@ -1 +1 @@ -Subproject commit 70b39d0fa8571c75f2d20473169c7e811b69f016 +Subproject commit 66011e39b9e5595e79d1dac87ebd76ff7bb05ffd From dcaf5bf76b7dafbbb278091528d4fae5b8696a6a Mon Sep 17 00:00:00 2001 From: thomasw04 <35061939+thomasw04@users.noreply.github.com> Date: Sat, 15 Feb 2025 15:34:31 +0100 Subject: [PATCH 04/25] fix cargo-tarpaulin. --- hal/ocortex-m | 2 +- hal/stm32l4 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hal/ocortex-m b/hal/ocortex-m index 90e209d..0e2ff28 160000 --- a/hal/ocortex-m +++ b/hal/ocortex-m @@ -1 +1 @@ -Subproject commit 90e209d4961b586e8845a92253c8686ffeefcf5a +Subproject commit 0e2ff286539b74efcd86c1e35c7ae648773c5ff2 diff --git a/hal/stm32l4 b/hal/stm32l4 index 3f1906d..47c2610 160000 --- a/hal/stm32l4 +++ b/hal/stm32l4 @@ -1 +1 @@ -Subproject commit 3f1906d3f299010d813fbbb835e0e99d64163abd +Subproject commit 47c261032ae2f565304659b8429125aaefa5846e From 79921f710e116a0f7626b5f6c7a5e1eda0853b1a Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 15:07:02 +0000 Subject: [PATCH 05/25] Add test coverage configuration --- .devcontainer/devcontainer.json | 14 +- .github/workflows/ci.yml | 39 +- .gitignore | 2 + Cargo.lock | 859 ++++++++++++++++++++++++++++++++ Cargo.toml | 8 + Makefile | 57 +++ 6 files changed, 941 insertions(+), 38 deletions(-) create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 Makefile diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 3cf8a9b..4238316 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -18,8 +18,18 @@ "rust-lang.rust-analyzer", "vadimcn.vscode-lldb", "ms-vscode.cmake-tools", - "llvm-vs-code-extensions.vscode-clangd" - ] + "llvm-vs-code-extensions.vscode-clangd", + "ryanluker.vscode-coverage-gutters" + ], + "settings": { + "rust-analyzer.cargo.cfgs": [ + "kani" + ], + "coverage-gutters.coverageBaseDir": "${workspaceFolder}", + "coverage-gutters.coverageFileNames": [ + "lcov.info" + ] + } } }, "runArgs": [ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f381e4f..cec03db 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,23 +69,8 @@ jobs: with: submodules: recursive - # This step is required to generate some Cargo.toml files - - name: Run CMake - run: cmake -B build - - name: Check formatting for all Cargo manifests - run: | - manifests=$(find . \( -path './build*' -o -path '*dep*' -o -path '*verus*' -o -path './target' \) -prune -false -o -name Cargo.toml) - failed=0 - for manifest in $manifests; do - echo "::group::Checking formatting for $manifest" - cargo fmt --manifest-path="$manifest" -- --check || failed=1 - echo "::endgroup::" - done - if [ $failed -ne 0 ]; then - echo "Formatting check failed for one or more manifests" - exit 1 - fi + run: make check_format kani: name: Kani verification @@ -100,23 +85,8 @@ jobs: with: submodules: recursive - # This step is required to generate some Cargo.toml files - - name: Run CMake - run: cmake -B build - - name: Run Kani - run: | - manifests=$(find . \( -path './build*' -o -path '*dep*' -o -path '*verus*' -o -path './target' \) -prune -false -o -name Cargo.toml) - failed=0 - for manifest in $manifests; do - echo "::group::Running kani for $manifest" - cargo kani --manifest-path="$manifest" || failed=1 - echo "::endgroup::" - done - if [ $failed -ne 0 ]; then - echo "Verification check failed for one or more manifests" - exit 1 - fi + run: make verify build-stm32l4r5zi: name: Build for the STM32L4R5ZI @@ -131,8 +101,5 @@ jobs: with: submodules: recursive - - name: Run CMake - run: cmake -DBOARD=stm32-nucleo-l4r5zi -DCPU=cortex-m4 -B build - - name: Build - run: cmake --build build --parallel $(nproc) + run: make osiris diff --git a/.gitignore b/.gitignore index 2988fc8..69869c6 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ build*/ qemu/ .venv/ *.gen.* +target +**.info diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..645535f --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,859 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" + +[[package]] +name = "bindgen" +version = "0.69.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088" +dependencies = [ + "bitflags 2.8.0", + "cexpr", + "clang-sys", + "itertools", + "lazy_static", + "lazycell", + "log", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.98", + "which", +] + +[[package]] +name = "bitfield" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "cbindgen" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97449daf9b8c245bcad10bbc7c9f4a37c06172c18dd5f9fac340deefc309b957" +dependencies = [ + "clap 2.34.0", + "heck 0.3.3", + "indexmap", + "log", + "proc-macro2", + "quote", + "serde", + "serde_json", + "syn 1.0.109", + "tempfile", + "toml", +] + +[[package]] +name = "cbindgen" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da6bc11b07529f16944307272d5bd9b22530bc7d05751717c9d416586cedab49" +dependencies = [ + "clap 3.2.25", + "heck 0.4.1", + "indexmap", + "log", + "proc-macro2", + "quote", + "serde", + "serde_json", + "syn 1.0.109", + "tempfile", + "toml", +] + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clang-sys" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "clap" +version = "2.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +dependencies = [ + "ansi_term", + "atty", + "bitflags 1.3.2", + "strsim 0.8.0", + "textwrap 0.11.0", + "unicode-width", + "vec_map", +] + +[[package]] +name = "clap" +version = "3.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" +dependencies = [ + "atty", + "bitflags 1.3.2", + "clap_lex", + "indexmap", + "strsim 0.10.0", + "termcolor", + "textwrap 0.16.1", +] + +[[package]] +name = "clap_lex" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +dependencies = [ + "os_str_bytes", +] + +[[package]] +name = "cortex-m" +version = "0.7.4" +dependencies = [ + "bitfield", + "serde", +] + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "errno" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.13.3+wasi-0.2.2", + "windows-targets", +] + +[[package]] +name = "glob" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" + +[[package]] +name = "hal" +version = "0.1.0" +dependencies = [ + "cbindgen 0.18.0", + "cortex-m", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "home" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown", +] + +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" + +[[package]] +name = "kernel" +version = "0.1.0" +dependencies = [ + "bindgen", + "cbindgen 0.26.0", + "hal", + "macros", + "quote", + "rand", + "syn 2.0.98", + "walkdir", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + +[[package]] +name = "libc" +version = "0.2.169" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" + +[[package]] +name = "libloading" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" +dependencies = [ + "cfg-if", + "windows-targets", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" + +[[package]] +name = "log" +version = "0.4.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" + +[[package]] +name = "macros" +version = "0.1.0" +dependencies = [ + "quote", + "syn 2.0.98", +] + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "once_cell" +version = "1.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e" + +[[package]] +name = "os_str_bytes" +version = "6.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" + +[[package]] +name = "ppv-lite86" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "prettyplease" +version = "0.2.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6924ced06e1f7dfe3fa48d57b9f74f55d8915f5036121bef647ef4b204895fac" +dependencies = [ + "proc-macro2", + "syn 2.0.98", +] + +[[package]] +name = "proc-macro2" +version = "1.0.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.15", +] + +[[package]] +name = "regex" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustix" +version = "0.38.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +dependencies = [ + "bitflags 2.8.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "ryu" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "serde" +version = "1.0.217" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.217" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "serde_json" +version = "1.0.138" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tempfile" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38c246215d7d24f48ae091a2902398798e05d978b24315d6efbc00ede9a8bb91" +dependencies = [ + "cfg-if", + "fastrand", + "getrandom 0.3.1", + "once_cell", + "rustix", + "windows-sys", +] + +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "textwrap" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" + +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + +[[package]] +name = "unicode-ident" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" + +[[package]] +name = "unicode-segmentation" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" + +[[package]] +name = "unicode-width" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasi" +version = "0.13.3+wasi-0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" +dependencies = [ + "wit-bindgen-rt", +] + +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "wit-bindgen-rt" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" +dependencies = [ + "bitflags 2.8.0", +] + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..06df049 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] +resolver = "2" +members = [ + "kernel", + "kernel/macros", + "hal/ocortex-m", + "hal/stm32l4/stm32-nucleo-l4r5zi" +] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0792471 --- /dev/null +++ b/Makefile @@ -0,0 +1,57 @@ +# Tell make to do as many things as possible at once +ifeq ($(filter -j,$(MAKEFLAGS)),) + MAKEFLAGS += -j +endif + +BUILD_DIR := build +SHELL := /bin/bash +.PHONY: check_format format fmt verify clean + +osiris: $(BUILD_DIR) + cmake --build $(BUILD_DIR) --parallel $(shell nproc) + +$(BUILD_DIR): + cmake -DBOARD=stm32-nucleo-l4r5zi -DCPU=cortex-m4 -B $(BUILD_DIR) + +define ci_check + @manifests=$$(if [ -z "$(3)" ]; then \ + find . \( -path './build*' -o -path '*dep*' -o -path '*verus*' -o -path './target' \) -prune -false -o -name Cargo.toml; \ + else \ + echo $(3); \ + fi); \ + failed=0; \ + for manifest in $$(echo $$manifests); do \ + if [ -n "$$CI" ]; then \ + echo "::group::Checking $(1) for $$manifest"; \ + else \ + echo "Checking $(1) for $$manifest"; \ + fi; \ + cargo $(1) --manifest-path="$$manifest" $(2) || failed=1; \ + if [ -n "$$CI" ]; then \ + echo "::endgroup::"; \ + fi; \ + done; \ + if [ $$failed -ne 0 ]; then \ + echo "$(1) check failed for one or more manifests"; \ + exit 1; \ + fi +endef + +check_format: cmake + $(call ci_check,fmt,-- --check) + +format: fmt +fmt: cmake + $(call ci_check,fmt,) + +verify: cmake + $(call ci_check,kani -Z concrete-playback --concrete-playback=print,,kernel/Cargo.toml) + +test: cmake + cargo tarpaulin --out Lcov --skip-clean --workspace + +watch-tests: cmake + cargo watch --why --exec 'tarpaulin --out Lcov --skip-clean --workspace' --ignore lcov.info + +clean: + rm -rf $(BUILD_DIR) From f48a7d18dc641baecca03c2d135e611120cd9d84 Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 15:13:26 +0000 Subject: [PATCH 06/25] Report code coverage in CI --- .github/workflows/ci.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cec03db..9d158da 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,6 +56,29 @@ jobs: type=registry,ref=${{ steps.set_output.outputs.container_without_tag }}:main-cache cache-to: type=registry,ref=${{ steps.set_output.outputs.container_name }}-cache,mode=max + test: + name: Build Container + runs-on: ubuntu-latest + permissions: + packages: write + outputs: + container_name: ${{ steps.set_output.outputs.container_name }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Run tests + run: make test + + - name: Report code coverage + uses: zgosalvez/github-actions-report-lcov@v4 + with: + coverage-files: lcov.info + github-token: ${{ secrets.GITHUB_TOKEN }} + update-comment: true + fmt: name: Check formatting needs: [container] From 1a2c47c2fb17a685bff0872e9f1de38f6c2927f7 Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 15:15:10 +0000 Subject: [PATCH 07/25] Use container for tests --- .github/workflows/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9d158da..0a84aab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,8 +59,7 @@ jobs: test: name: Build Container runs-on: ubuntu-latest - permissions: - packages: write + needs: [container] outputs: container_name: ${{ steps.set_output.outputs.container_name }} steps: From 715c2258a739c78ff8ed4ac2033e603e07c38cc9 Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 15:16:45 +0000 Subject: [PATCH 08/25] Fix CI --- .github/workflows/ci.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0a84aab..e879032 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,11 +57,12 @@ jobs: cache-to: type=registry,ref=${{ steps.set_output.outputs.container_name }}-cache,mode=max test: - name: Build Container - runs-on: ubuntu-latest + name: Testing needs: [container] - outputs: - container_name: ${{ steps.set_output.outputs.container_name }} + runs-on: ubuntu-latest + container: + image: ${{ needs.container.outputs.container_name }} + options: --user root steps: - name: Checkout uses: actions/checkout@v4 From 9683e37eaf207c64ee5abfbc66344af360315888 Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 15:20:30 +0000 Subject: [PATCH 09/25] Fix makefile --- Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 0792471..dfc0f14 100644 --- a/Makefile +++ b/Makefile @@ -37,20 +37,20 @@ define ci_check fi endef -check_format: cmake +check_format: $(BUILD_DIR) $(call ci_check,fmt,-- --check) format: fmt -fmt: cmake +fmt: $(BUILD_DIR) $(call ci_check,fmt,) -verify: cmake +verify: $(BUILD_DIR) $(call ci_check,kani -Z concrete-playback --concrete-playback=print,,kernel/Cargo.toml) -test: cmake +test: $(BUILD_DIR) cargo tarpaulin --out Lcov --skip-clean --workspace -watch-tests: cmake +watch-tests: $(BUILD_DIR) cargo watch --why --exec 'tarpaulin --out Lcov --skip-clean --workspace' --ignore lcov.info clean: From 74fa894193896353e7887eb983d7912fbfe975f4 Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 15:25:52 +0000 Subject: [PATCH 10/25] Fix --- .devcontainer/devcontainer.json | 4 +++- .github/workflows/ci.yml | 2 +- Makefile | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 4238316..667fda8 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -10,7 +10,9 @@ "privileged": false, "capAdd": [ // Permissions for accessing host USB devices - "SYS_RAWIO", "CAP_MKNOD" + "SYS_RAWIO", "CAP_MKNOD", + // Allow debugging + "SYS_PTRACE" ], "customizations": { "vscode": { diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e879032..2c5bd72 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,7 +62,7 @@ jobs: runs-on: ubuntu-latest container: image: ${{ needs.container.outputs.container_name }} - options: --user root + options: --user root --privileged steps: - name: Checkout uses: actions/checkout@v4 diff --git a/Makefile b/Makefile index dfc0f14..a6e58b5 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ $(BUILD_DIR): define ci_check @manifests=$$(if [ -z "$(3)" ]; then \ - find . \( -path './build*' -o -path '*dep*' -o -path '*verus*' -o -path './target' \) -prune -false -o -name Cargo.toml; \ + find . \(-path './Cargo.toml' -o -path './build*' -o -path '*dep*' -o -path '*verus*' -o -path './target' \) -prune -false -o -name Cargo.toml; \ else \ echo $(3); \ fi); \ From 93c787c22c941ed2b72e471e19742f1859dd2eeb Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 15:26:39 +0000 Subject: [PATCH 11/25] Fix indent --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2c5bd72..ea73b27 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,7 +62,7 @@ jobs: runs-on: ubuntu-latest container: image: ${{ needs.container.outputs.container_name }} - options: --user root --privileged + options: --user root --privileged steps: - name: Checkout uses: actions/checkout@v4 From daaa32c42f7ec5c1ee49b35a5371920d483ef59d Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 15:30:33 +0000 Subject: [PATCH 12/25] Add coverage report dependencies --- .devcontainer/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index a98bf73..9e12541 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -50,6 +50,7 @@ RUN dnf update -y && \ clang \ libusb1-devel \ openssl-devel \ + lcov \ 'dnf-command(copr)' && \ dnf copr enable -y rleh/arm-none-eabi-gdb && \ dnf install -y --setopt=keepcache=0 arm-none-eabi-gdb && \ From 9b707f481eb49cc8aa66d180d3484a44bb8e0d0e Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 15:42:41 +0000 Subject: [PATCH 13/25] Allow commenting --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ea73b27..acff46d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,6 +63,9 @@ jobs: container: image: ${{ needs.container.outputs.container_name }} options: --user root --privileged + permissions: + contents: read + issues: write steps: - name: Checkout uses: actions/checkout@v4 From 09f105b91ffcaca6683e5b772bb18a5f61b1dc31 Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 15:44:25 +0000 Subject: [PATCH 14/25] Fix permission --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index acff46d..fd43dc6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,6 +66,7 @@ jobs: permissions: contents: read issues: write + packages: read steps: - name: Checkout uses: actions/checkout@v4 From d3f47d9b2e6cc14a92958452e4133cefbe8ca085 Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 15:52:01 +0000 Subject: [PATCH 15/25] Exclude top-level Cargo.toml --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a6e58b5..aa5c877 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ $(BUILD_DIR): define ci_check @manifests=$$(if [ -z "$(3)" ]; then \ - find . \(-path './Cargo.toml' -o -path './build*' -o -path '*dep*' -o -path '*verus*' -o -path './target' \) -prune -false -o -name Cargo.toml; \ + find . \( -path './Cargo.toml' -o -path './build*' -o -path '*dep*' -o -path '*verus*' -o -path './target' \) -prune -false -o \( -name Cargo.toml -a -not -path './Cargo.toml' \); \ else \ echo $(3); \ fi); \ From 369e541d9eaf21523632c22ad90a8fcd73c03251 Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 15:55:23 +0000 Subject: [PATCH 16/25] Permissions --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fd43dc6..f004e2c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,6 +66,7 @@ jobs: permissions: contents: read issues: write + pull-requests: write packages: read steps: - name: Checkout From 1128ffdfce7bfdb623ec5b8d8685c492ee798c0d Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 16:06:47 +0000 Subject: [PATCH 17/25] Add group for build dir --- Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile b/Makefile index aa5c877..2a3500a 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,13 @@ osiris: $(BUILD_DIR) cmake --build $(BUILD_DIR) --parallel $(shell nproc) $(BUILD_DIR): + @if [ -n "$$CI" ]; then \ + echo "::group::Generating build dir $(BUILD_DIR)"; \ + fi cmake -DBOARD=stm32-nucleo-l4r5zi -DCPU=cortex-m4 -B $(BUILD_DIR) + @if [ -n "$$CI" ]; then \ + echo "::endgroup::"; \ + fi define ci_check @manifests=$$(if [ -z "$(3)" ]; then \ From 601afa5a573bf0bab60bd54ff124d9d1b7900308 Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 16:11:02 +0000 Subject: [PATCH 18/25] Rename job --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f004e2c..3dd2c32 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -116,8 +116,8 @@ jobs: - name: Run Kani run: make verify - build-stm32l4r5zi: - name: Build for the STM32L4R5ZI + build-stm32-nucleo-l4r5zi: + name: Build for the STM32 Nucleo L4R5ZI needs: [container] runs-on: ubuntu-latest container: From 357890c8363cbdefad675427b875de9d00cd3a40 Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 16:16:01 +0000 Subject: [PATCH 19/25] Add pre-commit hook for formatting --- .devcontainer/pre-commit.sh | 4 ++++ Makefile | 5 ++++- README.md | 8 +++++++- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100755 .devcontainer/pre-commit.sh diff --git a/.devcontainer/pre-commit.sh b/.devcontainer/pre-commit.sh new file mode 100755 index 0000000..42c7b55 --- /dev/null +++ b/.devcontainer/pre-commit.sh @@ -0,0 +1,4 @@ +#!/bin/bash +set -eoux pipefail + +make check_format diff --git a/Makefile b/Makefile index 2a3500a..b5d4aa6 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ endif BUILD_DIR := build SHELL := /bin/bash -.PHONY: check_format format fmt verify clean +.PHONY: check_format format fmt verify clean hooks osiris: $(BUILD_DIR) cmake --build $(BUILD_DIR) --parallel $(shell nproc) @@ -61,3 +61,6 @@ watch-tests: $(BUILD_DIR) clean: rm -rf $(BUILD_DIR) + +hooks: + ln -sf $(CURDIR)/.devcontainer/pre-commit.sh $(CURDIR)/.git/hooks/pre-commit diff --git a/README.md b/README.md index c750ad9..caa69d5 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,14 @@ $ cmake -DBOARD=stm32-nucleo-l4r5zi -DCPU=cortex-m4 .. $ make ``` +### Set up pre-commit hooks + +```sh +$ make hooks +``` + ## Boot -1. Install @thomasw04 qemu fork: https://github.com/thomasw04/qemu +1. Install @thomasw04 qemu fork: https://github.com/thomasw04/qemu 2. Run ```./boot.sh``` 3. Now you should see a: "Hello World!". From 9ec70f2542055bf89b35cef4bcde62fdf62b993c Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 16:19:51 +0000 Subject: [PATCH 20/25] Kernel formatting --- kernel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel b/kernel index 66011e3..e4b4b84 160000 --- a/kernel +++ b/kernel @@ -1 +1 @@ -Subproject commit 66011e39b9e5595e79d1dac87ebd76ff7bb05ffd +Subproject commit e4b4b84d4a34e2cd5119af890127ef70e5641d0e From 18648b2e4138a4298aee3fcd80527d53f5a39db1 Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 17:56:00 +0000 Subject: [PATCH 21/25] Small improvements --- .devcontainer/pre-commit.sh | 2 +- .github/workflows/ci.yml | 2 +- Makefile | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.devcontainer/pre-commit.sh b/.devcontainer/pre-commit.sh index 42c7b55..374f3bd 100755 --- a/.devcontainer/pre-commit.sh +++ b/.devcontainer/pre-commit.sh @@ -1,4 +1,4 @@ #!/bin/bash set -eoux pipefail -make check_format +make check-format diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3dd2c32..72e2283 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -98,7 +98,7 @@ jobs: submodules: recursive - name: Check formatting for all Cargo manifests - run: make check_format + run: make check-format kani: name: Kani verification diff --git a/Makefile b/Makefile index b5d4aa6..1441792 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ endif BUILD_DIR := build SHELL := /bin/bash -.PHONY: check_format format fmt verify clean hooks +.PHONY: check-format format fmt verify clean hooks osiris: $(BUILD_DIR) cmake --build $(BUILD_DIR) --parallel $(shell nproc) @@ -43,7 +43,7 @@ define ci_check fi endef -check_format: $(BUILD_DIR) +check-format: $(BUILD_DIR) $(call ci_check,fmt,-- --check) format: fmt @@ -64,3 +64,6 @@ clean: hooks: ln -sf $(CURDIR)/.devcontainer/pre-commit.sh $(CURDIR)/.git/hooks/pre-commit + +check: check-format test verify + echo "All checks passed" From 0984652991504bf8c34b3eb7cd9f565cd766789c Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sun, 16 Feb 2025 08:25:05 +0000 Subject: [PATCH 22/25] Include python --- .devcontainer/Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 9e12541..31f862e 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -51,6 +51,10 @@ RUN dnf update -y && \ libusb1-devel \ openssl-devel \ lcov \ + python3 \ + python3-pip \ + python3-setuptools \ + python3-wheel \ 'dnf-command(copr)' && \ dnf copr enable -y rleh/arm-none-eabi-gdb && \ dnf install -y --setopt=keepcache=0 arm-none-eabi-gdb && \ From 8deca2c3799c7bc9ffdfb6a786ad7c60049e3c75 Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sun, 16 Feb 2025 08:38:57 +0000 Subject: [PATCH 23/25] Test hardware CI --- .github/workflows/ci.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 72e2283..ddfa515 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -131,3 +131,22 @@ jobs: - name: Build run: make osiris + + hardware-test-stm32-nucleo-l4r5zi: + name: Hardware test for the STM32 Nucleo L4R5ZI + # needs: [build-stm32-nucleo-l4r5zi] + runs-on: stm32l4r5zi + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Run hardware test + # See https://github.com/OsirisRTOS/hardware-ci for more information + run: | + SERIAL_ID="$(board_serial stm32l4r5zi)" + echo "Working with chip $SERIAL_ID" + st-info --probe + st-flash --serial "$SERIAL_ID" reset + From 337389ec60f9d54deaf1bf3e8bfc6f59b70524e5 Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sun, 16 Feb 2025 09:55:30 +0000 Subject: [PATCH 24/25] Test --- .github/workflows/ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ddfa515..cd5342b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -145,8 +145,10 @@ jobs: - name: Run hardware test # See https://github.com/OsirisRTOS/hardware-ci for more information run: | - SERIAL_ID="$(board_serial stm32l4r5zi)" + SERIAL_ID="$(board_info serial stm32l4r5zi)" echo "Working with chip $SERIAL_ID" - st-info --probe + st-flash --serial "$SERIAL_ID" reset + board_info --serial "$SERIAL_ID" --flash-size + From 3e3432480fb7f7b18207c51a278b5e1d5ec0ce05 Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sun, 16 Feb 2025 10:08:55 +0000 Subject: [PATCH 25/25] Test --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cd5342b..896ee7d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -150,5 +150,5 @@ jobs: st-flash --serial "$SERIAL_ID" reset - board_info --serial "$SERIAL_ID" --flash-size + board_info print --serial "$SERIAL_ID" --flash-size