Skip to content

Commit 7bedf1d

Browse files
committed
Update Nano S UX to UX_FLOW
1 parent fd927e2 commit 7bedf1d

File tree

7 files changed

+17
-419
lines changed

7 files changed

+17
-419
lines changed

Makefile

+3-4
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ show-app:
6060
############
6161

6262
DEFINES += OS_IO_SEPROXYHAL
63-
DEFINES += HAVE_BAGL HAVE_SPRINTF
63+
DEFINES += HAVE_BAGL HAVE_SPRINTF HAVE_UX_FLOW
6464
DEFINES += HAVE_IO_USB HAVE_L4_USBLIB IO_USB_MAX_ENDPOINTS=6 IO_HID_EP_LENGTH=64 HAVE_USB_APDU
6565
DEFINES += HAVE_LEGACY_PID
6666
DEFINES += VERSION=\"$(APPVERSION)\" APPVERSION_M=$(APPVERSION_M)
@@ -73,15 +73,14 @@ DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=300
7373
DEFINES += HAVE_BLE BLE_COMMAND_TIMEOUT_MS=2000
7474
DEFINES += HAVE_BLE_APDU # basic ledger apdu transport over BLE
7575

76-
DEFINES += HAVE_GLO096 HAVE_UX_FLOW
76+
DEFINES += HAVE_GLO096
7777
DEFINES += HAVE_BAGL BAGL_WIDTH=128 BAGL_HEIGHT=64
7878
DEFINES += HAVE_BAGL_ELLIPSIS # long label truncation feature
7979
DEFINES += HAVE_BAGL_FONT_OPEN_SANS_REGULAR_11PX
8080
DEFINES += HAVE_BAGL_FONT_OPEN_SANS_EXTRABOLD_11PX
8181
DEFINES += HAVE_BAGL_FONT_OPEN_SANS_LIGHT_16PX
8282

8383
SDK_SOURCE_PATH += lib_blewbxx lib_blewbxx_impl
84-
SDK_SOURCE_PATH += lib_ux
8584
else
8685
DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=128
8786
endif
@@ -144,7 +143,7 @@ include $(BOLOS_SDK)/Makefile.glyphs
144143

145144
### computed variables
146145
APP_SOURCE_PATH += src
147-
SDK_SOURCE_PATH += lib_stusb lib_stusb_impl
146+
SDK_SOURCE_PATH += lib_stusb lib_stusb_impl lib_ux
148147

149148
### U2F support (wallet app only)
150149
ifeq ($(APP), tezos_wallet)

