Skip to content

Commit

Permalink
Merge pull request #43 from Zondax/support_nanos2
Browse files Browse the repository at this point in the history
Support nanos plus device
  • Loading branch information
jleni authored Mar 17, 2022
2 parents 0e4fd99 + 557c0a2 commit ec1bdcf
Show file tree
Hide file tree
Showing 244 changed files with 385 additions and 52 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/check_version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: "Verify PRs to main"

on:
workflow_dispatch:
pull_request:
branches:
- main

jobs:
configure:
runs-on: ubuntu-latest
outputs:
uid_gid: ${{ steps.get-user.outputs.uid_gid }}
steps:
- id: get-user
run: echo "::set-output name=uid_gid::$(id -u):$(id -g)"

get_version:
needs: configure
runs-on: ubuntu-latest
container:
image: zondax/builder-bolos:latest
options: --user ${{ needs.configure.outputs.uid_gid }}
env:
BOLOS_ENV: /opt/bolos
HOME: /home/zondax_circle
outputs:
version: ${{ steps.store-version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true

- name: Invoke `version`
shell: bash -l {0}
env:
BOLOS_SDK: ${{ github.workspace }}/deps/nanos-secure-sdk
run: make version

- id: store-version
run: echo ::set-output name=version::$(cat ./app/app.version)

check_app_version:
needs: get_version
runs-on: ubuntu-latest
steps:
- id: checkTag
uses: mukunku/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag: ${{ needs.get_version.outputs.version }}

- run: echo ${{ steps.checkTag.outputs.exists }}

- name: Tag exists
if: ${{ steps.checkTag.outputs.exists == 'true' }}
run: exit 1
86 changes: 77 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,27 @@ jobs:
source $HOME/.cargo/env
make
build_ledger_nano_SP:
needs: configure
runs-on: ubuntu-latest
container:
image: zondax/builder-bolos:latest
options: --user ${{ needs.configure.outputs.uid_gid }}
env:
BOLOS_SDK: ${{ github.workspace }}/deps/nanosplus-secure-sdk
BOLOS_ENV: /opt/bolos
HOME: /home/zondax_circle
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true
- name: Build Standard app
shell: bash -l {0}
run: |
source $HOME/.cargo/env
make
test_zemu:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -88,8 +109,8 @@ jobs:
export PATH=~/.cargo/bin:$PATH
make zemu_test
build_package:
needs: [ configure, build_ledger_nano_S, build_ledger_nano_X, test_zemu ]
build_package_0:
needs: [ configure, build_ledger_nano_S, build_ledger_nano_X, build_ledger_nano_SP, test_zemu ]
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
container:
Expand All @@ -106,23 +127,70 @@ jobs:
submodules: true
- name: Install deps
run: pip install ledgerblue
- name: Build

- name: Build NanoS
shell: bash -l {0}
run: |
source $HOME/.cargo/env
make
- name: Set tag name var
id: vars
mv ./app/pkg/installer_s.sh ./app/pkg/installer_nanos.sh
- name: Set tag
id: nanos
run: |
pip install ledgerblue
echo ::set-output name=tag_name::$(./app/pkg/installer_s.sh version)
- name: Create or Update Release
echo ::set-output name=tag_name::$(./app/pkg/installer_nanos.sh version)
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
files: ./app/pkg/installer_s.sh
tag_name: ${{ steps.vars.outputs.tag_name }}
files: ./app/pkg/installer_nanos.sh
tag_name: ${{ steps.nanos.outputs.tag_name }}
draft: false
prerelease: false

build_package_1:
needs: [ configure, build_ledger_nano_S, build_ledger_nano_X, build_ledger_nano_SP, test_zemu ]
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
container:
image: zondax/builder-bolos:latest
options: --user ${{ needs.configure.outputs.uid_gid }}
env:
BOLOS_SDK: ${{ github.workspace }}/deps/nanosplus-secure-sdk
BOLOS_ENV: /opt/bolos
HOME: /home/zondax_circle
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true
- name: Install deps
run: pip install ledgerblue

- name: Build NanoSP
shell: bash -l {0}
run: |
source $HOME/.cargo/env
make
mv ./app/pkg/installer_s2.sh ./app/pkg/installer_nanos_plus.sh
- name: Set tag
id: nanosp
run: |
pip install ledgerblue
echo ::set-output name=tag_name::$(./app/pkg/installer_nanos_plus.sh version)
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
files: ./app/pkg/installer_nanos_plus.sh
tag_name: ${{ steps.nanosp.outputs.tag_name }}
draft: false
prerelease: false
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
[submodule "deps/nanox-secure-sdk"]
path = deps/nanox-secure-sdk
url = https://github.com/LedgerHQ/nanox-secure-sdk.git
[submodule "deps/nanosplus-secure-sdk"]
path = deps/nanosplus-secure-sdk
url = https://github.com/LedgerHQ/nanosplus-secure-sdk
2 changes: 1 addition & 1 deletion app/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ bin/app.sha256
bin/app.apdu

\output/app.*
pkg/installer_?.sh
pkg/installer_*.sh
41 changes: 27 additions & 14 deletions app/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#*******************************************************************************
# Ledger App
# (c) 2018-2021 Zondax GmbH
# (c) 2017 Ledger
# Ledger App
# (c) 2018 - 2022 Zondax GmbH
# (c) 2017 Ledger
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -73,22 +73,32 @@ endef
$(error "$(error_message)")
endif

APP_LOAD_PARAMS = --appFlags 0x200 --delete $(COMMON_LOAD_PARAMS) --path ${APPPATH} --path "44'/1'"
APP_LOAD_PARAMS = --delete $(COMMON_LOAD_PARAMS) --path ${APPPATH} --path "44'/1'"

ifeq ($(TARGET_NAME),TARGET_NANOS)
APP_LOAD_PARAMS += --appFlags 0x000
APP_STACK_SIZE:=3216
ICONNAME:=$(CURDIR)/nanos_icon.gif
OUTPUT_ELF ?= $(CURDIR)/output/app_s.elf
OUTPUT_INSTALLER := $(CURDIR)/pkg/installer_s.sh
endif

ifeq ($(TARGET_NAME),TARGET_NANOX)
APP_LOAD_PARAMS += --appFlags 0x200
APP_STACK_SIZE:=4096
ICONNAME:=$(CURDIR)/nanox_icon.gif
OUTPUT_ELF ?= $(CURDIR)/output/app_x.elf
OUTPUT_INSTALLER:= $(CURDIR)/pkg/installer_x.sh
endif

ifeq ($(TARGET_NAME),TARGET_NANOS2)
APP_LOAD_PARAMS += --appFlags 0x200
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
endif

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

Expand Down Expand Up @@ -116,7 +126,10 @@ DEFINES += HAVE_BOLOS_APP_STACK_CANARY
DEFINES += HAVE_WEBUSB WEBUSB_URL_SIZE_B=0 WEBUSB_URL=""
DEFINES += HAVE_HASH HAVE_BLAKE2 HAVE_SHA256 HAVE_SHA512

ifeq ($(TARGET_NAME),TARGET_NANOX)
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
Expand All @@ -127,20 +140,16 @@ 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
else
# Assume Nano S
DEFINES += HAVE_BAGL BAGL_WIDTH=128 BAGL_HEIGHT=32
DEFINES += BAGL_WIDTH_MARGIN=10
DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=128
endif

# X specific

# App specific

#Feature temporarily disabled
Expand Down Expand Up @@ -210,11 +219,11 @@ clean: rust_clean
# load, delete and listvariants are provided to comply with Ledger requirements
.PHONY: load
load:
python -m ledgerblue.loadApp $(APP_LOAD_PARAMS)
python3 -m ledgerblue.loadApp $(APP_LOAD_PARAMS)

.PHONY: delete
delete:
python -m ledgerblue.deleteApp $(COMMON_DELETE_PARAMS)
python3 -m ledgerblue.deleteApp $(COMMON_DELETE_PARAMS)

# Import generic rules from the SDK
include $(BOLOS_SDK)/Makefile.rules
Expand All @@ -225,3 +234,7 @@ dep/%.d: %.c Makefile
.PHONY: listvariants
listvariants:
@echo VARIANTS COIN ZEC

.PHONY: version
version:
@echo "v$(APPVERSION)" > app.version
2 changes: 1 addition & 1 deletion app/Makefile.version
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
APPVERSION_M=3
APPVERSION_N=0
APPVERSION_P=0
APPVERSION_P=1
Loading

0 comments on commit ec1bdcf

Please sign in to comment.