Skip to content

Commit 7b29649

Browse files
committed
docs: update README.md to cover recent build/config changes
1 parent 71b9467 commit 7b29649

File tree

1 file changed

+138
-62
lines changed

1 file changed

+138
-62
lines changed

README.md

Lines changed: 138 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
11
# Jade Firmware
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 consumer devices - eg. 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+
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
55

66
* DO NOT ATTEMPT THE BELOW WITH BLOCKSTREAM OFFICIAL BLOCKSTREAM JADE HW UNITS
77

8-
To build you can use the docker image (see Dockerfile) or install the esp-idf toolchain and repo following the commands in this readme.
8+
To build you can use the docker image (see Dockerfile) or install the esp-idf toolchain and repository following the commands below.
99

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

14-
# Use docker
14+
# Build dependencies
1515

16-
If you are on MacOS, you are better off setting up the environment locally (see next step) 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).
16+
Cmake and ninja are needed to build the firmware.
1717

18-
Note the supplied docker-compose.yml assumes the Jade device is at /dev/ttyUSB0, but note that it may instead be /dev/ttyACM0 (or either with some other trailing number) or some other path as appropriate for the host operating system.
18+
On Debian based distributions, install with with:
1919

20-
Note the below instructions assume an original Jade v1.0 hardware with a true wheel.
21-
When using the later Jade v1.1 hw revision with a rocker/jog-wheel, use 'configs/sdkconfig_jade_v1_1.defaults' in place of 'configs/sdkconfig_jade.defaults'.
2220
```
23-
(local)$ docker-compose up -d
24-
(local)$ docker-compose exec dev bash
25-
(docker)$ cp configs/sdkconfig_jade.defaults sdkconfig.defaults
26-
(docker)$ idf.py flash
21+
sudo apt install cmake ninja-build
2722
```
2823

29-
The docker-compose.yml also mounts the local git repo so that it is the
30-
origin of the repo in the docker.
24+
On MacOS:
25+
26+
```
27+
brew install cmake ninja
28+
```
29+
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.
3132

3233
# Set up the environment
3334

@@ -41,95 +42,132 @@ Get the esp-idf sdk and required tools:
4142
mkdir ~/esp
4243
cd ~/esp
4344
git clone -b v5.4 --recursive https://github.com/espressif/esp-idf.git
44-
cd ~/esp/esp-idf && git checkout 67c1de1eebe095d554d281952fde63c16ee2dca0 && ./install.sh --enable-gdbgui esp32 esp32s3
45-
python ~/esp/esp-idf/tools/idf_tools.py install qemu-xtensa
45+
cd esp-idf
46+
git checkout 67c1de1eebe095d554d281952fde63c16ee2dca0
47+
./install.sh --enable-gdbgui esp32 esp32s3
48+
python ./tools/idf_tools.py install qemu-xtensa
4649
```
4750

48-
Set up the environmental variables:
51+
Set up the idf environmental and make the `idf.py` command available:
4952

5053
```
5154
. $HOME/esp/esp-idf/export.sh
5255
```
5356

54-
On MacOS: You will need cmake and ninja on your system for this step (`brew install cmake ninja`).
57+
# Devices
5558

56-
If you encounter Python dependencies issue, 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.
57-
58-
# Build dependencies
59+
There are currently three Jade device targets:
60+
- 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.
5963

60-
Cmake and ninja are needed to build the firmware, you can install them on debian based distros with:
61-
62-
```
63-
sudo apt install cmake ninja-build
64-
```
64+
Change `jade` in any calls to the `switch_to.sh` script below to the
65+
appropriate device you wish to target from the list above.
6566

6667
# Serial port
6768

68-
In order to have permissions using serial port to load firmware, your user should be in `dialout` group on debian
69-
based distros, other distros can use a different group name, you can figure out by checking the group of the serial
70-
port 'file' using `ls -l` command:
69+
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.
7170

72-
(serial port is usually `/dev/ttyACM0` or `/dev/ttyUSB0`)
71+
In order to have permission to use USB to install firmware, your user should be in `dialout` group on Debian
72+
based distributions. Other distributions may use a different group name: Check the group of the serial
73+
port pseudo-tty file using `ls -l` command to determine the required group, e.g:
7374

74-
```
75-
$ ls -l /dev/ttyACM0 14:37:07
75+
```
76+
$ ls -l /dev/ttyACM0
7677
crw-rw----+ 1 root dialout 166, 0 Apr 15 14:37 /dev/ttyACM0
7778
```
7879

79-
You can check that `dialout` appear in your user groups by running:
80+
The group name (`dialout` here) is shown after the owner (`root`). You can check that `dialout` appears in your user groups by running:
8081

81-
```
82+
```
8283
$ groups
8384
docker libvirt dialout storage kvm wheel plugdev
8485
```
8586

86-
if not present you should add your user to the group:
87+
If not present you should add your user to the group:
8788

88-
```
89+
```
8990
sudo usermod -aG dialout $USER
9091
```
9192

