Skip to content

Commit

Permalink
Experimenting with a simple cli tool
Browse files Browse the repository at this point in the history
  • Loading branch information
jleni committed Feb 26, 2018
1 parent cb56226 commit 88f12e4
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,11 @@
cmake-build-debug/

\.idea/workspace\.xml

\.idea/

src/ledger/bin/

src/ledger/debug/

src/ledger/obj/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ledger-ci
# ledger-ci-test

[![CircleCI](https://circleci.com/gh/jleni/ledger-ci-test.svg?style=svg)](https://circleci.com/gh/jleni/ledger-ci-test)

Expand Down
65 changes: 65 additions & 0 deletions nanocli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/env bash

SCRIPT_DIR=$(cd `dirname $0` && pwd)

handle_config()
{
os_string="$(uname -s)"
case "${os_string}" in
Linux*)
apt-get install libusb-1.0.0
apt-get install libudev-dev
;;
Darwin*)
brew install python3
brew install libusb
;;
*)
echo "OS not recognized"
;;
esac

pip3 install ledgerblue==0.1.15
}

handle_build()
{
# This function works in the scope of the container
DOCKER_IMAGE=zondax/builder_bolos
BOLOS_SDK=/root/project/deps/nanos-secure-sdk
BOLOS_ENV=/opt/bolos

docker run -it --rm \
-e BOLOS_SDK=${BOLOS_SDK} \
-e BOLOS_ENV=${BOLOS_ENV} \
-v $(pwd):/root/project \
${DOCKER_IMAGE} \
make -C /root/project/src/ledger $1
}

handle_load()
{
# This function works in the scope of the host
export BOLOS_SDK=${SCRIPT_DIR}/deps/nanos-secure-sdk
export BOLOS_ENV=/opt/bolos
make -C ${SCRIPT_DIR}/src/ledger load
}

handle_delete()
{
# This function works in the scope of the host
export BOLOS_SDK=${SCRIPT_DIR}/deps/nanos-secure-sdk
export BOLOS_ENV=/opt/bolos
make -C ${SCRIPT_DIR}/src/ledger delete
}

case "$1" in
build) handle_build;;
config) handle_config;;
load) handle_load;;
delete) handle_delete;;
upgrade) handle_delete && handle_load;;
*)
echo "ERROR. Valid commands: make, config, load, delete"
;;
esac
4 changes: 2 additions & 2 deletions src/ledger/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ SDK_SOURCE_PATH += lib_stusb lib_stusb_impl
all: default

load: all
python -m ledgerblue.loadApp $(APP_LOAD_PARAMS)
python3 -m ledgerblue.loadApp $(APP_LOAD_PARAMS)

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

# Import generic rules from the SDK

Expand Down
8 changes: 8 additions & 0 deletions src/ledger/main.c → src/ledger/src/main.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#include <os_io_seproxyhal.h>

ux_state_t ux;
unsigned char G_io_seproxyhal_spi_buffer[IO_SEPROXYHAL_BUFFER_SIZE_B];

void ui_init() {}
void app_init() {}
void app_main() {}
unsigned char io_event(unsigned char channel) { return 1; }

__attribute__((section(".boot"))) int
main(void)
{
Expand Down

0 comments on commit 88f12e4

Please sign in to comment.