Skip to content

Commit

Permalink
Update Nano S UX to UX_FLOW
Browse files Browse the repository at this point in the history
  • Loading branch information
TamtamHero committed Jul 27, 2020
1 parent fd927e2 commit 7bedf1d
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 419 deletions.
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ show-app:
############

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

DEFINES += HAVE_GLO096 HAVE_UX_FLOW
DEFINES += HAVE_GLO096
DEFINES += HAVE_BAGL BAGL_WIDTH=128 BAGL_HEIGHT=64
DEFINES += HAVE_BAGL_ELLIPSIS # long label truncation feature
DEFINES += HAVE_BAGL_FONT_OPEN_SANS_REGULAR_11PX
DEFINES += HAVE_BAGL_FONT_OPEN_SANS_EXTRABOLD_11PX
DEFINES += HAVE_BAGL_FONT_OPEN_SANS_LIGHT_16PX

SDK_SOURCE_PATH += lib_blewbxx lib_blewbxx_impl
SDK_SOURCE_PATH += lib_ux
else
DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=128
endif
Expand Down Expand Up @@ -144,7 +143,7 @@ include $(BOLOS_SDK)/Makefile.glyphs

### computed variables
APP_SOURCE_PATH += src
SDK_SOURCE_PATH += lib_stusb lib_stusb_impl
SDK_SOURCE_PATH += lib_stusb lib_stusb_impl lib_ux

### U2F support (wallet app only)
ifeq ($(APP), tezos_wallet)
Expand Down
1 change: 1 addition & 0 deletions src/apdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ void main_loop(apdu_handler const *const handlers, size_t const handlers_size) {
while (true) {
BEGIN_TRY {
TRY {
PRINTF("New APDU received:\n%.*H\n", rx, G_io_apdu_buffer);
// Process APDU of size rx

if (rx == 0) {
Expand Down
29 changes: 4 additions & 25 deletions src/globals.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
#include "exception.h"
#include "to_string.h"

#ifdef TARGET_NANOX
#include "ux.h"
#endif

#include <string.h>

Expand All @@ -21,12 +19,8 @@
globals_t global;

// These are strange variables that the SDK relies on us to define but uses directly itself.
#ifdef TARGET_NANOX
ux_state_t G_ux;
bolos_ux_params_t G_ux_params;
#else
ux_state_t ux;
#endif
ux_state_t G_ux;
bolos_ux_params_t G_ux_params;

unsigned char G_io_seproxyhal_spi_buffer[IO_SEPROXYHAL_BUFFER_SIZE_B];

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

#ifdef TARGET_NANOX
memset(&G_ux, 0, sizeof(G_ux));
memset(&G_ux_params, 0, sizeof(G_ux_params));
#else
memset(&ux, 0, sizeof(ux));
#endif

memset(G_io_seproxyhal_spi_buffer, 0, sizeof(G_io_seproxyhal_spi_buffer));
}
Expand All @@ -51,11 +41,8 @@ void init_globals(void) {

// DO NOT TRY TO INIT THIS. This can only be written via an system call.
// The "N_" is *significant*. It tells the linker to put this in NVRAM.
# ifdef TARGET_NANOX
nvram_data const N_data_real;
# else
nvram_data N_data_real;
# endif
nvram_data const N_data_real;


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

void calculate_baking_idle_screens_data(void) {
# ifdef TARGET_NANOX
memset(global.ui.baking_idle_screens.hwm, 0, sizeof(global.ui.baking_idle_screens.hwm));
static char const HWM_PREFIX[] = "HWM: ";
strcpy(global.ui.baking_idle_screens.hwm, HWM_PREFIX);
number_to_string(&global.ui.baking_idle_screens.hwm[sizeof(HWM_PREFIX) - 1], (level_t const)N_data.hwm.main.highest_level);
# else
number_to_string(global.ui.baking_idle_screens.hwm, N_data.hwm.main.highest_level);
# endif

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

# ifdef TARGET_NANOX
if (N_data.main_chain_id.v == 0) {
strcpy(global.ui.baking_idle_screens.chain, "Chain: any");
} else {
# endif

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

# ifdef TARGET_NANOX
}
# endif
}

void update_baking_idle_screens(void) {
Expand Down
32 changes: 7 additions & 25 deletions src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,10 @@ typedef struct {
ui_callback_t ok_callback;
ui_callback_t cxl_callback;

# ifndef TARGET_NANOX
uint32_t ux_step;
uint32_t ux_step_count;

uint32_t timeout_cycle_count;
# endif

# ifdef BAKING_APP
struct {
Expand All @@ -94,18 +92,10 @@ typedef struct {
string_generation_callback callbacks[MAX_SCREEN_COUNT];
const void *callback_data[MAX_SCREEN_COUNT];

# ifdef TARGET_NANOX
struct {
struct {
char prompt[PROMPT_WIDTH + 1];
char value[VALUE_WIDTH + 1];
} screen[MAX_SCREEN_COUNT];
# else
char active_prompt[PROMPT_WIDTH + 1];
char active_value[VALUE_WIDTH + 1];

// This will and must always be static memory full of constants
const char *const *prompts;
# endif
} screen[MAX_SCREEN_COUNT];
} prompt;
} ui;

Expand Down Expand Up @@ -159,12 +149,8 @@ extern globals_t global;
extern unsigned int app_stack_canary; // From SDK

// Used by macros that we don't control.
#ifdef TARGET_NANOX
extern ux_state_t G_ux;
extern bolos_ux_params_t G_ux_params;
#else
extern ux_state_t ux;
#endif
// extern ux_state_t G_ux;
// extern bolos_ux_params_t G_ux_params;
extern unsigned char G_io_seproxyhal_spi_buffer[IO_SEPROXYHAL_BUFFER_SIZE_B];

static inline void throw_stack_size() {
Expand All @@ -175,13 +161,9 @@ static inline void throw_stack_size() {
}

#ifdef BAKING_APP
# ifdef TARGET_NANOX
extern nvram_data const N_data_real;
# define N_data (*(volatile nvram_data *)PIC(&N_data_real))
# else
extern nvram_data N_data_real;
# define N_data (*(nvram_data*)PIC(&N_data_real))
# endif
extern nvram_data const N_data_real;
#define N_data (*(volatile nvram_data *)PIC(&N_data_real))


void calculate_baking_idle_screens_data(void);
void update_baking_idle_screens(void);
Expand Down
5 changes: 0 additions & 5 deletions src/ui_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ void require_pin(void) {

__attribute__((noreturn))
bool exit_app(void) {
# ifdef BAKING_APP
# ifndef TARGET_NANOX
require_pin();
# endif
# endif
BEGIN_TRY_L(exit) {
TRY_L(exit) {
os_sched_exit(-1);
Expand Down
Loading

0 comments on commit 7bedf1d

Please sign in to comment.