From 24a0f1ef975cfd8f3f000bdb747f06cd6c0d57eb Mon Sep 17 00:00:00 2001 From: Youssef Moosa Date: Wed, 16 Aug 2023 16:18:10 -0400 Subject: [PATCH 1/7] Add scuba build and instructions --- Dockerfile | 54 ++++++++++++++++++++++++++++++++++ EnvironmentSetup.md | 45 +++++++++++++++++++++++++++- Software/GameEngine/.scuba.yml | 19 ++++++++++++ 3 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 Dockerfile create mode 100644 Software/GameEngine/.scuba.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..917ddd2e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,54 @@ +FROM ubuntu:20.04 +ARG DEBIAN_FRONTEND=noninteractive + +# Setup for Desktop builds +# GDB from EnvironmentSetup.md is omitted +# because it should be installed on the host instead +RUN apt-get update && \ + apt-get install -y \ + build-essential \ + make \ + git \ + git-gui \ + gitk \ + wget \ + libsdl2-2.0-0 \ + libsdl2-image-2.0-0 \ + libsdl2-dev \ + libsdl2-image-dev \ + libncurses5 \ + libncurses-dev \ + python3-pip \ + coreutils \ + zip \ + unzip \ + && pip3 install compiledb + +ENV HOME="/home/dc801" + +RUN mkdir -p ~/dev/installer && \ + echo 'PATH="$HOME/.local/bin:$PATH"' >>~/.profile \ + && echo 'export PATH="$HOME/.local/bin:$PATH"' >>~/.bash_profile + + +# Setup for Embedded builds +WORKDIR "${HOME}/dev/installer" + +RUN wget https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/10-2020q4/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2 && \ + export EABI_VERSION=10-2020-q4-major && \ + tar xjf gcc-arm-none-eabi-$EABI_VERSION-x86_64-linux.tar.bz2 -C /usr/share && \ + ln -s /usr/share/gcc-arm-none-eabi-$EABI_VERSION/bin/arm-none-eabi-* /usr/bin + +RUN wget http://developer.nordicsemi.com/nRF5_SDK/nRF5_SDK_v15.x.x/nRF5_SDK_15.3.0_59ac345.zip && \ + unzip nRF5_SDK_15.3.0_59ac345.zip && \ + mv nRF5_SDK_*/ ~/dev/nordic-sdk15.3.0 + +RUN printf "GNU_INSTALL_ROOT ?= /usr/bin/\nGNU_VERSION ?= 10.2.1\nGNU_PREFIX ?= arm-none-eabi\n" \ + >~/dev/nordic-sdk15.3.0/components/toolchain/gcc/Makefile.posix + +RUN wget https://www.nordicsemi.com/-/media/Software-and-other-downloads/Desktop-software/nRF-command-line-tools/sw/Versions-10-x-x/10-12-2/nRF-Command-Line-Tools_10_12_2_Linux-amd64.zip && \ + unzip nRF-Command-Line-Tools_10_12_2_Linux-amd64.zip && \ + cd nRF-Command-Line-Tools_10_12_2_Linux-amd64 && \ + tar -xvf nRF-Command-Line-Tools_10_12_2_Linux-amd64.tar.gz && \ + dpkg -i *.deb + diff --git a/EnvironmentSetup.md b/EnvironmentSetup.md index 5dc34afe..3808ffff 100644 --- a/EnvironmentSetup.md +++ b/EnvironmentSetup.md @@ -10,6 +10,49 @@ This guide is written assuming you will be using Ubuntu 20.04 or greater. It wil ---- +## NEW: Docker Build + +You can now build an Ubuntu image with Docker and use scuba to build the project. + +First, install docker on your local machine. Unfortunately, this is very distro-dependent. Here's the [instructions for Ubuntu](https://docs.docker.com/engine/install/ubuntu/) at least. + +There's also some helpful [postinstall steps](https://docs.docker.com/engine/install/linux-postinstall/). You should at least add yourself to the docker group. The others are normally done for you or are non-essential. + +To build the project using Docker, you must build the image using the dockerfile in BM-Badge. That can be done like this. + +```sh +~/dev/BM-Badge $ docker build -t bm-badge . +``` + +After that, install scuba on your machine as well by following these [installation steps](https://scuba.readthedocs.io/en/latest/installation.html). + +```sh +sudo pip install scuba +``` + +Then, you can execute the following commands after navigating to Software/GameEngine in the BM-Badge repo + +```sh +# Do a desktop build +~/dev/BM-Badge/Software/GameEngine $ scuba desktop + +# Do an embedded build +~/dev/BM-Badge/Software/GameEngine $ scuba embedded + +# Clean the current project +~/dev/BM-Badge/Software/GameEngine $ scuba clean +~/dev/BM-Badge/Software/GameEngine $ scuba cleanall + +# Flash the embedded build to the hardware +~/dev/BM-Badge/Software/GameEngine $ scuba flash + +# Use GDBServer to debug on hardware +~/dev/BM-Badge/Software/GameEngine $ scuba gdbserver + +# Use JLink to debug on hardware +~/dev/BM-Badge/Software/GameEgnine $ scuba jlink +``` + ## Desktop Build Since __**THE HARDWARE ISN'T READY YET**__, you early adopters will have to try out our game on your computer that runs about a thousand times faster than our real badge hardware - so if it seems like it runs a little faster than it should, uhh... get used to it. @@ -225,7 +268,7 @@ mv nRF5_SDK_*/ ../nordic-sdk15.3.0/ Now you need to configure the SDK for the GCC compiler -Edit the file `~/dev/nordic-sdk15.3.0/components/toolchain/gcc/Makefike.posix` +Edit the file `~/dev/nordic-sdk15.3.0/components/toolchain/gcc/Makefile.posix` It should read: ```shell script diff --git a/Software/GameEngine/.scuba.yml b/Software/GameEngine/.scuba.yml new file mode 100644 index 00000000..d6374da8 --- /dev/null +++ b/Software/GameEngine/.scuba.yml @@ -0,0 +1,19 @@ +image: bm-badge:latest + +aliases: + desktop: cd $SCUBA_ROOT && compiledb make DESKTOP=1 -j`nproc` + embedded: cd $SCUBA_ROOT && compiledb make EMBEDDED=1 -j`nproc` + clean: cd $SCUBA_ROOT && make cleanall -j`nproc` + cleanall: cd $SCUBA_ROOT && make cleanall -j`nproc` + flash: + docker_args: --privileged -v /dev:/dev + script: + - cd $SCUBA_ROOT && compiledb make flash EMBEDDED=1 -j`nproc` + gdbserver: + docker_args: --privileged -v /dev:/dev -p 2331:2331 + script: + - JLinkGDBServer -device nrf52 -if SWD -speed 4000 + jlink: + docker_args: --privileged -v /dev:/dev + script: + - JLinkExe -device nrf52 -if SWD -speed 4000 -autoconnect 1 From 6c88da12f26ce6babe88d6b6049866c8806824d5 Mon Sep 17 00:00:00 2001 From: Youssef Moosa Date: Wed, 16 Aug 2023 21:10:48 -0400 Subject: [PATCH 2/7] Fix scuba to work for non-dc801 users --- EnvironmentSetup.md | 7 ++++++- Software/GameEngine/.scuba.yml | 22 +++++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/EnvironmentSetup.md b/EnvironmentSetup.md index 3808ffff..387f9595 100644 --- a/EnvironmentSetup.md +++ b/EnvironmentSetup.md @@ -50,9 +50,14 @@ Then, you can execute the following commands after navigating to Software/GameEn ~/dev/BM-Badge/Software/GameEngine $ scuba gdbserver # Use JLink to debug on hardware -~/dev/BM-Badge/Software/GameEgnine $ scuba jlink +~/dev/BM-Badge/Software/GameEngine $ scuba jlink ``` +Note that, even though you're allowed to execute scuba in a child directory +and it will find the .scuba.yml file in the parent, you can't do that here +because I'm a bad programmer and haven't been able to figure out how to +do what I want to do wihout executing it in the Software/GameEngine directory. + ## Desktop Build Since __**THE HARDWARE ISN'T READY YET**__, you early adopters will have to try out our game on your computer that runs about a thousand times faster than our real badge hardware - so if it seems like it runs a little faster than it should, uhh... get used to it. diff --git a/Software/GameEngine/.scuba.yml b/Software/GameEngine/.scuba.yml index d6374da8..0e803ea8 100644 --- a/Software/GameEngine/.scuba.yml +++ b/Software/GameEngine/.scuba.yml @@ -1,14 +1,26 @@ image: bm-badge:latest +volumes: + /home/dc801/dev/BM-Badge: + hostpath: "$PWD/../../" + options: rw + aliases: - desktop: cd $SCUBA_ROOT && compiledb make DESKTOP=1 -j`nproc` - embedded: cd $SCUBA_ROOT && compiledb make EMBEDDED=1 -j`nproc` - clean: cd $SCUBA_ROOT && make cleanall -j`nproc` - cleanall: cd $SCUBA_ROOT && make cleanall -j`nproc` + desktop: + script: + - cd /home/dc801/dev/BM-Badge/Software/GameEngine + - compiledb make DESKTOP=1 -j`nproc` + embedded: + script: + - cd /home/dc801/dev/BM-Badge/Software/GameEngine + - compiledb make EMBEDDED=1 -j`nproc` + clean: make cleanall -j`nproc` + cleanall: make cleanall -j`nproc` flash: docker_args: --privileged -v /dev:/dev script: - - cd $SCUBA_ROOT && compiledb make flash EMBEDDED=1 -j`nproc` + - cd /home/dummy/dev/BM-Badge/Software/GameEngine + - compiledb make flash EMBEDDED=1 -j`nproc` gdbserver: docker_args: --privileged -v /dev:/dev -p 2331:2331 script: From f6a1bcd47d6eec9ab522727e792db585de013ae9 Mon Sep 17 00:00:00 2001 From: Youssef Moosa Date: Wed, 16 Aug 2023 21:14:43 -0400 Subject: [PATCH 3/7] Fix the dummy mistake I did --- Software/GameEngine/.scuba.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Software/GameEngine/.scuba.yml b/Software/GameEngine/.scuba.yml index 0e803ea8..ebff64a3 100644 --- a/Software/GameEngine/.scuba.yml +++ b/Software/GameEngine/.scuba.yml @@ -19,7 +19,7 @@ aliases: flash: docker_args: --privileged -v /dev:/dev script: - - cd /home/dummy/dev/BM-Badge/Software/GameEngine + - cd /home/dc801/dev/BM-Badge/Software/GameEngine - compiledb make flash EMBEDDED=1 -j`nproc` gdbserver: docker_args: --privileged -v /dev:/dev -p 2331:2331 From 9109d2da46bbed921cf02efe867701bf98d80f15 Mon Sep 17 00:00:00 2001 From: Youssef Moosa Date: Fri, 18 Aug 2023 13:06:10 -0400 Subject: [PATCH 4/7] Change build dir for debuginfo --- Software/GameEngine/.scuba.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Software/GameEngine/.scuba.yml b/Software/GameEngine/.scuba.yml index ebff64a3..1f3521f3 100644 --- a/Software/GameEngine/.scuba.yml +++ b/Software/GameEngine/.scuba.yml @@ -1,25 +1,25 @@ image: bm-badge:latest volumes: - /home/dc801/dev/BM-Badge: - hostpath: "$PWD/../../" + "$PWD/../../..": + hostpath: "$PWD/../../.." options: rw aliases: desktop: script: - - cd /home/dc801/dev/BM-Badge/Software/GameEngine + - ln -sf /home/dc801/nordic-sdk15.3.0 "$SCUBA_ROOT/../../.." - compiledb make DESKTOP=1 -j`nproc` embedded: script: - - cd /home/dc801/dev/BM-Badge/Software/GameEngine + - ln -sf /home/dc801/nordic-sdk15.3.0 "$SCUBA_ROOT/../../.." - compiledb make EMBEDDED=1 -j`nproc` clean: make cleanall -j`nproc` cleanall: make cleanall -j`nproc` flash: docker_args: --privileged -v /dev:/dev script: - - cd /home/dc801/dev/BM-Badge/Software/GameEngine + - ln -sf /home/dc801/nordic-sdk15.3.0 "$SCUBA_ROOT/../../.." - compiledb make flash EMBEDDED=1 -j`nproc` gdbserver: docker_args: --privileged -v /dev:/dev -p 2331:2331 From 28b9ab82f4d339c4f7059e3472931fbe009ca45d Mon Sep 17 00:00:00 2001 From: Youssef Moosa Date: Fri, 18 Aug 2023 15:15:56 -0400 Subject: [PATCH 5/7] Fix symlink and clean up yml --- Software/GameEngine/.scuba.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Software/GameEngine/.scuba.yml b/Software/GameEngine/.scuba.yml index 1f3521f3..0059f602 100644 --- a/Software/GameEngine/.scuba.yml +++ b/Software/GameEngine/.scuba.yml @@ -6,20 +6,16 @@ volumes: options: rw aliases: - desktop: - script: - - ln -sf /home/dc801/nordic-sdk15.3.0 "$SCUBA_ROOT/../../.." - - compiledb make DESKTOP=1 -j`nproc` + desktop: compiledb make DESKTOP=1 -j`nproc` embedded: script: - - ln -sf /home/dc801/nordic-sdk15.3.0 "$SCUBA_ROOT/../../.." + - ln -sf /home/dc801/dev/nordic-sdk15.3.0 "$SCUBA_ROOT/../../.." - compiledb make EMBEDDED=1 -j`nproc` clean: make cleanall -j`nproc` cleanall: make cleanall -j`nproc` flash: docker_args: --privileged -v /dev:/dev script: - - ln -sf /home/dc801/nordic-sdk15.3.0 "$SCUBA_ROOT/../../.." - compiledb make flash EMBEDDED=1 -j`nproc` gdbserver: docker_args: --privileged -v /dev:/dev -p 2331:2331 From 159688c9ca5335fe7d3fd7b0258048e3d82aafee Mon Sep 17 00:00:00 2001 From: Youssef Moosa Date: Sat, 19 Aug 2023 17:26:14 -0400 Subject: [PATCH 6/7] Ignore ln or unlink fails on scuba embedded --- Software/GameEngine/.scuba.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Software/GameEngine/.scuba.yml b/Software/GameEngine/.scuba.yml index 0059f602..9ffa5fee 100644 --- a/Software/GameEngine/.scuba.yml +++ b/Software/GameEngine/.scuba.yml @@ -9,8 +9,9 @@ aliases: desktop: compiledb make DESKTOP=1 -j`nproc` embedded: script: - - ln -sf /home/dc801/dev/nordic-sdk15.3.0 "$SCUBA_ROOT/../../.." + - ln -sf /home/dc801/dev/nordic-sdk15.3.0 "$SCUBA_ROOT/../../.." 2>/dev/null || true - compiledb make EMBEDDED=1 -j`nproc` + - unlink "$SCUBA_ROOT/../../../nordic-sdk15.3.0" 2>/dev/null || true clean: make cleanall -j`nproc` cleanall: make cleanall -j`nproc` flash: From 2ae05574a1c46bf1bd54e9c8b84ae34a17e2d87e Mon Sep 17 00:00:00 2001 From: Youssef Moosa Date: Sun, 20 Aug 2023 11:57:15 -0400 Subject: [PATCH 7/7] Gen symlinks for flash --- Software/GameEngine/.scuba.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Software/GameEngine/.scuba.yml b/Software/GameEngine/.scuba.yml index 9ffa5fee..549cc3fb 100644 --- a/Software/GameEngine/.scuba.yml +++ b/Software/GameEngine/.scuba.yml @@ -17,7 +17,9 @@ aliases: flash: docker_args: --privileged -v /dev:/dev script: + - ln -sf /home/dc801/dev/nordic-sdk15.3.0 "$SCUBA_ROOT/../../.." 2>/dev/null || true - compiledb make flash EMBEDDED=1 -j`nproc` + - unlink "$SCUBA_ROOT/../../../nordic-sdk15.3.0" 2>/dev/null || true gdbserver: docker_args: --privileged -v /dev:/dev -p 2331:2331 script: