fix stm32 build

This commit is contained in:
Conor Patrick 2019-11-19 15:48:40 -05:00
parent dcd256faf4
commit 28e607ddac
3 changed files with 63 additions and 84 deletions

View File

@ -9,7 +9,7 @@ SRC += $(DRIVER_LIBS) $(USB_LIB)
# FIDO2 lib # FIDO2 lib
SRC += ../../fido2/apdu.c ../../fido2/util.c ../../fido2/u2f.c ../../fido2/test_power.c SRC += ../../fido2/apdu.c ../../fido2/util.c ../../fido2/u2f.c ../../fido2/test_power.c
SRC += ../../fido2/stubs.c ../../fido2/log.c ../../fido2/ctaphid.c ../../fido2/ctap.c SRC += ../../fido2/stubs.c ../../fido2/log.c ../../fido2/ctaphid.c ../../fido2/ctap.c
SRC += ../../fido2/ctap_parse.c ../../fido2/crypto.c ../../fido2/main.c SRC += ../../fido2/ctap_parse.c ../../fido2/crypto.c
SRC += ../../fido2/version.c SRC += ../../fido2/version.c
SRC += ../../fido2/data_migration.c SRC += ../../fido2/data_migration.c
SRC += ../../fido2/extensions/extensions.c ../../fido2/extensions/solo.c SRC += ../../fido2/extensions/extensions.c ../../fido2/extensions/solo.c
@ -68,9 +68,6 @@ all: $(TARGET).elf
../../crypto/micro-ecc/uECC.o: ../../crypto/micro-ecc/uECC.c ../../crypto/micro-ecc/uECC.o: ../../crypto/micro-ecc/uECC.c
$(CC) $^ $(HW) -O3 $(ECC_CFLAGS) -o $@ $(CC) $^ $(HW) -O3 $(ECC_CFLAGS) -o $@
%.o: %.s
$(CC) $^ $(HW) -Os $(CFLAGS) -o $@
%.elf: $(OBJ) %.elf: $(OBJ)
$(CC) $^ $(HW) $(LDFLAGS) -o $@ $(CC) $^ $(HW) $(LDFLAGS) -o $@
@echo "Built version: $(VERSION_FLAGS)" @echo "Built version: $(VERSION_FLAGS)"

View File

@ -2,6 +2,7 @@ CC=$(PREFIX)arm-none-eabi-gcc
CP=$(PREFIX)arm-none-eabi-objcopy CP=$(PREFIX)arm-none-eabi-objcopy
SZ=$(PREFIX)arm-none-eabi-size SZ=$(PREFIX)arm-none-eabi-size
AR=$(PREFIX)arm-none-eabi-ar AR=$(PREFIX)arm-none-eabi-ar
AS=$(PREFIX)arm-none-eabi-as
DRIVER_LIBS := lib/stm32l4xx_hal_pcd.c lib/stm32l4xx_hal_pcd_ex.c lib/stm32l4xx_ll_gpio.c \ DRIVER_LIBS := lib/stm32l4xx_hal_pcd.c lib/stm32l4xx_hal_pcd_ex.c lib/stm32l4xx_ll_gpio.c \
lib/stm32l4xx_ll_rcc.c lib/stm32l4xx_ll_rng.c lib/stm32l4xx_ll_tim.c \ lib/stm32l4xx_ll_rcc.c lib/stm32l4xx_ll_rng.c lib/stm32l4xx_ll_tim.c \
@ -27,3 +28,6 @@ _all:
echo $(VERSION_MAJ) echo $(VERSION_MAJ)
echo $(VERSION_MIN) echo $(VERSION_MIN)
echo $(VERSION_PAT) echo $(VERSION_PAT)
%.o: %.s
$(AS) -o $@ $^

View File

