diff --git a/Makefile b/Makefile index c7666795..46cf79af 100644 --- a/Makefile +++ b/Makefile @@ -130,9 +130,7 @@ endif ######################################## ifeq ($(DEBUG),1) -DEFINES += ZEMU_LOGGING=1 -else -DEFINES += ZEMU_LOGGING=0 +DEFINES += ZEMU_LOGGING endif ######################### diff --git a/deps/ledger-zxlib/app/common/app_main.c b/deps/ledger-zxlib/app/common/app_main.c index efa1ee02..1977b09b 100644 --- a/deps/ledger-zxlib/app/common/app_main.c +++ b/deps/ledger-zxlib/app/common/app_main.c @@ -30,7 +30,7 @@ #include "app_mode.h" #ifdef HAVE_SWAP #include "swap.h" -#endif +#endif // HAVE_SWAP unsigned char G_io_seproxyhal_spi_buffer[IO_SEPROXYHAL_BUFFER_SIZE_B]; @@ -157,11 +157,6 @@ void app_init() { #ifdef HAVE_BLE // Enable Bluetooth -#ifdef HAVE_SWAP - if (G_swap_state.called_from_swap) { - memset(&G_io_asynch_ux_callback, 0, sizeof(G_io_asynch_ux_callback)); - } -#endif // HAVE_SWAP BLE_power(0, NULL); BLE_power(1, NULL); #endif // HAVE_BLE @@ -220,11 +215,6 @@ void app_main() { } FINALLY; { - #ifdef HAVE_SWAP - if (G_swap_state.called_from_swap && G_swap_state.should_exit) { - os_sched_exit(0); - } - #endif } } END_TRY; diff --git a/deps/ledger-zxlib/app/ui/view.c b/deps/ledger-zxlib/app/ui/view.c index 2feef0eb..0d91711f 100644 --- a/deps/ledger-zxlib/app/ui/view.c +++ b/deps/ledger-zxlib/app/ui/view.c @@ -17,6 +17,7 @@ #include "view_internal.h" #include "actions.h" +#include "zxmacros.h" view_t viewdata; unsigned int review_type = 0; diff --git a/deps/ledger-zxlib/app/ui/view.h b/deps/ledger-zxlib/app/ui/view.h index 26bd7874..172a8c13 100644 --- a/deps/ledger-zxlib/app/ui/view.h +++ b/deps/ledger-zxlib/app/ui/view.h @@ -16,6 +16,7 @@ ********************************************************************************/ #pragma once +#include #include #include "coin.h" #include "zxerror.h" diff --git a/deps/ledger-zxlib/app/ui/view_inspect_s.c b/deps/ledger-zxlib/app/ui/view_inspect_s.c index 0effeb5e..d4e1e603 100644 --- a/deps/ledger-zxlib/app/ui/view_inspect_s.c +++ b/deps/ledger-zxlib/app/ui/view_inspect_s.c @@ -21,6 +21,7 @@ #include "view_templates.h" #include "ux.h" #include "bagl.h" +#include "zxmacros.h" static void h_inspect_button_left(); static void h_inspect_button_right(); diff --git a/deps/ledger-zxlib/app/ui/view_inspect_x.c b/deps/ledger-zxlib/app/ui/view_inspect_x.c index d2077dd8..f42ce141 100644 --- a/deps/ledger-zxlib/app/ui/view_inspect_x.c +++ b/deps/ledger-zxlib/app/ui/view_inspect_x.c @@ -20,6 +20,7 @@ #include "view_nano_inspect.h" #include "view_templates.h" #include "view_nano.h" +#include "zxmacros.h" extern const ux_flow_step_t *ux_review_flow[MAX_REVIEW_UX_SCREENS]; diff --git a/deps/ledger-zxlib/app/ui/view_nano_inspect.c b/deps/ledger-zxlib/app/ui/view_nano_inspect.c index 3e26e15a..0ad7e082 100644 --- a/deps/ledger-zxlib/app/ui/view_nano_inspect.c +++ b/deps/ledger-zxlib/app/ui/view_nano_inspect.c @@ -20,6 +20,7 @@ #include "view_internal.h" #include "view_templates.h" #include "view_nano.h" +#include "zxmacros.h" void h_inspect_init() { ZEMU_LOGF(50, "h_inspect_init\n") @@ -41,14 +42,12 @@ void view_inspect_init(viewfunc_getInnerItem_t view_funcGetInnerItem, } bool h_paging_inspect_go_to_root_screen() { - return (viewdata.innerField.level >= 0) && - (viewdata.innerField.paging.itemIdx == 0) + return (viewdata.innerField.paging.itemIdx == 0) && (viewdata.innerField.trace[0] != 0); } bool h_paging_inspect_back_screen() { - return (viewdata.innerField.level >= 0) && - (viewdata.innerField.paging.itemIdx == (viewdata.innerField.paging.itemCount - 1)) + return (viewdata.innerField.paging.itemIdx == (viewdata.innerField.paging.itemCount - 1)) && (viewdata.innerField.trace[0] != 0); } diff --git a/deps/ledger-zxlib/app/ui/view_x.c b/deps/ledger-zxlib/app/ui/view_x.c index 58603548..3c2b81a7 100644 --- a/deps/ledger-zxlib/app/ui/view_x.c +++ b/deps/ledger-zxlib/app/ui/view_x.c @@ -164,7 +164,11 @@ UX_FLOW_DEF_NOCB(ux_review_flow_2_review_title, pbb, { &C_icon_app, REVIEW_SCREE UX_FLOW_DEF_NOCB(ux_review_flow_3_review_title, pbb, { &C_icon_app, "Review", "configuration",}); UX_STEP_INIT(ux_review_flow_2_start_step, NULL, NULL, { h_review_loop_start(); }); +#ifdef HAVE_INSPECT UX_STEP_CB_INIT(ux_review_flow_2_step, bnnn_paging, h_review_loop_inside(), inspect_init(), { .title = viewdata.key, .text = viewdata.value, }); +#else +UX_STEP_NOCB_INIT(ux_review_flow_2_step, bnnn_paging, { h_review_loop_inside(); }, { .title = viewdata.key, .text = viewdata.value, }); +#endif UX_STEP_INIT(ux_review_flow_2_end_step, NULL, NULL, { h_review_loop_end(); }); UX_STEP_VALID(ux_review_flow_3_step, pb, h_approve(0), { &C_icon_validate_14, APPROVE_LABEL }); UX_STEP_VALID(ux_review_flow_4_step, pb, h_reject(review_type), { &C_icon_crossmark, REJECT_LABEL }); diff --git a/deps/ledger-zxlib/include/segwit_addr.h b/deps/ledger-zxlib/include/segwit_addr.h index d5f87ac3..1683b625 100644 --- a/deps/ledger-zxlib/include/segwit_addr.h +++ b/deps/ledger-zxlib/include/segwit_addr.h @@ -23,6 +23,7 @@ #define _SEGWIT_ADDR_H_ 1 #include +#include /** Encode a SegWit address * diff --git a/deps/ledger-zxlib/include/utf8.h b/deps/ledger-zxlib/include/utf8.h index fe2e8d9f..fc7eecd7 100644 --- a/deps/ledger-zxlib/include/utf8.h +++ b/deps/ledger-zxlib/include/utf8.h @@ -700,7 +700,7 @@ utf8_int8_t *c = utf8_null; size_t bytes = 0; /* Find the end of the string or stop when n is reached */ -while ('\0' != src[bytes] && bytes < n) { +while (bytes < n && '\0' != src[bytes]) { bytes++; } @@ -722,7 +722,7 @@ return utf8_null; bytes = 0; /* copy src byte-by-byte into our new utf8 string */ -while ('\0' != src[bytes] && bytes < n) { +while (bytes < n && '\0' != src[bytes]) { c[bytes] = src[bytes]; bytes++; } diff --git a/deps/ledger-zxlib/include/zxformat.h b/deps/ledger-zxlib/include/zxformat.h index 7d7f09c0..a9c44af6 100644 --- a/deps/ledger-zxlib/include/zxformat.h +++ b/deps/ledger-zxlib/include/zxformat.h @@ -413,10 +413,10 @@ __Z_INLINE void pageStringHex(char *outValue, uint16_t outValueLen, if (inValueLen == 0) { return; } - const uint16_t msgHexLen = inValueLen * 2; - // Last char from OutVal will be filled with a null terminator in array_to_hexstr function - *pageCount = (uint8_t) (msgHexLen / (outValueLen - 1) ); - const uint16_t lastChunkLen = (msgHexLen % (outValueLen - 1)); + // leaving space for null terminator + const uint16_t bytesPerPage = (outValueLen - 1) / 2; + *pageCount = (uint8_t) (inValueLen / bytesPerPage); + const uint16_t lastChunkLen = inValueLen % bytesPerPage; if (lastChunkLen > 0) { (*pageCount)++; @@ -424,9 +424,13 @@ __Z_INLINE void pageStringHex(char *outValue, uint16_t outValueLen, if (pageIdx < *pageCount) { if (lastChunkLen > 0 && pageIdx == *pageCount - 1) { - array_to_hexstr(outValue, outValueLen, (const uint8_t*)inValue+(pageIdx * (outValueLen/2)), lastChunkLen/2); + array_to_hexstr(outValue, outValueLen, + (const uint8_t *)inValue + pageIdx * bytesPerPage, + lastChunkLen); } else { - array_to_hexstr(outValue, outValueLen, (const uint8_t*)inValue+(pageIdx * (outValueLen/2)), outValueLen/2); + array_to_hexstr(outValue, outValueLen, + (const uint8_t *)inValue + pageIdx * bytesPerPage, + bytesPerPage); } } } diff --git a/deps/ledger-zxlib/include/zxmacros.h b/deps/ledger-zxlib/include/zxmacros.h index c9571270..f0ce1817 100644 --- a/deps/ledger-zxlib/include/zxmacros.h +++ b/deps/ledger-zxlib/include/zxmacros.h @@ -97,7 +97,7 @@ if( os_global_pin_is_validated() != BOLOS_UX_OK ) { \ } #if (defined (TARGET_NANOS) || defined(TARGET_NANOX) || defined(TARGET_NANOS2) || defined(TARGET_STAX)) -#if (ZEMU_LOGGING) +#if defined(ZEMU_LOGGING) __Z_INLINE void zemu_log(const char *buf) { /* diff --git a/deps/ledger-zxlib/include/zxmacros_ledger.h b/deps/ledger-zxlib/include/zxmacros_ledger.h index fd2d4682..7efaa37d 100644 --- a/deps/ledger-zxlib/include/zxmacros_ledger.h +++ b/deps/ledger-zxlib/include/zxmacros_ledger.h @@ -67,7 +67,7 @@ extern unsigned int app_stack_canary; if (__cx_err != CX_OK) { \ return __cx_err; \ } \ - } while (0); + } while (0) #define CATCH_CXERROR(CALL) \ @@ -76,6 +76,14 @@ extern unsigned int app_stack_canary; if (__cx_err != CX_OK) { \ goto catch_cx_error; \ } \ - } while (0); + } while (0) + +#define CHECK_CX_OK(CALL) \ + do { \ + cx_err_t __cx_err = CALL; \ + if (__cx_err != CX_OK) { \ + return zxerr_unknown; \ + } \ + } while (0) #endif diff --git a/deps/ledger-zxlib/include/zxversion.h b/deps/ledger-zxlib/include/zxversion.h index 971dfb70..bb270d05 100644 --- a/deps/ledger-zxlib/include/zxversion.h +++ b/deps/ledger-zxlib/include/zxversion.h @@ -15,6 +15,6 @@ ********************************************************************************/ #pragma once -#define ZXLIB_MAJOR 19 -#define ZXLIB_MINOR 8 +#define ZXLIB_MAJOR 21 +#define ZXLIB_MINOR 0 #define ZXLIB_PATCH 2