Skip to content

Commit f8bf5d4

Browse files
committed
docs: update docs for build updates
1 parent f9f2350 commit f8bf5d4

1 file changed

Lines changed: 119 additions & 81 deletions

File tree

README.md

Lines changed: 119 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
# Jade Firmware
1+
# Jade Firmware Development
22

3-
NOTE: The below instructions are for Jade developers with access to Jade development boards or for those wanting to build and flash their own esp32/esp32s3 consumer devices - e.g. M5Stack or TTGO T-Display boards.
4-
They are not for updating the firmware of an official Blockstream Jade HW unit - these can only be updated in-app, or using the 'update_jade_fw.py' script - see FWUPDATE.md
3+
* DO NOT ATTEMPT TO BUILD/FLASH WITH OFFICIAL BLOCKSTREAM JADE HARDWARE UNITS
54

6-
* DO NOT ATTEMPT THE BELOW WITH BLOCKSTREAM OFFICIAL BLOCKSTREAM JADE HW UNITS
5+
The below instructions are for developers with access to Jade development
6+
devices, or for those wanting to build and flash their own esp32/esp32s3
7+
DIY consumer devices such as M5Stack or TTGO T-Display boards.
78

8-
To build you can use the docker image (see Dockerfile) or install the esp-idf toolchain and repository following the commands below.
9+
Official Blockstream Jade hardware units can only be updated via a supported
10+
companion app, or by using the [Firmware Update Instructions](./FWUPDATE.md).
911

1012
# DIY Hardware & Programming Notes
11-
For information about suitable DIY hardware, as well as suggested configuration profiles and notes on secure boot,
12-
see [DIY Guide](./diy/)
13+
For information about suitable DIY hardware, as well as suggested configuration
14+
profiles and notes on secure boot, see the [DIY Guide](./diy/)
1315

1416
# Build dependencies
1517

16-
Cmake and ninja are needed to build the firmware.
18+
Cmake and ninja are needed to build Jade firmware images.
1719

1820
On Debian based distributions, install with with:
1921

@@ -27,58 +29,47 @@ On MacOS:
2729
brew install cmake ninja
2830
```
2931

30-
Make sure to use a recent Python version (e.g. Python 3.11) as the current system version which is used by the install script below.
31-
Failure to do so may result in problems installing Python dependencies.
32+
Make sure to use a recent Python version (Python 3.11+) when running the
33+
commands below. Failure to do so may result in problems installing Python
34+
dependencies.
3235

33-
# Set up the environment
36+
# Set up the build environment
3437

35-
Jade requires the esp-idf sdk.
38+
Jade requires the esp-idf SDK. You can use our docker image to build or
39+
install the esp-idf toolchain locally using the commands below.
3640

37-
More information is available in the [Espressif official guide](https://docs.espressif.com/projects/esp-idf/en/v5.4/esp32/get-started/index.html).
41+
See the [Espressif official guide](https://docs.espressif.com/projects/esp-idf/en/v5.4/esp32/get-started/index.html)
42+
for more information on the available tooling.
3843

39-
Get the esp-idf sdk and required tools:
44+
# Device targets
4045

41-
```
42-
mkdir ~/esp
43-
cd ~/esp
44-
git clone -b v5.4 --recursive https://github.com/espressif/esp-idf.git
45-
cd esp-idf
46-
git checkout 67c1de1eebe095d554d281952fde63c16ee2dca0
47-
./install.sh --enable-gdbgui esp32 esp32s3
48-
python ./tools/idf_tools.py install qemu-xtensa
49-
```
50-
51-
Set up the idf environmental and make the `idf.py` command available:
52-
53-
```
54-
. $HOME/esp/esp-idf/export.sh
55-
```
56-
57-
# Devices
58-
59-
There are currently three Jade device targets:
46+
There are currently four official Jade device targets:
6047
- jade: The original Jade 1.0 with a selection wheel.
61-
- jade_v1_1: Jade 1.1, which has a rocker/jog-wheel in place of the selection wheel.
62-
- jade_v2: Jade Plus, with a larger screen and left/right selection buttons in place of a wheel or rocker.
48+
- jade_v1_1: Jade 1.1, with a rocker/jog-wheel instead of the selection wheel.
49+
- jade_v2: Jade Plus, with a larger screen and left/right selection buttons
50+
instead of a wheel or rocker.
6351
- jade_v2c: Jade Core, Jade Plus without camera and battery.
6452

6553
Change `jade` in any calls to the `switch_to.sh` script below to the
6654
appropriate device you wish to target from the list above.
6755

6856
# Serial port
6957

70-
The serial port pseudo-tty file for Jade access via USB is usually `/dev/ttyACM0` or `/dev/ttyUSB0`, or `/dev/cu.SLAB_USBtoUART` on MacOS. Note that the supplied docker-compose.yml assumes the Jade device is at /dev/ttyUSB0.
58+
The serial port pseudo-tty file for Jade access via USB is usually
59+
`/dev/ttyACM0` or `/dev/ttyUSB0` (or `/dev/cu.SLAB_USBtoUART` on MacOS).
7160

72-
In order to have permission to use USB to install firmware, your user should be in `dialout` group on Debian
73-
based distributions. Other distributions may use a different group name: Check the group of the serial
74-
port pseudo-tty file using `ls -l` command to determine the required group, e.g:
61+
In order to have permission to use USB to install firmware, your user should
62+
be in the `dialout` group on Debian based distributions. Other distributions
63+
may use a different group name: Check the group of the serial port pseudo-tty
64+
file using `ls -l` to determine the required group, e.g:
7565

7666
```
7767
$ ls -l /dev/ttyACM0
7868
crw-rw----+ 1 root dialout 166, 0 Apr 15 14:37 /dev/ttyACM0
7969
```
8070

81-
The group name (`dialout` here) is shown after the owner (`root`). You can check that `dialout` appears in your user groups by running:
71+
The group name (`dialout` here) is shown after the owner (`root`). You can check
72+
that `dialout` appears in your user groups by running:
8273

8374
```
8475
$ groups
@@ -93,7 +84,70 @@ sudo usermod -aG dialout $USER
9384

