Skip to content

Commit 8baa318

Browse files
shufpsTamtamHeroEdouard Merle
authored
Update for Ledger Nano S Plus (#86)
* Remove standalone sha3, prepare for auto deploy and set release flags * add missing includes * bump version to 0.5.6 * Rename the app to IOTA Legacy * Bump version 0.5.7 * updated makefile to latest boilerplate * updated code with changed for ledger nano s plus, remove blue * updated docker * removed blue sdk, added nano x and nano s plus sdk * deleted blue-secure-sdk * added and updated submodules * small fix after removing blue; small change because of updated boilerplate * removed unused dockerfile * fix for build scripts to be able to also build / run simulator with ./docker/... * updated READMEs * fix for run_simulator.sh for running it from root directory of repository * unified build.sh for compiling, loading, running speculos * added some message that is printed after the start of speculos * removed automatic debug when compiling for speculos * get appname and version from makefile; needed to set speculos_appname correctly * updated workflow * update workflow * removed -ti from docker run for github actions * added exit code at end of script * conditional cx.h (for automatic testings) * changed back to APPVERSION_(MAJOR|MINOR|PATCH) for compatibility with testing * fixed wrong returns * changed building and loading instructions for current build.sh script * Allow %u in sprintf * changed empty-sdk-directory check * added -g|--gdb switch for starting speculos in debug mode (waiting for gdb) Co-authored-by: TamtamHero <10632523+TamtamHero@users.noreply.github.com> Co-authored-by: Edouard Merle <edouard.merle@ledger.fr>
1 parent e433854 commit 8baa318

31 files changed

+366
-977
lines changed

.github/workflows/build.yml

+3-6
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,18 @@ name: Build
22

33
on: [push, pull_request]
44

5-
env:
6-
DOCKER_IMAGE: 'wollac/ledger-bolos'
7-
85
jobs:
96
build:
107
runs-on: ubuntu-latest
118

129
strategy:
1310
matrix:
14-
sdk-version: ['nanos-secure-sdk', 'blue-secure-sdk']
11+
device: ['nanos', 'nanox', 'nanosplus']
1512

1613
steps:
1714
- uses: actions/checkout@v2
1815
with:
1916
submodules: recursive
2017

21-
- name: Build using ${{ matrix.sdk-version }}
22-
run: docker run -u $(id -u):$(id -g) -v $(pwd):/project -e BOLOS_SDK=/project/dev/sdk/${{ matrix.sdk-version }} $DOCKER_IMAGE make -C /project
18+
- name: Build using ${{ matrix.device }}
19+
run: ./build.sh -m ${{ matrix.device }}

.github/workflows/clang.yml

-36
This file was deleted.

.gitmodules

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1-
[submodule "dev/sdk/blue-secure-sdk"]
2-
path = dev/sdk/blue-secure-sdk
3-
url = https://github.com/LedgerHQ/blue-secure-sdk.git
41
[submodule "dev/sdk/nanos-secure-sdk"]
52
path = dev/sdk/nanos-secure-sdk
63
url = https://github.com/LedgerHQ/nanos-secure-sdk.git
74
[submodule "tests"]
85
path = tests
96
url = https://github.com/IOTA-Ledger/ledger-app-iota-tests.git
107
branch = master
8+
[submodule "dev/sdk/nanox-secure-sdk"]
9+
path = dev/sdk/nanox-secure-sdk
10+
url = https://github.com/LedgerHQ/nanox-secure-sdk
11+
[submodule "dev/sdk/nanosplus-secure-sdk"]
12+
path = dev/sdk/nanosplus-secure-sdk
13+
url = https://github.com/LedgerHQ/nanosplus-secure-sdk
14+
[submodule "dev/speculos"]
15+
path = dev/speculos
16+
url = https://github.com/LedgerHQ/speculos

Dockerfile

-55
This file was deleted.

Makefile

+60-91
Original file line numberDiff line numberDiff line change
@@ -1,113 +1,89 @@
1-
#*******************************************************************************
2-
# Ledger App
3-
# (c) 2017 Ledger
1+
# ****************************************************************************
2+
# Ledger App Boilerplate
3+
# (c) 2020 Ledger SAS.
44
#
5-
# Licensed under the Apache License, Version 2.0 (the "License");
6-
# you may not use this file except in compliance with the License.
7-
# You may obtain a copy of the License at
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
88
#
9-
# http://www.apache.org/licenses/LICENSE-2.0
9+
# http://www.apache.org/licenses/LICENSE-2.0
1010
#
11-
# Unless required by applicable law or agreed to in writing, software
12-
# distributed under the License is distributed on an "AS IS" BASIS,
13-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
# See the License for the specific language governing permissions and
15-
# limitations under the License.
16-
#*******************************************************************************
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
# ****************************************************************************
1717

1818
ifeq ($(BOLOS_SDK),)
19-
$(error Environment variable BOLOS_SDK is not set)
19+
$(error Environment variable BOLOS_SDK is not set)
2020
endif
21+
2122
include $(BOLOS_SDK)/Makefile.defines
2223

23-
APPNAME = "IOTA"
24-
APPVERSION_MAJOR = 0
25-
APPVERSION_MINOR = 5
26-
APPVERSION_PATCH = 5
27-
APPVERSION = $(APPVERSION_MAJOR).$(APPVERSION_MINOR).$(APPVERSION_PATCH)
2824
APP_LOAD_PARAMS = --path "44'/4218'" --appFlags 0x240 $(COMMON_LOAD_PARAMS)
2925

30-
ifeq ($(TARGET_NAME),TARGET_BLUE)
31-
ICONNAME = icons/blue_app_iota.gif
32-
else ifeq ($(TARGET_NAME),TARGET_NANOX)
33-
ICONNAME = icons/nanox_app_iota.gif
34-
else ifeq ($(TARGET_NAME),TARGET_NANOS)
35-
ICONNAME = icons/nanos_app_iota.gif
26+
APPNAME = "IOTA Legacy"
27+
APPVERSION_M = 0
28+
APPVERSION_N = 5
29+
APPVERSION_P = 9
30+
APPVERSION = "$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)"
31+
32+
ifeq ($(TARGET_NAME),TARGET_NANOS)
33+
ICONNAME=icons/nanos_app_iota.gif
3634
else
37-
$(error unexpected target: $(TARGET_NAME))
35+
ICONNAME=icons/nanox_app_iota.gif
3836
endif
3937

40-
41-
################
42-
# Default rule #
43-
################
4438
all: default
4539

46-
############
47-
# Platform #
48-
############
49-
5040
DEFINES += $(DEFINES_LIB)
51-
41+
DEFINES += APPNAME=\"$(APPNAME)\"
42+
DEFINES += APPVERSION=\"$(APPVERSION)\"
43+
DEFINES += APPVERSION_MAJOR=$(APPVERSION_M) APPVERSION_MINOR=$(APPVERSION_N) APPVERSION_PATCH=$(APPVERSION_P)
5244
DEFINES += OS_IO_SEPROXYHAL
53-
DEFINES += HAVE_BAGL HAVE_SPRINTF HAVE_SNPRINTF_FORMAT_U
45+
DEFINES += HAVE_BAGL HAVE_UX_FLOW HAVE_SPRINTF HAVE_SNPRINTF_FORMAT_U
5446
DEFINES += HAVE_IO_USB HAVE_L4_USBLIB IO_USB_MAX_ENDPOINTS=6 IO_HID_EP_LENGTH=64 HAVE_USB_APDU
55-
DEFINES += LEDGER_MAJOR_VERSION=$(APPVERSION_MAJOR) LEDGER_MINOR_VERSION=$(APPVERSION_MINOR) LEDGER_PATCH_VERSION=$(APPVERSION_PATCH)
56-
57-
# U2F
58-
DEFINES += HAVE_U2F HAVE_IO_U2F
59-
DEFINES += U2F_PROXY_MAGIC=\"IOT\"
6047
DEFINES += USB_SEGMENT_SIZE=64
61-
DEFINES += BLE_SEGMENT_SIZE=32 #max MTU, min 20
62-
63-
# WebUSB
64-
WEBUSB_URL = www.ledgerwallet.com
65-
DEFINES += HAVE_WEBUSB WEBUSB_URL_SIZE_B=$(shell echo -n $(WEBUSB_URL) | wc -c) WEBUSB_URL=$(shell echo -n $(WEBUSB_URL) | sed -e "s/./\\\'\0\\\',/g")
66-
67-
DEFINES += APPVERSION_MAJOR=$(APPVERSION_MAJOR)
68-
DEFINES += APPVERSION_MINOR=$(APPVERSION_MINOR)
69-
DEFINES += APPVERSION_PATCH=$(APPVERSION_PATCH)
70-
DEFINES += APPVERSION=\"$(APPVERSION)\"
71-
48+
DEFINES += BLE_SEGMENT_SIZE=32
49+
DEFINES += HAVE_WEBUSB WEBUSB_URL_SIZE_B=0 WEBUSB_URL=""
50+
DEFINES += UNUSED\(x\)=\(void\)x
7251

7352
ifeq ($(TARGET_NAME),TARGET_NANOX)
74-
DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=300
75-
DEFINES += HAVE_BLE BLE_COMMAND_TIMEOUT_MS=2000
76-
DEFINES += HAVE_BLE_APDU # basic ledger apdu transport over BLE
53+
DEFINES += HAVE_BLE BLE_COMMAND_TIMEOUT_MS=2000 HAVE_BLE_APDU
54+
endif
7755

56+
ifeq ($(TARGET_NAME),TARGET_NANOS)
57+
DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=128
58+
else
59+
# nanox, nanosplus
60+
DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=300
7861
DEFINES += HAVE_GLO096
79-
DEFINES += HAVE_BAGL BAGL_WIDTH=128 BAGL_HEIGHT=64
80-
DEFINES += HAVE_BAGL_ELLIPSIS # long label truncation feature
62+
DEFINES += BAGL_WIDTH=128 BAGL_HEIGHT=64
63+
DEFINES += HAVE_BAGL_ELLIPSIS
8164
DEFINES += HAVE_BAGL_FONT_OPEN_SANS_REGULAR_11PX
8265
DEFINES += HAVE_BAGL_FONT_OPEN_SANS_EXTRABOLD_11PX
8366
DEFINES += HAVE_BAGL_FONT_OPEN_SANS_LIGHT_16PX
84-
DEFINES += HAVE_UX_FLOW
85-
else
86-
DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=128
8767
endif
8868

89-
DEBUG = 1
69+
DEBUG = 0
9070
ifneq ($(DEBUG),0)
91-
# Development flags
9271
APP_LOAD_PARAMS += --path "44'/01'"
93-
DEFINES += HAVE_BOLOS_APP_STACK_CANARY
94-
ifeq ($(TARGET_NAME),TARGET_NANOX)
95-
DEFINES += HAVE_PRINTF PRINTF=mcu_usb_printf
72+
DEFINES += HAVE_BOLOS_APP_STACK_CANARY
73+
ifeq ($(TARGET_NAME),TARGET_NANOS)
74+
DEFINES += PRINTF=screen_printf
9675
else
97-
DEFINES += HAVE_PRINTF PRINTF=screen_printf
76+
# nanox, nanosplus
77+
DEFINES += PRINTF=mcu_usb_printf
9878
endif
9979
else
100-
# Release flags
101-
DEFINES += PRINTF\(...\)=
80+
DEFINES += PRINTF\(...\)=
10281
endif
10382

104-
##############
105-
# Compiler #
106-
##############
10783
ifneq ($(BOLOS_ENV),)
10884
$(info BOLOS_ENV=$(BOLOS_ENV))
10985
CLANGPATH := $(BOLOS_ENV)/clang-arm-fropi/bin/
110-
GCCPATH := $(BOLOS_ENV)/gcc-arm-none-eabi-5_3-2016q1/bin/
86+
GCCPATH := $(BOLOS_ENV)/gcc-arm-none-eabi-5_3-2016q1/bin/
11187
else
11288
$(info BOLOS_ENV is not set: falling back to CLANGPATH and GCCPATH)
11389
endif
@@ -118,41 +94,34 @@ ifeq ($(GCCPATH),)
11894
$(info GCCPATH is not set: arm-none-eabi-* will be used from PATH)
11995
endif
12096

121-
CC := $(CLANGPATH)clang
122-
CFLAGS += -O3 -Os
123-
124-
AS := $(GCCPATH)arm-none-eabi-gcc
125-
AFLAGS +=
126-
127-
LD := $(GCCPATH)arm-none-eabi-gcc
97+
CC := $(CLANGPATH)clang
98+
CFLAGS += -O3 -Os
99+
AS := $(GCCPATH)arm-none-eabi-gcc
100+
LD := $(GCCPATH)arm-none-eabi-gcc
128101
LDFLAGS += -O3 -Os
129-
LDLIBS += -lm -lgcc -lc
102+
LDLIBS += -lm -lgcc -lc
130103

131-
# import rules to compile glyphs(/pone)
132104
include $(BOLOS_SDK)/Makefile.glyphs
133105

134-
### variables processed by the common makefile.rules of the SDK to grab source files and include dirs
135106
APP_SOURCE_PATH += src
136-
SDK_SOURCE_PATH += lib_stusb lib_stusb_impl lib_u2f
107+
SDK_SOURCE_PATH += lib_stusb lib_stusb_impl lib_ux
137108

138109
ifeq ($(TARGET_NAME),TARGET_NANOX)
139110
SDK_SOURCE_PATH += lib_blewbxx lib_blewbxx_impl
140-
SDK_SOURCE_PATH += lib_ux
141111
endif
142112

143113
load: all
144-
python -m ledgerblue.loadApp $(APP_LOAD_PARAMS)
114+
python3 -m ledgerblue.loadApp $(APP_LOAD_PARAMS)
115+
116+
load-offline: all
117+
python3 -m ledgerblue.loadApp $(APP_LOAD_PARAMS) --offline
145118

146119
delete:
147-
python -m ledgerblue.deleteApp $(COMMON_DELETE_PARAMS)
120+
python3 -m ledgerblue.deleteApp $(COMMON_DELETE_PARAMS)
148121

149-
# import generic rules from the sdk
150122
include $(BOLOS_SDK)/Makefile.rules
151123

152-
#add dependency on custom makefile filename
153124
dep/%.d: %.c Makefile
154125

155-
156-
157126
listvariants:
158-
@echo VARIANTS COIN iota
127+
@echo VARIANTS COIN iota_legacy

0 commit comments

Comments
 (0)