1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-14 03:30:02 +00:00

update bootloader and demo to new usb api

This commit is contained in:
Pavol Rusnak 2015-08-05 16:57:23 +02:00
parent ec98e58bce
commit 90171e0aa6
4 changed files with 23 additions and 16 deletions

View File

@ -14,4 +14,6 @@ install:
script:
- cd libopencm3; make; cd ..
- TOOLCHAIN_DIR=libopencm3 make
- cd firmware; TOOLCHAIN_DIR=libopencm3 make; cd ..
- cd firmware; TOOLCHAIN_DIR=../libopencm3 make; cd ..
- cd bootloader; TOOLCHAIN_DIR=../libopencm3 make; cd ..
- cd demo; TOOLCHAIN_DIR=../libopencm3 make; cd ..

View File

@ -1,22 +1,20 @@
NAME = bootloader
MCU_DIR=$(subst /bootloader,,$(PWD))
OBJS += bootloader.o
OBJS += signatures.o
OBJS += usb.o
OBJS += $(MCU_DIR)/trezor-crypto/bignum.o
OBJS += $(MCU_DIR)/trezor-crypto/ecdsa.small.o
OBJS += $(MCU_DIR)/trezor-crypto/hmac.o
OBJS += $(MCU_DIR)/trezor-crypto/ripemd160.o
OBJS += $(MCU_DIR)/trezor-crypto/secp256k1.small.o
OBJS += $(MCU_DIR)/trezor-crypto/sha2.o
OBJS += ../trezor-crypto/bignum.o
OBJS += ../trezor-crypto/ecdsa.small.o
OBJS += ../trezor-crypto/hmac.o
OBJS += ../trezor-crypto/ripemd160.o
OBJS += ../trezor-crypto/secp256k1.small.o
OBJS += ../trezor-crypto/sha2.o
CFLAGS += -DUSE_PRECOMPUTED_IV=0
CFLAGS += -DUSE_PRECOMPUTED_CP=0
include $(MCU_DIR)/Makefile.include
include ../Makefile.include
align:
./firmware_align.py $(NAME).bin

View File

@ -187,8 +187,7 @@ static const char *usb_strings[] = {
"", // empty serial
};
static int hid_control_request(usbd_device *dev, struct usb_setup_data *req, uint8_t **buf, uint16_t *len,
void (**complete)(usbd_device *, struct usb_setup_data *))
static int hid_control_request(usbd_device *dev, struct usb_setup_data *req, uint8_t **buf, uint16_t *len, usbd_control_complete_callback *complete)
{
(void)complete;
(void)dev;

View File

@ -25,9 +25,9 @@
#include "layout.h"
#include "oled.h"
#include "setup.h"
//#include "util.h"
#include "hmac.h"
#include "pbkdf2.h"
#include "rng.h"
const int states = 2;
int state = 0;
@ -192,8 +192,7 @@ static const char *usb_strings[] = {
"01234567",
};
static int hid_control_request(usbd_device *dev, struct usb_setup_data *req, uint8_t **buf, uint16_t *len,
void (**complete)(usbd_device *, struct usb_setup_data *))
static int hid_control_request(usbd_device *dev, struct usb_setup_data *req, uint8_t **buf, uint16_t *len, usbd_control_complete_callback *complete)
{
(void)complete;
(void)dev;
@ -239,8 +238,17 @@ void usbInit(void)
usbd_register_set_config_callback(usbd_dev, hid_set_config);
}
uint32_t __stack_chk_guard;
void __attribute__((noreturn)) __stack_chk_fail(void)
{
layoutDialog(DIALOG_ICON_ERROR, NULL, NULL, NULL, "Stack smashing", "detected.", NULL, "Please unplug", "the device.", NULL);
for (;;) {} // loop forever
}
int main(void)
{
__stack_chk_guard = random32();
#ifndef APPVER
setup();
oledInit();
@ -264,7 +272,7 @@ int main(void)
usbd_poll(usbd_dev);
switch (state) {
case 1:
layoutProgress("WORKING", frame % 41 * 25, frame % 4);
layoutProgress("WORKING", frame % 41 * 25);
pbkdf2_hmac_sha512(pass, passlen, salt, saltlen, 100, seed, 64, NULL);
usbd_ep_write_packet(usbd_dev, 0x81, seed, 64);
break;