cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 VS Code Extension and Devcontainer

pcb
Associate II

I am a happy VSCode developer using docker devcontainers to create an easily reproducible environment for development. I am struggling with a strange bug with the "STM32 VS Code Extension" (v2.0.1).

If I try to access it, after opening the container, I get the following error:
"Cannot activate the 'STM32 VS Code Extension' extension because it depends on the 'C/C++ Extension Pack' extension, which is not loaded. Would you like to reload the window to load the extension?"

This is strange because the C/C++ Extension Pack is loaded and part of my dev container.

I have the option to "Reload Window", but hitting it only results in a reload and the same message popping back up.

Has anyone been able to use this vscode extension inside a devcontainer?

Joachim Spange
Head in the embedded
16 REPLIES 16

I was able to get this error to go away if i changed my profile to "Default" which doesnt have the STM32 extension on it

sslebie_0-1720736482768.png

 

sslebie
Associate II

Yeah by doing that I was able to install the STM32CubeCLT, build my project, and properly generate an elf file.

 

I'm wondering if you just need the STM32 VS Code Extension not to be installed on the local host. I'm going to work on getting the Dockerfile setup properly so that the image can fully build.

 

Do you know how to pass a USB device (The STLink Debugger tool) from Windows into the Docker Image?

I only have the "Default' profile. And since it works very well on the host machine, I think it is not the issue you have suggested. 

 

kestrel_1-1720740520119.png

Image from Visual Studio Code. Developing inside a Container.

And due to the way VSCode extension works, the host machine must have the extension installed to use it inside the container. Therefore, I think that the secons issue is also not the case I am experiencing now.

I also attach the Dockerfile I used to build an image. The entrypoint.sh is just a simple "bash -c sleep infinity".

 

 

RG BASEIMAGE
ARG BASETAG

# STAGE FOR CACHING APT PACKAGE LIST
FROM ${BASEIMAGE}:${BASETAG} AS stage_apt

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

ENV \
    DEBIAN_FRONTEND=noninteractive \
    LANG=C.UTF-8 \
    LC_ALL=C.UTF-8

RUN \
    rm -rf /etc/apt/apt.conf.d/docker-clean \
	&& echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache \
	&& apt-get update

# STAGE FOR INSTALLING APT DEPENDENCIES
FROM ${BASEIMAGE}:${BASETAG} AS stage_deps

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

ENV \
    DEBIAN_FRONTEND=noninteractive \
    LANG=C.UTF-8 \
    LC_ALL=C.UTF-8 \
    LICENSE_ALREADY_ACCEPTED=1 \
    JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64

COPY aptDeps.txt /tmp/aptDeps.txt

