commit ac672a42c8017a94066aa2ec2a14c023583aae82 Author: Josh Date: Wed May 8 21:45:28 2024 -0400 initial commit diff --git a/READEME.md b/READEME.md new file mode 100644 index 0000000..9c417e9 --- /dev/null +++ b/READEME.md @@ -0,0 +1,2 @@ +Tools for building infinitime and infinisim. +Place this directory in the same directory containing a InfiniTime and InfiniSim directory:w diff --git a/build-scripts/docker-infinisim-build.sh b/build-scripts/docker-infinisim-build.sh new file mode 100644 index 0000000..dde1889 --- /dev/null +++ b/build-scripts/docker-infinisim-build.sh @@ -0,0 +1,2 @@ +#!/bin/bash +sudo docker run --rm -it -v ./InfiniTime:/infinitime -v ./InfiniSim:/infinisim -v ./build-scripts:/build-scripts --user $(id -u):$(id -g) sha256:d98e39f8c51e606ab0ceea093054ae7009eb95a37ec949f8f9bcb204e3fb0771 bash /build-scripts/infinisim-build.sh diff --git a/build-scripts/infinisim-build.sh b/build-scripts/infinisim-build.sh new file mode 100644 index 0000000..6e3f3cd --- /dev/null +++ b/build-scripts/infinisim-build.sh @@ -0,0 +1,4 @@ +#!/bin/bash +cd /infinisim +cmake -S . -B build -DInfiniTime_DIR=/infinitime -DENABLE_USERAPPS="Apps::Music, Apps::Calculator" +cmake --build build -j4 diff --git a/build-scripts/infinisim-run.sh b/build-scripts/infinisim-run.sh new file mode 100644 index 0000000..f752c29 --- /dev/null +++ b/build-scripts/infinisim-run.sh @@ -0,0 +1,6 @@ +#!/bin/bash +echo loading resources +/infinisim/build/littlefs-do res load /infinitime/build/output/infinitime-resources-1.14.0.zip +echo loaded reources, starting simulator +/infinisim/build/infinisim --hide-status + diff --git a/docker/.gitpod.Dockerfile b/docker/.gitpod.Dockerfile new file mode 100644 index 0000000..4fbc7be --- /dev/null +++ b/docker/.gitpod.Dockerfile @@ -0,0 +1,43 @@ +FROM gitpod/workspace-full + +USER root +ARG DEBIAN_FRONTEND=noninteractive +RUN apt-get update -qq \ + && apt-get install -y \ +# x86_64 / generic packages + bash \ + build-essential \ + cmake \ + git \ + make \ + python3 \ + python3-pip \ + tar \ + unzip \ + wget \ +# aarch64 packages + libffi-dev \ + libssl-dev \ + python3-dev \ + git \ + && rm -rf /var/cache/apt/* /var/lib/apt/lists/*; + +# Git needed for PROJECT_GIT_COMMIT_HASH variable setting + +# Needs to be installed as root +RUN pip3 install adafruit-nrfutil +RUN pip3 install -Iv cryptography==3.3 + +COPY docker/build.sh /opt/ +# Lets get each in a separate docker layer for better downloads +# GCC +RUN bash -c "source /opt/build.sh; GetGcc;" +# NrfSdk +RUN bash -c "source /opt/build.sh; GetNrfSdk;" +# McuBoot +RUN bash -c "source /opt/build.sh; GetMcuBoot;" + +# Link the default checkout workspace in to the default $SOURCES_DIR +RUN ln -s /workspace/InfiniTime /sources + +USER gitpod diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..fb796a9 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,63 @@ +FROM ubuntu:22.04 + +ARG DEBIAN_FRONTEND=noninteractive +ARG NODE_MAJOR=20 +RUN apt-get update -qq \ + && apt-get install -y ca-certificates curl gnupg \ + && mkdir -p /etc/apt/keyrings \ + && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \ + && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" > /etc/apt/sources.list.d/nodesource.list \ + && apt-get update -qq \ + && apt-get install -y \ +# x86_64 / generic packages + bash \ + build-essential \ + cmake \ + git \ + make \ + nodejs \ + python3 \ + python3-pip \ + python3-pil \ + python-is-python3 \ + tar \ + unzip \ + wget \ + # aarch64 packages + libffi-dev \ + libssl-dev \ + python3-dev \ + git \ + apt-utils \ + pkg-config \ + libpixman-1-dev \ + libcairo2-dev \ + libpango-1.0-0 \ + ibpango1.0-dev \ + libpangocairo-1.0-0 \ + libsdl2-dev \ + g++ \ + libpng-dev \ + && rm -rf /var/cache/apt/* /var/lib/apt/lists/*; + +# Git needed for PROJECT_GIT_COMMIT_HASH variable setting + +RUN pip3 install adafruit-nrfutil +RUN pip3 install -Iv cryptography==3.3 +RUN pip3 install cbor +RUN npm i lv_font_conv@1.5.2 -g +RUN npm install ts-node@10.9.1 @swc/core@1.3.82 lv_img_conv@0.3.0 -g + +# build.sh knows how to compile +COPY build.sh /opt/ + +# Lets get each in a separate docker layer for better downloads +# GCC +RUN bash -c "source /opt/build.sh; GetGcc;" +# NrfSdk +RUN bash -c "source /opt/build.sh; GetNrfSdk;" +# McuBoot +RUN bash -c "source /opt/build.sh; GetMcuBoot;" + +ENV SOURCES_DIR /sources +CMD ["/opt/build.sh"] diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 0000000..5b897b2 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,2 @@ +Docker images and build script for building the project using Docker. +See [this page for more info](../doc/buildWithDocker.md). diff --git a/docker/build.sh b/docker/build.sh new file mode 100644 index 0000000..3a467b9 --- /dev/null +++ b/docker/build.sh @@ -0,0 +1,90 @@ +#!/bin/bash +(return 0 2>/dev/null) && SOURCED="true" || SOURCED="false" +export LC_ALL=C.UTF-8 +export LANG=C.UTF-8 +set -x +set -e + +# Default locations if the var isn't already set +export TOOLS_DIR="${TOOLS_DIR:=/opt}" +export SOURCES_DIR="${SOURCES_DIR:=/sources}" +export BUILD_DIR="${BUILD_DIR:=$SOURCES_DIR/build}" +export OUTPUT_DIR="${OUTPUT_DIR:=$SOURCES_DIR/build/output}" + +# Specify a folder with read/write access to NPM +export NPM_DIR="$BUILD_DIR/npm" +export npm_config_cache="${NPM_DIR}" + +export BUILD_TYPE=${BUILD_TYPE:=Release} +export GCC_ARM_VER=${GCC_ARM_VER:="10.3-2021.10"} +export NRF_SDK_VER=${NRF_SDK_VER:="nRF5_SDK_15.3.0_59ac345"} + +MACHINE="$(uname -m)" +[ "$MACHINE" = "arm64" ] && MACHINE="aarch64" + +export GCC_ARM_PATH="gcc-arm-none-eabi-$GCC_ARM_VER" + +main() { + local target="$1" + + mkdir -p "$TOOLS_DIR" + + [ ! -d "$TOOLS_DIR/$GCC_ARM_PATH" ] && GetGcc + [ ! -d "$TOOLS_DIR/$NRF_SDK_VER" ] && GetNrfSdk + [ ! -d "$TOOLS_DIR/mcuboot" ] && GetMcuBoot + + mkdir -p "$BUILD_DIR" + + CmakeGenerate + CmakeBuild $target + BUILD_RESULT=$? + if [ "$DISABLE_POSTBUILD" != "true" -a "$BUILD_RESULT" == 0 ]; then + source "$BUILD_DIR/post_build.sh" + fi + # assuming post_build.sh will never fail on a successful build + return $BUILD_RESULT +} + +GetGcc() { + wget -q https://developer.arm.com/-/media/Files/downloads/gnu-rm/$GCC_ARM_VER/$GCC_ARM_PATH-$MACHINE-linux.tar.bz2 -O - | tar -xj -C $TOOLS_DIR/ +} + +GetMcuBoot() { + git clone https://github.com/mcu-tools/mcuboot.git "$TOOLS_DIR/mcuboot" + pip3 install -r "$TOOLS_DIR/mcuboot/scripts/requirements.txt" +} + +GetNrfSdk() { + wget -q "https://developer.nordicsemi.com/nRF5_SDK/nRF5_SDK_v15.x.x/$NRF_SDK_VER.zip" -O /tmp/$NRF_SDK_VER + unzip -q /tmp/$NRF_SDK_VER -d "$TOOLS_DIR/" + rm /tmp/$NRF_SDK_VER +} + +CmakeGenerate() { + cmake -G "Unix Makefiles" \ + -S "$SOURCES_DIR" \ + -B "$BUILD_DIR" \ + -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ + -DARM_NONE_EABI_TOOLCHAIN_PATH="$TOOLS_DIR/$GCC_ARM_PATH" \ + -DNRF5_SDK_PATH="$TOOLS_DIR/$NRF_SDK_VER" \ + -DBUILD_DFU=1 \ + -DBUILD_RESOURCES=1 +} + +CmakeBuild() { + local target="$1" + [ -n "$target" ] && target="--target $target" + cmake --build "$BUILD_DIR" --config $BUILD_TYPE $target -- -j$(nproc) + BUILD_RESULT=$? + return $BUILD_RESULT +} + +if [ $SOURCED = "false" ]; then + # It is important to return exit code of main + # To be future-proof, this is handled explicitely + main "$@" + BUILD_RESULT=$? + exit $BUILD_RESULT +else + echo "Sourced!" +fi diff --git a/docker/post_build.sh.in b/docker/post_build.sh.in new file mode 100644 index 0000000..5d82f3b --- /dev/null +++ b/docker/post_build.sh.in @@ -0,0 +1,26 @@ +#!/bin/sh +export LC_ALL=C.UTF-8 +export LANG=C.UTF-8 +set -e +set +x + +export PROJECT_VERSION="@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@" + +mkdir -p "$OUTPUT_DIR" + +cp "$SOURCES_DIR"/bootloader/bootloader-5.0.4.bin $OUTPUT_DIR/bootloader.bin +cp "$BUILD_DIR/src/pinetime-mcuboot-app-image-$PROJECT_VERSION.bin" "$OUTPUT_DIR/pinetime-mcuboot-app-image-$PROJECT_VERSION.bin" +cp "$BUILD_DIR/src/pinetime-mcuboot-app-dfu-$PROJECT_VERSION.zip" "$OUTPUT_DIR/pinetime-mcuboot-app-dfu-$PROJECT_VERSION.zip" + +cp "$BUILD_DIR/src/pinetime-mcuboot-recovery-loader-image-$PROJECT_VERSION.bin" "$OUTPUT_DIR/pinetime-mcuboot-recovery-loader-image-$PROJECT_VERSION.bin" +cp "$BUILD_DIR/src/pinetime-mcuboot-recovery-loader-dfu-$PROJECT_VERSION.zip" "$OUTPUT_DIR/pinetime-mcuboot-recovery-loader-dfu-$PROJECT_VERSION.zip" + +cp "$BUILD_DIR/src/resources/infinitime-resources-$PROJECT_VERSION.zip" "$OUTPUT_DIR/infinitime-resources-$PROJECT_VERSION.zip" + +mkdir -p "$OUTPUT_DIR/src" +cp $BUILD_DIR/src/*.bin "$OUTPUT_DIR/src/" +cp $BUILD_DIR/src/*.hex "$OUTPUT_DIR/src/" +cp $BUILD_DIR/src/*.out "$OUTPUT_DIR/src/" +cp $BUILD_DIR/src/*.map "$OUTPUT_DIR/src/" + +ls -RUv1 "$OUTPUT_DIR" | sed 's;^\([^/]\); \1;g' \ No newline at end of file diff --git a/infinisim-build/docker-compose.yml b/infinisim-build/docker-compose.yml new file mode 100644 index 0000000..16accf9 --- /dev/null +++ b/infinisim-build/docker-compose.yml @@ -0,0 +1,11 @@ +version: "3.3" +services: + bash: + stdin_open: true + tty: true + volumes: + - ../../InfiniTime:/infinitime + - ../../InfiniSim:/infinisim + - ../build-scripts:/build-scripts + image: infini-build + command: bash /build-scripts/infinisim-build.sh diff --git a/infinisim-run/docker-compose.yml b/infinisim-run/docker-compose.yml new file mode 100644 index 0000000..a48c007 --- /dev/null +++ b/infinisim-run/docker-compose.yml @@ -0,0 +1,16 @@ +version: "3.3" +services: + bash: + stdin_open: true + tty: true + volumes: + - ../../InfiniTime:/infinitime + - ../../InfiniSim:/infinisim + - ../build-scripts:/build-scripts + - /tmp/.X11-unix:/tmp/.X11-unix + - /home/brickman/.Xauthority:/root/.Xauthority:rw + environment: + - DISPLAY=${DISPLAY} + image: sha256:d98e39f8c51e606ab0ceea093054ae7009eb95a37ec949f8f9bcb204e3fb0771 + command: /infinisim/build/infinisim + network_mode: host diff --git a/infinitime-build/docker-compose.yml b/infinitime-build/docker-compose.yml new file mode 100644 index 0000000..a236adb --- /dev/null +++ b/infinitime-build/docker-compose.yml @@ -0,0 +1,9 @@ +version: "3.3" +services: + bash: + stdin_open: true + tty: true + volumes: + - ../../InfiniTime:/sources + image: infini-build + #command: bash /build-scripts/infinisim-build.sh