src/apdu.c

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ void main_loop(apdu_handler const *const handlers, size_t const handlers_size) {
4242
while (true) {
4343
BEGIN_TRY {
4444
TRY {
45+
PRINTF("New APDU received:\n%.*H\n", rx, G_io_apdu_buffer);
4546
// Process APDU of size rx
4647

4748
if (rx == 0) {

src/globals.c

+4-25
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
#include "exception.h"
44
#include "to_string.h"
55

6-
#ifdef TARGET_NANOX
76
#include "ux.h"
8-
#endif
97

108
#include <string.h>
119

@@ -21,12 +19,8 @@
2119
globals_t global;
2220

2321
// These are strange variables that the SDK relies on us to define but uses directly itself.
24-
#ifdef TARGET_NANOX
25-
ux_state_t G_ux;
26-
bolos_ux_params_t G_ux_params;
27-
#else
28-
ux_state_t ux;
29-
#endif
22+
ux_state_t G_ux;
23+
bolos_ux_params_t G_ux_params;
3024

3125
unsigned char G_io_seproxyhal_spi_buffer[IO_SEPROXYHAL_BUFFER_SIZE_B];
3226

@@ -37,12 +31,8 @@ void clear_apdu_globals(void) {
3731
void init_globals(void) {
3832
memset(&global, 0, sizeof(global));
3933

40-
#ifdef TARGET_NANOX
4134
memset(&G_ux, 0, sizeof(G_ux));
4235
memset(&G_ux_params, 0, sizeof(G_ux_params));
43-
#else
44-
memset(&ux, 0, sizeof(ux));
45-
#endif
4636

4737
memset(G_io_seproxyhal_spi_buffer, 0, sizeof(G_io_seproxyhal_spi_buffer));
4838
}
@@ -51,11 +41,8 @@ void init_globals(void) {
5141

5242
// DO NOT TRY TO INIT THIS. This can only be written via an system call.
5343
// The "N_" is *significant*. It tells the linker to put this in NVRAM.
54-
# ifdef TARGET_NANOX
55-
nvram_data const N_data_real;
56-
# else
57-
nvram_data N_data_real;
58-
# endif
44+
nvram_data const N_data_real;
45+
5946

6047
high_watermark_t volatile *select_hwm_by_chain(chain_id_t const chain_id, nvram_data volatile *const ram) {
6148
check_null(ram);
@@ -65,14 +52,10 @@ high_watermark_t volatile *select_hwm_by_chain(chain_id_t const chain_id, nvram_
6552
}
6653

6754
void calculate_baking_idle_screens_data(void) {
68-
# ifdef TARGET_NANOX
6955
memset(global.ui.baking_idle_screens.hwm, 0, sizeof(global.ui.baking_idle_screens.hwm));
7056
static char const HWM_PREFIX[] = "HWM: ";
7157
strcpy(global.ui.baking_idle_screens.hwm, HWM_PREFIX);
7258
number_to_string(&global.ui.baking_idle_screens.hwm[sizeof(HWM_PREFIX) - 1], (level_t const)N_data.hwm.main.highest_level);
73-
# else
74-
number_to_string(global.ui.baking_idle_screens.hwm, N_data.hwm.main.highest_level);
75-
# endif
7659

7760
if (N_data.baking_key.bip32_path.length == 0) {
7861
STRCPY(global.ui.baking_idle_screens.pkh, "No Key Authorized");
@@ -85,19 +68,15 @@ void calculate_baking_idle_screens_data(void) {
8568
(derivation_type_t const)N_data.baking_key.derivation_type, pubkey);
8669
}
8770

88-
# ifdef TARGET_NANOX
8971
if (N_data.main_chain_id.v == 0) {
9072
strcpy(global.ui.baking_idle_screens.chain, "Chain: any");
9173
} else {
92-
# endif
9374

9475
chain_id_to_string_with_aliases(
9576
global.ui.baking_idle_screens.chain, sizeof(global.ui.baking_idle_screens.chain),
9677
(chain_id_t const *const)&N_data.main_chain_id);
9778

98-
# ifdef TARGET_NANOX
9979
}
100-
# endif
10180
}
10281

10382
void update_baking_idle_screens(void) {

src/globals.h

+7-25
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,10 @@ typedef struct {
7575
ui_callback_t ok_callback;
7676
ui_callback_t cxl_callback;
7777

78-
# ifndef TARGET_NANOX
7978
uint32_t ux_step;
8079
uint32_t ux_step_count;
8180

8281
uint32_t timeout_cycle_count;
83-
# endif
8482

8583
# ifdef BAKING_APP
8684
struct {
@@ -94,18 +92,10 @@ typedef struct {
9492
string_generation_callback callbacks[MAX_SCREEN_COUNT];
9593
const void *callback_data[MAX_SCREEN_COUNT];
9694

97-
# ifdef TARGET_NANOX
98-
struct {
95+
struct {
9996
char prompt[PROMPT_WIDTH + 1];
10097
char value[VALUE_WIDTH + 1];
101-
} screen[MAX_SCREEN_COUNT];
102-
# else
103-
char active_prompt[PROMPT_WIDTH + 1];
104-
char active_value[VALUE_WIDTH + 1];
105-
106-
// This will and must always be static memory full of constants
107-
const char *const *prompts;
108-
# endif
98+
} screen[MAX_SCREEN_COUNT];
10999
} prompt;
110100
} ui;
111101

@@ -159,12 +149,8 @@ extern globals_t global;
159149
extern unsigned int app_stack_canary; // From SDK
160150

161151
// Used by macros that we don't control.
162-
#ifdef TARGET_NANOX
163-
extern ux_state_t G_ux;
164-
extern bolos_ux_params_t G_ux_params;
165-
#else
166-
extern ux_state_t ux;
167-
#endif
152+
// extern ux_state_t G_ux;
153+
// extern bolos_ux_params_t G_ux_params;
168154
extern unsigned char G_io_seproxyhal_spi_buffer[IO_SEPROXYHAL_BUFFER_SIZE_B];
169155

170156
static inline void throw_stack_size() {
@@ -175,13 +161,9 @@ static inline void throw_stack_size() {
175161
}
176162

177163
#ifdef BAKING_APP
178-
# ifdef TARGET_NANOX
179-
extern nvram_data const N_data_real;
180-
# define N_data (*(volatile nvram_data *)PIC(&N_data_real))
181-
# else
182-
extern nvram_data N_data_real;
183-
# define N_data (*(nvram_data*)PIC(&N_data_real))
184-
# endif
164+
extern nvram_data const N_data_real;
165+
#define N_data (*(volatile nvram_data *)PIC(&N_data_real))
166+
185167

186168
void calculate_baking_idle_screens_data(void);
187169
void update_baking_idle_screens(void);

src/ui_common.c

-5
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ void require_pin(void) {
2828

2929
__attribute__((noreturn))
3030
bool exit_app(void) {
31-
# ifdef BAKING_APP
32-
# ifndef TARGET_NANOX
33-
require_pin();
34-
# endif
35-
# endif
3631
BEGIN_TRY_L(exit) {
3732
TRY_L(exit) {
3833
os_sched_exit(-1);

0 commit comments

Comments
 (0)