From 57bd74ed48b2c82b6fa1d02af1711449722ec43b Mon Sep 17 00:00:00 2001 From: Jiri Jakes Date: Fri, 2 Feb 2024 23:32:04 +0800 Subject: [PATCH 1/3] ci: Add Coldcard simulator --- .github/workflows/main.yml | 10 +++++++--- ci/Dockerfile.coldcard | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 ci/Dockerfile.coldcard diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4f4470b..bf55b7d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -45,8 +45,12 @@ jobs: - version: 1.48.0 # MSRV features: miniscript emulator: - - name: trezor - - name: ledger +# - name: trezor +# docker-params: '--network=host' +# - name: ledger +# docker-params: '--network=host' + - name: coldcard + docker-params: '-v /tmp:/tmp' steps: - name: Checkout uses: actions/checkout@v3 @@ -70,7 +74,7 @@ jobs: cache-from: type=gha cache-to: type=gha - name: Run simulator image - run: docker run --name simulator --network=host hwi/${{ matrix.emulator.name }}_emulator & + run: docker run --name simulator ${{ matrix.emulator.docker-params }} hwi/${{ matrix.emulator.name }}_emulator & - name: Install Python uses: actions/setup-python@v4 with: diff --git a/ci/Dockerfile.coldcard b/ci/Dockerfile.coldcard new file mode 100644 index 0000000..7b58dce --- /dev/null +++ b/ci/Dockerfile.coldcard @@ -0,0 +1,33 @@ +FROM python:3-slim + +# Install required packages +RUN apt-get update +RUN apt-get install -y build-essential git python3 python3-pip libudev-dev gcc-arm-none-eabi libffi-dev swig libpcsclite-dev python-is-python3 autoconf libtool python3-venv pkg-config + +# Prepare source code +RUN git clone --depth 1 --recursive -b 2024-01-18T1507-v6.2.2X https://github.com/Coldcard/firmware.git +WORKDIR /firmware +RUN git apply unix/linux_addr.patch + +# Prepare virtual env +ENV VIRTUAL_ENV=/opt/venv +RUN python3 -m venv $VIRTUAL_ENV +ENV PATH="$VIRTUAL_ENV/bin:$PATH" + +# Install dependencies +RUN pip install -U pip setuptools +RUN pip install -r requirements.txt + +# Build the Coldcard simulator +WORKDIR /firmware/external/micropython/mpy-cross/ +RUN make +WORKDIR /firmware/unix +RUN make setup +RUN make ngu-setup +RUN make + +# Run simulator +## for running on developers' machines +# USER 1000 +VOLUME ["/tmp"] +CMD ["./headless.py"] From 3f7586c3fbb94b1a2841c03d96bdd422d0ea999a Mon Sep 17 00:00:00 2001 From: Jiri Jakes Date: Sat, 3 Feb 2024 08:34:24 +0800 Subject: [PATCH 2/3] Try reduce size --- ci/Dockerfile.coldcard | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ci/Dockerfile.coldcard b/ci/Dockerfile.coldcard index 7b58dce..445a67f 100644 --- a/ci/Dockerfile.coldcard +++ b/ci/Dockerfile.coldcard @@ -3,11 +3,17 @@ FROM python:3-slim # Install required packages RUN apt-get update RUN apt-get install -y build-essential git python3 python3-pip libudev-dev gcc-arm-none-eabi libffi-dev swig libpcsclite-dev python-is-python3 autoconf libtool python3-venv pkg-config +RUN apt-get clean # Prepare source code RUN git clone --depth 1 --recursive -b 2024-01-18T1507-v6.2.2X https://github.com/Coldcard/firmware.git +WORKDIR /firmware/external/libngu/libs/bech32 +RUN git apply ../../bech32.patch WORKDIR /firmware RUN git apply unix/linux_addr.patch +RUN rm -rf .git +RUN sed -i "/git/d" unix/Makefile +RUN sed -i "/git/d" external/libngu/Makefile # Prepare virtual env ENV VIRTUAL_ENV=/opt/venv From d0c7eed880a9d96fdb051e438cfb003766e5e495 Mon Sep 17 00:00:00 2001 From: Jiri Jakes Date: Sat, 3 Feb 2024 11:38:37 +0800 Subject: [PATCH 3/3] Try some more --- .github/workflows/main.yml | 4 ++-- ci/Dockerfile.coldcard | 20 +++++++------------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bf55b7d..9491dbb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -42,8 +42,8 @@ jobs: rust: - version: 1.66.1 # STABLE features: miniscript - - version: 1.48.0 # MSRV - features: miniscript +# - version: 1.48.0 # MSRV +# features: miniscript emulator: # - name: trezor # docker-params: '--network=host' diff --git a/ci/Dockerfile.coldcard b/ci/Dockerfile.coldcard index 445a67f..210a938 100644 --- a/ci/Dockerfile.coldcard +++ b/ci/Dockerfile.coldcard @@ -1,19 +1,16 @@ -FROM python:3-slim +# Ubuntu 23.04 uses gcc-12 by default +# In coldcard, micropython does not build with gcc-13 +FROM ubuntu:23.04 # Install required packages -RUN apt-get update -RUN apt-get install -y build-essential git python3 python3-pip libudev-dev gcc-arm-none-eabi libffi-dev swig libpcsclite-dev python-is-python3 autoconf libtool python3-venv pkg-config -RUN apt-get clean +RUN apt-get update && apt-get install -y build-essential git python3 python3-pip libudev-dev gcc-arm-none-eabi libffi-dev swig libpcsclite-dev python-is-python3 autoconf libtool python3-venv pkg-config && apt-get clean # Prepare source code RUN git clone --depth 1 --recursive -b 2024-01-18T1507-v6.2.2X https://github.com/Coldcard/firmware.git WORKDIR /firmware/external/libngu/libs/bech32 RUN git apply ../../bech32.patch WORKDIR /firmware -RUN git apply unix/linux_addr.patch -RUN rm -rf .git -RUN sed -i "/git/d" unix/Makefile -RUN sed -i "/git/d" external/libngu/Makefile +RUN git apply unix/linux_addr.patch && rm -rf .git && sed -i "/git/d" unix/Makefile && sed -i "/git/d" external/libngu/Makefile # Prepare virtual env ENV VIRTUAL_ENV=/opt/venv @@ -21,16 +18,13 @@ RUN python3 -m venv $VIRTUAL_ENV ENV PATH="$VIRTUAL_ENV/bin:$PATH" # Install dependencies -RUN pip install -U pip setuptools -RUN pip install -r requirements.txt +RUN pip install -U pip setuptools && pip install -r requirements.txt # Build the Coldcard simulator WORKDIR /firmware/external/micropython/mpy-cross/ RUN make WORKDIR /firmware/unix -RUN make setup -RUN make ngu-setup -RUN make +RUN make setup && make ngu-setup && make # Run simulator ## for running on developers' machines