1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-12 18:49:07 +00:00
This commit is contained in:
Pavol Rusnak 2013-09-20 21:49:17 +02:00
parent 92f070498f
commit 638cf2310b
15 changed files with 69 additions and 52 deletions

View File

@ -21,7 +21,6 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include "bignum.h"
#include "secp256k1.h"
@ -504,16 +503,3 @@ void bn_divmod58(const bignum256 *a, bignum256 *q, uint32_t *r)
*r = rem.val[0];
}
void bn_print(const bignum256 *a)
{
printf("%04x", a->val[8] & 0x0000FFFF);
printf("%08x", (a->val[7] << 2) | ((a->val[6] & 0x30000000) >> 28));
printf("%07x", a->val[6] & 0x0FFFFFFF);
printf("%08x", (a->val[5] << 2) | ((a->val[4] & 0x30000000) >> 28));
printf("%07x", a->val[4] & 0x0FFFFFFF);
printf("%08x", (a->val[3] << 2) | ((a->val[2] & 0x30000000) >> 28));
printf("%07x", a->val[2] & 0x0FFFFFFF);
printf("%08x", (a->val[1] << 2) | ((a->val[0] & 0x30000000) >> 28));
printf("%07x", a->val[0] & 0x0FFFFFFF);
}

View File

@ -80,6 +80,4 @@ void bn_substract_noprime(const bignum256 *a, const bignum256 *b, bignum256 *res
void bn_divmod58(const bignum256 *a, bignum256 *q, uint32_t *r);
void bn_print(const bignum256 *a);
#endif

View File

@ -1,9 +1,16 @@
NAME = speed
OBJS += bignum.o
OBJS += ecdsa.o
NAME = speed
OBJS += rand.o
OBJS += secp256k1.o
OBJS += hmac.o
OBJS += sha2.o
OBJS += speed.o
OBJS += ../bignum.o
OBJS += ../bip32.o
OBJS += ../ecdsa.o
OBJS += ../hmac.o
OBJS += ../ripemd160.o
OBJS += ../secp256k1.o
OBJS += ../sha2.o
include Makefile.include
CFLAGS += -I..

View File

@ -1,30 +1,66 @@
PREFIX ?= arm-none-eabi
CC = $(PREFIX)-gcc
LD = $(PREFIX)-gcc
OBJCOPY = $(PREFIX)-objcopy
OBJDUMP = $(PREFIX)-objdump
FLASH = $(shell which st-flash)
APPIFY ?= 0
PREFIX ?= arm-none-eabi-
CC = $(PREFIX)gcc
LD = $(PREFIX)gcc
OBJCOPY = $(PREFIX)objcopy
OBJDUMP = $(PREFIX)objdump
FLASH = st-flash
OPENOCD = openocd
TOP_DIR = /home/stick/work/trezor/trezor-mcu
TOOLCHAIN_DIR = /home/stick/work/STM/libopencm3
TOOLCHAIN_DIR ?= ../../../STM/libopencm3
OPTFLAGS = -Os -g
CFLAGS += -Os -g \
-Wall -Wextra -Wimplicit-function-declaration -Wredundant-decls -Wstrict-prototypes -Wundef -Wshadow \
-fno-common -mcpu=cortex-m3 -mthumb -msoft-float -MD -DSTM32F2 \
-I$(TOOLCHAIN_DIR)/include
LDSCRIPT ?= $(NAME).ld
LDFLAGS += --static -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group \
-L$(TOOLCHAIN_DIR)/lib -L$(TOOLCHAIN_DIR)/lib/stm32/f2 \
-T$(LDSCRIPT) -nostartfiles -Wl,--gc-sections \
-mthumb -march=armv7 -mfix-cortex-m3-ldrd -msoft-float
OBJS += $(NAME).o
CFLAGS += $(OPTFLAGS) \
-Wall \
-Wextra \
-Wimplicit-function-declaration \
-Wredundant-decls \
-Wstrict-prototypes \
-Wundef \
-Wshadow \
-fno-common \
-mcpu=cortex-m3 \
-mthumb \
-msoft-float \
-DSTM32F2 \
-I$(TOOLCHAIN_DIR)/include \
-I$(TOP_DIR) \
-DAPPIFY=$(APPIFY)
all: images
LDSCRIPT = $(TOP_DIR)/layout$(APPIFY).ld
images: $(NAME).bin
LDFLAGS += --static \
-Wl,--start-group \
-lc \
-lgcc \
-lnosys \
-Wl,--end-group \
-L$(TOP_DIR) \
-L$(TOOLCHAIN_DIR)/lib \
-L$(TOOLCHAIN_DIR)/lib/stm32/f2 \
-T$(LDSCRIPT) \
-nostartfiles \
-Wl,--gc-sections \
-mthumb \
-march=armv7 \
-mfix-cortex-m3-ldrd \
-msoft-float
all: $(NAME).bin
flash: $(NAME).bin
$(FLASH) write $(NAME).bin 0x8000000
flash2: $(NAME).hex
$(OPENOCD) -f board/stm32f4discovery.cfg \
-c "init" \
-c "reset init" \
-c "stm32f2x mass_erase 0" \
-c "flash write_image $(NAME).hex" \
-c "reset" \
-c "shutdown"
$(NAME).bin: $(NAME).elf
$(OBJCOPY) -Obinary $(NAME).elf $(NAME).bin
@ -44,6 +80,7 @@ $(NAME).elf: $(OBJS) $(LDSCRIPT) $(TOOLCHAIN_DIR)/lib/libopencm3_stm32f2.a
$(CC) $(CFLAGS) -o $@ -c $<
clean:
rm -f *.a
rm -f *.o
rm -f *.d
rm -f *.elf

View File

@ -1 +0,0 @@
../bignum.c

View File

@ -1 +0,0 @@
../bignum.h

View File

@ -1 +0,0 @@
../ecdsa.c

View File

@ -1 +0,0 @@
../ecdsa.h

View File

@ -1 +0,0 @@
../hmac.c

View File

@ -1 +0,0 @@
../hmac.h

View File

@ -1 +0,0 @@
../rand.h

View File

@ -1 +0,0 @@
../secp256k1.c

View File

@ -1 +0,0 @@
../secp256k1.h

View File

@ -1 +0,0 @@
../sha2.c

View File

@ -1 +0,0 @@
../sha2.h