@ -4,105 +4,83 @@
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be // http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms. // copied, modified, or distributed except according to those terms.
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <stdlib.h>
#include "stm32l4xx.h" #include <stdint.h>
#include "stm32l4xx_ll_gpio.h" #include <stdbool.h>
#include "stm32l4xx_ll_rcc.h" #include <unistd.h>
#include "stm32l4xx_ll_system.h"
#include "stm32l4xx_ll_pwr.h"
#include "stm32l4xx_ll_utils.h"
#include "stm32l4xx_ll_cortex.h"
#include "stm32l4xx_ll_gpio.h"
#include "stm32l4xx_ll_usart.h"
#include "stm32l4xx_ll_bus.h"
#include "stm32l4xx_ll_usb.h"
#include "stm32l4xx_hal_pcd.h" #include "cbor.h"
#include "usbd_core.h"
#include "usbd_desc.h"
#include "usbd_hid.h"
/*#include "usbd_hid.h"*/
#include APP_CONFIG
#include "flash.h"
#include "rng.h"
#include "led.h"
#include "device.h" #include "device.h"
#include "ctaphid.h"
//#include "bsp.h"
#include "util.h" #include "util.h"
#include "fifo.h"
#include "log.h" #include "log.h"
#include "ctap.h"
#include APP_CONFIG
#ifdef TEST_SOLO_STM32 #if !defined(TEST)
#define Error_Handler() _Error_Handler(__FILE__,__LINE__)
#define PAGE_SIZE 2048
#define PAGES 128
// Pages 119-127 are data
#define COUNTER2_PAGE (PAGES - 4)
#define COUNTER1_PAGE (PAGES - 3)
#define STATE2_PAGE (PAGES - 2)
#define STATE1_PAGE (PAGES - 1)
uint32_t __90_ms = 0; int main(int argc, char *argv[])
#define IS_BUTTON_PRESSED() (0 == (LL_GPIO_ReadInputPort(SOLO_BUTTON_PORT) & SOLO_BUTTON_PIN))
// Timer6 overflow handler. happens every ~90ms.
void TIM6_DAC_IRQHandler()
{ {
// timer is only 16 bits, so roll it over here uint8_t hidmsg[64];
TIM6->SR = 0; uint32_t t1 = 0;
__90_ms += 1;
} set_logging_mask(
/*0*/
//TAG_GEN|
// TAG_MC |
// TAG_GA |
TAG_WALLET |
TAG_STOR |
//TAG_NFC_APDU |
TAG_NFC |
//TAG_CP |
// TAG_CTAP|
//TAG_HID|
TAG_U2F|
//TAG_PARSE |
//TAG_TIME|
// TAG_DUMP|
TAG_GREEN|
TAG_RED|
TAG_EXT|
TAG_CCID|
TAG_ERR
);
device_init(argc, argv);
memset(hidmsg,0,sizeof(hidmsg));
uint32_t millis(void)
{
return (((uint32_t)TIM6->CNT) + (__90_ms * 90));
}
void _Error_Handler(char *file, int line)
{
while(1) while(1)
{ {
} if (millis() - t1 > HEARTBEAT_PERIOD)
}
int main(void)
{
uint32_t i = 5;
hw_init();
LL_GPIO_SetPinMode(SOLO_BUTTON_PORT,SOLO_BUTTON_PIN,LL_GPIO_MODE_INPUT);
LL_GPIO_SetPinPull(SOLO_BUTTON_PORT,SOLO_BUTTON_PIN,LL_GPIO_PULL_UP);
flash_option_bytes_init(1);
while (1)
{
uint32_t t0 = millis() % 750;
if (! IS_BUTTON_PRESSED())
{ {
if (t0 < 750*1/3) heartbeat();
{ t1 = millis();
led_rgb(0 | (0 << 8) | (i << 17)); }
}
else if (t0 < 750*2/3) device_manage();
{
led_rgb(0 | (i << 8) | (0 << 16)); if (usbhid_recv(hidmsg) > 0)
} {
else ctaphid_handle_packet(hidmsg);
{ memset(hidmsg, 0, sizeof(hidmsg));
led_rgb(i | (0 << 8) | (0 << 16));
}
} }
else else
{ {
led_rgb(0x151515);
} }
ctaphid_check_timeouts();
} }
// Should never get here
usbhid_close();
printf1(TAG_GREEN, "done\n");
return 0;
} }
#endif #endif