You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

222 lines
8.5 KiB

4 years ago
# Development
This document describes how to develop for Passport.
## Operating System
While Passport may compile on other Linux distributions, the instructions below are based on **Ubuntu 18.04**, which is also what is used for official Passport builds.
4 years ago
## Installation
### Get the Source Code
The instructions below assume you are installing into your home folder at `~/passport-firmware`. You can choose
to install to a different folder, and just update command paths appropriately.
4 years ago
cd ~/
git clone git@github.com:Foundation-Devices/passport-firmware.git
4 years ago
### Install Dependencies
Several tools are required for building and debugging Passport.
#### Cross-Compiler Toolchain
sudo apt install gcc-arm-none-eabi
cd ~/passport-firmware
4 years ago
make -C mpy-cross
#### Autotools and USB
sudo apt install autotools-dev
sudo apt install automake
sudo apt install libusb-1.0-0-dev
sudo apt install libtool
#### OpenOCD - On-Chip Debugger
cd ~/
git clone https://github.com/ntfreak/openocd.git
cd ~/openocd/
./bootstrap
./configure --enable-stlink
make
sudo make install
#### RShell - Micropython Shell and REPL
cd ~/
git clone https://github.com/dhylands/rshell
sudo apt install python3-pip
sudo pip3 install rshell # (this should install rshell in /usr/local/)
4 years ago
Dev v1.0.7 (#57) * PASS1-133: Modify cosign file naming for fully signed binaries. (#34) * PASS1-133: Modify cosign file naming for fully signed binaries. * Remove all USE_CRYPTO, it is not used anymore Also remove function that is not needed. * Added use of firmware version from header, also fixed a seg fault * PASS1-135: Fix sticky up or down key (#33) * PASS1-135: Fix sticky up or down key * Add comment for input.reset function * PASS1-128: Add support back for Bitcoin testnet (#29) * Fixes part of PASS-91 Show address and index of the address being verified * Second half of fix for ENV1-91 Add better messaging for address range searching Fix a bug when saving next_addrs (was comparing dicts by ref) * Fixes PASS1-122 Check change addresses in addition to receive address in "Verify Address" * Fix comment punctuation * Show backup filename to user after successful backup (#18) Fix PASS1-92 * Auto-truncate multisig config names (#19) Fix PASS1-101 * PASS1-101: Auto-truncate multisig config names (#19) Fix PASS1-101 * Remove unnecessary comments * PASS1-92 (#20) * Show backup filename to user after successful backup Fix PASS1-92 * Add missing 'card' parameter to `get_backups_folder_path()` calls * Revert path function changes since 'card' is not available * PASS1-102: Fix backwards microSD issue Found that `ErrorCode` in `SD_HandleTypeDef` was not reset after a failure. Updated `HAL_SD_Init()` to reset it before attempting initialization. * PASS1-102: Fix backwards microSD issue (#21) Found that `ErrorCode` in `SD_HandleTypeDef` was not reset after a failure. Updated `HAL_SD_Init()` to reset it before attempting initialization. * PASS1-102_b (#22) * PASS1-102: Fix backwards microSD issue Found that `ErrorCode` in `SD_HandleTypeDef` was not reset after a failure. Updated `HAL_SD_Init()` to reset it before attempting initialization. * Switch back to hard-coded path for now * PASS1-122_b (#23) * PASS1-102: Fix backwards microSD issue Found that `ErrorCode` in `SD_HandleTypeDef` was not reset after a failure. Updated `HAL_SD_Init()` to reset it before attempting initialization. * Update user messaging for found/not found case of Verify Address Fix bug with trailing space at end of line in `word_wrap()` * Strip ever time through the loop * PASS1-125: Add Git commit-msg hook to check for Linear ID (#24) * PASS1-125: Add Git commit-msg hook to check for Linear ID * Update .githooks/commit-msg Co-authored-by: Jean Pierre Dudey <jeandudey@hotmail.com> Co-authored-by: Jean Pierre Dudey <jeandudey@hotmail.com> * PASS1-122: Minor updates to text (#27) * PASS1-127: Fix `reuse lint` issues in the repo (#26) * PASS1-113: Give the user a way to clear the developer pubkey slot (#25) * PASS1-122: Added "Address Verified" text to new wallet pairing (#28) * PASS1-122: Minor updates to text * PASS1-122: Added "Address Verified" text to new wallet pairing * PASS1-128: Add support back for Bitcoin testnet Co-authored-by: Ken Carpenter <ken@foundationdevices.com> Co-authored-by: Ken Carpenter <62639971+FoundationKen@users.noreply.github.com> Co-authored-by: Jean Pierre Dudey <jeandudey@hotmail.com> * PASS1-56: Use XFP in backups filename and don't save `backup_num` (#32) * PASS1-34: Refactor find address code so there is only one copy (#37) * PASS1-94: Prevent installing user-signed firmware if no user-key installed (#38) * PASS1-94: Prevent installing user-signed firmware if no user signing key installed * Fixed case where user pubkey was removed manually * Fixed text to match other areas where text is used * Update text message for developer pubkey * Hard coded user signed field to false Co-authored-by: Ken Carpenter <62639971+FoundationKen@users.noreply.github.com> * PASS1-55: Add menu to switch to a different Passphrase without rebooting (#35) * PASS1-55: Add menu to switch to a different Passphrase without rebooting * Changed order of menu items in Passphrase menu * Modified menu titles and removed "a" from inconsistent text * PASS1-137: Add Justfile support to Gen 1 repo (#36) * PASS1-137: Add Justfile support to Gen 1 repo First pass - not all expected commands are added yet * Update Justfile with fmt command Add py and c/h formatting Need to finalize .clang-format file before doing a full reformatting PR * Refactor Justfiles to separate them out Also add graphics build commands * Update Justfiles a bit Fix formatting of graphics header files in preparation for automatic code formatting * PASS1-139: Implement code to allow OCD to capture a screenshot over JTAG (#42) * PASS1-139: Implement code to allow OCD to capture a screenshot over JTAG * Update sram4.py * PASS1-132: Remove duplicate file compilation (#39) * PASS1-78: In display.text_input, split lines based on pixel widths (#41) * PASS1-78: In display.text_input, split lines based on pixel widths * Check for StringIO object before calling split_by_char_size * PASS1-89: Show exported filename when exporting wallet to microSD (#43) * PASS1-89: Show exported filename when exporting wallet to microSD * Deleted/commented unnecessary lines * PASS1-136: Add Specter wallet back once they fix UR issues (#44) * PASS1-136: Add Specter wallet back once they fix UR issues * Rebase onto dev-v1.0.7 * Remove passport from export filename * Remove flag from all wallets besides Specter wallet * Removed flag from unnecessary field and renamed flag to import * Renamed multisig_import function * PASS1-112: Passphrase input dialog improvements (#48) * PASS1-112: Passphrase input dialog improvements The passphrase is limited to 64 characters. The line spacing was reduced to make room for 7 lines. 63 capital W's will fill all 7 lines (+1 over), otherwise 64 characters usually takes about 4 lines. * Add constant for max message length * TOOL-3: Setup Docker infra for Gen 1 Development (#45) * Add Dockerfile for building the firmware Setting up a local environment for building the firmware can be a painful process. This wraps that process up in a Dockerfile containing all the deps needed which is then used in the justfile to build the firmware. * Add just targets for signing and cleaning * Change sha target to take a sha and verify it directly * Add docs for verifying the firmware SHA sum * Add version param to sign just target * Update verify-sha output to be more explicit * PASS1-67: Change unit to sats in settings (#46) * PASS1-67: Change unit to sats in settings * Added warnings for Testnet and made the setting volatile * Added 'chain' removal to schema_evolution and moved Units menu to top * Moved Units below Change Pin in menu * TOOL-4: Implement CI for Passport Gen 1 build (#49) * TOOL-4: Create CI for firmware build * TOOL-4: Improve handling of git describe output * TOOL-4: Rename Justfile to match others in repo * TOOL-4: Add caching and separated Docker building in CI * TOOL-4: Update CI to push image to local registry service * TOOL-4: Update CI to allow customizing of D_BASE * TOOL-4: Change clang format action * TOOL-4: User correct clang format version * TOOL-4: YAML :( * TOOL-4: Update to clang-format-10.0 * TOOL-4: Updaet to 10 * TOOL-4: Build and export the bootloader * TOOL-4: Add D_BASE to bootload build step * TOOL-4: Correctly pass D_BASE to bootloader job * TOOL-4: Update bootloader make path in Justfile * TOOL-4: Update CI to output tools * PASS1-140: Add Justfile commands to DEVELOPMENT.md (#51) * PASS1-140: Add Justfile commands to DEVELOPMENT.md * Update DEVELOPMENT.md * Update DEVELOPMENT.md Co-authored-by: Ken Carpenter <62639971+FoundationKen@users.noreply.github.com> * PASS1-148: Fix missing address prefixes for testnet (#53) * PASS1-148: Fix missing address prefixes for testnet * Add comma separations to sats values * Casa support added * Added testnet prefix check to Verify Address process * PASS1-150: Fixed missing argument in `import_from_psbt()` call (#55) * PASS1-150: Fixed missing argument in `import_from_psbt()` call Also fixed typo in function description. * Added a space between value and label of BTC/sats * Disable Casa Support Casa has not approved the support for Passport yet, until then Casa is disabled temporarily. Co-authored-by: Corey Lakey <corey.lakey@gmail.com> Co-authored-by: Jean Pierre Dudey <jeandudey@hotmail.com> Co-authored-by: Alex Sears <searsaw@users.noreply.github.com>
3 years ago
### Using Justfile commands
To use Just for running commands, first follow the instructions here: https://github.com/casey/just#installation to install Just. Note that `Pillow` must be updated to `8.3.1` for all commands to work properly.
Once Just has been installed, the developer can use `just` commands to perform actions such as building, flashing, resetting and even taking screenshots of the displays screen.
Note that all `just` commands must be run from `ports/stm32/` directory.
Here are some of the most common `just` commands and their usages:
just flash {version} - Builds if necessary, signs with a user key and then flashes the device with the firmware binary created under `build-Passport/`
just reset - Resets the device
just screenshot {filename} - Screenshots the device and saves to the desired filename
See the `Justfile` included in our source for the full list of `just` commands.
4 years ago
## Building
### Open Shell Windows/Tabs
You will need several shell windows or tabs open to interact with the various tools.
### Build Window
#### Building the Main Firmare
In one shell, make sure that you `cd` to the root `stm32` source folder, e.g., `cd ~/passport-firmware/ports/stm32`:
4 years ago
make BOARD=Passport
4 years ago
To include debug symbols for use in `ddd`, run the following:
make BOARD=Passport DEBUG=1
You should see it building various `.c` files and freezing `.py` files. Once complete, the final output should look similar to the following:
LINK build-Passport/firmware.elf
text data bss dec hex filename
475304 792 57600 533696 824c0 build-Passport/firmware.elf
GEN build-Passport/firmware.dfu
GEN build-Passport/firmware.hex
Dev v1.0.7 (#57) * PASS1-133: Modify cosign file naming for fully signed binaries. (#34) * PASS1-133: Modify cosign file naming for fully signed binaries. * Remove all USE_CRYPTO, it is not used anymore Also remove function that is not needed. * Added use of firmware version from header, also fixed a seg fault * PASS1-135: Fix sticky up or down key (#33) * PASS1-135: Fix sticky up or down key * Add comment for input.reset function * PASS1-128: Add support back for Bitcoin testnet (#29) * Fixes part of PASS-91 Show address and index of the address being verified * Second half of fix for ENV1-91 Add better messaging for address range searching Fix a bug when saving next_addrs (was comparing dicts by ref) * Fixes PASS1-122 Check change addresses in addition to receive address in "Verify Address" * Fix comment punctuation * Show backup filename to user after successful backup (#18) Fix PASS1-92 * Auto-truncate multisig config names (#19) Fix PASS1-101 * PASS1-101: Auto-truncate multisig config names (#19) Fix PASS1-101 * Remove unnecessary comments * PASS1-92 (#20) * Show backup filename to user after successful backup Fix PASS1-92 * Add missing 'card' parameter to `get_backups_folder_path()` calls * Revert path function changes since 'card' is not available * PASS1-102: Fix backwards microSD issue Found that `ErrorCode` in `SD_HandleTypeDef` was not reset after a failure. Updated `HAL_SD_Init()` to reset it before attempting initialization. * PASS1-102: Fix backwards microSD issue (#21) Found that `ErrorCode` in `SD_HandleTypeDef` was not reset after a failure. Updated `HAL_SD_Init()` to reset it before attempting initialization. * PASS1-102_b (#22) * PASS1-102: Fix backwards microSD issue Found that `ErrorCode` in `SD_HandleTypeDef` was not reset after a failure. Updated `HAL_SD_Init()` to reset it before attempting initialization. * Switch back to hard-coded path for now * PASS1-122_b (#23) * PASS1-102: Fix backwards microSD issue Found that `ErrorCode` in `SD_HandleTypeDef` was not reset after a failure. Updated `HAL_SD_Init()` to reset it before attempting initialization. * Update user messaging for found/not found case of Verify Address Fix bug with trailing space at end of line in `word_wrap()` * Strip ever time through the loop * PASS1-125: Add Git commit-msg hook to check for Linear ID (#24) * PASS1-125: Add Git commit-msg hook to check for Linear ID * Update .githooks/commit-msg Co-authored-by: Jean Pierre Dudey <jeandudey@hotmail.com> Co-authored-by: Jean Pierre Dudey <jeandudey@hotmail.com> * PASS1-122: Minor updates to text (#27) * PASS1-127: Fix `reuse lint` issues in the repo (#26) * PASS1-113: Give the user a way to clear the developer pubkey slot (#25) * PASS1-122: Added "Address Verified" text to new wallet pairing (#28) * PASS1-122: Minor updates to text * PASS1-122: Added "Address Verified" text to new wallet pairing * PASS1-128: Add support back for Bitcoin testnet Co-authored-by: Ken Carpenter <ken@foundationdevices.com> Co-authored-by: Ken Carpenter <62639971+FoundationKen@users.noreply.github.com> Co-authored-by: Jean Pierre Dudey <jeandudey@hotmail.com> * PASS1-56: Use XFP in backups filename and don't save `backup_num` (#32) * PASS1-34: Refactor find address code so there is only one copy (#37) * PASS1-94: Prevent installing user-signed firmware if no user-key installed (#38) * PASS1-94: Prevent installing user-signed firmware if no user signing key installed * Fixed case where user pubkey was removed manually * Fixed text to match other areas where text is used * Update text message for developer pubkey * Hard coded user signed field to false Co-authored-by: Ken Carpenter <62639971+FoundationKen@users.noreply.github.com> * PASS1-55: Add menu to switch to a different Passphrase without rebooting (#35) * PASS1-55: Add menu to switch to a different Passphrase without rebooting * Changed order of menu items in Passphrase menu * Modified menu titles and removed "a" from inconsistent text * PASS1-137: Add Justfile support to Gen 1 repo (#36) * PASS1-137: Add Justfile support to Gen 1 repo First pass - not all expected commands are added yet * Update Justfile with fmt command Add py and c/h formatting Need to finalize .clang-format file before doing a full reformatting PR * Refactor Justfiles to separate them out Also add graphics build commands * Update Justfiles a bit Fix formatting of graphics header files in preparation for automatic code formatting * PASS1-139: Implement code to allow OCD to capture a screenshot over JTAG (#42) * PASS1-139: Implement code to allow OCD to capture a screenshot over JTAG * Update sram4.py * PASS1-132: Remove duplicate file compilation (#39) * PASS1-78: In display.text_input, split lines based on pixel widths (#41) * PASS1-78: In display.text_input, split lines based on pixel widths * Check for StringIO object before calling split_by_char_size * PASS1-89: Show exported filename when exporting wallet to microSD (#43) * PASS1-89: Show exported filename when exporting wallet to microSD * Deleted/commented unnecessary lines * PASS1-136: Add Specter wallet back once they fix UR issues (#44) * PASS1-136: Add Specter wallet back once they fix UR issues * Rebase onto dev-v1.0.7 * Remove passport from export filename * Remove flag from all wallets besides Specter wallet * Removed flag from unnecessary field and renamed flag to import * Renamed multisig_import function * PASS1-112: Passphrase input dialog improvements (#48) * PASS1-112: Passphrase input dialog improvements The passphrase is limited to 64 characters. The line spacing was reduced to make room for 7 lines. 63 capital W's will fill all 7 lines (+1 over), otherwise 64 characters usually takes about 4 lines. * Add constant for max message length * TOOL-3: Setup Docker infra for Gen 1 Development (#45) * Add Dockerfile for building the firmware Setting up a local environment for building the firmware can be a painful process. This wraps that process up in a Dockerfile containing all the deps needed which is then used in the justfile to build the firmware. * Add just targets for signing and cleaning * Change sha target to take a sha and verify it directly * Add docs for verifying the firmware SHA sum * Add version param to sign just target * Update verify-sha output to be more explicit * PASS1-67: Change unit to sats in settings (#46) * PASS1-67: Change unit to sats in settings * Added warnings for Testnet and made the setting volatile * Added 'chain' removal to schema_evolution and moved Units menu to top * Moved Units below Change Pin in menu * TOOL-4: Implement CI for Passport Gen 1 build (#49) * TOOL-4: Create CI for firmware build * TOOL-4: Improve handling of git describe output * TOOL-4: Rename Justfile to match others in repo * TOOL-4: Add caching and separated Docker building in CI * TOOL-4: Update CI to push image to local registry service * TOOL-4: Update CI to allow customizing of D_BASE * TOOL-4: Change clang format action * TOOL-4: User correct clang format version * TOOL-4: YAML :( * TOOL-4: Update to clang-format-10.0 * TOOL-4: Updaet to 10 * TOOL-4: Build and export the bootloader * TOOL-4: Add D_BASE to bootload build step * TOOL-4: Correctly pass D_BASE to bootloader job * TOOL-4: Update bootloader make path in Justfile * TOOL-4: Update CI to output tools * PASS1-140: Add Justfile commands to DEVELOPMENT.md (#51) * PASS1-140: Add Justfile commands to DEVELOPMENT.md * Update DEVELOPMENT.md * Update DEVELOPMENT.md Co-authored-by: Ken Carpenter <62639971+FoundationKen@users.noreply.github.com> * PASS1-148: Fix missing address prefixes for testnet (#53) * PASS1-148: Fix missing address prefixes for testnet * Add comma separations to sats values * Casa support added * Added testnet prefix check to Verify Address process * PASS1-150: Fixed missing argument in `import_from_psbt()` call (#55) * PASS1-150: Fixed missing argument in `import_from_psbt()` call Also fixed typo in function description. * Added a space between value and label of BTC/sats * Disable Casa Support Casa has not approved the support for Passport yet, until then Casa is disabled temporarily. Co-authored-by: Corey Lakey <corey.lakey@gmail.com> Co-authored-by: Jean Pierre Dudey <jeandudey@hotmail.com> Co-authored-by: Alex Sears <searsaw@users.noreply.github.com>
3 years ago
If you are using `just` commands, then building the firmware can be done by running the following command:
just build
4 years ago
#### Code Signing
In order to load the files onto the device, they need to first be signed by two separate keys.
The `cosign` program performs this task, and it needs to be called twice with two separate
private keys.
First, you need to build the `cosign` tool and copy it somewhere in your `PATH`:
sudo apt-get install libssl-dev
4 years ago
cd ports/stm32/boards/Passport/tools/cosign
make
cp x86/release/cosign ~/.local/bin # You can run `echo $PATH` to see the list of possible places you can put this file
Next you need to sign the firmware twice. The `cosign` tool appends `-signed` to the end of the main filename each time it signs.
4 years ago
Assuming you are still in the `ports/stm32` folder run the following:
# TODO: Update command arguments once final signing flow is in place
cosign -f build-Passport/firmware.bin -k 1 -v 0.9
4 years ago
cosign -f build-Passport/firmware-signed.bin -k 2
You can also dump the contents of the firmware header with the following command:
cosign -f build-Passport/firmware-signed-signed.bin -x
Dev v1.0.7 (#57) * PASS1-133: Modify cosign file naming for fully signed binaries. (#34) * PASS1-133: Modify cosign file naming for fully signed binaries. * Remove all USE_CRYPTO, it is not used anymore Also remove function that is not needed. * Added use of firmware version from header, also fixed a seg fault * PASS1-135: Fix sticky up or down key (#33) * PASS1-135: Fix sticky up or down key * Add comment for input.reset function * PASS1-128: Add support back for Bitcoin testnet (#29) * Fixes part of PASS-91 Show address and index of the address being verified * Second half of fix for ENV1-91 Add better messaging for address range searching Fix a bug when saving next_addrs (was comparing dicts by ref) * Fixes PASS1-122 Check change addresses in addition to receive address in "Verify Address" * Fix comment punctuation * Show backup filename to user after successful backup (#18) Fix PASS1-92 * Auto-truncate multisig config names (#19) Fix PASS1-101 * PASS1-101: Auto-truncate multisig config names (#19) Fix PASS1-101 * Remove unnecessary comments * PASS1-92 (#20) * Show backup filename to user after successful backup Fix PASS1-92 * Add missing 'card' parameter to `get_backups_folder_path()` calls * Revert path function changes since 'card' is not available * PASS1-102: Fix backwards microSD issue Found that `ErrorCode` in `SD_HandleTypeDef` was not reset after a failure. Updated `HAL_SD_Init()` to reset it before attempting initialization. * PASS1-102: Fix backwards microSD issue (#21) Found that `ErrorCode` in `SD_HandleTypeDef` was not reset after a failure. Updated `HAL_SD_Init()` to reset it before attempting initialization. * PASS1-102_b (#22) * PASS1-102: Fix backwards microSD issue Found that `ErrorCode` in `SD_HandleTypeDef` was not reset after a failure. Updated `HAL_SD_Init()` to reset it before attempting initialization. * Switch back to hard-coded path for now * PASS1-122_b (#23) * PASS1-102: Fix backwards microSD issue Found that `ErrorCode` in `SD_HandleTypeDef` was not reset after a failure. Updated `HAL_SD_Init()` to reset it before attempting initialization. * Update user messaging for found/not found case of Verify Address Fix bug with trailing space at end of line in `word_wrap()` * Strip ever time through the loop * PASS1-125: Add Git commit-msg hook to check for Linear ID (#24) * PASS1-125: Add Git commit-msg hook to check for Linear ID * Update .githooks/commit-msg Co-authored-by: Jean Pierre Dudey <jeandudey@hotmail.com> Co-authored-by: Jean Pierre Dudey <jeandudey@hotmail.com> * PASS1-122: Minor updates to text (#27) * PASS1-127: Fix `reuse lint` issues in the repo (#26) * PASS1-113: Give the user a way to clear the developer pubkey slot (#25) * PASS1-122: Added "Address Verified" text to new wallet pairing (#28) * PASS1-122: Minor updates to text * PASS1-122: Added "Address Verified" text to new wallet pairing * PASS1-128: Add support back for Bitcoin testnet Co-authored-by: Ken Carpenter <ken@foundationdevices.com> Co-authored-by: Ken Carpenter <62639971+FoundationKen@users.noreply.github.com> Co-authored-by: Jean Pierre Dudey <jeandudey@hotmail.com> * PASS1-56: Use XFP in backups filename and don't save `backup_num` (#32) * PASS1-34: Refactor find address code so there is only one copy (#37) * PASS1-94: Prevent installing user-signed firmware if no user-key installed (#38) * PASS1-94: Prevent installing user-signed firmware if no user signing key installed * Fixed case where user pubkey was removed manually * Fixed text to match other areas where text is used * Update text message for developer pubkey * Hard coded user signed field to false Co-authored-by: Ken Carpenter <62639971+FoundationKen@users.noreply.github.com> * PASS1-55: Add menu to switch to a different Passphrase without rebooting (#35) * PASS1-55: Add menu to switch to a different Passphrase without rebooting * Changed order of menu items in Passphrase menu * Modified menu titles and removed "a" from inconsistent text * PASS1-137: Add Justfile support to Gen 1 repo (#36) * PASS1-137: Add Justfile support to Gen 1 repo First pass - not all expected commands are added yet * Update Justfile with fmt command Add py and c/h formatting Need to finalize .clang-format file before doing a full reformatting PR * Refactor Justfiles to separate them out Also add graphics build commands * Update Justfiles a bit Fix formatting of graphics header files in preparation for automatic code formatting * PASS1-139: Implement code to allow OCD to capture a screenshot over JTAG (#42) * PASS1-139: Implement code to allow OCD to capture a screenshot over JTAG * Update sram4.py * PASS1-132: Remove duplicate file compilation (#39) * PASS1-78: In display.text_input, split lines based on pixel widths (#41) * PASS1-78: In display.text_input, split lines based on pixel widths * Check for StringIO object before calling split_by_char_size * PASS1-89: Show exported filename when exporting wallet to microSD (#43) * PASS1-89: Show exported filename when exporting wallet to microSD * Deleted/commented unnecessary lines * PASS1-136: Add Specter wallet back once they fix UR issues (#44) * PASS1-136: Add Specter wallet back once they fix UR issues * Rebase onto dev-v1.0.7 * Remove passport from export filename * Remove flag from all wallets besides Specter wallet * Removed flag from unnecessary field and renamed flag to import * Renamed multisig_import function * PASS1-112: Passphrase input dialog improvements (#48) * PASS1-112: Passphrase input dialog improvements The passphrase is limited to 64 characters. The line spacing was reduced to make room for 7 lines. 63 capital W's will fill all 7 lines (+1 over), otherwise 64 characters usually takes about 4 lines. * Add constant for max message length * TOOL-3: Setup Docker infra for Gen 1 Development (#45) * Add Dockerfile for building the firmware Setting up a local environment for building the firmware can be a painful process. This wraps that process up in a Dockerfile containing all the deps needed which is then used in the justfile to build the firmware. * Add just targets for signing and cleaning * Change sha target to take a sha and verify it directly * Add docs for verifying the firmware SHA sum * Add version param to sign just target * Update verify-sha output to be more explicit * PASS1-67: Change unit to sats in settings (#46) * PASS1-67: Change unit to sats in settings * Added warnings for Testnet and made the setting volatile * Added 'chain' removal to schema_evolution and moved Units menu to top * Moved Units below Change Pin in menu * TOOL-4: Implement CI for Passport Gen 1 build (#49) * TOOL-4: Create CI for firmware build * TOOL-4: Improve handling of git describe output * TOOL-4: Rename Justfile to match others in repo * TOOL-4: Add caching and separated Docker building in CI * TOOL-4: Update CI to push image to local registry service * TOOL-4: Update CI to allow customizing of D_BASE * TOOL-4: Change clang format action * TOOL-4: User correct clang format version * TOOL-4: YAML :( * TOOL-4: Update to clang-format-10.0 * TOOL-4: Updaet to 10 * TOOL-4: Build and export the bootloader * TOOL-4: Add D_BASE to bootload build step * TOOL-4: Correctly pass D_BASE to bootloader job * TOOL-4: Update bootloader make path in Justfile * TOOL-4: Update CI to output tools * PASS1-140: Add Justfile commands to DEVELOPMENT.md (#51) * PASS1-140: Add Justfile commands to DEVELOPMENT.md * Update DEVELOPMENT.md * Update DEVELOPMENT.md Co-authored-by: Ken Carpenter <62639971+FoundationKen@users.noreply.github.com> * PASS1-148: Fix missing address prefixes for testnet (#53) * PASS1-148: Fix missing address prefixes for testnet * Add comma separations to sats values * Casa support added * Added testnet prefix check to Verify Address process * PASS1-150: Fixed missing argument in `import_from_psbt()` call (#55) * PASS1-150: Fixed missing argument in `import_from_psbt()` call Also fixed typo in function description. * Added a space between value and label of BTC/sats * Disable Casa Support Casa has not approved the support for Passport yet, until then Casa is disabled temporarily. Co-authored-by: Corey Lakey <corey.lakey@gmail.com> Co-authored-by: Jean Pierre Dudey <jeandudey@hotmail.com> Co-authored-by: Alex Sears <searsaw@users.noreply.github.com>
3 years ago
If you are using `just` commands, then signing the firmware can be done by running the following command with the desired version:
just sign 1.0.7
It will build the firmware first if necessary.
4 years ago
#### Building the Bootloader
To build the bootloader do the following:
cd ports/stm32/boards/Passport/bootloader folder
4 years ago
make
### OpenOCD Server Window
OpenOCD server provides a socket on `localhost:4444` that you can connect to and issue commands. This server acts as an intermediary between that socket and the board connected over JTAG.
Once the OpenOCD server is running, you can pretty much ignore this window. You will interact with the OpenOCD client window (see below). Open a second shell and run the following:
/usr/local/bin/openocd -f stlink.cfg -c "adapter speed 1000; transport select hla_swd" -f stm32h7x.cfg
You should see output similar to the following:
Open On-Chip Debugger 0.10.0+dev-01383-gd46f28c2e-dirty (2020-08-24-08:31)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
hla_swd
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 1800 kHz
Info : STLINK V2J29S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 2.975559
Info : stm32h7x.cpu0: hardware has 8 breakpoints, 4 watchpoints
Info : starting gdb server for stm32h7x.cpu0 on 3333
Info : Listening on port 3333 for gdb connections
### OpenOCD Client Window (aka `telnet` Window)
We use `telnet` to connect to the OpenOCD Server. Open a third shell and run the following:
telnet localhost 4444
From here can connect over JTAG and run a range of commands (see the help for OpenOCD for details):
Whenever you change any code in the `bootloader` folder or in the `common` folder, you will need to rebuild the bootloader (see above), and then flash it to the device with the following sequence in OpenOCD:
4 years ago
reset halt
flash write_image erase boards/Passport/bootloader/arm/release/bootloader.bin 0x8000000
4 years ago
reset
### TBD: Add docs on appending secrets to the end of the bootloader.bin file during development.
4 years ago
The following command sequence is one you will run repeatedly (i.e., after each build):
reset halt
flash write_image erase build-Passport/firmware-signed-signed.bin 0x8020000
4 years ago
reset
These commands do the following:
- Stop execution of code on the MCU
- Write the firmware to flash at address 0x8000000
4 years ago
- Reset the MCU and start executing code at address 0x8000000
Dev v1.0.7 (#57) * PASS1-133: Modify cosign file naming for fully signed binaries. (#34) * PASS1-133: Modify cosign file naming for fully signed binaries. * Remove all USE_CRYPTO, it is not used anymore Also remove function that is not needed. * Added use of firmware version from header, also fixed a seg fault * PASS1-135: Fix sticky up or down key (#33) * PASS1-135: Fix sticky up or down key * Add comment for input.reset function * PASS1-128: Add support back for Bitcoin testnet (#29) * Fixes part of PASS-91 Show address and index of the address being verified * Second half of fix for ENV1-91 Add better messaging for address range searching Fix a bug when saving next_addrs (was comparing dicts by ref) * Fixes PASS1-122 Check change addresses in addition to receive address in "Verify Address" * Fix comment punctuation * Show backup filename to user after successful backup (#18) Fix PASS1-92 * Auto-truncate multisig config names (#19) Fix PASS1-101 * PASS1-101: Auto-truncate multisig config names (#19) Fix PASS1-101 * Remove unnecessary comments * PASS1-92 (#20) * Show backup filename to user after successful backup Fix PASS1-92 * Add missing 'card' parameter to `get_backups_folder_path()` calls * Revert path function changes since 'card' is not available * PASS1-102: Fix backwards microSD issue Found that `ErrorCode` in `SD_HandleTypeDef` was not reset after a failure. Updated `HAL_SD_Init()` to reset it before attempting initialization. * PASS1-102: Fix backwards microSD issue (#21) Found that `ErrorCode` in `SD_HandleTypeDef` was not reset after a failure. Updated `HAL_SD_Init()` to reset it before attempting initialization. * PASS1-102_b (#22) * PASS1-102: Fix backwards microSD issue Found that `ErrorCode` in `SD_HandleTypeDef` was not reset after a failure. Updated `HAL_SD_Init()` to reset it before attempting initialization. * Switch back to hard-coded path for now * PASS1-122_b (#23) * PASS1-102: Fix backwards microSD issue Found that `ErrorCode` in `SD_HandleTypeDef` was not reset after a failure. Updated `HAL_SD_Init()` to reset it before attempting initialization. * Update user messaging for found/not found case of Verify Address Fix bug with trailing space at end of line in `word_wrap()` * Strip ever time through the loop * PASS1-125: Add Git commit-msg hook to check for Linear ID (#24) * PASS1-125: Add Git commit-msg hook to check for Linear ID * Update .githooks/commit-msg Co-authored-by: Jean Pierre Dudey <jeandudey@hotmail.com> Co-authored-by: Jean Pierre Dudey <jeandudey@hotmail.com> * PASS1-122: Minor updates to text (#27) * PASS1-127: Fix `reuse lint` issues in the repo (#26) * PASS1-113: Give the user a way to clear the developer pubkey slot (#25) * PASS1-122: Added "Address Verified" text to new wallet pairing (#28) * PASS1-122: Minor updates to text * PASS1-122: Added "Address Verified" text to new wallet pairing * PASS1-128: Add support back for Bitcoin testnet Co-authored-by: Ken Carpenter <ken@foundationdevices.com> Co-authored-by: Ken Carpenter <62639971+FoundationKen@users.noreply.github.com> Co-authored-by: Jean Pierre Dudey <jeandudey@hotmail.com> * PASS1-56: Use XFP in backups filename and don't save `backup_num` (#32) * PASS1-34: Refactor find address code so there is only one copy (#37) * PASS1-94: Prevent installing user-signed firmware if no user-key installed (#38) * PASS1-94: Prevent installing user-signed firmware if no user signing key installed * Fixed case where user pubkey was removed manually * Fixed text to match other areas where text is used * Update text message for developer pubkey * Hard coded user signed field to false Co-authored-by: Ken Carpenter <62639971+FoundationKen@users.noreply.github.com> * PASS1-55: Add menu to switch to a different Passphrase without rebooting (#35) * PASS1-55: Add menu to switch to a different Passphrase without rebooting * Changed order of menu items in Passphrase menu * Modified menu titles and removed "a" from inconsistent text * PASS1-137: Add Justfile support to Gen 1 repo (#36) * PASS1-137: Add Justfile support to Gen 1 repo First pass - not all expected commands are added yet * Update Justfile with fmt command Add py and c/h formatting Need to finalize .clang-format file before doing a full reformatting PR * Refactor Justfiles to separate them out Also add graphics build commands * Update Justfiles a bit Fix formatting of graphics header files in preparation for automatic code formatting * PASS1-139: Implement code to allow OCD to capture a screenshot over JTAG (#42) * PASS1-139: Implement code to allow OCD to capture a screenshot over JTAG * Update sram4.py * PASS1-132: Remove duplicate file compilation (#39) * PASS1-78: In display.text_input, split lines based on pixel widths (#41) * PASS1-78: In display.text_input, split lines based on pixel widths * Check for StringIO object before calling split_by_char_size * PASS1-89: Show exported filename when exporting wallet to microSD (#43) * PASS1-89: Show exported filename when exporting wallet to microSD * Deleted/commented unnecessary lines * PASS1-136: Add Specter wallet back once they fix UR issues (#44) * PASS1-136: Add Specter wallet back once they fix UR issues * Rebase onto dev-v1.0.7 * Remove passport from export filename * Remove flag from all wallets besides Specter wallet * Removed flag from unnecessary field and renamed flag to import * Renamed multisig_import function * PASS1-112: Passphrase input dialog improvements (#48) * PASS1-112: Passphrase input dialog improvements The passphrase is limited to 64 characters. The line spacing was reduced to make room for 7 lines. 63 capital W's will fill all 7 lines (+1 over), otherwise 64 characters usually takes about 4 lines. * Add constant for max message length * TOOL-3: Setup Docker infra for Gen 1 Development (#45) * Add Dockerfile for building the firmware Setting up a local environment for building the firmware can be a painful process. This wraps that process up in a Dockerfile containing all the deps needed which is then used in the justfile to build the firmware. * Add just targets for signing and cleaning * Change sha target to take a sha and verify it directly * Add docs for verifying the firmware SHA sum * Add version param to sign just target * Update verify-sha output to be more explicit * PASS1-67: Change unit to sats in settings (#46) * PASS1-67: Change unit to sats in settings * Added warnings for Testnet and made the setting volatile * Added 'chain' removal to schema_evolution and moved Units menu to top * Moved Units below Change Pin in menu * TOOL-4: Implement CI for Passport Gen 1 build (#49) * TOOL-4: Create CI for firmware build * TOOL-4: Improve handling of git describe output * TOOL-4: Rename Justfile to match others in repo * TOOL-4: Add caching and separated Docker building in CI * TOOL-4: Update CI to push image to local registry service * TOOL-4: Update CI to allow customizing of D_BASE * TOOL-4: Change clang format action * TOOL-4: User correct clang format version * TOOL-4: YAML :( * TOOL-4: Update to clang-format-10.0 * TOOL-4: Updaet to 10 * TOOL-4: Build and export the bootloader * TOOL-4: Add D_BASE to bootload build step * TOOL-4: Correctly pass D_BASE to bootloader job * TOOL-4: Update bootloader make path in Justfile * TOOL-4: Update CI to output tools * PASS1-140: Add Justfile commands to DEVELOPMENT.md (#51) * PASS1-140: Add Justfile commands to DEVELOPMENT.md * Update DEVELOPMENT.md * Update DEVELOPMENT.md Co-authored-by: Ken Carpenter <62639971+FoundationKen@users.noreply.github.com> * PASS1-148: Fix missing address prefixes for testnet (#53) * PASS1-148: Fix missing address prefixes for testnet * Add comma separations to sats values * Casa support added * Added testnet prefix check to Verify Address process * PASS1-150: Fixed missing argument in `import_from_psbt()` call (#55) * PASS1-150: Fixed missing argument in `import_from_psbt()` call Also fixed typo in function description. * Added a space between value and label of BTC/sats * Disable Casa Support Casa has not approved the support for Passport yet, until then Casa is disabled temporarily. Co-authored-by: Corey Lakey <corey.lakey@gmail.com> Co-authored-by: Jean Pierre Dudey <jeandudey@hotmail.com> Co-authored-by: Alex Sears <searsaw@users.noreply.github.com>
3 years ago
If you are using `just` commands, ocd and telnet steps are not required and instead, flashing the firmware can be done using the following command with the desired version number:
just flash 1.0.7
It will build and sign the firmware first if necessary.
4 years ago
### RShell Window
We use `rshell` to connect to the MicroPython device over USB serial. Open another shell and run:
sudo rshell -p /dev/ttyUSB0
This gives us an interactive shell where we can do things like inspect the flash file system, or run a REPL:
- `ls -la /flash` - Get a listing of the files in `/flash` on the device
- `cp local_folder/my_math.py /flash` - Copy a local file into `/flash`
- `repl` - Open a MicroPython REPL. If there are any files in `/flash`, you can import them. For example:
```
import my_math
my_math.add(1, 2)
```
### Debugging with DDD
To debug the firmware, open a new shell window or tab and run the following command from the `passport/ports/stm32` folder:
ddd --debugger gdb-multiarch build-Passport/firmware.elf &
To debug the bootloader, open a new shell window or tab and run the following command from the `passport/ports/stm32/boards/Passport/bootloader` folder:
ddd --debugger gdb-multiarch bootloader.elf &
Go to the `telnet` session with OpenOCD and run the following to prepare to connect DDD:
reset halt
Next, connect DDD to the OpenOCD GDB server with:
target remote localhost:3333
From here you can run normal GDB commands like:
b stm32_main # Stop at stm32_main, which is MicroPython's entry point
list main.c # Show the main.c file at line 1
c # continue
n # step over
s # step into