Skip to content

Commit

Permalink
feat: lite support & monero support (#159)
Browse files Browse the repository at this point in the history
* feat: added lite card support (#138)

* Support OneKey lite card

* Monero coin supports SE signing. (#113)

* feat(core): add support for psbt sign  by qr (#139)

* feat(core): add support for psbt sign and address verify and get multi accounts

* fix(core): optimize Near transfer amount display

* fix(core): optimize boot ui

* fix(core): fix ada message sign

* fix(core): optimize polkadot code base

* fix(core): optimize onboarding guide && update FCC Id

* fix: Lite Card UI Issues and Mnemonic Word Count Validation  (#141)

Fix Lite Card UI Text Display and Mnemonic Count  Validation issue

* fix: update pro lite card i18n (#143)

* Optimize SDRAM and PN532 reset timing. (#144)

* Verify firmware data in SDRAM.

* Reconfigure SDRAM-related GPIOs in the firmware.

* Add SDRAM test item to aging test.

* Optimize PN532 reset timing.

* chore(core): bump firmware version to 4.10.0 (#140)

* fix(core): fix ethereum sign issue by qr

* fix(core): fix polkadot transfer amount decode issue

* bump firmware version to 4.10.0

* ci(core): pin nix version to avoid some issue

* Update USB recognition method, wireless charging && fix storage bug. (#142)

* Use USB3320C register status to detect USB connection.

* Check battery temperature when enabling wireless charging.

* Fix bug where data storage exceeds space.

* Support FIDO

* Verify firmware data in SDRAM.

* Keep screen in reset state when turned off.

* Add SDRAM test item to aging test.

* Optimize PN532 reset timing.

* bump firmware version to 4.10.0

---------

Co-authored-by: loatheb <[email protected]>

* chore: rebuild lokalise i18n

* chore: fix conflict

* fix: conflict issue

* fix: conflict

* fix: remove workflow qr update

* fix: remove unused utils import

* fix: isort issue

---------

Co-authored-by: guowei0105 <[email protected]>
Co-authored-by: lihuanhuan <[email protected]>
Co-authored-by: Ritchie <[email protected]>
  • Loading branch information
4 people authored Aug 27, 2024
1 parent 2480f55 commit 7c60aea
Show file tree
Hide file tree
Showing 96 changed files with 4,565 additions and 2,094 deletions.
1 change: 1 addition & 0 deletions core/SConscript.bootloader
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ SOURCE_TREZORHAL = [
'embed/trezorhal/usbd_msc_scsi.c',
'embed/trezorhal/usbd_msc_storage.c',
'embed/trezorhal/usbd_desc.c',
'embed/trezorhal/usbd_ulpi.c',
'embed/trezorhal/trans_fifo.c',
'embed/trezorhal/i2c.c',
'embed/trezorhal/spi.c',
Expand Down
9 changes: 9 additions & 0 deletions core/SConscript.firmware
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ if TREZOR_MODEL in ('T',):
'embed/trezorhal/fatfs/diskio.c',
]
SOURCE_MOD.extend(Glob('embed/pn532/*.c'))
SOURCE_MOD.extend(Glob('embed/lite_card/*.c'))

# modtrezorui
CPPPATH_MOD += [
Expand Down Expand Up @@ -434,6 +435,7 @@ if PRODUCTION_MODEL == 'H':
'vendor/micropython/lib/stm32lib/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_jpeg.c',
'vendor/micropython/lib/stm32lib/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rtc.c',
'vendor/micropython/lib/stm32lib/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rtc_ex.c',
'vendor/micropython/lib/stm32lib/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_lptim.c',
'vendor/micropython/lib/stm32lib/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_fmc.c',
'vendor/micropython/lib/stm32lib/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_sdmmc.c',
'vendor/micropython/lib/stm32lib/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_usb.c',
Expand Down Expand Up @@ -478,6 +480,7 @@ if PRODUCTION_MODEL == 'H':
'embed/trezorhal/usbd_ctlreq.c',
'embed/trezorhal/usbd_ioreq.c',
'embed/trezorhal/usbd_desc.c',
'embed/trezorhal/usbd_ulpi.c',
'embed/trezorhal/thd89.c',
'embed/trezorhal/se_thd89.c',
'embed/trezorhal/trans_fifo.c',
Expand Down Expand Up @@ -571,6 +574,10 @@ SOURCE_DEBUG_UTILS.extend(Glob('embed/debug_utils/*.c'))
SOURCE_PN532_WRAPPER = []
SOURCE_PN532_WRAPPER.extend(Glob('embed/pn532/*.c'))

# lite card wrapper
SOURCE_LITE_CARD_WRAPPER = []
SOURCE_LITE_CARD_WRAPPER.extend(Glob('embed/lite_card/*.c'))

# fp_sensor wrapper
SOURCE_FP_SENSOR_WRAPPER = []
SOURCE_FP_SENSOR_WRAPPER.extend(Glob('embed/fp_sensor_wrapper/*.c'))
Expand Down Expand Up @@ -705,6 +712,7 @@ if PRODUCTION_MODEL == 'H':
'embed/zbar/qrcode',
'embed/zbar/decoder',
'embed/bytewords/',
'embed/lite_card',
] + CPPPATH_MOD,
CPPDEFINES=[
'TREZOR_MODEL_'+TREZOR_MODEL,
Expand Down Expand Up @@ -833,6 +841,7 @@ if FROZEN:
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/common.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/reset.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/recovery.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/lite.py'))
if EVERYTHING:
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/altcoin.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/webauthn.py'))
Expand Down
44 changes: 21 additions & 23 deletions core/embed/bootloader/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,32 +246,30 @@ static void usb_init_all(secbool usb21_landing) {

static void usb_switch(void) {
static bool usb_opened = false;

if (!ble_charging_state()) {
ble_cmd_req(BLE_PWR, BLE_PWR_CHARGING);
return;
}

if(ble_get_charge_type() != 0)
{
if((ble_get_charge_type() == CHARGE_BY_USB) && (!usb_opened))
{
usb_start();
usb_opened = true;
static uint32_t counter0 = 0, counter1 = 0;

if (usb_3320_host_connected()) {
counter0++;
counter1 = 0;
if (counter0 > 5) {
counter0 = 0;
if (!usb_opened) {
usb_start();
usb_opened = true;
}
}
else if (usb_opened)
{
usb_stop();
usb_opened = false;

} else {
counter0 = 0;
counter1++;
if (counter1 > 5) {
counter1 = 0;
if (usb_opened) {
usb_stop();
usb_opened = false;
}
}
}
else
{
// default enable usb if no power status obtained
usb_start();
usb_opened = true;
}

}

static void charge_switch(void) {
Expand Down
6 changes: 4 additions & 2 deletions core/embed/bootloader/messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@ static void send_msg_features(uint8_t iface_num,
MSG_SEND_ASSIGN_STRING_LEN(fw_vendor, vhdr->vstr, vhdr->vstr_len);
const char *ver_str = format_ver("%d.%d.%d", hdr->onekey_version);
MSG_SEND_ASSIGN_STRING_LEN(onekey_version, ver_str, strlen(ver_str));
MSG_SEND_ASSIGN_STRING_LEN(onekey_firmware_version, ver_str, strlen(ver_str));
MSG_SEND_ASSIGN_STRING_LEN(onekey_firmware_version, ver_str,
strlen(ver_str));

} else {
MSG_SEND_ASSIGN_VALUE(firmware_present, false);
Expand Down Expand Up @@ -425,7 +426,8 @@ static void send_msg_features_ex(uint8_t iface_num,

if (vhdr && hdr) {
const char *ver_str = format_ver("%d.%d.%d", hdr->onekey_version);
MSG_SEND_ASSIGN_STRING_LEN(onekey_firmware_version, ver_str, strlen(ver_str));
MSG_SEND_ASSIGN_STRING_LEN(onekey_firmware_version, ver_str,
strlen(ver_str));

uint8_t *fimware_hash = get_firmware_hash();
MSG_SEND_ASSIGN_BYTES(onekey_firmware_hash, fimware_hash, 32);
Expand Down
41 changes: 41 additions & 0 deletions core/embed/extmod/modtrezorcrypto/modtrezorcrypto-bip32.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,45 @@ STATIC mp_obj_t mod_trezorcrypto_HDNode_derive_path(mp_obj_t self,
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_trezorcrypto_HDNode_derive_path_obj,
mod_trezorcrypto_HDNode_derive_path);

/// def derive_fido_path(self, path: Sequence[int]) -> None:
/// """
/// Go through a list of indexes and iteratively derive a child node in
/// place.
/// """
STATIC mp_obj_t mod_trezorcrypto_HDNode_derive_fido_path(mp_obj_t self,
mp_obj_t path) {
mp_obj_HDNode_t *o = MP_OBJ_TO_PTR(self);

// get path objects and length
size_t plen = 0;
mp_obj_t *pitems = NULL;
mp_obj_get_array(path, &plen, &pitems);
if (plen > 32) {
mp_raise_ValueError("Path cannot be longer than 32 indexes");
}

#if USE_THD89
uint32_t address_n[plen];

for (uint32_t pi = 0; pi < plen; pi++) {
address_n[pi] = trezor_obj_get_uint(pitems[pi]);
}
const char *curve = o->hdnode.curve->curve_name;
if (!se_derive_fido_keys(&o->hdnode, curve, address_n, plen,
&o->fingerprint)) {
o->fingerprint = 0;
memzero(&o->hdnode, sizeof(o->hdnode));
mp_raise_ValueError("Failed to derive path");
}
#else

mp_raise_ValueError("Not implemented");
#endif
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_trezorcrypto_HDNode_derive_fido_path_obj,
mod_trezorcrypto_HDNode_derive_fido_path);

/// def serialize_public(self, version: int) -> str:
/// """
/// Serialize the public info from HD node to base58 string.
Expand Down Expand Up @@ -537,6 +576,8 @@ STATIC const mp_rom_map_elem_t mod_trezorcrypto_HDNode_locals_dict_table[] = {
MP_ROM_PTR(&mod_trezorcrypto_HDNode_nem_encrypt_obj)},
{MP_ROM_QSTR(MP_QSTR_ethereum_pubkeyhash),
MP_ROM_PTR(&mod_trezorcrypto_HDNode_ethereum_pubkeyhash_obj)},
{MP_ROM_QSTR(MP_QSTR_derive_fido_path),
MP_ROM_PTR(&mod_trezorcrypto_HDNode_derive_fido_path_obj)},
#endif
};
STATIC MP_DEFINE_CONST_DICT(mod_trezorcrypto_HDNode_locals_dict,
Expand Down
Loading

0 comments on commit 7c60aea

Please sign in to comment.