diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..fee4307 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,22 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/debian +{ + "name": "Debian", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "dockerFile": "../CubeMx/Dockerfile", + "privileged": true, + "forwardPorts": [14500, 14500] + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" + +} diff --git a/CubeClt/Dockerfile b/CubeClt/Dockerfile new file mode 100644 index 0000000..8bc0834 --- /dev/null +++ b/CubeClt/Dockerfile @@ -0,0 +1,30 @@ +FROM mcr.microsoft.com/devcontainers/cpp:1-debian-12 + +ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="3.22.2" + +ARG INSTALL_CUBE_CLT="true" + +# Optionally install the cmake for vcpkg +COPY ./Resources/Scripts/reinstall-cmake.sh /tmp/ + +RUN if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then \ + chmod +x /tmp/reinstall-cmake.sh && /tmp/reinstall-cmake.sh ${REINSTALL_CMAKE_VERSION_FROM_SOURCE}; \ + fi \ + && rm -f /tmp/reinstall-cmake.sh + + +# Optionally install the Cube CLT +COPY ../Resources/CubeCLT /tmp/CubeCLT/ +RUN if [ "${INSTALL_CUBE_CLT}" = "true" ]; then \ + chmod +x /tmp/CubeCLT/install.sh && /tmp/CubeCLT/install.sh; \ + fi \ +&& rm -rf /tmp/CubeCLT + + +# [Optional] Uncomment this section to install additional vcpkg ports. +# RUN su vscode -c "${VCPKG_ROOT}/vcpkg install " + +# [Optional] Uncomment this section to install additional packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends + diff --git a/CubeClt/Resources/CubeCLT/install.sh b/CubeClt/Resources/CubeCLT/install.sh new file mode 100644 index 0000000..7532b9d --- /dev/null +++ b/CubeClt/Resources/CubeCLT/install.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +# Set the script to fail if any command fails. +set -e + +echo "Installing CubeCLT..." + +# Extract zip file +unzip -q /tmp/CubeCLT/en.st-stm32cubeclt_1.17* -d /tmp/cubeclt +cd /tmp/cubeclt && chmod +x *.sh +export LICENSE_ALREADY_ACCEPTED=1 +/tmp/cubeclt/*.sh --target . --noexec + +export DEBIAN_FRONTEND=noninteractive +apt-get update +apt-get install -y /tmp/cubeclt/st-stlink-udev-rules*.deb +apt-get install -y /tmp/cubeclt/st-stlink-server*.deb +apt-get install -y /tmp/cubeclt/st-stm32cubeclt*.deb + +rm -rf /tmp/cubeclt + + + + diff --git a/CubeClt/Resources/Scripts/reinstall-cmake.sh b/CubeClt/Resources/Scripts/reinstall-cmake.sh new file mode 100644 index 0000000..408b81d --- /dev/null +++ b/CubeClt/Resources/Scripts/reinstall-cmake.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash +#------------------------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. +#------------------------------------------------------------------------------------------------------------- +# +set -e + +CMAKE_VERSION=${1:-"none"} + +if [ "${CMAKE_VERSION}" = "none" ]; then + echo "No CMake version specified, skipping CMake reinstallation" + exit 0 +fi + +# Cleanup temporary directory and associated files when exiting the script. +cleanup() { + EXIT_CODE=$? + set +e + if [[ -n "${TMP_DIR}" ]]; then + echo "Executing cleanup of tmp files" + rm -Rf "${TMP_DIR}" + fi + exit $EXIT_CODE +} +trap cleanup EXIT + + +echo "Installing CMake..." +apt-get -y purge --auto-remove cmake +mkdir -p /opt/cmake + +architecture=$(dpkg --print-architecture) +case "${architecture}" in + arm64) + ARCH=aarch64 ;; + amd64) + ARCH=x86_64 ;; + *) + echo "Unsupported architecture ${architecture}." + exit 1 + ;; +esac + +CMAKE_BINARY_NAME="cmake-${CMAKE_VERSION}-linux-${ARCH}.sh" +CMAKE_CHECKSUM_NAME="cmake-${CMAKE_VERSION}-SHA-256.txt" +TMP_DIR=$(mktemp -d -t cmake-XXXXXXXXXX) + +echo "${TMP_DIR}" +cd "${TMP_DIR}" + +curl -sSL "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_BINARY_NAME}" -O +curl -sSL "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_CHECKSUM_NAME}" -O + +sha256sum -c --ignore-missing "${CMAKE_CHECKSUM_NAME}" +sh "${TMP_DIR}/${CMAKE_BINARY_NAME}" --prefix=/opt/cmake --skip-license + +ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake +ln -s /opt/cmake/bin/ctest /usr/local/bin/ctest diff --git a/CubeClt/build_and_publish.sh b/CubeClt/build_and_publish.sh new file mode 100755 index 0000000..ed54430 --- /dev/null +++ b/CubeClt/build_and_publish.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +push=false +# Process oprions +while getopts "pt:" opt; do + case $opt in + p) push=true;; + t) tag=$OPTARG;; + \?) echo "Invalid option: -$OPTARG" >&2 ;; + :) echo "Option -$OPTARG requires an argument." >&2 ;; + esac +done + + + +docker build -t nexus.springblast.de:8082/carly/docker-stm32/cubeclt:$tag . +docker build -t nexus.springblast.de:8082/carly/docker-stm32/cubeclt:latest . + +if [ "$push" = true ]; then + docker push nexus.springblast.de:8082/carly/docker-stm32/cubeclt:$tag + docker push nexus.springblast.de:8082/carly/docker-stm32/cubeclt:latest +fi diff --git a/CubeMx/Dockerfile b/CubeMx/Dockerfile new file mode 100644 index 0000000..0d3eb86 --- /dev/null +++ b/CubeMx/Dockerfile @@ -0,0 +1,24 @@ +FROM nexus.springblast.de:8082/carly/docker-stm32/cubeclt:latest + +ARG INSTALL_CUBEMX="true" + +# Install Xpra, X server, and window manager +RUN apt-get update && apt-get install -y xpra xorg openbox xauth xterm + +RUN apt-get update && apt-get install -y \ + libxext6 \ + libxrender1 \ + libxtst6 \ + libxi6 + +# Optionally install the CubeMX +COPY ./Resources/CubeMX/cubemx.tar.gz /home/vscode +RUN tar -xvf /home/vscode/cubemx.tar.gz + +# RUN if [ "${INSTALL_CUBEMX}" = "true" ]; then \ +# chmod +x /tmp/CubeMX/install-cubemx.sh && /tmp/CubeMX/install-cubemx.sh; \ +# fi + # && rm -rf /tmp/CubeMX + + #CMD xpra start --start=xeyes --bind-tcp=0.0.0.0:14500 --html=on --daemon=no && bash + #sudo xpra start :100 --start=xterm --no-daemon --bind-tcp=0.0.0.0:14500 --html=on \ No newline at end of file diff --git a/CubeMx/Resources/CubeMX/install-cubemx.sh b/CubeMx/Resources/CubeMX/install-cubemx.sh new file mode 100644 index 0000000..dbe7e0e --- /dev/null +++ b/CubeMx/Resources/CubeMX/install-cubemx.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# Set the script to fail if any command fails. +set -e + +# Cleanup temporary directory and associated files when exiting the script. +cleanup() { + EXIT_CODE=$? + set +e + if [[ -n "${TMP_DIR}" ]]; then + echo "Executing cleanup of tmp files" + rm -Rf "${TMP_DIR}" + fi + exit $EXIT_CODE +} + +echo "Installing CubeMX..." + +# Extract zip file +unzip -q /tmp/CubeMX/en.stm32cubemx-lin-v6-13-0.zip -d /tmp/CubeMX + + diff --git a/CubeMx/build_and_publish.sh b/CubeMx/build_and_publish.sh new file mode 100755 index 0000000..9cf34fd --- /dev/null +++ b/CubeMx/build_and_publish.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +push=false +# Process oprions +while getopts "pt:" opt; do + case $opt in + p) push=true;; + t) tag=$OPTARG;; + \?) echo "Invalid option: -$OPTARG" >&2 ;; + :) echo "Option -$OPTARG requires an argument." >&2 ;; + esac +done + + +docker build -t nexus.springblast.de:8082/carly/docker-stm32/cubemx:$tag . \ No newline at end of file diff --git a/README.md b/README.md index 2d27b4e..b333534 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -# docker-stm32 +# stm32