Skip to content

Commit

Permalink
Merge pull request #109 from Foundation-Devices/dev-v2.0.5
Browse files Browse the repository at this point in the history
Dev v2.0.5
  • Loading branch information
FoundationKen committed Feb 8, 2023
2 parents c177786 + 4d5597d commit aa3ae7b
Show file tree
Hide file tree
Showing 317 changed files with 11,725 additions and 1,408 deletions.
61 changes: 61 additions & 0 deletions CHANGELOG.md
@@ -0,0 +1,61 @@
<!--
SPDX-FileCopyrightText: 2023 Foundation Devices, Inc. <hello@foundationdevices.com>
SPDX-License-Identifier: GPL-3.0-or-later
-->

## Head

## 2.0.5
- Ensured "New Account" UI returns to the "More" menu (PASS1-582)
- Added changelog (PASS1-581)
- Reverted some changes to multisig imports (PASS1-504)
- Reduced keypad double click cooldown to 20 ms (PASS1-509)
- Reverted multisig import to only check against the current XFP (PASS1-587)
- Reverted backup code page cursor color to previous look (PASS1-591)
- Limited number of files on the file picker page (PASS1-584)
- Fixed passphrase and account header text color (PASS1-582)
- Raised passphrase character limit to 1000 (PASS1-519)
- Fixed sign via microsd success page (PASS1-545)
- Fixed up/down keys on pin entry page (PASS1-573)
- Fixed UI memory leaks (PASS1-572)
- Fixed direction keys on pin entry page (PASS1-567)
- Carried over quirc library from Founder's Edition (PASS1-558)
- Used constants where possible (PASS1-555)
- Fixed Casa microsd export (PASS1-534)
- Carried over camera parameters from Founder's Edition (PASS1-551)
- Fixed os.sync not present in the simulator (PASS1-546)
- Fixed microsd error handling (PASS1-543, PASS1-541, PASS1-526)
- Added Keeper wallet integration (PASS1-542)
- Moved passphrase display to show seed words flow (PASS1-536)
- Reset extension settings and default search address upon erase (PASS1-535)
- Used 4:3 camera resolution (PASS1-539)
- Fixed mono colors for various features (PASS1-538)
- Improved Casa health check error handling (PASS1-532)
- Improved address verification animation (PASS1-529)
- Fixed special character UI memory leak (PASS1-533)
- Fixed mono QR scanning (PASS1-530)
- Reduced keypad cooldown to 50 ms (PASS1-527)
- Sped up address verification (PASS1-437)
- Improved mono color choice for security word box (PASS1-531)
- Revised pin entry page code (PASS1-510)
- Used root xfp as the backup file name (PASS1-517, PASS1-523)
- Updated mono icons (PASS1-522)
- Allowed users to change setup method (PASS1-506)
- Documented developer pubkey setup (PASS1-515)
- Fixed confirmation page when cancelling backup (PASS1-512)
- Made keypad match device version (PASS1-521)
- Added flash bootloader with secrets Just recipe (PASS1-520)
- Improved multisig import error handling (PASS1-504)
- Ensured extension accounts show the passphrase indicator (PASS1-514)
- Showed security words immediately after feature activation (PASS1-503)
- Looped through menu pages (PASS1-513)
- Prevented accidental double clicks (PASS1-509)
- Ported the current codebase to Passport Founder's Edition
- Made supply chain validation error more specific (PASS1-505)
- Fixed camera rotation on Founder's Edition (PASS1-495)
- Automatically generated required directories for the simulator (PASS1-502)
- Prevented security word indexing (PASS1-157)
- Pushed back auto shutdown while scanning QR codes (PASS1-165)
- Replaced keypad interrupts with polling
- Made camera widget size adaptable (PASS1-492)
24 changes: 21 additions & 3 deletions DEVELOPMENT.md
Expand Up @@ -15,6 +15,9 @@ In order to build the Passport firmware, you need to:
* Install the dependencies
* Run the build or sign command

