diff --git a/Makefile b/Makefile index 2028b8281..a21e185cc 100644 --- a/Makefile +++ b/Makefile @@ -32,6 +32,10 @@ binctl: ./tools/binctl micropython/firmware/vendorheader.bin ./tools/binctl micropython/firmware/build/firmware.bin +sign: + ./tools/binctl micropython/loader/build/loader.bin -s + ./tools/binctl micropython/firmware/build/firmware.bin -s + ## emulator commands: run: ## run unix port diff --git a/Makefile.loader b/Makefile.loader index be8f94c1d..bd8de0925 100644 --- a/Makefile.loader +++ b/Makefile.loader @@ -66,6 +66,7 @@ OBJ_FW += $(addprefix $(BUILD_FW)/, \ extmod/modtrezorui/font_robotomono_regular_20.o \ trezorhal/common.o \ trezorhal/image.o \ + trezorhal/touch.o \ trezorhal/stm32_it.o \ trezorhal/stm32_system.o \ trezorhal/hal/stm32f4xx_hal_sram.o \ diff --git a/micropython/loader/main.c b/micropython/loader/main.c index 70290bf44..e23cd9fb6 100644 --- a/micropython/loader/main.c +++ b/micropython/loader/main.c @@ -5,6 +5,7 @@ #include "common.h" #include "display.h" #include "image.h" +#include "touch.h" #define LOADER_FGCOLOR 0xFFFF #define LOADER_BGCOLOR 0x0000 @@ -85,11 +86,18 @@ void check_and_jump(void) } } +void mainloop(void) +{ + __fatal_error("touch detected - launch aborted"); +} + int main(void) { SCB->VTOR = LOADER_START + HEADER_SIZE; periph_init(); + touch_init(); + display_init(); display_clear(); display_backlight(255); @@ -98,7 +106,11 @@ int main(void) LOADER_PRINTLN("============="); LOADER_PRINTLN("starting loader"); - check_and_jump(); + if (touch_read() != 0) { + mainloop(); + } else { + check_and_jump(); + } __fatal_error("halt"); diff --git a/tools/binctl b/tools/binctl index 5b99a3767..18374dcb2 100755 --- a/tools/binctl +++ b/tools/binctl @@ -7,10 +7,14 @@ import pyblake2 def get_sig(data): - print('Enter index : ', end='') - idx = int(input()) - print('Enter privkey : ', end='') - seckey = binascii.unhexlify(input()) + if False: + print('Enter index : ', end='') + idx = int(input()) + print('Enter privkey : ', end='') + seckey = binascii.unhexlify(input()) + else: + idx = 1 + seckey = binascii.unhexlify('4141414141414141414141414141414141414141414141414141414141414141') signkey = ed25519.SigningKey(seckey) digest = pyblake2.blake2s(data).digest() sigmask = 1 << (idx - 1) @@ -206,13 +210,13 @@ def main(): fn = sys.argv[1] sign = len(sys.argv) > 2 and sys.argv[2] == '-s' b = binopen(fn) - b.print() if sign: - print() b.sign() print() b.print() b.write(fn) + else: + b.print() if __name__ == '__main__':