diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..ae5138a --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,86 @@ +FROM fedora:latest + +# Install Development Tools and required packages +RUN dnf update -y && \ + dnf install -y @development-tools && \ + dnf install -y \ + direnv \ + arm-none-eabi-gcc-cs \ + arm-none-eabi-gcc-c++ \ + arm-none-eabi-newlib \ + cmake \ + git \ + python3 \ + python3-virtualenv \ + python3-pip \ + ninja-build \ + pkgconf \ + glib2-devel \ + flex \ + bison \ + clang \ + zlib-devel \ + meson \ + pixman-devel \ + alsa-lib-devel \ + texinfo \ + lzo-devel \ + snappy-devel \ + libaio-devel \ + libtasn1-devel \ + gnutls-devel \ + nettle-devel \ + curl \ + dtc \ + libcap-devel \ + libcap-ng-devel \ + socat \ + libslirp-devel \ + libffi-devel \ + libusb1-devel \ + ncurses-devel && \ + dnf clean all + +RUN dnf install -y 'dnf-command(copr)' && \ + dnf copr enable -y rleh/arm-none-eabi-gdb && \ + dnf install -y arm-none-eabi-gdb + +ARG USERNAME=vscode +RUN useradd -m -s /bin/bash ${USERNAME} && \ + echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers + +# Set working directory and switch to non-root user +WORKDIR /home/${USERNAME} +USER ${USERNAME} + +# Install Rust +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \ + . $HOME/.cargo/env && \ + rustup component add rust-src && \ + rustup component add llvm-tools-preview && \ + cargo install cargo-binutils && \ + rustup target add thumbv7em-none-eabihf && \ + rustup target add thumbv7em-none-eabi + +# Clone, build, and install QEMU +RUN git clone --depth 1 https://github.com/thomasw04/qemu.git /tmp/qemu && \ + cd /tmp/qemu && \ + python3 -m venv .venv && \ + . .venv/bin/activate && \ + pip install --no-cache-dir tomli sphinx && \ + mkdir build && cd build && \ + ../configure --disable-werror --cc=clang --cxx=clang++ --extra-cflags="-Wno-error -fdeclspec" --target-list=arm-softmmu,arm-linux-user --enable-kvm && \ + make -j$(nproc) && \ + sudo make install && \ + cd / && \ + rm -rf /tmp/qemu + +RUN git clone --single-branch --depth 1 -b "develop" \ + https://github.com/stlink-org/stlink.git /tmp/stlink && \ + cd /tmp/stlink && \ + make -j release && \ + sudo make install && \ + sudo ldconfig + +# Fix for fedora not finding libstlink.so.1 +ENV LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..2ea96a9 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,33 @@ +// For format details, see https://aka.ms/devcontainer.json. +{ + "name": "Osiris Dev Container", + "build": { + "dockerfile": "Dockerfile", + "context": ".." + }, + "remoteUser": "vscode", + "privileged": false, + "capAdd": [ + // Permissions for accessing host USB devices + "SYS_RAWIO", "CAP_MKNOD" + ], + "customizations": { + "vscode": { + "extensions": [ + "rust-lang.rust-analyzer", + "vadimcn.vscode-lldb", + "ms-vscode.cmake-tools", + "llvm-vs-code-extensions.vscode-clangd" + ] + } + }, + "runArgs": [ + // Mount USB devices under Linux + "--device", + "/dev/bus/usb:/dev/bus/usb" + ], + "mounts": [ + // Make ssh keys available + "source=${localEnv:HOME}/.ssh,target=/home/vscode/.ssh,type=bind,consistency=cached" + ] +} diff --git a/.gitignore b/.gitignore index 467fd94..2988fc8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -build/ +build*/ .vscode/ qemu/ .venv/