Skip to content

Commit 6ae74e3

Browse files
authored
build(core): add BUILD_ID (#96)
test(core): add tron unit tests fix typo
1 parent 5bc9cbd commit 6ae74e3

File tree

24 files changed

+278
-3
lines changed

24 files changed

+278
-3
lines changed

.github/workflows/build-touch.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
poetry run make build_boardloader
4040
poetry run make build_bootloader
4141
poetry run make build_firmware
42-
poetry run tools/headertool.py -h build/firmware/firmware.bin -S 1:${{ secrets.SECRET_KEY_1 }} -S 2:${{ secrets.SECRET_KEY_2 }}
42+
poetry run tools/headertool.py -h build/firmware/touch*Stable*.bin -S 1:${{ secrets.SECRET_KEY_1 }} -S 2:${{ secrets.SECRET_KEY_2 }}
4343
4444
- name: Upload Artifacts
4545
uses: actions/upload-artifact@v2
@@ -48,7 +48,7 @@ jobs:
4848
path: |
4949
./core/build/boardloader/boardloader.bin
5050
./core/build/bootloader/bootloader.bin
51-
./core/build/firmware/firmware.bin
51+
./core/build/firmware/touch*Stable*.bin
5252
5353
- name: Set Env
5454
run: |

common/protob/messages-management.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ message Features {
131131
optional string pre_firmware = 516;
132132

133133
optional uint32 coin_switch = 517;
134+
optional bytes build_id = 518;
134135
}
135136

136137
/**

core/Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ FIRMWARE_P2_MAXSIZE = 917504
4949
FIRMWARE_MAXSIZE = 1703936
5050

5151
CFLAGS += -DSCM_REVISION='\"$(shell git rev-parse HEAD | sed 's:\(..\):\\x\1:g')\"'
52+
FIRMWARE_BUILD_VERSION=$(shell cat ./embed/firmware/version.h | grep "ONEKEY_VERSION " | awk -F "[\"\"]" '{print $$2}')
53+
FIRMWARE_BUILD_DATE=$(shell date "+%m%d")
54+
ifndef BUILD_ID
55+
BUILD_COMMIT=$(shell git rev-parse HEAD | cut -c1-7)
56+
NAME=touch.$(FIRMWARE_BUILD_VERSION)-Stable-$(FIRMWARE_BUILD_DATE)-$(BUILD_COMMIT)
57+
else
58+
NAME=touch.$(FIRMWARE_BUILD_VERSION)-Alpha-$(FIRMWARE_BUILD_DATE)-$(BUILD_ID)
59+
endif
60+
#CFLAGS += -DBUILD_ID='\"$(BUILD_COMMIT)\"'
61+
CFLAGS += -DBUILD_ID='\"$(NAME)\"'
62+
5263

5364
TESTPATH = $(CURDIR)/../tests
5465

@@ -158,6 +169,7 @@ build_reflash: ## build reflash firmware + reflash image
158169

159170
build_firmware: templates build_cross ## build firmware with frozen modules
160171
$(SCONS) CFLAGS="$(CFLAGS)" PRODUCTION="$(PRODUCTION)" TREZOR_MODEL="$(TREZOR_MODEL)" PRODUCTION_MODEL="$(PRODUCTION_MODEL)" PYOPT="$(PYOPT)" BITCOIN_ONLY="$(BITCOIN_ONLY)" UI2="$(UI2)" $(FIRMWARE_BUILD_DIR)/firmware.bin
172+
cp $(FIRMWARE_BUILD_DIR)/firmware.bin $(FIRMWARE_BUILD_DIR)/$(NAME).bin
161173

162174
build_unix: templates ## build unix port
163175
$(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/trezor-emu-core $(UNIX_PORT_OPTS) TREZOR_MODEL="$(TREZOR_MODEL)" BITCOIN_ONLY="$(BITCOIN_ONLY)" TREZOR_EMULATOR_ASAN="$(ADDRESS_SANITIZER)" UI2="$(UI2)" UNAME_S="$(UNAME_S)" CURRENT_DIR="$(CURRENT_DIR)"

core/embed/extmod/modtrezorutils/modtrezorutils.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,16 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_trezorutils_reboot_to_bootloader_obj,
271271
STATIC mp_obj_str_t mod_trezorutils_revision_obj = {
272272
{&mp_type_bytes}, 0, sizeof(SCM_REVISION) - 1, (const byte *)SCM_REVISION};
273273

274+
STATIC mp_obj_str_t mod_trezorutils_build_id_obj = {
275+
{&mp_type_bytes}, 0, sizeof(BUILD_ID) - 1, (const byte *)BUILD_ID};
276+
274277
#define PASTER(s) MP_QSTR_##s
275278
#define MP_QSTR(s) PASTER(s)
276279

277280
MP_DEFINE_STR_OBJ(mp_ONEKEY_VERSION, ONEKEY_VERSION);
278281

279282
/// SCM_REVISION: bytes
283+
/// BUILD_ID: bytes
280284
/// VERSION_MAJOR: int
281285
/// VERSION_MINOR: int
282286
/// VERSION_PATCH: int
@@ -307,6 +311,7 @@ STATIC const mp_rom_map_elem_t mp_module_trezorutils_globals_table[] = {
307311
// various built-in constants
308312
{MP_ROM_QSTR(MP_QSTR_SCM_REVISION),
309313
MP_ROM_PTR(&mod_trezorutils_revision_obj)},
314+
{MP_ROM_QSTR(MP_QSTR_BUILD_ID), MP_ROM_PTR(&mod_trezorutils_build_id_obj)},
310315
{MP_ROM_QSTR(MP_QSTR_VERSION_MAJOR), MP_ROM_INT(VERSION_MAJOR)},
311316
{MP_ROM_QSTR(MP_QSTR_VERSION_MINOR), MP_ROM_INT(VERSION_MINOR)},
312317
{MP_ROM_QSTR(MP_QSTR_VERSION_PATCH), MP_ROM_INT(VERSION_PATCH)},

core/embed/trezorhal/common.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ __fatal_error(const char *expr, const char *msg, const char *file, int line,
8484
const uint8_t *rev = (const uint8_t *)SCM_REVISION;
8585
display_printf("rev : %02x%02x%02x%02x%02x\n", rev[0], rev[1], rev[2], rev[3],
8686
rev[4]);
87+
#endif
88+
#ifdef BUILD_ID
89+
const uint8_t *id = (const uint8_t *)BUILD_ID;
90+
display_printf("build id: %s\n", id);
8791
#endif
8892
display_printf("\nPlease contact OneKey support.\n");
8993
shutdown();

core/embed/unix/common.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ __fatal_error(const char *expr, const char *msg, const char *file, int line,
6464
rev[4]);
6565
printf("rev : %02x%02x%02x%02x%02x\n", rev[0], rev[1], rev[2], rev[3],
6666
rev[4]);
67+
#endif
68+
#ifdef BUILD_ID
69+
const uint8_t *id = (const uint8_t *)BUILD_ID;
70+
display_printf("build id: %s\n", id);
71+
printf("build id: %s\n", id);
6772
#endif
6873
display_printf("\n\n\nHint:\nIsn't the emulator already running?\n");
6974
printf("Hint:\nIsn't the emulator already running?\n");

core/mocks/generated/trezorutils.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ def reboot_to_bootloader() -> None:
8787
Reboots to bootloader.
8888
"""
8989
SCM_REVISION: bytes
90+
BUILD_ID: bytes
9091
VERSION_MAJOR: int
9192
VERSION_MINOR: int
9293
VERSION_PATCH: int

core/src/apps/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def get_features() -> Features:
5151
ble_ver=uart.get_ble_version(),
5252
ble_enable=storage.device.ble_enabled(),
5353
serial_no=storage.device.get_serial(),
54+
build_id=utils.BUILD_ID,
5455
)
5556

5657
if utils.BITCOIN_ONLY:

core/src/trezor/lvglui/i18n/keys.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,4 +668,36 @@
668668
# Do you want to extract device firmware? Your recovery phrase will not be rev
669669
# ealed.
670670
SUBTITLE__EXTRACT_FIRMWARE = 311
671+
# Security Check
672+
TITLE__SECURITY_CHECK = 312
673+
# Are you sure to authenticate your device with the OneKey secure server? Tap
674+
# confirm to check whether your device is genuine and without tampered.
675+
SUBTITLE__SECURITY_CHECK = 313
676+
# Swipe to Show Apps
677+
BUTTON__SWIPE_TO_SHOW_APPS = 314
678+
# Tap to Close
679+
BUTTON__TAP_TO_CLOSE = 315
680+
# Processing...
681+
BUTTON__PROCESSING = 316
682+
# Slide to Sign
683+
BUTTON__SLIDE_TO_SIGN = 317
684+
# Slide to Reset
685+
BUTTON__SLIDE_TO_RESET = 318
686+
# Slide to Confirm
687+
BUTTON__SLIDE_TO_CONFIRM = 319
688+
# USB Lock
689+
ITEM__USB_LOCK = 320
690+
TITLE__USB_LOCK = 320
691+
# USB Lock is enabled. Device will be automatically locked every time when USB
692+
# plug or unplug.
693+
CONTENT__USB_LOCK_ENABLED__HINT = 321
694+
# USB Lock is disabled. Device will always remain unlocked when USB plug or un
695+
# plug.
696+
CONTENT__USB_LOCK_DISABLED__HINT = 322
697+
# Go to Update Mode
698+
TITLE__GO_TO_UPDATE_MODE = 323
699+
# Do you want to restart device in update mode?
700+
SUBTITLE__GO_TO_UPDATE_MODE = 324
701+
# Build ID
702+
ITEM__BUILD_ID = 325
671703
# fmt: on

core/src/trezor/lvglui/i18n/locales/de.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,5 +312,19 @@
312312
"Wollen Sie Entropie exportieren? Fahren Sie nur fort, wenn Sie wissen, was Sie tun!",
313313
"Firmware extrahieren",
314314
"Möchten Sie die Geräte-Firmware extrahieren? Ihre Wiederherstellungsphrase wird nicht angezeigt.",
315+
"Sicherheitskontrolle",
316+
"Sind Sie sicher, dass Sie Ihr Gerät mit dem sicheren OneKey-Server authentifizieren? Tippen Sie auf Bestätigen, um zu überprüfen, ob Ihr Gerät echt und nicht manipuliert ist.",
317+
"Wischen Sie, um Apps anzuzeigen",
318+
"Zum Schließen tippen",
319+
"Verarbeitung...",
320+
"Dia zum Unterschreiben",
321+
"Zum Zurücksetzen schieben",
322+
"Schieben zum Bestätigen",
323+
"USB-Schloss",
324+
"USB-Sperre ist aktiviert. Das Gerät wird jedes Mal automatisch gesperrt, wenn der USB-Stecker ein- oder ausgesteckt wird.",
325+
"USB-Sperre ist deaktiviert. Das Gerät bleibt immer entsperrt, wenn der USB-Stecker angeschlossen oder entfernt wird.",
326+
"Wechseln Sie in den Update-Modus",
327+
"Möchten Sie das Gerät im Update-Modus neu starten?",
328+
"Build-ID",
315329
]
316330
# fmt: on

core/src/trezor/lvglui/i18n/locales/en.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,5 +312,19 @@
312312
"Do you want to export entropy? Continue only id you know what you are doing!",
313313
"Extract Firmware",
314314
"Do you want to extract device firmware? Your recovery phrase will not be revealed.",
315+
"Security Check",
316+
"Are you sure to authenticate your device with the OneKey secure server? Tap confirm to check whether your device is genuine and without tampered.",
317+
"Swipe to Show Apps",
318+
"Tap to Close",
319+
"Processing...",
320+
"Slide to Sign",
321+
"Slide to Reset",
322+
"Slide to Confirm",
323+
"USB Lock",
324+
"USB Lock is enabled. Device will be automatically locked every time when USB plug or unplug.",
325+
"USB Lock is disabled. Device will always remain unlocked when USB plug or unplug.",
326+
"Go to Update Mode",
327+
"Do you want to restart device in update mode?",
328+
"Build ID",
315329
]
316330
# fmt: on

core/src/trezor/lvglui/i18n/locales/fr.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,5 +312,19 @@
312312
"Voulez-vous exporter l'entropie? Continuez uniquement si vous savez ce que vous faites!",
313313
"Extraire le micrologiciel",
314314
"Voulez-vous extraire le firmware de l'appareil ? Votre phrase de récupération ne sera pas révélée.",
315+
"Contrôle de sécurité",
316+
"Êtes-vous sûr d'authentifier votre appareil auprès du serveur sécurisé OneKey ? Appuyez sur confirmer pour vérifier si votre appareil est authentique et non falsifié.",
317+
"Afficher les applications",
318+
"Appuyez pour fermer",
319+
"Traitement...",
320+
"Slide to Sign",
321+
"Glisser pour réinitialiser",
322+
"Faites glisser pour confirmer",
323+
"Verrouillage USB",
324+
"Le verrouillage USB est activé. L'appareil sera automatiquement verrouillé à chaque fois que vous branchez ou débranchez l'USB.",
325+
"Le verrouillage USB est désactivé. L'appareil restera toujours déverrouillé lorsque l'USB est branché ou débranché.",
326+
"Aller en mode mise à jour",
327+
"Voulez-vous redémarrer l'appareil en mode mise à jour ?",
328+
"Build ID",
315329
]
316330
# fmt: on

core/src/trezor/lvglui/i18n/locales/it.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,5 +312,19 @@
312312
"Vuoi esportare entropia? Continua solo se sai cosa stai facendo!",
313313
"Estrarre il firmware",
314314
"Vuoi estrarre il firmware del dispositivo? La tua frase di recupero non verrà rivelata.",
315+
"Controllo di sicurezza",
316+
"Sei sicuro di autenticare il tuo dispositivo con il server sicuro OneKey? Tocca conferma per verificare se il tuo dispositivo è originale e non manomesso.",
317+
"Scorri per mostrare le app",
318+
"Tocca per chiudere",
319+
"Elaborazione...",
320+
"Scorri per firmare",
321+
"Scorri per ripristinare",
322+
"Scorri per confermare",
323+
"Blocco USB",
324+
"Blocco USB è abilitato. Il dispositivo verrà automaticamente bloccato ogni volta che si collega o si scollega l'USB.",
325+
"Il blocco USB è disabilitato. Il dispositivo rimarrà sempre sbloccato quando si collega o si scollega l'USB.",
326+
"Vai alla modalità di aggiornamento",
327+
"Vuoi riavviare il dispositivo in modalità di aggiornamento?",
328+
"ID edificio",
315329
]
316330
# fmt: on

core/src/trezor/lvglui/i18n/locales/ja.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,5 +312,19 @@
312312
"エントロピーをエクスポートしますか?自分が何をしているのかを知っている場合にのみ続行してください。",
313313
"ファームウェアの抽出",
314314
"デバイスファームウェアを抽出しますか?あなたの回復フレーズは明らかにされません。",
315+
"セキュリティーチェック",
316+
"OneKeyセキュアサーバーでデバイスを認証してもよろしいですか? [確認]をタップして、デバイスが本物であり、改ざんされていないかどうかを確認します。",
317+
"スワイプしてアプリを表示",
318+
"タップして閉じる",
319+
"処理...",
320+
"スライドでサイン",
321+
"スライドしてリセット",
322+
"スライドして確認",
323+
"USBロック",
324+
"USBロックが有効になっています。 USBを抜き差しするたびに、デバイスは自動的にロックされます。",
325+
"USBロックが無効になっています。 USBを抜き差ししても、デバイスは常にロック解除されたままになります。",
326+
"アップデートモードへ",
327+
"デバイスを更新モードで再起動しますか?",
328+
"ビルド ID",
315329
]
316330
# fmt: on

core/src/trezor/lvglui/i18n/locales/ko.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,5 +312,19 @@
312312
"엔트로피를 내보내시겠습니까? 당신이 무엇을하고 있는지 알고 이드만 계속!",
313313
"펌웨어 추출",
314314
"장치 펌웨어를 추출하시겠습니까? 복구 문구는 공개되지 않습니다.",
315+
"보안 검색",
316+
"OneKey 보안 서버로 장치를 인증하시겠습니까? 확인을 눌러 장치가 변조되지 않은 정품인지 확인하십시오.",
317+
"스와이프하여 앱 표시",
318+
"닫으려면 탭하세요.",
319+
"처리 중...",
320+
"서명으로 슬라이드",
321+
"슬라이드하여 재설정",
322+
"슬라이드하여 확인",
323+
"USB 잠금",
324+
"USB 잠금이 활성화되었습니다. USB를 연결하거나 분리할 때마다 장치가 자동으로 잠깁니다.",
325+
"USB 잠금이 비활성화되었습니다. USB를 연결하거나 분리할 때 장치는 항상 잠금 해제된 상태로 유지됩니다.",
326+
"업데이트 모드로 이동",
327+
"업데이트 모드에서 장치를 다시 시작하시겠습니까?",
328+
"빌드 ID",
315329
]
316330
# fmt: on

core/src/trezor/lvglui/i18n/locales/zh_cn.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,5 +312,19 @@
312312
"确定要导出熵吗?继续操作之前请明白你在做什么!",
313313
"提取固件",
314314
"确定要提取固件吗?你的助记词不会被泄漏。",
315+
"防伪校验",
316+
"确定使用 OneKey 安全服务器对你的设备进行身份验证吗?要确认你的设备是正品且未被恶意篡改,请点击确认键以继续。",
317+
"轻扫查看应用程序",
318+
"点击关闭",
319+
"正在处理…",
320+
"拖动以签名",
321+
"拖动以重置",
322+
"拖动以确认",
323+
"USB 锁",
324+
"USB 锁已启用。每次插拔 USB 时,设备将自动锁定。",
325+
"USB 锁已关闭。插拔 USB 时设备将始终保持解锁状态。",
326+
"进入更新模式",
327+
"确定要重启设备并进入更新模式吗?",
328+
"构建版本号",
315329
]
316330
# fmt: on

core/src/trezor/lvglui/i18n/locales/zh_hk.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,5 +312,19 @@
312312
"確定要導出熵嗎?繼續操作之前請明白你在做什麽!",
313313
"提取固件",
314314
"確定要提取固件嗎?你的助記詞不會被泄漏。",
315+
"防偽校驗",
316+
"確定使用 OneKey 安全服務器對你的設備進行身份驗證嗎?要確認你的設備是正品且未被惡意篡改,請點擊確認鍵以繼續。",
317+
"輕掃查看應用程序",
318+
"點擊關閉",
319+
"正在處理…",
320+
"拖動以簽名",
321+
"拖動以重置",
322+
"拖動以確認",
323+
"USB 鎖",
324+
"USB 鎖已啟用。每次插拔 USB 時,設備將自動鎖定。",
325+
"USB 鎖已關閉。插拔 USB 時設備將始終保持解鎖狀態。",
326+
"進入更新模式",
327+
"確定要重啟設備並進入更新模式嗎?",
328+
"構建版本號",
315329
]
316330
# fmt: on

core/src/trezor/lvglui/scrs/homescreen.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,12 @@ def __init__(self, prev_scr=None):
531531
right_text=storage,
532532
has_next=False,
533533
)
534+
self.storage = ListItemBtn(
535+
self.container,
536+
_(i18n_keys.ITEM__BUILD_ID),
537+
right_text=utils.BUILD_ID[-7:],
538+
has_next=False,
539+
)
534540

535541

536542
class PowerOff(FullSizeWindow):

core/src/trezor/messages.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2199,6 +2199,7 @@ class Features(protobuf.MessageType):
21992199
cpu_info: "str | None"
22002200
pre_firmware: "str | None"
22012201
coin_switch: "int | None"
2202+
build_id: "bytes | None"
22022203

22032204
def __init__(
22042205
self,
@@ -2257,6 +2258,7 @@ def __init__(
22572258
cpu_info: "str | None" = None,
22582259
pre_firmware: "str | None" = None,
22592260
coin_switch: "int | None" = None,
2261+
build_id: "bytes | None" = None,
22602262
) -> None:
22612263
pass
22622264

core/src/trezor/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import sys
44
from trezorutils import ( # noqa: F401
55
BITCOIN_ONLY,
6+
BUILD_ID,
67
EMULATOR,
78
FIRMWARE_SECTORS_COUNT,
89
LVGL_UI,

core/tests/test_apps.tron.address.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from common import *
2+
from apps.common.paths import HARDENED
3+
4+
from trezor.crypto.curve import secp256k1
5+
6+
if not utils.BITCOIN_ONLY:
7+
from apps.tron.address import get_address_from_public_key
8+
9+
10+
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
11+
class TestTronAddress(unittest.TestCase):
12+
def test_privkey_to_address(self):
13+
#source of test data - binance javascript SDK
14+
privkey = "8d596057e510b14cbb9bf24f88803a6d6dbd138dd303a62b175b9e6cc0f3f941"
15+
expected_address = "TY72iA3SBtrds3QLYsS7LwYfkzXwAXCRWT"
16+
17+
pubkey = secp256k1.publickey(unhexlify(privkey), False)
18+
address = get_address_from_public_key(pubkey[:65])
19+
20+
self.assertEqual(address, expected_address)
21+
22+
23+
if __name__ == '__main__':
24+
unittest.main()

0 commit comments

Comments
 (0)