From 53214ceb5721e502de072f7c57061fadb90e5365 Mon Sep 17 00:00:00 2001 From: xarantolus Date: Fri, 14 Feb 2025 16:04:24 +0000 Subject: [PATCH 01/20] Initial dev container configuration --- .devcontainer/Dockerfile | 73 +++++++++++++++++++++++++++++++++ .devcontainer/devcontainer.json | 23 +++++++++++ .gitignore | 2 +- 3 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..1def7d7 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,73 @@ +FROM fedora:latest + +# Install Development Tools and required packages +RUN dnf update -y && \ + dnf install -y @development-tools && \ + dnf install -y \ + direnv \ + arm-none-eabi-gcc-cs \ + arm-none-eabi-gcc-c++ \ + arm-none-eabi-newlib \ + cmake \ + git \ + python3 \ + python3-virtualenv \ + python3-pip \ + ninja-build \ + pkgconf \ + glib2-devel \ + flex \ + bison \ + clang \ + zlib-devel \ + meson \ + pixman-devel \ + alsa-lib-devel \ + texinfo \ + lzo-devel \ + snappy-devel \ + libaio-devel \ + libtasn1-devel \ + gnutls-devel \ + nettle-devel \ + curl \ + dtc \ + libcap-devel \ + libcap-ng-devel \ + socat \ + libslirp-devel \ + libffi-devel \ + ncurses-devel && \ + dnf clean all + +ARG USERNAME=vscode +RUN useradd -m -s /bin/bash ${USERNAME} && \ + echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers + +# Set working directory and switch to non-root user +WORKDIR /home/${USERNAME} +USER ${USERNAME} + +# Install Rust +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \ + . $HOME/.cargo/env && \ + rustup component add rust-src && \ + rustup component add llvm-tools-preview && \ + cargo install cargo-binutils && \ + rustup target add thumbv7em-none-eabihf && \ + rustup target add thumbv7em-none-eabi + +# Clone, build, and install QEMU +RUN git clone --depth 1 https://github.com/thomasw04/qemu.git /tmp/qemu && \ + cd /tmp/qemu && \ + python3 -m venv .venv && \ + . .venv/bin/activate && \ + pip install --no-cache-dir tomli sphinx && \ + mkdir build && cd build && \ + ../configure --disable-werror --cc=clang --cxx=clang++ --extra-cflags="-Wno-error -fdeclspec" --target-list=arm-softmmu,arm-linux-user --enable-kvm && \ + make -j$(nproc) && \ + sudo make install && \ + cd / && \ + rm -rf /tmp/qemu + +CMD ["bash"] diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..576989d --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,23 @@ +// For format details, see https://aka.ms/devcontainer.json. +{ + "name": "Nix Dev Container", + "build": { + "dockerfile": "Dockerfile", + "context": ".." + }, + "remoteUser": "vscode", + "privileged": false, + "customizations": { + "vscode": { + "extensions": [ + "rust-lang.rust-analyzer", + "vadimcn.vscode-lldb", + "ms-vscode.cmake-tools", + "llvm-vs-code-extensions.vscode-clangd" + ] + } + }, + "mounts": [ + "source=${localEnv:HOME}/.ssh,target=/home/vscode/.ssh,type=bind,consistency=cached" + ] +} diff --git a/.gitignore b/.gitignore index 467fd94..2988fc8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -build/ +build*/ .vscode/ qemu/ .venv/ From 0489914902220f981d985f96e6a31c9afc981693 Mon Sep 17 00:00:00 2001 From: xarantolus Date: Fri, 14 Feb 2025 18:46:15 +0000 Subject: [PATCH 02/20] Hardware interaction from container --- .devcontainer/Dockerfile | 15 ++++++++++++++- .devcontainer/devcontainer.json | 12 +++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 1def7d7..ae5138a 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -37,9 +37,14 @@ RUN dnf update -y && \ socat \ libslirp-devel \ libffi-devel \ + libusb1-devel \ ncurses-devel && \ dnf clean all +RUN dnf install -y 'dnf-command(copr)' && \ + dnf copr enable -y rleh/arm-none-eabi-gdb && \ + dnf install -y arm-none-eabi-gdb + ARG USERNAME=vscode RUN useradd -m -s /bin/bash ${USERNAME} && \ echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers @@ -70,4 +75,12 @@ RUN git clone --depth 1 https://github.com/thomasw04/qemu.git /tmp/qemu && \ cd / && \ rm -rf /tmp/qemu -CMD ["bash"] +RUN git clone --single-branch --depth 1 -b "develop" \ + https://github.com/stlink-org/stlink.git /tmp/stlink && \ + cd /tmp/stlink && \ + make -j release && \ + sudo make install && \ + sudo ldconfig + +# Fix for fedora not finding libstlink.so.1 +ENV LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 576989d..2ea96a9 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,12 +1,16 @@ // For format details, see https://aka.ms/devcontainer.json. { - "name": "Nix Dev Container", + "name": "Osiris Dev Container", "build": { "dockerfile": "Dockerfile", "context": ".." }, "remoteUser": "vscode", "privileged": false, + "capAdd": [ + // Permissions for accessing host USB devices + "SYS_RAWIO", "CAP_MKNOD" + ], "customizations": { "vscode": { "extensions": [ @@ -17,7 +21,13 @@ ] } }, + "runArgs": [ + // Mount USB devices under Linux + "--device", + "/dev/bus/usb:/dev/bus/usb" + ], "mounts": [ + // Make ssh keys available "source=${localEnv:HOME}/.ssh,target=/home/vscode/.ssh,type=bind,consistency=cached" ] } From 3807d9107d533dd308d55cdac378a8bd3a84dda3 Mon Sep 17 00:00:00 2001 From: xarantolus Date: Fri, 14 Feb 2025 21:34:52 +0100 Subject: [PATCH 03/20] Try out actions workflow --- .github/workflows/formatting.yml | 58 ++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/formatting.yml diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml new file mode 100644 index 0000000..11e9ac5 --- /dev/null +++ b/.github/workflows/formatting.yml @@ -0,0 +1,58 @@ +on: + push: + branches-ignore: + - "gh-readonly-queue/**" + pull_request: + merge_group: + workflow_dispatch: + +name: Code formatting check + +jobs: + get-manifests: + name: Get Cargo manifests + runs-on: ubuntu-latest + outputs: + manifests: ${{ steps.find.outputs.manifests }} + steps: + - 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: Find Cargo.toml files + id: find + run: | + files=$(find . \( -path './build*' -o -path '*dep*' -o -path '*verus*' -o -path './target' \) -prune -false -o -name Cargo.toml) + echo "Found the following manifests:" + echo "$files" + json=$(printf '%s\n' $files | jq -R . | jq -s .) + echo "manifests=$json" >> $GITHUB_OUTPUT + + fmt: + name: rustfmt check for ${{ matrix.manifest }} + needs: get-manifests + runs-on: ubuntu-latest + strategy: + matrix: + manifest: ${{ fromJson(needs.get-manifests.outputs.manifests) }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Setup Rust + uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt + + # This step is required to generate some Cargo.toml files + - name: Run CMake + run: cmake -B build + + - name: Check formatting + run: cargo fmt --manifest-path="${{ matrix.manifest }}" -- --check From fbc857d167a9aaa573f582bbef62a6a05623ccbd Mon Sep 17 00:00:00 2001 From: xarantolus Date: Fri, 14 Feb 2025 21:39:09 +0100 Subject: [PATCH 04/20] Allow reading repos --- .github/workflows/formatting.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml index 11e9ac5..9a49276 100644 --- a/.github/workflows/formatting.yml +++ b/.github/workflows/formatting.yml @@ -8,6 +8,9 @@ on: name: Code formatting check +permissions: + contents: read + jobs: get-manifests: name: Get Cargo manifests From 856e9f2471beb3935609c2a790b9d2bd0d7dd94d Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 07:15:49 +0100 Subject: [PATCH 05/20] Run in container --- .github/workflows/{formatting.yml => ci.yml} | 46 +++++++++++++++++--- 1 file changed, 39 insertions(+), 7 deletions(-) rename .github/workflows/{formatting.yml => ci.yml} (53%) diff --git a/.github/workflows/formatting.yml b/.github/workflows/ci.yml similarity index 53% rename from .github/workflows/formatting.yml rename to .github/workflows/ci.yml index 9a49276..bdb908a 100644 --- a/.github/workflows/formatting.yml +++ b/.github/workflows/ci.yml @@ -6,15 +6,47 @@ on: merge_group: workflow_dispatch: -name: Code formatting check - -permissions: - contents: read +name: Osiris CI jobs: - get-manifests: + container: + name: Build Container + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + context: .devcontainer + file: .devcontainer/Dockerfile + push: true + tags: ghcr.io/${{ github.repository }}/devcontainer:${{ github.ref_name | replace('/', '-') }} + + - name: Set container name as output + id: set_output + run: | + container_name="ghcr.io/${{ github.repository }}/devcontainer:${{ github.ref_name | replace('/', '-') }}" + echo "container_name=$container_name" >> $GITHUB_OUTPUT + + manifests: name: Get Cargo manifests runs-on: ubuntu-latest + needs: container + container: ${{ needs.container.outputs.container_name }} outputs: manifests: ${{ steps.find.outputs.manifests }} steps: @@ -37,11 +69,11 @@ jobs: fmt: name: rustfmt check for ${{ matrix.manifest }} - needs: get-manifests + needs: manifests runs-on: ubuntu-latest strategy: matrix: - manifest: ${{ fromJson(needs.get-manifests.outputs.manifests) }} + manifest: ${{ fromJson(needs.manifests.outputs.manifests) }} steps: - name: Checkout uses: actions/checkout@v4 From d92e60d319d51e7da4f9f4ef708c937af88d4ef1 Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 07:17:20 +0100 Subject: [PATCH 06/20] Try --- .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 bdb908a..d3395a9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,12 +34,12 @@ jobs: context: .devcontainer file: .devcontainer/Dockerfile push: true - tags: ghcr.io/${{ github.repository }}/devcontainer:${{ github.ref_name | replace('/', '-') }} + tags: ghcr.io/${{ github.repository }}/devcontainer:${{ github.ref_name.replace('/', '-') }} - name: Set container name as output id: set_output run: | - container_name="ghcr.io/${{ github.repository }}/devcontainer:${{ github.ref_name | replace('/', '-') }}" + container_name="ghcr.io/${{ github.repository }}/devcontainer:${{ github.ref_name.replace('/', '-') }}" echo "container_name=$container_name" >> $GITHUB_OUTPUT manifests: From fab53c302c1be2de150bb11242ea5bf26a933940 Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 07:20:13 +0100 Subject: [PATCH 07/20] Use shell for branch name? --- .github/workflows/ci.yml | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d3395a9..e44a425 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,19 +28,21 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Set container name as output + id: set_output + run: | + BRANCH_NAME=$(echo "${GITHUB_REF}" | sed 's|refs/heads/||') + # Replaces / with - in branch name + CONTAINER_NAME="ghcr.io/${GITHUB_REPOSITORY}/devcontainer:${BRANCH_NAME//\//-}" + echo "container_name=$CONTAINER_NAME" >> $GITHUB_OUTPUT + - name: Build and push Docker image uses: docker/build-push-action@v2 with: context: .devcontainer file: .devcontainer/Dockerfile push: true - tags: ghcr.io/${{ github.repository }}/devcontainer:${{ github.ref_name.replace('/', '-') }} - - - name: Set container name as output - id: set_output - run: | - container_name="ghcr.io/${{ github.repository }}/devcontainer:${{ github.ref_name.replace('/', '-') }}" - echo "container_name=$container_name" >> $GITHUB_OUTPUT + tags: ${{ steps.set_output.outputs.container_name }} manifests: name: Get Cargo manifests @@ -69,8 +71,9 @@ jobs: fmt: name: rustfmt check for ${{ matrix.manifest }} - needs: manifests + needs: [container, manifests] runs-on: ubuntu-latest + container: ${{ needs.container.outputs.container_name }} strategy: matrix: manifest: ${{ fromJson(needs.manifests.outputs.manifests) }} From 4b7cf425533bec2cd85b043ff29e11fb08658b8b Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 07:22:04 +0100 Subject: [PATCH 08/20] Fix container name --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e44a425..5c011f2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,9 +31,9 @@ jobs: - name: Set container name as output id: set_output run: | - BRANCH_NAME=$(echo "${GITHUB_REF}" | sed 's|refs/heads/||') - # Replaces / with - in branch name - CONTAINER_NAME="ghcr.io/${GITHUB_REPOSITORY}/devcontainer:${BRANCH_NAME//\//-}" + BRANCH=$(echo "${GITHUB_REF}" | sed 's|refs/heads/||' | tr '[:upper:]' '[:lower:]') + REPO=$(echo "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]') + CONTAINER_NAME="ghcr.io/${REPO}/devcontainer:${BRANCH//\//-}" echo "container_name=$CONTAINER_NAME" >> $GITHUB_OUTPUT - name: Build and push Docker image From 14842755f5d070b74ec36d2aa4b93e5134e6cebb Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 07:24:19 +0100 Subject: [PATCH 09/20] Caching --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5c011f2..4ede564 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,6 +43,8 @@ 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-to: type=registry,ref=${{ steps.set_output.outputs.container_name }}-cache,mode=max manifests: name: Get Cargo manifests From d486f97ebcc492a6c66b0f069bf113fed3e5862c Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 07:56:24 +0100 Subject: [PATCH 10/20] Improvements --- .devcontainer/Dockerfile | 113 ++++++++++++++++++++------------------- 1 file changed, 57 insertions(+), 56 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index ae5138a..fea80d0 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,86 +1,87 @@ -FROM fedora:latest +# We build qemu in a separate stage to avoid installing a bunch of build dependencies in the final image +FROM fedora:latest AS qemu-builder -# Install Development Tools and required packages RUN dnf update -y && \ - dnf install -y @development-tools && \ dnf install -y \ - direnv \ - arm-none-eabi-gcc-cs \ - arm-none-eabi-gcc-c++ \ - arm-none-eabi-newlib \ - cmake \ + @development-tools \ git \ + clang \ python3 \ - python3-virtualenv \ python3-pip \ + python3-setuptools \ + python3-wheel \ ninja-build \ - pkgconf \ + clang \ glib2-devel \ flex \ bison \ - clang \ zlib-devel \ meson \ pixman-devel \ - alsa-lib-devel \ - texinfo \ - lzo-devel \ - snappy-devel \ - libaio-devel \ - libtasn1-devel \ - gnutls-devel \ - nettle-devel \ - curl \ - dtc \ - libcap-devel \ - libcap-ng-devel \ - socat \ - libslirp-devel \ - libffi-devel \ - libusb1-devel \ - ncurses-devel && \ - dnf clean all + dtc && \ + ln -sf /usr/bin/clang /usr/bin/cc && \ + ln -sf /usr/bin/clang++ /usr/bin/c++ -RUN dnf install -y 'dnf-command(copr)' && \ +RUN git clone --depth 1 https://github.com/thomasw04/qemu.git /tmp/qemu && \ + cd /tmp/qemu && \ + python3 -m venv .venv && \ + . .venv/bin/activate && \ + pip install --no-cache-dir tomli sphinx && \ + mkdir build && cd build && \ + ../configure --disable-werror --extra-cflags="-Wno-error -fdeclspec" --target-list=arm-softmmu,arm-linux-user --enable-kvm && \ + make -j$(nproc) && \ + make install && \ + cd / && \ + rm -rf /tmp/qemu + +# This is the final image +FROM fedora:latest AS devcontainer + +RUN dnf update -y && \ + dnf install -y \ + @development-tools \ + direnv \ + arm-none-eabi-gcc-cs \ + arm-none-eabi-gcc-c++ \ + arm-none-eabi-newlib \ + cmake \ + git \ + make \ + clang \ + libusb1-devel \ + 'dnf-command(copr)' && \ dnf copr enable -y rleh/arm-none-eabi-gdb && \ - dnf install -y arm-none-eabi-gdb + dnf install -y arm-none-eabi-gdb && \ + dnf clean all && \ + ln -sf /usr/bin/clang /usr/bin/cc && \ + ln -sf /usr/bin/clang++ /usr/bin/c++ +RUN git clone --single-branch --depth 1 -b "develop" https://github.com/stlink-org/stlink.git /tmp/stlink && \ + cd /tmp/stlink && \ + make -j release && \ + sudo make install && \ + sudo ldconfig && \ + rm -rf /tmp/stlink + +# Fix for Fedora not finding libstlink.so.1 +ENV LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64 + +# The runs with a non-root user to not mess up file permissions ARG USERNAME=vscode RUN useradd -m -s /bin/bash ${USERNAME} && \ echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers -# Set working directory and switch to non-root user WORKDIR /home/${USERNAME} USER ${USERNAME} # Install Rust RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \ . $HOME/.cargo/env && \ - rustup component add rust-src && \ - rustup component add llvm-tools-preview && \ + rustup component add rust-src llvm-tools-preview && \ cargo install cargo-binutils && \ - rustup target add thumbv7em-none-eabihf && \ - rustup target add thumbv7em-none-eabi + rustup target add thumbv7em-none-eabihf thumbv7em-none-eabi -# Clone, build, and install QEMU -RUN git clone --depth 1 https://github.com/thomasw04/qemu.git /tmp/qemu && \ - cd /tmp/qemu && \ - python3 -m venv .venv && \ - . .venv/bin/activate && \ - pip install --no-cache-dir tomli sphinx && \ - mkdir build && cd build && \ - ../configure --disable-werror --cc=clang --cxx=clang++ --extra-cflags="-Wno-error -fdeclspec" --target-list=arm-softmmu,arm-linux-user --enable-kvm && \ - make -j$(nproc) && \ - sudo make install && \ - cd / && \ - rm -rf /tmp/qemu -RUN git clone --single-branch --depth 1 -b "develop" \ - https://github.com/stlink-org/stlink.git /tmp/stlink && \ - cd /tmp/stlink && \ - make -j release && \ - sudo make install && \ - sudo ldconfig +COPY --from=qemu-builder /usr/local/ /usr/local/ -# Fix for fedora not finding libstlink.so.1 -ENV LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64 +ENTRYPOINT ["/bin/bash"] From 877043c40fc93a70254db86e5720f77afb6dabf9 Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 06:59:01 +0000 Subject: [PATCH 11/20] Don't use sudo --- .devcontainer/Dockerfile | 4 ++-- hal/cortex-m | 1 + hal/stm32l4 | 2 +- kernel | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) create mode 160000 hal/cortex-m diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index fea80d0..8ea69f4 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -59,8 +59,8 @@ RUN dnf update -y && \ RUN git clone --single-branch --depth 1 -b "develop" https://github.com/stlink-org/stlink.git /tmp/stlink && \ cd /tmp/stlink && \ make -j release && \ - sudo make install && \ - sudo ldconfig && \ + make install && \ + ldconfig && \ rm -rf /tmp/stlink # Fix for Fedora not finding libstlink.so.1 diff --git a/hal/cortex-m b/hal/cortex-m new file mode 160000 index 0000000..ab2662d --- /dev/null +++ b/hal/cortex-m @@ -0,0 +1 @@ +Subproject commit ab2662dee48d4cd578904fdea3445499b8880e90 diff --git a/hal/stm32l4 b/hal/stm32l4 index ed58275..9dd2aea 160000 --- a/hal/stm32l4 +++ b/hal/stm32l4 @@ -1 +1 @@ -Subproject commit ed5827558b543f0b1986509f36f38496c7734938 +Subproject commit 9dd2aeaacb6891c1e141b0e399a02320f86d9fb5 diff --git a/kernel b/kernel index 4f10e96..339fccd 160000 --- a/kernel +++ b/kernel @@ -1 +1 @@ -Subproject commit 4f10e96066d0e0f97a4afd8fdc37f9e357cb01e4 +Subproject commit 339fccd0af6fc748b0958147f1a51e8f505479be From e7b79f001f31d8a234f7276a7f5b379b5b72885b Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 07:10:58 +0000 Subject: [PATCH 12/20] Fix submodule --- hal/cortex-m | 1 - 1 file changed, 1 deletion(-) delete mode 160000 hal/cortex-m diff --git a/hal/cortex-m b/hal/cortex-m deleted file mode 160000 index ab2662d..0000000 --- a/hal/cortex-m +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ab2662dee48d4cd578904fdea3445499b8880e90 From 0139814a4da406c51c6cc1d97fed44a1fae0593e Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 07:16:25 +0000 Subject: [PATCH 13/20] Formatting --- .github/workflows/ci.yml | 52 ++++++++++++---------------------------- 1 file changed, 15 insertions(+), 37 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4ede564..a541360 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,53 +46,31 @@ jobs: cache-from: type=registry,ref=${{ steps.set_output.outputs.container_name }}-cache cache-to: type=registry,ref=${{ steps.set_output.outputs.container_name }}-cache,mode=max - manifests: - name: Get Cargo manifests - runs-on: ubuntu-latest - needs: container - container: ${{ needs.container.outputs.container_name }} - outputs: - manifests: ${{ steps.find.outputs.manifests }} - steps: - - 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: Find Cargo.toml files - id: find - run: | - files=$(find . \( -path './build*' -o -path '*dep*' -o -path '*verus*' -o -path './target' \) -prune -false -o -name Cargo.toml) - echo "Found the following manifests:" - echo "$files" - json=$(printf '%s\n' $files | jq -R . | jq -s .) - echo "manifests=$json" >> $GITHUB_OUTPUT - fmt: - name: rustfmt check for ${{ matrix.manifest }} - needs: [container, manifests] + name: Check formatting + needs: [container] runs-on: ubuntu-latest container: ${{ needs.container.outputs.container_name }} - strategy: - matrix: - manifest: ${{ fromJson(needs.manifests.outputs.manifests) }} steps: - name: Checkout uses: actions/checkout@v4 with: submodules: recursive - - name: Setup Rust - uses: dtolnay/rust-toolchain@stable - with: - components: rustfmt - # This step is required to generate some Cargo.toml files - name: Run CMake run: cmake -B build - - name: Check formatting - run: cargo fmt --manifest-path="${{ matrix.manifest }}" -- --check + - 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 From 82c44df9a8909825f7acb7b97c8ead8714754790 Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 07:19:01 +0000 Subject: [PATCH 14/20] Set job output --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a541360..2d519dc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,6 +14,8 @@ jobs: runs-on: ubuntu-latest permissions: packages: write + outputs: + container_name: ${{ steps.set_output.outputs.container_name }} steps: - name: Checkout repository uses: actions/checkout@v4 From 880d02c8b384df01a4e31a39ac0b8ba4b4941efa Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 07:23:58 +0000 Subject: [PATCH 15/20] Maybe fix permission error --- .devcontainer/Dockerfile | 21 +++++++++++++-------- .github/workflows/ci.yml | 4 +++- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 8ea69f4..60a2bf3 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -66,6 +66,19 @@ RUN git clone --single-branch --depth 1 -b "develop" https://github.com/stlink-o # Fix for Fedora not finding libstlink.so.1 ENV LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64 +# Install Rust system-wide (for all users) +ENV RUSTUP_HOME=/usr/local/rustup +ENV CARGO_HOME=/usr/local/cargo +ENV PATH="/usr/local/cargo/bin:${PATH}" + +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \ + | sh -s -- -y --no-modify-path && \ + rustup update stable && \ + rustup component add rust-src llvm-tools-preview && \ + cargo install cargo-binutils && \ + rustup target add thumbv7em-none-eabihf thumbv7em-none-eabi + + # The runs with a non-root user to not mess up file permissions ARG USERNAME=vscode RUN useradd -m -s /bin/bash ${USERNAME} && \ @@ -74,14 +87,6 @@ RUN useradd -m -s /bin/bash ${USERNAME} && \ WORKDIR /home/${USERNAME} USER ${USERNAME} -# Install Rust -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \ - . $HOME/.cargo/env && \ - rustup component add rust-src llvm-tools-preview && \ - cargo install cargo-binutils && \ - rustup target add thumbv7em-none-eabihf thumbv7em-none-eabi - - COPY --from=qemu-builder /usr/local/ /usr/local/ ENTRYPOINT ["/bin/bash"] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2d519dc..8ed40dc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,7 +52,9 @@ jobs: name: Check formatting needs: [container] runs-on: ubuntu-latest - container: ${{ needs.container.outputs.container_name }} + container: + image: ${{ needs.container.outputs.container_name }} + options: --user vscode steps: - name: Checkout uses: actions/checkout@v4 From ad206e10bc86d9648588616f0b42bab438492a73 Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 07:28:47 +0000 Subject: [PATCH 16/20] Use root in CI? --- .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 8ed40dc..d10d442 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,7 +54,7 @@ jobs: runs-on: ubuntu-latest container: image: ${{ needs.container.outputs.container_name }} - options: --user vscode + options: --user root steps: - name: Checkout uses: actions/checkout@v4 From 1b7d6cb3b8930b45ec6b79880b657c1346dd2792 Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 07:51:57 +0000 Subject: [PATCH 17/20] Try this --- .devcontainer/Dockerfile | 22 +++++++++++++--------- .github/workflows/ci.yml | 19 +++++++++++++++++++ 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 60a2bf3..a98f98c 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -66,20 +66,16 @@ RUN git clone --single-branch --depth 1 -b "develop" https://github.com/stlink-o # Fix for Fedora not finding libstlink.so.1 ENV LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64 -# Install Rust system-wide (for all users) +# Set Rust environment variables ENV RUSTUP_HOME=/usr/local/rustup ENV CARGO_HOME=/usr/local/cargo ENV PATH="/usr/local/cargo/bin:${PATH}" -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \ - | sh -s -- -y --no-modify-path && \ - rustup update stable && \ - rustup component add rust-src llvm-tools-preview && \ - cargo install cargo-binutils && \ - rustup target add thumbv7em-none-eabihf thumbv7em-none-eabi +# 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} - -# The runs with a non-root user to not mess up file permissions +# The container now runs with a non-root user to avoid file permission issues ARG USERNAME=vscode RUN useradd -m -s /bin/bash ${USERNAME} && \ echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers @@ -87,6 +83,14 @@ RUN useradd -m -s /bin/bash ${USERNAME} && \ WORKDIR /home/${USERNAME} USER ${USERNAME} +RUN umask 0002 && \ + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \ + | sh -s -- -y --no-modify-path && \ + rustup update stable && \ + rustup component add rust-src llvm-tools-preview && \ + cargo install cargo-binutils && \ + rustup target add thumbv7em-none-eabihf thumbv7em-none-eabi + COPY --from=qemu-builder /usr/local/ /usr/local/ ENTRYPOINT ["/bin/bash"] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d10d442..4dca433 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,3 +78,22 @@ jobs: echo "Formatting check failed for one or more manifests" exit 1 fi + + build-stm32l4r5zi: + name: Build for the STM32L4R5ZI + 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 + + - name: Run CMake + run: cmake -DBOARD=stm32-nucleo-l4r5zi -DCPU=cortex-m4 -B build + + - name: Build + run: cmake --build build --parallel $(nproc) From a3551281df2d1e846527584b67196e09a6632dcc Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 07:59:10 +0000 Subject: [PATCH 18/20] Fix submodules --- hal/stm32l4 | 2 +- kernel | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hal/stm32l4 b/hal/stm32l4 index 9dd2aea..ed58275 160000 --- a/hal/stm32l4 +++ b/hal/stm32l4 @@ -1 +1 @@ -Subproject commit 9dd2aeaacb6891c1e141b0e399a02320f86d9fb5 +Subproject commit ed5827558b543f0b1986509f36f38496c7734938 diff --git a/kernel b/kernel index 339fccd..4f10e96 160000 --- a/kernel +++ b/kernel @@ -1 +1 @@ -Subproject commit 339fccd0af6fc748b0958147f1a51e8f505479be +Subproject commit 4f10e96066d0e0f97a4afd8fdc37f9e357cb01e4 From c16e857804db257e4c2484bb6806cc79080687df Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 08:14:39 +0000 Subject: [PATCH 19/20] Enable color output --- .github/workflows/ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4dca433..2f79d5a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,11 @@ on: name: Osiris CI +env: + CARGO_TERM_COLOR: always + TERM: xterm-256color + + jobs: container: name: Build Container From 880b44e503cd21b88feb886c6f398c29ad20c342 Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sat, 15 Feb 2025 09:58:47 +0100 Subject: [PATCH 20/20] Cache options --- .devcontainer/Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index a98f98c..352df6e 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -2,7 +2,7 @@ FROM fedora:latest AS qemu-builder RUN dnf update -y && \ - dnf install -y \ + dnf install -y --setopt=keepcache=0 \ @development-tools \ git \ clang \ @@ -38,7 +38,7 @@ RUN git clone --depth 1 https://github.com/thomasw04/qemu.git /tmp/qemu && \ FROM fedora:latest AS devcontainer RUN dnf update -y && \ - dnf install -y \ + dnf install -y --setopt=keepcache=0 \ @development-tools \ direnv \ arm-none-eabi-gcc-cs \ @@ -51,7 +51,7 @@ RUN dnf update -y && \ libusb1-devel \ 'dnf-command(copr)' && \ dnf copr enable -y rleh/arm-none-eabi-gdb && \ - dnf install -y arm-none-eabi-gdb && \ + dnf install -y --setopt=keepcache=0 arm-none-eabi-gdb && \ dnf clean all && \ ln -sf /usr/bin/clang /usr/bin/cc && \ ln -sf /usr/bin/clang++ /usr/bin/c++