92-
(you should then login/logout or reboot)
93+
You should then login/logout or reboot for the group changes to take effect.
9394

9495
# Build the firmware
9596

97+
First, you'll need the Jade source code including its sub-modules checked out:
98+
9699
```
97100
git clone --recursive https://github.com/Blockstream/Jade.git $HOME/jade
98101
cd $HOME/jade
99102
git submodule update --init --recursive
100-
cp configs/sdkconfig_jade.defaults sdkconfig.defaults
101-
idf.py flash monitor
102103
```
103-
Use a config file from the configs folder that is specific to your hardware (if available).
104104

105-
_For example for the TTGO T-Display:_
105+
Choose your configuration. For Jade development, the script `tools/switch_to.sh` allows
106+
choosing the device and features you want. Run `tools/switch_to.sh --help` to see the
107+
available options. A standard development Jade Plus build for example would use something
108+
like:
109+
110+
```
111+
./tools/switch_to.sh jade_v2 --dev --log --jtag [--noradio]
112+
```
113+
114+
115+
For other devices, copy (and modify if desired) a suitable config from the `configs`
116+
directory to `sdkconfig.defaults`. You should also run e.g. `idf.py set-target esp32` or
117+
`idf.py set-target esp32s3` once initially to ensure you are targeting the correct
118+
toolchain for your hardware. So for example for the TTGO T-Display:
119+
106120
```
107121
cp configs/sdkconfig_display_ttgo_tdisplay.defaults sdkconfig.defaults
108122
```
109123

110-
If you flash multiple devices or make changes to the original config file that you used, make sure to delete the `sdkconfig` file that gets created from `sdkconfig.defaults`. Otherwise, your changes will not get picked up when building and re-flashing the firmware.
124+
To build the firmware, run:
125+
126+
```
127+
idf.py all
128+
```
129+
130+
To flash the resulting build to your device, run:
111131

112-
Some hardware configurations (eg: M5StickC-Plus) may not support the default baud rate and won't be detected, so you can force a specific baud rate for flash/monitor by using the `-b` argument.
132+
```
133+
idf.py flash [monitor]
134+
```
135+
136+
Some hardware configurations (e.g. M5StickC-Plus) may not support the default baud
137+
rate and so won't be detected. If this occurs you can force a specific baud rate
138+
for flash/monitor by using the `-b` argument, e.g:
113139

114-
_For example, the last line of the above code block would change be:_
115140
```
116141
idf.py -b 115200 flash monitor
117142
```
118143

119-
# Build configurations
144+
If you have errors relating to unknown bytes when flashing, place your device
145+
into download mode. This is device specific, for Jade development devices,
146+
turn off the device, then hold the select and power buttons for 10 seconds.
147+
Note the device screen will stay blank when in download mode.
148+
149+
If you switch between JTAG and non-JTAG builds in particular, you will need to
150+
flash from download mode.
120151

121-
There are various build configurations used by the CI in the configs/ directory, which may be required for specific builds eg. without BLE radio, with the screen enabled (or disabled, as with the CI tests), or for specific hardware (eg. the m5-fire).
152+
If you flash multiple device types, or make changes to the sdkconfig.config file,
153+
delete the `sdkconfig` file that gets created from `sdkconfig.defaults` between
154+
builds. Otherwise, your changes will not get picked up when re-building/flashing
155+
the firmware.
122156

123-
The menuconfig tool can also be used to adjust the build settings.
157+
# Build customization
158+
159+
Beyond the build configurations in the `configs/` directory, you can edit the config
160+
manually with the `menuconfig` tool:
124161

125162
```
126163
idf.py menuconfig
127164
```
165+
128166
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 )
129167

130168
# Run the tests
131169

132-
Virtualenv and bluez-tools are required, you can install them on debian based distros with:
170+
Virtualenv and bluez-tools are required, you can install them on Debian based distributions with:
133171

134172
```
135173
sudo apt install virtualenv bluez-tools
@@ -149,51 +187,83 @@ python test_jade.py
149187
deactivate
150188
```
151189

190+
Note that the tests require a CI build; this is a configuration that automatically
191+
accepts the default action without requiring user interaction. This is enabled using
192+
the `--ci` argument to `switch_to.sh` or by setting `CONFIG_DEBUG_UNATTENDED_CI=y`
193+
in sdkconfig.defaults.
194+
195+
Debug support is also required to expose debug functions for testing. Use `--debug`
196+
or set `CONFIG_DEBUG_MODE=y` to enable this.
197+
198+
# Use docker
199+
200+
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).
201+
202+
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).
203+
204+
The build steps within docker are the same as detailed above, e.g:
205+
206+
```
207+
(local)$ docker-compose up -d
208+
(local)$ docker-compose exec dev bash
209+
(docker)$ ./tools/switch_to.sh jade --dev --log --jtag [--noradio]
210+
(docker)$ idf.py all
211+
(docker)$ idf.py flash
212+
```
213+
214+
The docker-compose.yml also mounts the local git repository so that it is the
215+
origin of the repository in the docker.
216+
217+
152218
# Emulator/Virtualizer (qemu in Docker)
153219

