Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #30 from Zondax/support_nanos2
Browse files Browse the repository at this point in the history
Support nanos plus device
  • Loading branch information
ftheirs authored Mar 18, 2022
2 parents d0d0d11 + 871a140 commit 97e7f02
Show file tree
Hide file tree
Showing 128 changed files with 1,801 additions and 1,474 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/check_version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: "Verify PRs to master"

on:
pull_request:
branches:
- master

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/tag-exists-action@v1.0.0
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
98 changes: 79 additions & 19 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ jobs:
export PATH=~/.cargo/bin:$PATH
cd tests_zemu && yarn testSR25519
build_package:
build_package_0:
needs: [ configure, build, build_ledger, test_zemu, test_zemu_sr25519 ]
if: ${{ github.ref == 'refs/heads/master' }}
runs-on: ubuntu-latest
Expand All @@ -169,41 +169,101 @@ jobs:
submodules: true
- name: Install deps
run: pip install ledgerblue
- name: Build

- name: Build NanoS light
shell: bash -l {0}
run: |
source $HOME/.cargo/env
make SUBSTRATE_PARSER_FULL=0
- name: Set tag name var (1)
id: vars_1
run: echo ::set-output name=tag_name::$(./app/pkg/installer_s.sh version)
mv ./app/pkg/installer_s.sh ./app/pkg/installer_nanos_light.sh
- name: Set tag
id: nanos_light
run: echo ::set-output name=tag_name::$(./app/pkg/installer_nanos_light.sh version)
- name: Create or Update Release (1)
id: create_release_1
id: create_release_0
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_1.outputs.tag_name }}
files: ./app/pkg/installer_nanos_light.sh
tag_name: ${{ steps.nanos_light.outputs.tag_name }}
draft: false
prerelease: false
- name: Clear and rebuild XL version

build_package_1:
needs: [ configure, build, build_ledger, test_zemu, test_zemu_sr25519 ]
if: ${{ github.ref == 'refs/heads/master' }}
runs-on: ubuntu-latest
container:
image: zondax/builder-bolos:latest
options: --user ${{ needs.configure.outputs.uid_gid }}
env:
BOLOS_SDK: ${{ github.workspace }}/deps/nanos-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 NanoS XL
shell: bash -l {0}
run: |
source $HOME/.cargo/env
make SUBSTRATE_PARSER_FULL=1
cp rust/app/pkg/installer_s.sh rust/app/pkg/installer_baking_s.sh
cp app/pkg/installer_s.sh app/pkg/installer_XL_s.sh
- name: Set tag name var (2)
id: vars_2
run: echo ::set-output name=tag_name::$(./app/pkg/installer_XL_s.sh version)
- name: Create or Update Release (2)
id: create_release_2
mv ./app/pkg/installer_s.sh ./app/pkg/installer_nanos_xl.sh
- name: Set tag
id: nanos_xl
run: echo ::set-output name=tag_name::$(./app/pkg/installer_nanos_xl.sh version)
- name: Update Release
id: update_release_1
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_XL_s.sh
tag_name: ${{ steps.vars_2.outputs.tag_name }}
files: ./app/pkg/installer_nanos_xl.sh
tag_name: ${{ steps.nanos_xl.outputs.tag_name }}
draft: false
prerelease: false
prerelease: false

build_package_2:
needs: [ configure, build, build_ledger, test_zemu, test_zemu_sr25519 ]
if: ${{ github.ref == 'refs/heads/master' }}
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 XL
shell: bash -l {0}
run: |
source $HOME/.cargo/env
make SUBSTRATE_PARSER_FULL=1
mv ./app/pkg/installer_s2.sh ./app/pkg/installer_nanosp_xl.sh
- name: Set tag
id: nanosp_xl
run: echo ::set-output name=tag_name::$(./app/pkg/installer_nanosp_xl.sh version)
- name: Update Release
id: update_release_2
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_nanosp_xl.sh
tag_name: ${{ steps.nanosp_xl.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 @@ -10,3 +10,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 @@ -49,4 +49,4 @@ bin/app.apdu

\output/app.*
pkg/zxtool.sh
pkg/installer_?.sh
pkg/installer_*.sh
41 changes: 28 additions & 13 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) 2019 - 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 @@ -95,27 +95,37 @@ endef
$(error "$(error_message)")
endif

APP_LOAD_PARAMS = --appFlags 0x200 --delete $(COMMON_LOAD_PARAMS) --path $(APPPATH)
APP_LOAD_PARAMS = --curve ed25519 --delete $(COMMON_LOAD_PARAMS) --path $(APPPATH)

# Pending review parameters
APP_LOAD_PARAMS += --tlvraw 9F:01
DEFINES += HAVE_PENDING_REVIEW_SCREEN


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
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
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 ICONNAME = [$(ICONNAME)])

ifndef ICONNAME
Expand All @@ -142,7 +152,10 @@ DEFINES += HAVE_BOLOS_APP_STACK_CANARY

DEFINES += HAVE_WEBUSB WEBUSB_URL_SIZE_B=0 WEBUSB_URL=""

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 @@ -153,18 +166,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 += IO_SEPROXYHAL_BUFFER_SIZE_B=128
endif

# X specific

#Feature temporarily disabled
DEFINES += LEDGER_SPECIFIC

Expand Down Expand Up @@ -231,11 +242,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 @@ -247,6 +258,10 @@ dep/%.d: %.c Makefile
listvariants:
ifeq ($(TARGET_NAME),TARGET_NANOS)
@echo VARIANTS COIN EDG EDG_XL
else ifeq ($(TARGET_NAME),TARGET_NANOX)
else
@echo VARIANTS COIN EDG
endif

.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
Expand Up @@ -3,4 +3,4 @@ APPVERSION_M=1
# This is the `spec_version` field of `Runtime`
APPVERSION_N=46
# This is the patch version of this release
APPVERSION_P=4
APPVERSION_P=5
Loading

0 comments on commit 97e7f02

Please sign in to comment.