Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scuba build and instructions #16

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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

50 changes: 49 additions & 1 deletion EnvironmentSetup.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,54 @@ 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/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.

Expand Down Expand Up @@ -225,7 +273,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
Expand Down
30 changes: 30 additions & 0 deletions Software/GameEngine/.scuba.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
image: bm-badge:latest

volumes:
"$PWD/../../..":
hostpath: "$PWD/../../.."
options: rw

aliases:
desktop: compiledb make DESKTOP=1 -j`nproc`
embedded:
script:
- 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:
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:
- JLinkGDBServer -device nrf52 -if SWD -speed 4000
jlink:
docker_args: --privileged -v /dev:/dev
script:
- JLinkExe -device nrf52 -if SWD -speed 4000 -autoconnect 1