diff --git a/.changesets/devcontainer-none.md b/.changesets/devcontainer-none.md new file mode 100644 index 000000000..d72edbe50 --- /dev/null +++ b/.changesets/devcontainer-none.md @@ -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 Focal hack. Also adds **devcontainer** config and installs **stlink-server**. \ No newline at end of file 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..7205fa5b6 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,22 @@ +{ + "name": "ST-LIB Dev Container", + "build": { + "dockerfile": "Containerfile" + }, + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + "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..f121cc701 100644 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -1,45 +1,47 @@ -FROM ubuntu:24.04 +FROM ubuntu:22.04 ARG 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