From 08eccf544339a3957283a9255890fa2ad81ea064 Mon Sep 17 00:00:00 2001 From: FoniksFox Date: Sun, 5 Apr 2026 16:39:08 +0000 Subject: [PATCH 1/4] feat(ci): Use Ubuntu 22.04 without hacks and with stlink-server and set up devcontainer --- .devcontainer/Containerfile | 3 ++ .devcontainer/devcontainer.json | 25 +++++++++++++ ci/Dockerfile | 64 +++++++++++++++++---------------- 3 files changed, 61 insertions(+), 31 deletions(-) create mode 100644 .devcontainer/Containerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Containerfile b/.devcontainer/Containerfile new file mode 100644 index 000000000..7292575ea --- /dev/null +++ b/.devcontainer/Containerfile @@ -0,0 +1,3 @@ +FROM ghcr.io/hyperloop-upv/hyperloop-firmware-toolchain:latest + +WORKDIR /workspaces \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..285e64125 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,25 @@ +{ + "name": "ST-LIB Dev Container", + "build": { + "dockerfile": "Containerfile" + }, + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + "runArgs": [ + "--userns=keep-id" + ], + "containerEnv": { + "CONTAINER_NAME": "stm32-project" + }, + "customizations": { + "vscode": { + "extensions": [ + "ms-vscode.cpptools", + "marus25.cortex-debug", + "twxs.cmake", + "ms-vscode.cmake-tools" + ] + } + }, + "containerUser": "root", + "updateRemoteUserUID": true +} diff --git a/ci/Dockerfile b/ci/Dockerfile index 62ca6205b..13778aeff 100644 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -1,45 +1,47 @@ -FROM ubuntu:24.04 +FROM ubuntu:22.04 -ARG DEBIAN_FRONTEND=noninteractive +ENV DEBIAN_FRONTEND=noninteractive ARG CUBECLT_VERSION=1.21.0 ARG CUBECLT_INSTALLER=cubeclt_${CUBECLT_VERSION}_installer.sh -ARG UV_INSTALLER_URL=https://astral.sh/uv/install.sh -RUN echo "deb http://security.ubuntu.com/ubuntu focal-security main universe" > /etc/apt/sources.list.d/ubuntu-focal-sources.list && \ - apt-get update && \ - apt-get install -y --no-install-recommends \ - bash ca-certificates curl git git-lfs \ - python3 python3-pip python3-venv \ - cmake ninja-build \ - g++ build-essential \ - libncurses5 libusb-1.0-0 \ - gdb && \ - git lfs install --system && \ - rm -rf /var/lib/apt/lists/* +# 1. Install System Dependencies (Revised for Programmer CLI) +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential cmake ninja-build git git-lfs \ + python3 python3-pip python3-venv curl \ + libncurses5 libusb-1.0-0 stlink-tools openocd \ + libglib2.0-0 libusb-0.1-4 libsm6 libice6 \ + tio cu lsb-release \ + && rm -rf /var/lib/apt/lists/* -RUN curl -LsSf "${UV_INSTALLER_URL}" | sh && \ - ln -sf /root/.local/bin/uv /usr/local/bin/uv && \ - python3 -m pip install --break-system-packages \ - Jinja2==3.1.5 \ - GitPython==3.1.43 +RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \ + ln -sf /root/.local/bin/uv /usr/local/bin/uv -# Install cubeclt (STM32CubeCLT) WORKDIR /tmp RUN git clone --depth 1 https://github.com/Hyperloop-UPV/cubeclt.git && \ cd cubeclt && \ git lfs pull --include="${CUBECLT_INSTALLER}" && \ chmod +x ${CUBECLT_INSTALLER} && \ - echo | LICENSE_ALREADY_ACCEPTED=1 ./${CUBECLT_INSTALLER} && \ - actual_root="$(find /opt/st -maxdepth 1 -type d -name "stm32cubeclt_${CUBECLT_VERSION}*" | head -n1)" && \ - test -n "${actual_root}" && \ - mkdir -p /opt/ST && \ - ln -s "${actual_root}" "/opt/ST/STM32CubeCLT_${CUBECLT_VERSION}" && \ - cd / && \ - rm -rf /tmp/cubeclt + ./${CUBECLT_INSTALLER} --target /tmp/extract --noexec && \ + # --- Part A: STM32CubeCLT --- + mkdir -p /opt/st/STM32CubeCLT_${CUBECLT_VERSION} && \ + tar -xzf /tmp/extract/st-stm32cubeclt_*.tar.gz -C /opt/st/STM32CubeCLT_${CUBECLT_VERSION} --strip-components=1 && \ + cp /tmp/extract/version.txt /opt/st/STM32CubeCLT_${CUBECLT_VERSION}/version.txt && \ + # --- Part B: ST-LINK Server --- + export LICENSE_ALREADY_ACCEPTED=1 && \ + SERVER_INSTALL=$(ls /tmp/extract/st-stlink-server.*.install.sh) && \ + sh "$SERVER_INSTALL" --target /tmp/server_extract --noexec && \ + cp /tmp/server_extract/stlink-server /usr/bin/stlink-server && \ + chmod +x /usr/bin/stlink-server && \ + # --- Part C: FIX THE PATH MISMATCH --- + # Create the directory structure the VS Code extension expects + mkdir -p /usr/local/STMicroelectronics/STM32Cube/STM32CubeProgrammer && \ + ln -s /opt/st/STM32CubeCLT_${CUBECLT_VERSION}/STM32CubeProgrammer/bin /usr/local/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin && \ + # Cleanup + cd / && rm -rf /tmp/cubeclt /tmp/extract /tmp/server_extract -ENV STM32_CLT_ROOT=/opt/ST/STM32CubeCLT_${CUBECLT_VERSION} -ENV HYPER_STM32CLT_ROOT=/opt/ST/STM32CubeCLT_${CUBECLT_VERSION} -ENV PATH="/root/.local/bin:${STM32_CLT_ROOT}/GNU-tools-for-STM32/bin:${STM32_CLT_ROOT}/STM32CubeProgrammer/bin:${STM32_CLT_ROOT}/CMake/bin:${STM32_CLT_ROOT}/Ninja/bin:${PATH}" +ENV STM32_CLT_ROOT=/opt/st/STM32CubeCLT_${CUBECLT_VERSION} +ENV HYPER_STM32CLT_ROOT=/opt/st/STM32CubeCLT_${CUBECLT_VERSION} +ENV PATH="/root/.local/bin:${STM32_CLT_ROOT}/GNU-tools-for-STM32/bin:${STM32_CLT_ROOT}/STM32CubeProgrammer/bin:${STM32_CLT_ROOT}/STLink-gdb-server/bin:${STM32_CLT_ROOT}/CMake/bin:${STM32_CLT_ROOT}/Ninja/bin:${PATH}" -WORKDIR /workspace +WORKDIR /workspaces From dbe5a2064af571ea0bf4c24f91828a9f3aa3f5a8 Mon Sep 17 00:00:00 2001 From: FoniksFox Date: Sun, 5 Apr 2026 16:51:10 +0000 Subject: [PATCH 2/4] fix(devcontainer): Add changeset for devcontainer --- .changesets/devcontainer-none | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .changesets/devcontainer-none diff --git a/.changesets/devcontainer-none b/.changesets/devcontainer-none new file mode 100644 index 000000000..71055aab5 --- /dev/null +++ b/.changesets/devcontainer-none @@ -0,0 +1,4 @@ +release: none +summary: Add devcontainer config and fix some things to hyperloop-firmware-toolchain + +Use **Ubuntu 22.04** instead of 24.04 in the package image to eliminate the ubuntu 20.04 Noble hack. Also adds **devcontainer** config and installs **stlink-server**. \ No newline at end of file From 6773c6e51967ba1e20f035ccb4b3c2bad8ac7942 Mon Sep 17 00:00:00 2001 From: FoniksFox Date: Sun, 5 Apr 2026 16:52:40 +0000 Subject: [PATCH 3/4] fix(devcontainer): Fix extension --- .changesets/{devcontainer-none => devcontainer-none.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .changesets/{devcontainer-none => devcontainer-none.md} (100%) diff --git a/.changesets/devcontainer-none b/.changesets/devcontainer-none.md similarity index 100% rename from .changesets/devcontainer-none rename to .changesets/devcontainer-none.md From da1d2f946a399e63c5b20698c7f98bbea837e327 Mon Sep 17 00:00:00 2001 From: FoniksFox Date: Sun, 5 Apr 2026 17:06:12 +0000 Subject: [PATCH 4/4] fix(devcontainer): Implement suggestions --- .changesets/devcontainer-none.md | 2 +- .devcontainer/devcontainer.json | 3 --- ci/Dockerfile | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.changesets/devcontainer-none.md b/.changesets/devcontainer-none.md index 71055aab5..d72edbe50 100644 --- a/.changesets/devcontainer-none.md +++ b/.changesets/devcontainer-none.md @@ -1,4 +1,4 @@ release: none summary: Add devcontainer config and fix some things to hyperloop-firmware-toolchain -Use **Ubuntu 22.04** instead of 24.04 in the package image to eliminate the ubuntu 20.04 Noble hack. Also adds **devcontainer** config and installs **stlink-server**. \ No newline at end of file +Use **Ubuntu 22.04** instead of 24.04 in the package image to eliminate the ubuntu 20.04 Focal hack. Also adds **devcontainer** config and installs **stlink-server**. \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 285e64125..7205fa5b6 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -4,9 +4,6 @@ "dockerfile": "Containerfile" }, "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", - "runArgs": [ - "--userns=keep-id" - ], "containerEnv": { "CONTAINER_NAME": "stm32-project" }, diff --git a/ci/Dockerfile b/ci/Dockerfile index 13778aeff..f121cc701 100644 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -1,6 +1,6 @@ FROM ubuntu:22.04 -ENV DEBIAN_FRONTEND=noninteractive +ARG DEBIAN_FRONTEND=noninteractive ARG CUBECLT_VERSION=1.21.0 ARG CUBECLT_INSTALLER=cubeclt_${CUBECLT_VERSION}_installer.sh