# INSTALL APT DEPENDENCIES USING CACHE OF stage_apt
RUN \
    --mount=type=cache,target=/var/cache/apt,from=stage_apt,source=/var/cache/apt \
    --mount=type=cache,target=/var/lib/apt,from=stage_apt,source=/var/lib/apt \
    --mount=type=cache,target=/etc/apt/sources.list.d,from=stage_apt,source=/etc/apt/sources.list.d \
	apt-get install --no-install-recommends -y $(cat /tmp/aptDeps.txt) \
    && rm -rf /tmp/*

COPY \
    resource/en.st-stm32cubeclt_1.12.1_16088_20230420_1057_amd64.deb_bundle.sh.zip \
    /tmp/en.st-stm32cubeclt_1.12.1_16088_20230420_1057_amd64.deb_bundle.sh.zip

# INSTALL STM32CUBECTL
RUN \
    --mount=type=cache,target=/var/cache/apt,from=stage_apt,source=/var/cache/apt \
    --mount=type=cache,target=/var/lib/apt,from=stage_apt,source=/var/lib/apt \
    --mount=type=cache,target=/etc/apt/sources.list.d,from=stage_apt,source=/etc/apt/sources.list.d \
    unzip -q /tmp/en.st-stm32cubeclt_1.12.1_16088_20230420_1057_amd64.deb_bundle.sh.zip -d /tmp/stm32cubeclt \
    && chmod +x /tmp/stm32cubeclt/st-stm32cubeclt_1.12.1_16088_20230420_1057_amd64.deb_bundle.sh \
    && /tmp/stm32cubeclt/st-stm32cubeclt_1.12.1_16088_20230420_1057_amd64.deb_bundle.sh --target /tmp/stm32cubeclt/debfiles --noexec \
    && apt-get install -y /tmp/stm32cubeclt/debfiles/*.deb \
    && chmod 755 -R /opt/st/stm32cubeclt_1.12.1 \
    && rm -rf /tmp/*

COPY \
    resource/en.stm32cubemx-lin-v6-8-1.zip \
    /tmp/en.stm32cubemx-lin-v6-8-1.zip

COPY \
    resource/auto-install-cubemx.xml \
    /tmp/auto-install-cubemx.xml

# INSTALL STM32CUBEMX
RUN \
    unzip -q /tmp/en.stm32cubemx-lin-v6-8-1.zip -d /tmp/stm32cubemx \
    && chmod +x /tmp/stm32cubemx/SetupSTM32CubeMX-6.8.1 \
    && /tmp/stm32cubemx/SetupSTM32CubeMX-6.8.1 /tmp/auto-install-cubemx.xml \
    && chmod 755 -R /usr/local/STMicroelectronics/STM32Cube/STM32CubeMX/jre \
    && rm -rf /tmp/*

COPY \
    resource/en.st-mcu-finderlin-v6-0-0.zip \
    /tmp/en.st-mcu-finderlin-v6-0-0.zip

COPY \
    resource/auto-install-stm-mcu-finder.xml \
    /tmp/auto-install-stm-mcu-finder.xml

# INSTALL STMMCUFINDER
RUN \
    unzip -q /tmp/en.st-mcu-finderlin-v6-0-0.zip -d /tmp/st-mcu-finderlin \
    && /tmp/st-mcu-finderlin/SetupSTMCUFinder-6.0.0 /tmp/auto-install-stm-mcu-finder.xml \
    && chmod 755 -R /usr/local/STMicroelectronics/STMCUFinder/jre \
    && rm -rf /tmp/*

COPY \
    resource/en.st-stm32cubeide_1.12.1_16088_20230420_1057_amd64.sh.zip \
    /tmp/en.st-stm32cubeide_1.12.1_16088_20230420_1057_amd64.sh.zip

# INSTALL STM32CUBEIDE
RUN \
    unzip -q /tmp/en.st-stm32cubeide_1.12.1_16088_20230420_1057_amd64.sh.zip -d /tmp/stm32cubeide \
    && chmod +x /tmp/stm32cubeide/st-stm32cubeide_1.12.1_16088_20230420_1057_amd64.sh \
    && /tmp/stm32cubeide/st-stm32cubeide_1.12.1_16088_20230420_1057_amd64.sh --target /tmp/stm32cubeide/debfiles --noexec \
    && sed -i '23,43d' /tmp/stm32cubeide/debfiles/install_as_root.sh

WORKDIR /tmp/stm32cubeide/debfiles

RUN \
    /tmp/stm32cubeide/debfiles/setup.sh /opt/st/stm32cubeide_1.12.1 \
    && chmod 755 -R /opt/st/stm32cubeide_1.12.1 \
    && rm -rf /tmp/*

WORKDIR /

# ADD NON-ROOT USER user FOR RUNNING THE WEBUI
RUN \
    groupadd user \
    && useradd -ms /bin/bash user -g user \
    && echo "user ALL=NOPASSWD: ALL" >> /etc/sudoers

USER user
WORKDIR /home/user

RUN \
    ln -s /usr/local/STMicroelectronics/STM32Cube/STM32CubeMX /home/user/STM32CubeMX \
    && ln -s /usr/local/STMicroelectronics/STMCUFinder /home/user/STMCUFinder \
    && ln -s /opt/st/stm32cubeide_1.12.1 /home/user/STM32CubeIDE \
    && ln -s /opt/st/stm32cubeclt_1.12.1 /home/user/STM32CubeCLT

COPY entrypoint.sh /usr/local/bin/entrypoint.sh

ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

 

 

Paths will be:

  • CubeMX: /home/user/STM32CubeMX/STM32CubeMX
  • CubeCLT: /opt/st/stm32cubeclt_1.12.1
  • STMCUFinder: /home/user/STMCUFinder/STMCUFinder

In order to pass the USB device from the WIndows host to the docker container running on the hyper-V, the method I can think of is to use a docker running on WSL. Through USBIP, you can pass the USB device attached to the Windows host to the client on the WSL session.

After this, passing the USB device on the WSL host to the docker container through "device" option or volume mount with privileged flag will work. However, I can't think of the working way for the docker container running directly on the Hyper-V environment. I don't know which docker environment is the case of yours, but if it is the case of the latter one, I think it would be better to use a docker running on WSL.

By the way, I work on the Ubuntu instead of the WSL or Docker Desktop on Windows. I personally have bad user experience for USBIP or equivalent solutions when working on hardware-driven devices.

 

Ah, I think the version might be the issue for my case. The extension recommends CubeCLT v1.15.0 and version of other packaged to be higher.

I was able to get a simple Nucleo Project built and running through the Dev Container!

 

I had to pass the STLink through WSL like you suggested. I'm working on refining the Docker Image to include all the supporting applications and trying to streamline the workflow so I can actually start using this and sharing it!

Could you please share what you got right now?

Thank you!

@STTwo-32 Is this issue been worked on by the STM32 VS Code extension team? Is @Nawres GHARBI still provinding support for the STM32 VS Code extension?

hi @Rob.Riggs 

still no solution found for this issue