## Contributing
Foundation requires commits to be signed with GPG keys in order to be merged. Follow [Github's guide to commit signature verification](https://docs.github.com/en/authentication/managing-commit-signature-verification) to get started.

### Get the Source Code
The instructions below assume you are installing into your home folder at `~/passport2`. You can choose
to install to a different folder, and just update command paths appropriately.
Expand Down Expand Up @@ -73,7 +76,11 @@ If you just want to build without signing, use one of the following commands:
There are other `just` command as well, but most are only useful to developers who have the Developer board with a connection to an STLink V2 debug probe.

#### Building the Simulator
First, make sure you are in the simulator folder:
First, install xterm

sudo apt install xterm

Next, make sure you are in the simulator folder:

cd simulator

Expand All @@ -95,6 +102,19 @@ First, you need to build the `cosign` tool and copy it somewhere in your `PATH`:
make
cp x86/release/cosign ~/.local/bin # You can run `echo $PATH` to see the list of possible places you can put this file

If you don't already have an openssl key, return to the repo root directory and generate a Pubkey using `tools/genkeys.sh`. This takes a key number as an argument.

./tools/genkeys.sh 1

Now, move the keys into `~/bin/keys/`, or look ahead a few steps for instructions on setting a custom `cosign_keypath`. Create the directory if it doesn't exist yet. If you already have keys here for another use, make sure not to overwrite them. Make sure not to commit these keys in the git repo.

mkdir ~/bin/keys
mv tools/1.pem ~/bin/keys/user.pem
mv tools/1-pub.bin ~/bin/keys/user-pub.bin
mv tools/1-pub.pem ~/bin/keys/user-pub.pem

Next, save `user-pub.bin` to a microSD card, and upload it to the passport by inserting the microSD, going to the leftmost settings page, and selecting Advanced -> Developer Pubkey -> Install Pubkey, then selecting user-pub.bin.

Next you need to sign the firmware and give it a version number. Once signed, `cosign` will output a filename of the format `v2.0.3-passport.bin`, but with the version number
replaced with whatever you specified. Note that you need to tell `cosign` whether you are signing for a `mono` (Founder's Edition) Passport or a `color` (Batch 2 onward) Passport.

Expand All @@ -115,8 +135,6 @@ You can also print the contents of the firmware header with the following comman

The signed firmware can be put onto a microSD card and installed on Passport. You just need to upload the corresponding Developer Pubkey first.

***TBD: Insert link to article on installing Developer Pubkey***

#### Building the Bootloader
To build the bootloader for a reproducibility check, go to the repo root folder:

Expand Down
15 changes: 15 additions & 0 deletions LICENSES/ISC.txt
@@ -0,0 +1,15 @@
ISC License:

Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC")
Copyright (c) 1995-2003 by Internet Software Consortium

Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD
TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 changes: 0 additions & 22 deletions extmod/foundation/image_conversion.c
Expand Up @@ -72,27 +72,6 @@ void convert_rgb565_to_grayscale(uint8_t *rgb565,
// printf("gray_hor_res=%lu gray_ver_res=%lu\n", gray_hor_res, gray_ver_res);
// printf("rgb565=%08x grayscale=%08x\n", (void*)rgb565, (void*)grayscale);

// TODO: We need to rotate for the color case of the first dev board
#ifdef SCREEN_MODE_MONO
// Intentionally using width with y and height with x since image sensor is rotated vs. grayscale buffer
for (uint32_t y = 0; y < gray_hor_res; y++)
{
uint32_t y_offset = y * gray_ver_res;
// printf("y=%u y_offset=%u\n", y, y_offset);
for (uint32_t x = 0; x < gray_ver_res; x++)
{
uint16_t pixel = rgb565[y_offset + x];
uint16_t gray = (pixel & 0xF800) >> 8;

// Rotate coordinates for grayscale image and set pixel
uint32_t dest_y = gray_ver_res - x;
uint32_t dest_x = y;
grayscale[dest_y * gray_hor_res + dest_x] = gray;
}
}
#endif

#ifdef SCREEN_MODE_COLOR
for (uint32_t y = 0; y < gray_ver_res; y++) {
uint32_t line = y * (gray_hor_res * sizeof(uint16_t));
for (uint32_t x = 0; x < gray_hor_res; x++) {
Expand All @@ -114,5 +93,4 @@ void convert_rgb565_to_grayscale(uint8_t *rgb565,
grayscale[y * gray_hor_res + x] = (uint8_t)(((r * 39) + (g * 150) + (b * 29)) >> 8);
}
}
#endif
}
10 changes: 3 additions & 7 deletions extmod/foundation/modfoundation-qr.h
Expand Up @@ -13,15 +13,13 @@
/// package: foundation.qr

#ifndef CONFIG_QUIRC_QR_MAX_HOR_RES
#define CONFIG_QUIRC_QR_MAX_HOR_RES (350)
#define CONFIG_QUIRC_QR_MAX_HOR_RES (396)
#endif

#ifndef CONFIG_QUIRC_QR_MAX_VER_RES
#define CONFIG_QUIRC_QR_MAX_VER_RES (350)
#define CONFIG_QUIRC_QR_MAX_VER_RES (330)
#endif

#define CONFIG_QUIRC_FLOOD_FILL_VARS (QUIRC_VARS_NUMOF(CONFIG_QUIRC_QR_MAX_VER_RES))

#ifndef CONFIG_QR_DEBUG
#define CONFIG_QR_DEBUG 0
#endif
Expand All @@ -36,12 +34,10 @@
} while (0)
#endif

typedef struct quirc_flood_fill_vars quirc_flood_fill_vars_t;
typedef struct quirc quirc_t;
typedef struct quirc_code quirc_code_t;
typedef struct quirc_data quirc_data_t;

static quirc_flood_fill_vars_t _flood_fill_vars[CONFIG_QUIRC_FLOOD_FILL_VARS];
static quirc_t _quirc;
static quirc_code_t _code;
static quirc_data_t _data;
Expand All @@ -60,7 +56,7 @@ STATIC mp_obj_t mod_foundation_qr_init(mp_obj_t hor_res_obj, mp_obj_t ver_res_ob
CONFIG_QUIRC_QR_MAX_HOR_RES, CONFIG_QUIRC_QR_MAX_VER_RES);
}

if (quirc_init(&_quirc, hor_res, ver_res, _framebuffer, _flood_fill_vars, CONFIG_QUIRC_FLOOD_FILL_VARS) < 0) {
if (quirc_init(&_quirc, hor_res, ver_res, _framebuffer) < 0) {
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("Invalid buffer size for this decoder"));
return mp_const_none;
}
Expand Down
39 changes: 7 additions & 32 deletions extmod/quirc/decode.c
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright (C) 2010-2012 Daniel Beer <dlbeer@gmail.com>
// SPDX-License-Identifier: ISC
//
/* quirc -- QR-code recognition library
* Copyright (C) 2010-2012 Daniel Beer <dlbeer@gmail.com>
*
Expand Down Expand Up @@ -399,7 +402,7 @@ static quirc_decode_error_t correct_format(uint16_t *f_ret)
*/

struct datastream {
uint8_t *raw;
uint8_t raw[QUIRC_MAX_PAYLOAD];
int data_bits;
int ptr;

Expand All @@ -409,6 +412,7 @@ struct datastream {
static inline int grid_bit(const struct quirc_code *code, int x, int y)
{
int p = y * code->size + x;

return (code->cell_bitmap[p >> 3] >> (p & 7)) & 1;
}

Expand Down Expand Up @@ -880,14 +884,12 @@ static quirc_decode_error_t decode_payload(struct quirc_data *data,
return QUIRC_SUCCESS;
}

struct datastream ds;

quirc_decode_error_t quirc_decode(const struct quirc_code *code,
struct quirc_data *data)
{
quirc_decode_error_t err;
struct datastream ds;

if (code->size > QUIRC_MAX_GRID_SIZE)
return QUIRC_ERROR_INVALID_GRID_SIZE;

if ((code->size - 17) % 4)
return QUIRC_ERROR_INVALID_GRID_SIZE;
Expand All @@ -908,41 +910,14 @@ quirc_decode_error_t quirc_decode(const struct quirc_code *code,
if (err)
return err;

/*
* Borrow data->payload to store the raw bits.
* It's only used during read_data + coddestream_ecc below.
*
* This trick saves the size of struct datastream, which we allocate
* on the stack.
*/

ds.raw = data->payload;

read_data(code, data, &ds);
err = codestream_ecc(data, &ds);
if (err)
return err;

ds.raw = NULL; /* We've done with this buffer. */

err = decode_payload(data, &ds);
if (err)
return err;

return QUIRC_SUCCESS;
}

void quirc_flip(struct quirc_code *code)
{
struct quirc_code flipped = {0};
unsigned int offset = 0;
for (int y = 0; y < code->size; y++) {
for (int x = 0; x < code->size; x++) {
if (grid_bit(code, y, x)) {
flipped.cell_bitmap[offset >> 3u] |= (1u << (offset & 7u));
}
offset++;
}
}
memcpy(&code->cell_bitmap, &flipped.cell_bitmap, sizeof(flipped.cell_bitmap));
}

0 comments on commit aa3ae7b

Please sign in to comment.