Skip to content

Commit

Permalink
Merge pull request #6 from LedgerHQ/stax-develop
Browse files Browse the repository at this point in the history
Stax develop
  • Loading branch information
apaillier-ledger authored May 17, 2023
2 parents 26f3eca + 1b05a56 commit 8a3955c
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
name: "nanox"
- sdk: "$NANOSP_SDK"
name: "nanosp"
- sdk: "$STAX_SDK"
name: "stax"

runs-on: ubuntu-latest
container:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ bin/
debug/
dep/
obj/
tests/elfs/
build/

# Editors
.idea/
Expand Down
35 changes: 19 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ endif

include $(BOLOS_SDK)/Makefile.defines

# EDIT THIS: Put your plugin name
APPNAME = "Staderlabs"

ifeq ($(ETHEREUM_PLUGIN_SDK),)
Expand All @@ -37,11 +36,15 @@ APPVERSION_N = 0
APPVERSION_P = 1
APPVERSION = "$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)"

# EDIT THIS: Change the name of the gif, and generate you own GIFs!
ifeq ($(TARGET_NAME), TARGET_NANOS)
ICONNAME=icons/nanos_app_boilerplate.gif
ICONNAME=icons/nanos_app_staderlabs.gif
else ifeq ($(TARGET_NAME), TARGET_STAX)
ICONNAME=icons/stax_app_staderlabs.gif
DEFINES += ICONGLYPH=C_stax_staderlabs_64px
DEFINES += ICONBITMAP=C_stax_staderlabs_64px_bitmap
GLYPH_FILES += $(ICONNAME)
else
ICONNAME=icons/nanox_app_boilerplate.gif
ICONNAME=icons/nanox_app_staderlabs.gif
endif

################
Expand All @@ -54,14 +57,15 @@ all: default
############

DEFINES += OS_IO_SEPROXYHAL
DEFINES += HAVE_BAGL HAVE_SPRINTF
DEFINES += HAVE_SPRINTF
DEFINES += LEDGER_MAJOR_VERSION=$(APPVERSION_M) LEDGER_MINOR_VERSION=$(APPVERSION_N) LEDGER_PATCH_VERSION=$(APPVERSION_P)
DEFINES += IO_HID_EP_LENGTH=64

DEFINES += UNUSED\(x\)=\(void\)x
DEFINES += APPVERSION=\"$(APPVERSION)\"
CFLAGS += -DAPPNAME=\"$(APPNAME)\"

ifeq ($(TARGET_NAME),TARGET_NANOX)
ifneq (,$(filter $(TARGET_NAME),TARGET_NANOX TARGET_STAX))
DEFINES += HAVE_BLE BLE_COMMAND_TIMEOUT_MS=2000
DEFINES += HAVE_BLE_APDU # basic ledger apdu transport over BLE
endif
Expand All @@ -70,6 +74,11 @@ ifeq ($(TARGET_NAME),TARGET_NANOS)
DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=128
else
DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=300
endif

ifneq ($(TARGET_NAME),TARGET_STAX)
DEFINES += HAVE_BAGL
ifneq ($(TARGET_NAME),TARGET_NANOS)
DEFINES += HAVE_GLO096
DEFINES += HAVE_BAGL BAGL_WIDTH=128 BAGL_HEIGHT=64
DEFINES += HAVE_BAGL_ELLIPSIS # long label truncation feature
Expand All @@ -78,13 +87,12 @@ DEFINES += HAVE_BAGL_FONT_OPEN_SANS_EXTRABOLD_11PX
DEFINES += HAVE_BAGL_FONT_OPEN_SANS_LIGHT_16PX
DEFINES += HAVE_UX_FLOW
endif

endif

# Enabling debug PRINTF
DEBUG:= 0
ifneq ($(DEBUG),0)
DEFINES += HAVE_STACK_OVERFLOW_CHECK
SDK_SOURCE_PATH += lib_stusb lib_stusb_impl lib_u2f
SDK_SOURCE_PATH += lib_stusb lib_stusb_impl
DEFINES += HAVE_IO_USB HAVE_L4_USBLIB IO_USB_MAX_ENDPOINTS=4 IO_HID_EP_LENGTH=64 HAVE_USB_APDU

ifeq ($(DEBUG),10)
Expand Down Expand Up @@ -122,27 +130,23 @@ endif

CC := $(CLANGPATH)clang

CFLAGS += -Oz

AS := $(GCCPATH)arm-none-eabi-gcc

LD := $(GCCPATH)arm-none-eabi-gcc
LDFLAGS += -O3 -Os
LDLIBS += -lm -lgcc -lc

# import rules to compile glyphs(/pone)
include $(BOLOS_SDK)/Makefile.glyphs

### variables processed by the common makefile.rules of the SDK to grab source files and include dirs
APP_SOURCE_PATH += src $(ETHEREUM_PLUGIN_SDK)
ifneq ($(TARGET_NAME), TARGET_STAX)
SDK_SOURCE_PATH += lib_ux
endif
ifneq (,$(findstring HAVE_BLE,$(DEFINES)))
SDK_SOURCE_PATH += lib_blewbxx lib_blewbxx_impl
endif

# remove UX warnings from SDK even though the plugin doesn't use it
DEFINES += HAVE_UX_FLOW

### initialize plugin SDK submodule if needed
ifneq ($(shell git submodule status | grep '^[-+]'),)
$(info INFO: Need to reinitialize git submodules)
Expand All @@ -163,5 +167,4 @@ include $(BOLOS_SDK)/Makefile.rules
dep/%.d: %.c Makefile

listvariants:
# EDIT THIS: replace `boilerplate` by the lowercase name of your plugin
@echo VARIANTS NONE staderlabs
2 changes: 1 addition & 1 deletion ethereum-plugin-sdk
Binary file added glyphs/stax_staderlabs_64px.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/stax_app_staderlabs.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 19 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "os.h"
#include "cx.h"
#include "glyphs.h"

#include "staderlabs_plugin.h"

Expand Down Expand Up @@ -155,10 +156,27 @@ void handle_query_ui_exception(unsigned int *args) {

// Calls the ethereum app.
void call_app_ethereum() {
unsigned int libcall_params[3];
unsigned int libcall_params[5];

libcall_params[0] = (unsigned int) "Ethereum";
libcall_params[1] = 0x100;
libcall_params[2] = RUN_APPLICATION;
libcall_params[3] = (unsigned int) NULL;
#ifdef HAVE_NBGL
caller_app_t capp;
char name[] = APPNAME;
nbgl_icon_details_t icon_details;
uint8_t bitmap[sizeof(ICONBITMAP)];

memcpy(&icon_details, &ICONGLYPH, sizeof(ICONGLYPH));
memcpy(&bitmap, &ICONBITMAP, sizeof(bitmap));
icon_details.bitmap = (const uint8_t *) bitmap;
capp.name = name;
capp.icon = &icon_details;
libcall_params[4] = (unsigned int) &capp;
#else
libcall_params[4] = (unsigned int) NULL;
#endif
os_lib_call((unsigned int *) &libcall_params);
}

Expand Down

0 comments on commit 8a3955c

Please sign in to comment.