Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/jm@add-bluetooth' into ledgerhq-…
Browse files Browse the repository at this point in the history
…2-2-1-with-bluetooth
  • Loading branch information
matthewbauer committed Nov 4, 2019
2 parents 8dd8b10 + a7b5bf9 commit ba17453
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 25 deletions.
8 changes: 6 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ For development, use `nix/watch.sh s make APP=<tezos_baking|tezos_wallet>` to in
To do a full Nix build run `nix/build.sh`. You can pass `nix-build` arguments to this to build specific attributes, e.g. `nix/build.sh -A nano.s.wallet`.

### Installing
`nix/install.sh` will install both the wallet and baking apps. Use `nix/install.sh baking` to install just the baking app or `nix/install.sh wallet` to install just the wallet.
`nix/install.sh` will install both the wallet and baking apps. Use
`nix/install.sh s baking` to install just the baking app or
`nix/install.sh s wallet` to install just the wallet.

### Editor Integration

Expand All @@ -28,7 +30,9 @@ To do a full Nix build run `nix/build.sh`. You can pass `nix-build` arguments to

### Releasing

`nix/build.sh -A release.all`
`nix/build.sh -A nano.s.release.all`

`nix/build.sh -A nano.x.release.all`

### Notes on testing

Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ APPNAME = "Tezos Baking"
else ifeq ($(APP),tezos_wallet)
APPNAME = "Tezos Wallet"
endif
APP_LOAD_PARAMS=--appFlags 0 --curve ed25519 --curve secp256k1 --curve prime256r1 --path "44'/1729'" $(COMMON_LOAD_PARAMS)
APP_LOAD_PARAMS= --appFlags 0 --curve ed25519 --curve secp256k1 --curve prime256r1 --path "44'/1729'" $(COMMON_LOAD_PARAMS)

GIT_DESCRIBE ?= $(shell git describe --tags --abbrev=8 --always --long --dirty 2>/dev/null)

Expand Down Expand Up @@ -68,6 +68,7 @@ DEFINES += COMMIT=\"$(COMMIT)\" APPVERSION_N=$(APPVERSION_N) APPVERSION_P=$(AP
# DEFINES += _Static_assert\(...\)=

ifeq ($(TARGET_NAME),TARGET_NANOX)
APP_LOAD_PARAMS += --appFlags 0x240 # with BLE support
DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=300
DEFINES += HAVE_BLE BLE_COMMAND_TIMEOUT_MS=2000
DEFINES += HAVE_BLE_APDU # basic ledger apdu transport over BLE
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ configuration, most often the `udev` configuration. Using `sudo` for commands
that should not require it can create security vulnerabilities and corrupt
your configuration.

##Hacking
## Hacking

See [CONTRIBUTING.md](CONTRIBUTING.md)

