chore: Simulator Docker instructions

This commit is contained in:
tadeubas 2025-12-29 16:33:42 -03:00 committed by doc-hex
parent 0484e3cd3b
commit 421d3c1bf4
4 changed files with 65 additions and 1 deletions

1
.gitignore vendored
View File

@ -26,3 +26,4 @@ __pycache__/
pp
.idea/
firmware

32
Dockerfile Normal file
View File

@ -0,0 +1,32 @@
FROM gcc:11.5.0-bullseye
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y \
git \
make \
python3 python3-venv python3-pip \
swig \
libpcsclite-dev pcscd \
pkg-config \
libffi-dev \
xterm \
autoconf automake libtool m4
WORKDIR /build
RUN git clone --depth 1 --recursive \
https://github.com/Coldcard/firmware.git
WORKDIR /build/firmware/unix
# Build mpy-cross
RUN make -C ../external/micropython/mpy-cross
# Build simulator & tools
RUN make setup
RUN make ngu-setup
RUN make
# remove unnecessary git files
RUN find /build/firmware -name ".git" -type d -prune -exec rm -rf '{}' +

View File

@ -91,6 +91,25 @@ so at the top level, do this command:
pip install -r requirements.txt
```
### Using Docker to build simulator
Install [Docker Desktop or Docker Engine](https://docs.docker.com/desktop/) (don't forget to add your user to the docker group `sudo usermod -aG docker $USER` than logout and login again)
```
# Build simulator
docker build -t coldcard-simulator .
docker create --name cc coldcard-simulator
docker cp cc:/build/firmware ./firmware
docker rm cc
# Install specific libffi7 (as new Ubuntu versions ship with libffi8 only)
wget http://archive.ubuntu.com/ubuntu/pool/main/libf/libffi/libffi7_3.3-4_amd64.deb
sudo dpkg -i libffi7_3.3-4_amd64.deb
# Run simulator (remember to follow the OS specific instructions detailed below to install python and its dependencies)
cd firmware/unix
./simulator.py
```
### macOS
[Python 3.5 or higher](https://www.python.org) and [Homebrew](https://brew.sh) is required.
@ -179,7 +198,13 @@ All steps you need to install and run the Coldcard simulator on Ubuntu 20.04:
apt install build-essential git python3 python3-pip libudev-dev gcc-arm-none-eabi libffi-dev xterm swig libpcsclite-dev python-is-python3 autoconf libtool python3-venv
# Get sources, this takes a long time (because of external libraries), then open
# Recommended (fast, minimal download; sufficient for building and running the simulator):
git clone --depth 1 --recursive https://github.com/Coldcard/firmware.git
# Full clone (developers only; required for history, bisecting, or contributing):
git clone --recursive https://github.com/Coldcard/firmware.git
cd firmware
# Apply address patch

View File

@ -903,8 +903,14 @@ Q1 specials:
child.kill()
return
logfile = '/tmp/cc_simulator.log'
# truncate logfile and set correct permissions before starting xterm
open(logfile, 'w').close()
os.chmod(logfile, 0o644)
xterm = subprocess.Popen(['xterm', '-title', 'Coldcard Simulator REPL',
'-geom', '132x40+650+40', '-e'] + cc_cmd,
'-geom', '132x40+650+40', '-l', '-lf', logfile, '-e'] + cc_cmd,
env=env,
stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
pass_fds=pass_fds, shell=False)