From 638cf2310b63e8affe32c856d29e6c891f8b2415 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Fri, 20 Sep 2013 21:49:17 +0200 Subject: [PATCH] cleanup --- bignum.c | 14 ------ bignum.h | 2 - speed-stm32/Makefile | 19 ++++++--- speed-stm32/Makefile.include | 83 ++++++++++++++++++++++++++---------- speed-stm32/bignum.c | 1 - speed-stm32/bignum.h | 1 - speed-stm32/ecdsa.c | 1 - speed-stm32/ecdsa.h | 1 - speed-stm32/hmac.c | 1 - speed-stm32/hmac.h | 1 - speed-stm32/rand.h | 1 - speed-stm32/secp256k1.c | 1 - speed-stm32/secp256k1.h | 1 - speed-stm32/sha2.c | 1 - speed-stm32/sha2.h | 1 - 15 files changed, 73 insertions(+), 56 deletions(-) delete mode 120000 speed-stm32/bignum.c delete mode 120000 speed-stm32/bignum.h delete mode 120000 speed-stm32/ecdsa.c delete mode 120000 speed-stm32/ecdsa.h delete mode 120000 speed-stm32/hmac.c delete mode 120000 speed-stm32/hmac.h delete mode 120000 speed-stm32/rand.h delete mode 120000 speed-stm32/secp256k1.c delete mode 120000 speed-stm32/secp256k1.h delete mode 120000 speed-stm32/sha2.c delete mode 120000 speed-stm32/sha2.h diff --git a/bignum.c b/bignum.c index 37b60e8f4..0e438bdab 100644 --- a/bignum.c +++ b/bignum.c @@ -21,7 +21,6 @@ * OTHER DEALINGS IN THE SOFTWARE. */ -#include #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); -} diff --git a/bignum.h b/bignum.h index 6a59c4122..320451711 100644 --- a/bignum.h +++ b/bignum.h @@ -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 diff --git a/speed-stm32/Makefile b/speed-stm32/Makefile index 946e85564..94560dfe0 100644 --- a/speed-stm32/Makefile +++ b/speed-stm32/Makefile @@ -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.. diff --git a/speed-stm32/Makefile.include b/speed-stm32/Makefile.include index 26f52eb6a..cdf2b406d 100644 --- a/speed-stm32/Makefile.include +++ b/speed-stm32/Makefile.include @@ -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) - -TOOLCHAIN_DIR ?= ../../../STM/libopencm3 - -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 - -all: images - -images: $(NAME).bin +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 + +OPTFLAGS = -Os -g + +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) + +LDSCRIPT = $(TOP_DIR)/layout$(APPIFY).ld + +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 diff --git a/speed-stm32/bignum.c b/speed-stm32/bignum.c deleted file mode 120000 index ae4e38c68..000000000 --- a/speed-stm32/bignum.c +++ /dev/null @@ -1 +0,0 @@ -../bignum.c \ No newline at end of file diff --git a/speed-stm32/bignum.h b/speed-stm32/bignum.h deleted file mode 120000 index 5efc7ca42..000000000 --- a/speed-stm32/bignum.h +++ /dev/null @@ -1 +0,0 @@ -../bignum.h \ No newline at end of file diff --git a/speed-stm32/ecdsa.c b/speed-stm32/ecdsa.c deleted file mode 120000 index 72f7870c9..000000000 --- a/speed-stm32/ecdsa.c +++ /dev/null @@ -1 +0,0 @@ -../ecdsa.c \ No newline at end of file diff --git a/speed-stm32/ecdsa.h b/speed-stm32/ecdsa.h deleted file mode 120000 index 23affb2f2..000000000 --- a/speed-stm32/ecdsa.h +++ /dev/null @@ -1 +0,0 @@ -../ecdsa.h \ No newline at end of file diff --git a/speed-stm32/hmac.c b/speed-stm32/hmac.c deleted file mode 120000 index 68437fdea..000000000 --- a/speed-stm32/hmac.c +++ /dev/null @@ -1 +0,0 @@ -../hmac.c \ No newline at end of file diff --git a/speed-stm32/hmac.h b/speed-stm32/hmac.h deleted file mode 120000 index 10ae0cd97..000000000 --- a/speed-stm32/hmac.h +++ /dev/null @@ -1 +0,0 @@ -../hmac.h \ No newline at end of file diff --git a/speed-stm32/rand.h b/speed-stm32/rand.h deleted file mode 120000 index f3be0086c..000000000 --- a/speed-stm32/rand.h +++ /dev/null @@ -1 +0,0 @@ -../rand.h \ No newline at end of file diff --git a/speed-stm32/secp256k1.c b/speed-stm32/secp256k1.c deleted file mode 120000 index 5a9d1084e..000000000 --- a/speed-stm32/secp256k1.c +++ /dev/null @@ -1 +0,0 @@ -../secp256k1.c \ No newline at end of file diff --git a/speed-stm32/secp256k1.h b/speed-stm32/secp256k1.h deleted file mode 120000 index c5f18c823..000000000 --- a/speed-stm32/secp256k1.h +++ /dev/null @@ -1 +0,0 @@ -../secp256k1.h \ No newline at end of file diff --git a/speed-stm32/sha2.c b/speed-stm32/sha2.c deleted file mode 120000 index 8e8fb5a97..000000000 --- a/speed-stm32/sha2.c +++ /dev/null @@ -1 +0,0 @@ -../sha2.c \ No newline at end of file diff --git a/speed-stm32/sha2.h b/speed-stm32/sha2.h deleted file mode 120000 index 3eba17921..000000000 --- a/speed-stm32/sha2.h +++ /dev/null @@ -1 +0,0 @@ -../sha2.h \ No newline at end of file