154220
The following will build a docker image running the headless ci-test (approves every request):
221+
155222
```
156223
docker build -t jade-qemu-ci -f Dockerfile.qemu .
157224
docker run --rm -p 30121:30121 -it jade-qemu-ci
158225
```
159-
The python 'jadepy' api can talk to it as if it were a serial interface, if given the device string 'tcp:localhost:30121'.
226+
227+
The python 'jadepy' API can talk to it as if it were a serial interface, if given the device string 'tcp:localhost:30121'.
228+
160229
```
161230
python -c "from jadepy.jade import JadeAPI; jade = JadeAPI.create_serial(device='tcp:localhost:30121'); jade.connect(); print(jade.get_version_info()); jade.disconnect()"
162231
```
163232

164233
Similarly, for a manually driven web-enabled 'virtual jade' (at 'http://localhost:30122/'):
234+
165235
```
166236
docker build -t jade-qemu-web -f Dockerfile.qemu --build-arg="SDK_CONFIG=configs/sdkconfig_qemu_psram_webdisplay.defaults" .
167237
docker run --rm -p 30121:30121 -p 30122:30122 -it jade-qemu-web
168238
```
169239

170-
Alternatively, to run the qemu emulator with display and camera support is to run
240+
Alternatively, to run the qemu emulator with display and camera support, run:
241+
171242
```
172-
main/qemu/run_emulator.sh
243+
main/qemu/run_emulator.sh [--larger-display]
173244
```
174245

175-
Then you will be able to open the browser and point it to 'http://localhost:30122' to interface with the emulated Jade.
246+
Open a web browser and point it to 'http://localhost:30122' to interface with the emulated Jade.
176247

177248
Note that the ```run_emulator.sh``` command will launch a docker image so it will only work on Linux.
178-
You can also optionally pass the flag ```--larger-display``` to run the emulator with a bigger display.
179249

180250
Otherwise if you don't need the display or want to run with gdb, follow the below steps.
181251

182-
Run these commands inside the jade source repo root directory, it will enter a docker container:
252+
Run these commands inside the jade source repository root directory to enter a docker container:
183253

184254
```
185255
DOCKER_BUILDKIT=1 docker build . -t testjadeqemu
186256
docker run -v ${PWD}:/jade -p 30121:30121 -it testjadeqemu bash
187257
```
188258

189-
Note: You can skip the build step if you want by fetching the prebuilt image and running with
259+
Note: You can skip the build step if you want by fetching the pre-built image and running with
190260

191261
```
192262
docker pull blockstream/verde
193263
docker run -v ${PWD}:/jade -p 30121:30121 -it blockstream/verde bash
194264
```
195265

196-
Now inside the container
266+
Inside the container, run:
197267

198268
```
199269
. /root/esp/esp-idf/export.sh
@@ -227,16 +297,22 @@ See [REPRODUCIBLE.md](./REPRODUCIBLE.md) for instructions on locally reproducing
227297

228298
# DIY
229299

230-
Seen working on M5 Stack gray/black/FIRE, M5 Stick Plus, Core 2, Core S3, LilyGO T-Display, T-DisplayS3, RPI Zero + display shield (via QEMU), Desktop via Qemu (browser for display/webcam)
300+
Seen working on M5 Stack gray/black/FIRE, M5 Stick Plus, Core 2, Core S3, LilyGO T-Display, T-DisplayS3, RPI Zero + display shield (via QEMU), and Desktop via Qemu (browser for display/webcam).
231301

232302
# Client
233303

234-
A python client is available to communicate with genuine or diy Jade units:
304+
A python client is available to communicate with genuine or DIY Jade units:
305+
235306
```
236307
pip install jade-client
237308
```
238-
This installs the `jadepy` directory from this repo. See [jade-client-requirements.txt](./jade-client-requirements.txt) and [jade-client-requirements.txt.asc](./jade-client-requirements.txt.asc)
309+
310+
This installs the `jadepy` directory from this repository. See [jade-client-requirements.txt](./jade-client-requirements.txt) and [jade-client-requirements.txt.asc](./jade-client-requirements.txt.asc)
311+
312+
# Firmware development
313+
314+
See [libjade](./libjade/README.md) For a local build setup that allows for initial feature development and debugging off-device.
239315

240316
# License
241317

242-
The collection is subject to gpl3 but individual source components can be used under their specific licenses.
318+
The collection is subject to GPL3 but individual source components can be used under their specific licenses.

0 commit comments

Comments
 (0)