Expand Down
18 changes: 12 additions & 6 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,18 @@ let
release = rec {
wallet = mkRelease "wallet" "Tezos Wallet" walletApp;
baking = mkRelease "baking" "Tezos Baking" bakingApp;
all = pkgs.runCommand "${bolos.name}-release.tar.gz" {} ''
cp -r '${wallet}' wallet
cp -r '${baking}' baking
cp '${./release-installer.sh}' install.sh
chmod +x install.sh
tar czf "$out" install.sh wallet baking
all = pkgs.runCommand "ledger-app-tezos-${bolos.name}.tar.gz" {} ''
mkdir ledger-app-tezos-${bolos.name}
cp -r ${wallet} ledger-app-tezos-${bolos.name}/wallet
# No baking app for Nano X yet
${pkgs.lib.optionalString (bolos.name == "s") ''
cp -r ${baking} ledger-app-tezos-${bolos.name}/baking
''}
install -m a=rx ${./release-installer.sh} ledger-app-tezos-${bolos.name}/install.sh
tar czf $out ledger-app-tezos-${bolos.name}/*
'';
};
};
Expand Down
4 changes: 3 additions & 1 deletion nix/build.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/usr/bin/env bash
set -Eeuo pipefail

root="$(git rev-parse --show-toplevel)"

# Override package set by passing --arg pkgs

descr=$(git describe --tags --abbrev=8 --always --long --dirty 2>/dev/null)
echo >&2 "Git description: $descr"
exec nix-build --no-out-link --argstr gitDescribe "$descr" "$@" ${NIX_BUILD_ARGS:-}
exec nix-build "$root" --no-out-link --argstr gitDescribe "$descr" "$@" ${NIX_BUILD_ARGS:-}
33 changes: 20 additions & 13 deletions nix/install.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
#!/usr/bin/env bash
#! /usr/bin/env nix-shell
#! nix-shell -i bash ./ledgerblue.nix -A shell

set -Eeuo pipefail

export target="${1:?Please specify target, either 's' for Nano S or 'x' for Nano X}"
root="$(git rev-parse --show-toplevel)"

target="${1:?Please specify target, either 's' for Nano S or 'x' for Nano X}"
shift

root="$(git rev-parse --show-toplevel)"
export root
case "$target" in
s) ;; x) ;;
*)
>&2 echo "Target must either be 's' for Nano S or 'x' for Nano X"
exit 1
esac

install() {
local app=$1
shift
local release_file
release_file=$("$root/nix/build.sh" -A "nano.${target}.release.$1")
release_file=$("$root/nix/build.sh" -A "nano.$target.release.$app" "$@")
bash "$root/release-installer.sh" "$release_file"
}
export -f install

nix-shell "$root/nix/ledgerblue.nix" -A shell --run "$(cat <<EOF
set -Eeuo pipefail
if [ $# -eq 0 ]; then
install wallet
install baking
install wallet "$@"
install baking "$@"
else
install "${1:-}"
app="$1"
shift
install "$app" "$@"
fi
EOF
)"
30 changes: 30 additions & 0 deletions nix/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p gitAndTools.hub coreutils

root="$(cd "$(dirname "${BASH_SOURCE[0]}")" && git rev-parse --show-toplevel)"

nano_s_tarball=$("$root/nix/build.sh" -A "nano.s.release.all" "$@")
nano_x_tarball=$("$root/nix/build.sh" -A "nano.x.release.all" "$@")

cp -f $nano_s_tarball nano-s-release.tar.gz
cp -f $nano_x_tarball nano-x-release.tar.gz

# hub release create \
# -a $nano_s_tarball'#'nano-s-release.tar.gz \
# -a $nano_x_tarball'#'nano-x-release.tar.gz \
# -F -

echo '## Checksums'
echo '### nano-s-release.tar.gz'
echo 'Type | Value'
echo '-- | --'
echo "MD5 | $(md5sum nano-s-release.tar.gz | cut -f1 -d' ')"
echo "SHA256 | $(sha256sum nano-s-release.tar.gz | cut -f1 -d' ')"
echo "SHA512 | $(sha512sum nano-s-release.tar.gz | cut -f1 -d' ')"

echo '### nano-x-release.tar.gz'
echo 'Type | Value'
echo '-- | --'
echo "MD5 | $(md5sum nano-x-release.tar.gz | cut -f1 -d' ')"
echo "SHA256 | $(sha256sum nano-x-release.tar.gz | cut -f1 -d' ')"
echo "SHA512 | $(sha512sum nano-x-release.tar.gz | cut -f1 -d' ')"
8 changes: 7 additions & 1 deletion release-installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@ for arg in "$@"; do
echo

set -x

appFlag="0x00"
if [ $target == "nano_x" ]; then
appFlag="0x240"
fi

python -m ledgerblue.loadApp \
--appFlags 0x00 \
--appFlags "$appFlag" \
--dataSize "${nvram_size:?manifest file is missing field}" \
--tlv \
--curve ed25519 \
Expand Down
11 changes: 11 additions & 0 deletions src/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,20 @@ __attribute__((section(".boot"))) int main(void) {

io_seproxyhal_init();

#ifdef TARGET_NANOX
// grab the current plane mode setting
// requires "--appFlag 0x240" to be set in makefile
G_io_app.plane_mode = os_setting_get(OS_SETTING_PLANEMODE, NULL, 0);
#endif // TARGET_NANOX

USB_power(0);
USB_power(1);

#ifdef HAVE_BLE
BLE_power(0, NULL);
BLE_power(1, "Nano X");
#endif // HAVE_BLE

ui_initial_screen();

app_main();
Expand Down

0 comments on commit ba17453

Please sign in to comment.