Skip to content

Commit 08eccf5

Browse files
committed
feat(ci): Use Ubuntu 22.04 without hacks and with stlink-server and set up devcontainer
1 parent 4ab7fe3 commit 08eccf5

3 files changed

Lines changed: 61 additions & 31 deletions

File tree

.devcontainer/Containerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM ghcr.io/hyperloop-upv/hyperloop-firmware-toolchain:latest
2+
3+
WORKDIR /workspaces

.devcontainer/devcontainer.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "ST-LIB Dev Container",
3+
"build": {
4+
"dockerfile": "Containerfile"
5+
},
6+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
7+
"runArgs": [
8+
"--userns=keep-id"
9+
],
10+
"containerEnv": {
11+
"CONTAINER_NAME": "stm32-project"
12+
},
13+
"customizations": {
14+
"vscode": {
15+
"extensions": [
16+
"ms-vscode.cpptools",
17+
"marus25.cortex-debug",
18+
"twxs.cmake",
19+
"ms-vscode.cmake-tools"
20+
]
21+
}
22+
},
23+
"containerUser": "root",
24+
"updateRemoteUserUID": true
25+
}

ci/Dockerfile

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,47 @@
1-
FROM ubuntu:24.04
1+
FROM ubuntu:22.04
22

3-
ARG DEBIAN_FRONTEND=noninteractive
3+
ENV DEBIAN_FRONTEND=noninteractive
44
ARG CUBECLT_VERSION=1.21.0
55
ARG CUBECLT_INSTALLER=cubeclt_${CUBECLT_VERSION}_installer.sh
6-
ARG UV_INSTALLER_URL=https://astral.sh/uv/install.sh
76

8-
RUN echo "deb http://security.ubuntu.com/ubuntu focal-security main universe" > /etc/apt/sources.list.d/ubuntu-focal-sources.list && \
9-
apt-get update && \
10-
apt-get install -y --no-install-recommends \
11-
bash ca-certificates curl git git-lfs \
12-
python3 python3-pip python3-venv \
13-
cmake ninja-build \
14-
g++ build-essential \
15-
libncurses5 libusb-1.0-0 \
16-
gdb && \
17-
git lfs install --system && \
18-
rm -rf /var/lib/apt/lists/*
7+
# 1. Install System Dependencies (Revised for Programmer CLI)
8+
RUN apt-get update && apt-get install -y --no-install-recommends \
9+
build-essential cmake ninja-build git git-lfs \
10+
python3 python3-pip python3-venv curl \
11+
libncurses5 libusb-1.0-0 stlink-tools openocd \
12+
libglib2.0-0 libusb-0.1-4 libsm6 libice6 \
13+
tio cu lsb-release \
14+
&& rm -rf /var/lib/apt/lists/*
1915

20-
RUN curl -LsSf "${UV_INSTALLER_URL}" | sh && \
21-
ln -sf /root/.local/bin/uv /usr/local/bin/uv && \
22-
python3 -m pip install --break-system-packages \
23-
Jinja2==3.1.5 \
24-
GitPython==3.1.43
16+
RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \
17+
ln -sf /root/.local/bin/uv /usr/local/bin/uv
2518

26-
# Install cubeclt (STM32CubeCLT)
2719
WORKDIR /tmp
2820

2921
RUN git clone --depth 1 https://github.com/Hyperloop-UPV/cubeclt.git && \
3022
cd cubeclt && \
3123
git lfs pull --include="${CUBECLT_INSTALLER}" && \
3224
chmod +x ${CUBECLT_INSTALLER} && \
33-
echo | LICENSE_ALREADY_ACCEPTED=1 ./${CUBECLT_INSTALLER} && \
34-
actual_root="$(find /opt/st -maxdepth 1 -type d -name "stm32cubeclt_${CUBECLT_VERSION}*" | head -n1)" && \
35-
test -n "${actual_root}" && \
36-
mkdir -p /opt/ST && \
37-
ln -s "${actual_root}" "/opt/ST/STM32CubeCLT_${CUBECLT_VERSION}" && \
38-
cd / && \
39-
rm -rf /tmp/cubeclt
25+
./${CUBECLT_INSTALLER} --target /tmp/extract --noexec && \
26+
# --- Part A: STM32CubeCLT ---
27+
mkdir -p /opt/st/STM32CubeCLT_${CUBECLT_VERSION} && \
28+
tar -xzf /tmp/extract/st-stm32cubeclt_*.tar.gz -C /opt/st/STM32CubeCLT_${CUBECLT_VERSION} --strip-components=1 && \
29+
cp /tmp/extract/version.txt /opt/st/STM32CubeCLT_${CUBECLT_VERSION}/version.txt && \
30+
# --- Part B: ST-LINK Server ---
31+
export LICENSE_ALREADY_ACCEPTED=1 && \
32+
SERVER_INSTALL=$(ls /tmp/extract/st-stlink-server.*.install.sh) && \
33+
sh "$SERVER_INSTALL" --target /tmp/server_extract --noexec && \
34+
cp /tmp/server_extract/stlink-server /usr/bin/stlink-server && \
35+
chmod +x /usr/bin/stlink-server && \
36+
# --- Part C: FIX THE PATH MISMATCH ---
37+
# Create the directory structure the VS Code extension expects
38+
mkdir -p /usr/local/STMicroelectronics/STM32Cube/STM32CubeProgrammer && \
39+
ln -s /opt/st/STM32CubeCLT_${CUBECLT_VERSION}/STM32CubeProgrammer/bin /usr/local/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin && \
40+
# Cleanup
41+
cd / && rm -rf /tmp/cubeclt /tmp/extract /tmp/server_extract
4042

41-
ENV STM32_CLT_ROOT=/opt/ST/STM32CubeCLT_${CUBECLT_VERSION}
42-
ENV HYPER_STM32CLT_ROOT=/opt/ST/STM32CubeCLT_${CUBECLT_VERSION}
43-
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}"
43+
ENV STM32_CLT_ROOT=/opt/st/STM32CubeCLT_${CUBECLT_VERSION}
44+
ENV HYPER_STM32CLT_ROOT=/opt/st/STM32CubeCLT_${CUBECLT_VERSION}
45+
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}"
4446

45-
WORKDIR /workspace
47+
WORKDIR /workspaces

0 commit comments

Comments
 (0)