From ec1fbf3ec1035ae436546438a50eda9a9ca1b758 Mon Sep 17 00:00:00 2001 From: Mateusz Faderewski Date: Sun, 26 Sep 2021 14:42:50 +0200 Subject: [PATCH] [SC64][CI/CD] Moved docker build environment to another repository (#7) --- {.media => .github}/sc64_clean_pcb.jpg | Bin {.media => .github}/sc64_in_n64.jpg | Bin {.media => .github}/sc64_on_table.jpg | Bin .github/workflows/docker.yml | 49 ------------- .github/workflows/main.yml | 4 +- README.md | 6 +- build.sh | 44 +++++++++++- build_in_docker.sh | 3 + docker/Dockerfile | 93 ------------------------- docker/build.sh | 42 ----------- docker/setup_quartus.sh | 25 ------- fw/build.sh | 3 + sw/n64/build.sh | 2 +- sw/riscv/build.sh | 2 +- 14 files changed, 56 insertions(+), 217 deletions(-) rename {.media => .github}/sc64_clean_pcb.jpg (100%) rename {.media => .github}/sc64_in_n64.jpg (100%) rename {.media => .github}/sc64_on_table.jpg (100%) delete mode 100644 .github/workflows/docker.yml create mode 100755 build_in_docker.sh delete mode 100644 docker/Dockerfile delete mode 100755 docker/build.sh delete mode 100755 docker/setup_quartus.sh create mode 100755 fw/build.sh diff --git a/.media/sc64_clean_pcb.jpg b/.github/sc64_clean_pcb.jpg similarity index 100% rename from .media/sc64_clean_pcb.jpg rename to .github/sc64_clean_pcb.jpg diff --git a/.media/sc64_in_n64.jpg b/.github/sc64_in_n64.jpg similarity index 100% rename from .media/sc64_in_n64.jpg rename to .github/sc64_in_n64.jpg diff --git a/.media/sc64_on_table.jpg b/.github/sc64_on_table.jpg similarity index 100% rename from .media/sc64_on_table.jpg rename to .github/sc64_on_table.jpg diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index 32338c2..0000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Build docker - -on: - push: - branches: - - main - pull_request: - branches: - - main - release: - types: - - created - workflow_dispatch: - -env: - REGISTRY: ghcr.io - IMAGE_NAME: polprzewodnikowy/sc64env - -jobs: - build-and-push-image: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Log in to the Container registry - uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - - name: Build and push Docker image - uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc - with: - context: ./docker - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5aeceef..5a9163d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -name: Build fw/hw/sw +name: build on: push: @@ -22,7 +22,7 @@ jobs: submodules: true - name: Build script - run: ./build.sh + run: ./build_in_docker.sh - name: Upload artifact uses: actions/upload-artifact@v2 diff --git a/README.md b/README.md index 667cbc5..042cf04 100644 --- a/README.md +++ b/README.md @@ -66,8 +66,8 @@ Current goal is to fix bugs in SDRAM and PC modules. ## Finished sample -![SummerCart64 clean PCB](.media/sc64_clean_pcb.jpg) +![SummerCart64 clean PCB](.github/sc64_clean_pcb.jpg) -![SummerCart64 on table](.media/sc64_on_table.jpg) +![SummerCart64 on table](.github/sc64_on_table.jpg) -![SummerCart64 in partialy disassembled Nintendo 64](.media/sc64_in_n64.jpg) +![SummerCart64 in partialy disassembled Nintendo 64](.github/sc64_in_n64.jpg) diff --git a/build.sh b/build.sh index aff53b9..d5c8053 100755 --- a/build.sh +++ b/build.sh @@ -1,3 +1,45 @@ #!/bin/bash -docker run --mount type=bind,src="$(pwd)",target="/workdir" ghcr.io/polprzewodnikowy/sc64env:v0.9 /bin/bash ./docker/build.sh + +PACKAGE_FILE_NAME="SummerCart64" +FILES=( + "./fw/output_files/SummerCart64.pof" + "./hw/v1/ftdi-template.xml" + "./sw/cic/UltraCIC-III.hex" + "./sw/riscv/build/controller.rom" + "./LICENSE" +) + + +set -e + + +pushd sw/cic +echo "Building UltraCIC-III software" +avra UltraCIC-III.asm -D attiny45 +popd + + +pushd sw/n64 +echo "Building N64 bootloader software" +make clean all +popd + + +pushd sw/riscv +echo "Building RISC-V controller software" +make clean all +popd + + +pushd fw +echo "Building FPGA firmware" +quartus_sh --flow compile ./SummerCart64.qpf +popd + + +echo "Zipping files" +if [[ -e "./${PACKAGE_FILE_NAME}.zip" ]]; then + rm -f "./${PACKAGE_FILE_NAME}.zip" +fi +zip -r "./${PACKAGE_FILE_NAME}.zip" ${FILES[@]} diff --git a/build_in_docker.sh b/build_in_docker.sh new file mode 100755 index 0000000..7405b54 --- /dev/null +++ b/build_in_docker.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker run --mount type=bind,src="$(pwd)",target="/workdir" ghcr.io/polprzewodnikowy/sc64env:v1.0 /bin/bash ./build.sh diff --git a/docker/Dockerfile b/docker/Dockerfile deleted file mode 100644 index 4add992..0000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,93 +0,0 @@ -FROM ubuntu:18.04 AS base - - -FROM base AS build_base -SHELL ["/bin/bash", "-c"] -WORKDIR /tmp/scratchpad -ENV DEBIAN_FRONTEND="noninteractive" -RUN apt-get update && \ - apt-get upgrade -y && \ - apt-get install -y \ - autoconf \ - automake \ - autotools-dev \ - bc \ - bison \ - build-essential \ - bzip2 \ - curl \ - expect \ - file \ - flex \ - g++ \ - gawk \ - gcc \ - gcc-multilib \ - git \ - gperf \ - libexpat-dev \ - libgmp-dev \ - libmpc-dev \ - libmpfr-dev \ - libpng-dev \ - libtool \ - make \ - patchutils \ - python3 \ - texinfo \ - texinfo \ - wget \ - zlib1g-dev - - -FROM build_base AS build_riscv -RUN git clone --branch 2021.09.21 https://github.com/riscv/riscv-gnu-toolchain && \ - pushd ./riscv-gnu-toolchain && \ - ./configure --prefix=/opt/riscv --with-arch=rv32i --with-abi=ilp32 && \ - make -j$(nproc) && \ - popd && \ - rm -rf ./riscv-gnu-toolchain - - -FROM build_base AS build_n64 -ENV N64_INST=/opt/n64 -ENV FORCE_DEFAULT_GCC=true -RUN git clone https://github.com/DragonMinded/libdragon && \ - pushd ./libdragon && \ - git checkout fc4b6708df7439b9386bb6631e24d8909d78d6ae && \ - pushd ./tools && \ - ./build-toolchain.sh && \ - popd && \ - make install && \ - make tools-install && \ - popd && \ - rm -rf ./libdragon - - -FROM build_base AS build_quartus -ADD setup_quartus.sh . -RUN mkdir -p ./quartus && \ - pushd ./quartus && \ - wget -q http://download.altera.com/akdlm/software/acdsinst/20.1std.1/720/ib_tar/Quartus-lite-20.1.1.720-linux.tar && \ - tar xvf Quartus-lite-20.1.1.720-linux.tar && \ - popd && \ - ./setup_quartus.sh 20.1 && \ - rm -rf ./quartus setup_quartus.sh - - -FROM base AS release -WORKDIR /workdir -ENV DEBIAN_FRONTEND="noninteractive" -ENV LC_ALL="en_US.UTF-8" -ENV N64_INST="/usr/local" -ENV PATH="${PATH}:/opt/intelFPGA_lite/20.1/quartus/bin" -RUN apt-get update && \ - apt-get upgrade -y && \ - apt-get install -y avra make python3 libglib2.0-0 libtcmalloc-minimal4 libmpc3 locales zip && \ - echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \ - locale-gen en_US.UTF-8 && \ - /usr/sbin/update-locale LANG=en_US.UTF-8 -COPY --from=build_riscv /opt/riscv /usr/local -COPY --from=build_n64 /opt/n64 /usr/local -COPY --from=build_quartus /opt/intelFPGA_lite /opt/intelFPGA_lite -ENV LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libtcmalloc_minimal.so.4" diff --git a/docker/build.sh b/docker/build.sh deleted file mode 100755 index 49191ee..0000000 --- a/docker/build.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - - -PACKAGE_FILE_NAME="SummerCart64" -FILES=( - "./fw/output_files/SummerCart64.pof" - "./hw/v1/ftdi-template.xml" - "./sw/cic/UltraCIC-III.hex" - "./sw/riscv/build/controller.rom" - "./LICENSE" -) - - -pushd sw/cic -echo "Building UltraCIC-III software" -avra UltraCIC-III.asm -D attiny45 -popd - - -pushd sw/n64 -echo "Building N64 bootloader software" -make clean all -popd - - -pushd sw/riscv -echo "Building RISC-V controller software" -make clean all -popd - - -pushd fw -echo "Building FPGA firmware" -quartus_sh --flow compile SummerCart64.qpf -popd - - -echo "Zipping files" -if [[ -e "./${PACKAGE_FILE_NAME}.zip" ]]; then - rm -f "./${PACKAGE_FILE_NAME}.zip" -fi -zip -r "./${PACKAGE_FILE_NAME}.zip" ${FILES[@]} diff --git a/docker/setup_quartus.sh b/docker/setup_quartus.sh deleted file mode 100755 index a17964c..0000000 --- a/docker/setup_quartus.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/expect - -set timeout -1 - -set version [lindex $argv 0] - -spawn ./quartus/setup.sh - -expect { - "Press \\\[Enter\\\] to continue:" { send "\r"; exp_continue } - "Do you accept this license? \\\[y/n\\\]" { send "y\r"; exp_continue } - "Installation directory \\\[/root/intelFPGA_lite/$version\\\]:" { send "/opt/intelFPGA_lite/$version\r"; exp_continue } - "Quartus Prime Lite Edition (Free) \\\[Y/n\\\] :" { send "y\r"; exp_continue } - "Quartus Prime Lite Edition (Free) - Quartus Prime Help" { send "n\r"; exp_continue } - "Quartus Prime Lite Edition (Free) - Devices \\\[Y/n\\\] " { send "y\r"; exp_continue } - "Quartus Prime Lite Edition (Free) - Devices - MAX 10 FPGA" { send "y\r"; exp_continue } - "Quartus Prime Lite Edition (Free) - Devices - " { send "n\r"; exp_continue } - "ModelSim - Intel FPGA Starter Edition (Free)" { send "n\r"; exp_continue } - "ModelSim - Intel FPGA Edition" { send "n\r"; exp_continue } - "Is the selection above correct? \\\[Y/n\\\]:" { send "y\r"; exp_continue } - "Create shortcuts on Desktop \\\[Y/n\\\]:" { send "n\r"; exp_continue } - "Launch Quartus Prime Lite Edition \\\[Y/n\\\]:" { send "n\r"; exp_continue } - "Provide your feedback at" { send "n\r"; exp_continue } - eof { } -} diff --git a/fw/build.sh b/fw/build.sh new file mode 100755 index 0000000..4c1b7c8 --- /dev/null +++ b/fw/build.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker run --mount type=bind,src="$(pwd)/..",target="/workdir" ghcr.io/polprzewodnikowy/sc64env:v1.0 /bin/bash -c "cd fw && quartus_sh --flow compile ./SummerCart64.qpf" diff --git a/sw/n64/build.sh b/sw/n64/build.sh index 5196c38..faeb3d6 100755 --- a/sw/n64/build.sh +++ b/sw/n64/build.sh @@ -1,3 +1,3 @@ #!/bin/bash -docker run --mount type=bind,src="$(pwd)",target="/workdir" ghcr.io/polprzewodnikowy/sc64env:v0.9 /bin/bash -c "make clean all" +docker run --mount type=bind,src="$(pwd)",target="/workdir" ghcr.io/polprzewodnikowy/sc64env:v1.0 /bin/bash -c "make clean all" diff --git a/sw/riscv/build.sh b/sw/riscv/build.sh index 5196c38..faeb3d6 100755 --- a/sw/riscv/build.sh +++ b/sw/riscv/build.sh @@ -1,3 +1,3 @@ #!/bin/bash -docker run --mount type=bind,src="$(pwd)",target="/workdir" ghcr.io/polprzewodnikowy/sc64env:v0.9 /bin/bash -c "make clean all" +docker run --mount type=bind,src="$(pwd)",target="/workdir" ghcr.io/polprzewodnikowy/sc64env:v1.0 /bin/bash -c "make clean all"