Skip to content

Commit

Permalink
Merge pull request #195 from Zondax/ready-to-merge
Browse files Browse the repository at this point in the history
Support for SNS, NNS and ICRC
  • Loading branch information
ftheirs authored Feb 6, 2023
2 parents 912c522 + d0af1da commit f09b1f4
Show file tree
Hide file tree
Showing 465 changed files with 8,764 additions and 2,810 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ file(GLOB_RECURSE LIB_SRC
${CMAKE_CURRENT_SOURCE_DIR}/app/src/crypto.c
${CMAKE_CURRENT_SOURCE_DIR}/app/src/base32.c
${CMAKE_CURRENT_SOURCE_DIR}/app/src/protobuf/*.c
${CMAKE_CURRENT_SOURCE_DIR}/app/src/parser_print_*.c
)

add_library(app_lib STATIC
Expand Down
157 changes: 7 additions & 150 deletions app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,13 @@ endif

MY_DIR := $(dir $(lastword $(MAKEFILE_LIST)))

all: bin/app.elf
@echo "#!/usr/bin/env bash" > $(OUTPUT_INSTALLER)
@echo "APPNAME=\"${APPNAME}\"" >> $(OUTPUT_INSTALLER)
@echo "APPVERSION=\"${APPVERSION}\"" >> $(OUTPUT_INSTALLER)
@echo "APPPATH=\""${APPPATH}"\"" >> $(OUTPUT_INSTALLER)
@echo "LOAD_PARAMS=($$(echo "${APP_LOAD_PARAMS}" | sed -e "s|"${APPNAME}"|\""${APPNAME}"\"|"))" >> $(OUTPUT_INSTALLER)
@echo "DELETE_PARAMS=($$(echo "${COMMON_DELETE_PARAMS}" | sed -e "s|"${APPNAME}"|\""${APPNAME}"\"|"))" >> $(OUTPUT_INSTALLER)
@echo "APPHEX=\"" >> $(OUTPUT_INSTALLER)
@cat $(CURDIR)/bin/app.hex >> $(OUTPUT_INSTALLER)
@echo "\"" >> $(OUTPUT_INSTALLER)
@cat $(CURDIR)/../deps/ledger-zxlib/scripts/template.sh >> $(OUTPUT_INSTALLER)
@chmod +x $(OUTPUT_INSTALLER)
@cp $(CURDIR)/bin/* $(CURDIR)/output
@cp $(CURDIR)/output/app.elf ${OUTPUT_ELF}
@rm $(CURDIR)/output/app.elf
include $(CURDIR)/../deps/ledger-zxlib/makefiles/Makefile.installer_script

include $(BOLOS_SDK)/Makefile.defines

$(info ************ TARGET_NAME = [$(TARGET_NAME)])

ifeq ($(APP_TESTING),1)
DEFINES += APP_TESTING
DEFINES += ZEMU_LOGGING
$(info ************ LOGGING ENABLED ************)
endif
include $(CURDIR)/../deps/ledger-zxlib/makefiles/Makefile.app_testing

ifndef COIN
COIN=ICP
Expand All @@ -66,41 +48,17 @@ else ifeq ($(COIN),ICP_INVALID)
else
define error_message


COIN value not supported: [$(COIN)]


endef
$(error "$(error_message)")
endif

APP_LOAD_PARAMS = --delete $(COMMON_LOAD_PARAMS) --path $(APPPATH) --path "44'/1'"

ifeq ($(TARGET_NAME),TARGET_NANOS)
APP_STACK_SIZE:=2050
ICONNAME:=$(CURDIR)/nanos_icon.gif
OUTPUT_ELF ?= $(CURDIR)/output/app_s.elf
OUTPUT_INSTALLER := $(CURDIR)/pkg/installer_s.sh
DEFINES += CBOR_PARSER_MAX_RECURSIONS=4
endif

ifeq ($(TARGET_NAME),TARGET_NANOX)
APP_LOAD_PARAMS += --appFlags 0x200
SCRIPT_LD:=$(CURDIR)/script_x.ld
ICONNAME:=$(CURDIR)/nanox_icon.gif
OUTPUT_ELF ?= $(CURDIR)/output/app_x.elf
OUTPUT_INSTALLER:= $(CURDIR)/pkg/installer_x.sh
DEFINES += CBOR_PARSER_MAX_RECURSIONS=16
endif
NANOS_STACK_SIZE := 2050

ifeq ($(TARGET_NAME),TARGET_NANOS2)
APP_LOAD_PARAMS += --appFlags 0x000
SCRIPT_LD:=$(CURDIR)/script_s2.ld
ICONNAME:=$(CURDIR)/nanox_icon.gif
OUTPUT_ELF ?= $(CURDIR)/output/app_s2.elf
OUTPUT_INSTALLER:= $(CURDIR)/pkg/installer_s2.sh
DEFINES += CBOR_PARSER_MAX_RECURSIONS=16
endif
include $(CURDIR)/../deps/ledger-zxlib/makefiles/Makefile.devices

$(info TARGET_NAME = [$(TARGET_NAME)])
$(info ICONNAME = [$(ICONNAME)])
Expand All @@ -109,102 +67,8 @@ ifndef ICONNAME
$(error ICONNAME is not set)
endif

############
# Platform

DEFINES += UNUSED\(x\)=\(void\)x
DEFINES += PRINTF\(...\)=

APPVERSION=$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)
DEFINES += APPVERSION=\"$(APPVERSION)\"

DEFINES += OS_IO_SEPROXYHAL
DEFINES += HAVE_BAGL HAVE_SPRINTF
DEFINES += HAVE_IO_USB HAVE_L4_USBLIB IO_USB_MAX_ENDPOINTS=7 IO_HID_EP_LENGTH=64 HAVE_USB_APDU

DEFINES += LEDGER_MAJOR_VERSION=$(APPVERSION_M) LEDGER_MINOR_VERSION=$(APPVERSION_N) LEDGER_PATCH_VERSION=$(APPVERSION_P)

DEFINES += USB_SEGMENT_SIZE=64
DEFINES += HAVE_BOLOS_APP_STACK_CANARY

DEFINES += HAVE_WEBUSB WEBUSB_URL_SIZE_B=0 WEBUSB_URL=""

ifeq ($(TARGET_NAME),TARGET_NANOS)
DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=128
else
# Assume Nano X/S+
DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=300

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

DEFINES += HAVE_UX_FLOW
endif

ifeq ($(TARGET_NAME),TARGET_NANOX)
# X specific
DEFINES += HAVE_BLE
DEFINES += HAVE_BLE_APDU BLE_COMMAND_TIMEOUT_MS=2000

SDK_SOURCE_PATH += lib_blewbxx lib_blewbxx_impl
endif

# App specific

#Feature temporarily disabled
DEFINES += LEDGER_SPECIFIC

# Compiler, assembler, and linker

ifneq ($(BOLOS_ENV),)
$(info BOLOS_ENV is $(BOLOS_ENV))
CLANGPATH := /usr/bin/
GCCPATH := /usr/bin/
else
$(info BOLOS_ENV is not set: falling back to CLANGPATH and GCCPATH)
endif

ifeq ($(CLANGPATH),)
$(info CLANGPATH is not set: clang will be used from PATH)
endif

ifeq ($(GCCPATH),)
$(info GCCPATH is not set: arm-none-eabi-* will be used from PATH)
endif

#########################

CC := $(CLANGPATH)clang
CFLAGS += -O3 -Os -Wno-unknown-pragmas -Wvla -Wno-implicit-fallthrough

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

LD := $(GCCPATH)arm-none-eabi-gcc
LDFLAGS += -O3 -Os
LDLIBS += -lm -lgcc -lc
#LDLIBS += -Lrust/target/thumbv6m-none-eabi/release -lrslib

##########################
GLYPH_SRC_DIR = glyphs
INCLUDES_PATH += $(MY_DIR)/glyphs
include $(BOLOS_SDK)/Makefile.glyphs

APP_SOURCE_PATH += $(MY_DIR)/../deps/picohash/
APP_SOURCE_PATH += $(MY_DIR)/src
APP_SOURCE_PATH += $(MY_DIR)/glyphs
APP_SOURCE_PATH += $(MY_DIR)/../deps/ledger-zxlib/include
APP_SOURCE_PATH += $(MY_DIR)/../deps/ledger-zxlib/src
APP_SOURCE_PATH += $(MY_DIR)/../deps/ledger-zxlib/app/common

SDK_SOURCE_PATH += lib_stusb lib_stusb_impl
SDK_SOURCE_PATH += lib_ux

# NanoX SDK does not allow += in APP_SOURCE_PATH or INCLUDES_PATH
include $(CURDIR)/../deps/ledger-zxlib/makefiles/Makefile.platform
CFLAGS += -Wvla -Wno-implicit-fallthrough
CFLAGS += -I$(MY_DIR)/../deps/tinycbor/src
APP_SOURCE_PATH += $(MY_DIR)/../deps/tinycbor-ledger

Expand All @@ -226,14 +90,7 @@ rust_clean:

clean: rust_clean

# load, delete and listvariants are provided to comply with Ledger requirements
.PHONY: load
load:
python3 -m ledgerblue.loadApp $(APP_LOAD_PARAMS)

.PHONY: delete
delete:
python3 -m ledgerblue.deleteApp $(COMMON_DELETE_PARAMS)
include $(CURDIR)/../deps/ledger-zxlib/makefiles/Makefile.side_loading

# Import generic rules from the SDK
include $(BOLOS_SDK)/Makefile.rules
Expand Down
4 changes: 2 additions & 2 deletions app/Makefile.version
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This is the major version of this release
APPVERSION_M=2
# This is the minor version of this release
APPVERSION_N=2
APPVERSION_N=3
# This is the patch version of this release
APPVERSION_P=1
APPVERSION_P=0
Binary file modified app/glyphs/icon_app.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 modified app/nanos_icon.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 modified app/nanox_icon.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f09b1f4

Please sign in to comment.