Skip to content

Commit

Permalink
Added Docker based Dev Container for VS Code.
Browse files Browse the repository at this point in the history
  • Loading branch information
feaser committed Jan 14, 2024
1 parent 9ce1bd5 commit dbac6dd
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Container base
FROM mcr.microsoft.com/devcontainers/base:ubuntu-22.04

# Configuration
ARG TOOLS_PATH=/opt/gcc-arm-none-eabi

# Update package repositories
RUN apt-get update

# Install package dependencies
RUN apt-get install build-essential wget git cmake cppcheck openocd libncurses5 usbutils -y

# Download and install ARM GNU Embedded toolchain
RUN wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/10-2020q4/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.gz
RUN mkdir ${TOOLS_PATH}
RUN tar xf gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.gz --strip-components=1 -C ${TOOLS_PATH}
RUN rm gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.gz

# Add ARM GNU Embedded toolchain binaries directory to the path
ENV PATH="$PATH:${TOOLS_PATH}/bin"
92 changes: 92 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"name": "MicroTBX",
"build": {
"dockerfile": "Dockerfile"
},
// Run in privileged mode, needed for access to USB devices.
"privileged": true,
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-vscode.cpptools",
"ms-vscode.cpptools-extension-pack",
"ms-vscode.cpptools-themes",
"marus25.cortex-debug",
"ms-vscode.cmake-tools",
"twxs.cmake",
"jgclark.vscode-todo-highlight"
],
// Add preferred user settings.
"settings": {
"cmake.configureArgs": ["-DMISRA_ENABLED=ON" ],
"cmake.preferredGenerators": ["Unix Makefiles"],
"cmake.buildBeforeRun": true,
"cmake.options.statusBarVisibility": "visible",
"cmake.options.advanced": {
"build": {
"statusBarVisibility": "visible"
},
"launch": {
"statusBarVisibility": "hidden"
},
"debug": {
"statusBarVisibility": "hidden"
}
},
"editor.fontSize": 12,
"editor.rulers": [89],
"editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.fontFamily": "'Hack', 'Droid Sans Mono', 'monospace', monospace, 'Droid Sans Fallback'",
"editor.minimap.enabled": false,
"editor.guides.indentation": false,
"editor.formatOnType": true,
"C_Cpp.inlayHints.referenceOperator.showSpace": true,
"C_Cpp.autoAddFileAssociations": false,
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
"C_Cpp.commentContinuationPatterns": [
"/*",
"/**"
],
"todohighlight.include": [
"**/*.c",
"**/*.h",
"**/*.cpp",
"**/*.hpp"
],
"todohighlight.exclude": [
"**/dist/**",
"**/build/**",
"**/.vscode/**",
"**/.github/**",
"**/*.min.*",
"**/*.map"
],
"todohighlight.keywords": [
"TODO",
"FIXME"
]
}
}
},

// Bind /dev/bus/usb for access to USB devices such as an ST-Link. You can test if it
// works by running something like openocd -f board/st_nucleo_f0.cfg from the
// container's terminal. Note that this only works if you also set "privileged" to
// true. It also assumes that you already setup the udev rules on the host OS such that
// you have permissions to access the USB device(s) you intend to access from the
// container. If not, then you can try connecting using "remoteUser": "root".
"mounts": ["type=bind,source=/dev/bus/usb,target=/dev/bus/usb"]

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [3333, 4444, 6666, 50000, 50001, 50002],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "arm-none-eabi-gcc -v",

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}

0 comments on commit dbac6dd

Please sign in to comment.