9485
You should then login/logout or reboot for the group changes to take effect.
9586

96-
# Build the firmware
87+
**NOTE**: For docker builds no group changes are usually required as the
88+
docker image is privileged.
89+
90+
You should set the environment variable `JADESERIALPORT` to the Jade USB
91+
device to default its value when running development scripts.
92+
93+
## Docker build environment
94+
95+
NOTE: MacOS users should set up the environment locally as detailed below to
96+
avoid issues with device access. For more information see
97+
[this article](https://dev.to/rubberduck/using-usb-with-docker-for-mac-3fdd).
98+
99+
Blockstream provides the `blockstream/jade_build` docker image which provides
100+
the idf tooling and other dependencies required to build. To run a shell inside
101+
the Jade development builder, use:
102+
103+
```
104+
docker run -it blockstream/jade_build:latest bash
105+
```
106+
107+
Run `get_idf` within this container to enable the idf tools.
108+
109+
Alternately, the `docker-compose.yml` file in this repository can be used to
110+
work on the current respository source code from within the `jade_build`
111+
container.
112+
113+
```
114+
$ # Build the image and run a shell inside it
115+
$ docker compose run dev bash
116+
(docker)$ Set up idf environment
117+
(docker)$ get_idf
118+
(docker)# Make the serial device available to internal scripts, for example:
119+
(docker)$ export JADESERIALPORT=/dev/ttyACM0
120+
```
121+
122+
You can then build and flash as detailed below.
123+
124+
## Local build environment
125+
126+
Install the esp-idf SDK and required tools. From a checked-out Jade
127+
git repository, run the following commands:
128+
129+
```
130+
$ export ESP_IDF_BRANCH=$(grep ESP_IDF_BRANCH Dockerfile | sed 's/.*=//g')
131+
$ mkdir ~/esp
132+
$ cd ~/esp
133+
$ git clone --recursive https://github.com/espressif/esp-idf.git
134+
$ cd esp-idf
135+
$ git checkout $ESP_IDF_BRANCH
136+
$ ./install.sh --enable-gdbgui esp32 esp32s3
137+
$ python ./tools/idf_tools.py install qemu-xtensa
138+
```
139+
140+
Set up the idf environment to make the `idf.py` command available,
141+
and then install the Jade dependencies into the idf environment:
142+
143+
```
144+
$ . ~/esp/esp-idf/export.sh
145+
$ pip install --require-hashes -r ./requirements.txt
146+
```
147+
148+
You can then build and flash as detailed below.
149+
150+
# Build The firmware
97151

98152
First, you'll need the Jade source code including its sub-modules checked out:
99153

@@ -103,43 +157,42 @@ cd $HOME/jade
103157
git submodule update --init --recursive
104158
```
105159

106-
Choose your configuration. For Jade development, the script `tools/switch_to.sh` allows
160+
Choose your configuration. For official Jade devices, the script `tools/switch_to.sh` allows
107161
choosing the device and features you want. Run `tools/switch_to.sh --help` to see the
108162
available options. A standard development Jade Plus build for example would use something
109163
like:
110164

111165
```
112-
./tools/switch_to.sh jade_v2 --dev --log --jtag [--noradio]
166+
$ ./tools/switch_to.sh jade_v2 --dev --log --jtag [--noradio]
113167
```
114168

115-
116169
For other devices, copy (and modify if desired) a suitable config from the `configs`
117170
directory to `sdkconfig.defaults`. You should also run e.g. `idf.py set-target esp32` or
118171
`idf.py set-target esp32s3` once initially to ensure you are targeting the correct
119172
toolchain for your hardware. So for example for the TTGO T-Display:
120173

121174
```
122-
cp configs/sdkconfig_display_ttgo_tdisplay.defaults sdkconfig.defaults
175+
$ cp configs/sdkconfig_display_ttgo_tdisplay.defaults sdkconfig.defaults
123176
```
124177

125178
To build the firmware, run:
126179

127180
```
128-
idf.py all
181+
$ idf.py all
129182
```
130183

131184
To flash the resulting build to your device, run:
132185

133186
```
134-
idf.py flash [monitor]
187+
$ idf.py -p $JADESERIALPORT flash [monitor]
135188
```
136189

137190
Some hardware configurations (e.g. M5StickC-Plus) may not support the default baud
138191
rate and so won't be detected. If this occurs you can force a specific baud rate
139192
for flash/monitor by using the `-b` argument, e.g:
140193

141194
```
142-
idf.py -b 115200 flash monitor
195+
idf.py -p $JADESERIALPORT -b 115200 flash [monitor]
143196
```
144197

145198
If you have errors relating to unknown bytes when flashing, place your device
@@ -161,14 +214,18 @@ Beyond the build configurations in the `configs/` directory, you can edit the co
161214
manually with the `menuconfig` tool:
162215

163216
```
164-
idf.py menuconfig
217+
$ idf.py menuconfig
165218
```
166219

167-
Note: for any but the simplest CI-like build with no GUI, no camera, no user-interaction etc. it is recommended that PSRAM is available and enabled. ( Component Config -> ESP-32 specific -> Support external SPI connected RAM )
220+
**NOTE**: for any but the simplest CI-like build with no GUI, no camera, no
221+
user-interaction etc. it is recommended that PSRAM (available under
222+
`Component Config -> ESP-32 specific -> Support external SPI connected RAM`
223+
is available and enabled.
168224

169225
# Run the tests
170226

171-
Virtualenv and bluez-tools are required, you can install them on Debian based distributions with:
227+
Virtualenv and bluez-tools are required, you can install them on Debian
228+
based distributions with:
172229

173230
```
174231
sudo apt install virtualenv bluez-tools
@@ -177,45 +234,26 @@ sudo apt install virtualenv bluez-tools
177234
Then to run the tests:
178235

179236
```
180-
cd $HOME/jade
181-
virtualenv -p python3 venv3
182-
source venv3/bin/activate
183-
pip install -r requirements.txt
184-
pip install -r pinserver/requirements.txt
185-
186-
python test_jade.py
187-
188-
deactivate
237+
$ cd $HOME/jade
238+
$ # Create and activate a Python virtualenv
239+
$ virtualenv -p python3 venv3
240+
$ source venv3/bin/activate
241+
$ pip install -r requirements.txt
242+
$ pip install -r pinserver/requirements.txt
243+
$ # Run the tests
244+
$ python test_jade.py --serialport $JADESERIALPORT
245+
$ # Cleanup
246+
$ deactivate
189247
```
190248

191-
Note that the tests require a CI build; this is a configuration that automatically
249+
The tests require a CI build; this is a configuration that automatically
192250
accepts the default action without requiring user interaction. This is enabled using
193251
the `--ci` argument to `switch_to.sh` or by setting `CONFIG_DEBUG_UNATTENDED_CI=y`
194252
in sdkconfig.defaults.
195253

196254
Debug support is also required to expose debug functions for testing. Use `--debug`
197255
or set `CONFIG_DEBUG_MODE=y` to enable this.
198256

199-
# Use docker
200-
201-
If you are on MacOS, you are better off setting up the environment locally as detailed above, rather than trying to get access to your device from the docker container. For more, see [this article](https://dev.to/rubberduck/using-usb-with-docker-for-mac-3fdd).
202-
203-
The supplied docker-compose.yml assumes the Jade device is at /dev/ttyUSB0, but note that it may instead be e.g. /dev/ttyACM0 (or have another numeric suffix or path depending on the host operating system).
204-
205-
The build steps within docker are the same as detailed above, e.g:
206-
207-
```
208-
(local)$ docker-compose up -d
209-
(local)$ docker-compose exec dev bash
210-
(docker)$ ./tools/switch_to.sh jade --dev --log --jtag [--noradio]
211-
(docker)$ idf.py all
212-
(docker)$ idf.py flash
213-
```
214-
215-
The docker-compose.yml also mounts the local git repository so that it is the
216-
origin of the repository in the docker.
217-
218-
219257
# Emulator/Virtualizer (qemu in Docker)
220258

221259
The following will build a docker image running the headless ci-test (approves every request):

0 commit comments

Comments
 (0)