Even though this repo is pushed here it is (for now) intended to be a submodule of trezor-mcu repository.
Trezor-mcu contains firmware and bootloader code example for STM32 hardware.
This code aims at tranforming the cipher library from this repository into firmware for the STM32 hardware.
git clone https://github.com/mpsido/trezor-skycoin.git
cd trezor-skycoin
You should be on a branch called skycoin
wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/6-2017q2/gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2
tar xjf gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2
export PATH="gcc-arm-none-eabi-6-2017-q2-update/bin:$PATH"
The steps are the following, you can create a make_firmware.sh file with this content.
#this option is important, it prevents the bootloader from locking the firmware in case its signature is wrong
export MEMORY_PROTECT=0
make -C vendor/libopencm3/
make -C vendor/nanopb/generator/proto/
make -C firmware/protob/
make -C vendor/skycoin-crypto/
make
#Merge the bootloader and the firmware into one file
make -C bootloader/ align
make -C firmware/ sign
cp bootloader/bootloader.bin bootloader/combine/bl.bin
cp firmware/trezor.bin bootloader/combine/fw.bin
pushd bootloader/combine/ && ./prepare.py
popd;
The output binary file is combined.bin located in bootloader/combine
Follow the steps here.
You can check the device is seen by your ST-LINK using this command:
st-info --probe
To flash the device on a microcontroller of STM32f2xx family the command is:
st-flash write combined.bin 0x08000000;
cd ..
git clone https://github.com/mpsido/python-trezor.git
cd python-trezor
You need superuser priviledges for this step.
sudo apt-get -y install python-dev cython libusb-1.0-0-dev libudev-dev (note: required for python-trezor testing)
We need to tell your kernel to use the hidraw module to communicate with the hardware device. If you don't your kernel will treat the device as a mouse or a keyboard.
Create a file named 99-dev-kit.rules in your /etc/udev/rules.d/ folder and write this content in that file (super user priviledges are required for this step).
# 0483:df11 STMicroelectronics STM Device in DFU Mode
SUBSYSTEM=="usb", ATTR{idVendor}=="0483", ATTR{idProduct}=="df11", MODE="0666"
# 0483:3748 STMicroelectronics ST-LINK/V2
SUBSYSTEM=="usb", ATTR{idVendor}=="0483", ATTR{idProduct}=="3748", MODE="0666"
# 0483:374b STMicroelectronics ST-LINK/V2.1 (Nucleo-F103RB)
SUBSYSTEM=="usb", ATTR{idVendor}=="0483", ATTR{idProduct}=="374b", MODE="0666"
# 534c:0001 SatoshiLabs Bitcoin Wallet [TREZOR]
SUBSYSTEM=="usb", ATTR{idVendor}=="534c", ATTR{idProduct}=="0001", MODE="0666"
KERNEL=="hidraw*", ATTRS{idVendor}=="534c", ATTRS{idProduct}=="0001", MODE="0666"
# 1209:53c0 SatoshiLabs TREZOR v2 Bootloader
SUBSYSTEM=="usb", ATTR{idVendor}=="1209", ATTR{idProduct}=="53c0", MODE="0666"
KERNEL=="hidraw*", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="53c0", MODE="0666"
# 1209:53c1 SatoshiLabs TREZOR v2
SUBSYSTEM=="usb", ATTR{idVendor}=="1209", ATTR{idProduct}=="53c1", MODE="0666"
KERNEL=="hidraw*", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="53c1", MODE="0666"
Restart your machine or force your udev kernel module to reload the rules.
If when you plug the device your OS is not seeing the device, skip the warning on device's screen saying that the signature is wrong and then try this.
./trezorctl skycoin_address seed
This repository includes header files coming from Trezor-crypto repository.
Download the repository
git clone git@github.com:trezor/trezor-crypto.git
Then setup the TREZOR_CRYPTO_PATH environment variable:
export TREZOR_CRYPTO_PATH=$PWD/trezor-crypto
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TREZOR_CRYPTO_PATH
The dependancy libTrezorCrypto.a can be recompiled from sources.
Add this line to the CFLAGS: "CFLAGS += -DUSE_BN_PRINT=1"
Then run :
make
ar rcs libTrezorCrypto.a $(find -name "*.o")
The source code necessary to compile libcheck.a can be downloaded from this repository Download the repository
git clone git@github.com:libcheck/check.git
Then setup the TREZOR_CRYPTO_PATH environment variable:
export CHECK_PATH=$PWD/check
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CHECK_PATH
make
./test_skycoin_crypto