From 400b37a96a2275717beae7df1642523b14c71f46 Mon Sep 17 00:00:00 2001 From: yparitcher Date: Sun, 6 Jan 2019 01:19:14 -0500 Subject: [PATCH 01/24] clean up build: GCC warnings --- fido2/ctap.c | 13 ++- fido2/ctaphid.c | 16 +++ fido2/log.h | 6 +- fido2/u2f.c | 19 ++++ targets/stm32l432/Makefile | 2 +- targets/stm32l432/bootloader/bootloader.c | 5 +- targets/stm32l432/bootloader/main.c | 4 + targets/stm32l432/build/application.mk | 2 +- targets/stm32l432/build/bootloader.mk | 2 +- targets/stm32l432/lib/usbd/usbd_cdc.c | 20 ++-- targets/stm32l432/lib/usbd/usbd_hid.c | 124 +++++++++++----------- targets/stm32l432/linker/stm32l4xx.ld | 2 +- targets/stm32l432/src/device.c | 13 ++- targets/stm32l432/src/flash.h | 1 + targets/stm32l432/src/init.c | 4 + targets/stm32l432/src/led.c | 2 + 16 files changed, 150 insertions(+), 85 deletions(-) diff --git a/fido2/ctap.c b/fido2/ctap.c index 76c6339..bc09e9c 100644 --- a/fido2/ctap.c +++ b/fido2/ctap.c @@ -1358,8 +1358,9 @@ uint8_t ctap_request(uint8_t * pkt_raw, int length, CTAP_RESPONSE * resp) CborEncoder encoder; uint8_t status = 0; uint8_t cmd = *pkt_raw; - uint64_t t1; - uint64_t t2; +#if DEBUG_LEVEL > 0 + uint64_t t1,t2; +#endif pkt_raw++; length--; @@ -1392,10 +1393,14 @@ uint8_t ctap_request(uint8_t * pkt_raw, int length, CTAP_RESPONSE * resp) case CTAP_MAKE_CREDENTIAL: device_set_status(CTAPHID_STATUS_PROCESSING); printf1(TAG_CTAP,"CTAP_MAKE_CREDENTIAL\n"); +#if DEBUG_LEVEL > 0 t1 = millis(); +#endif status = ctap_make_credential(&encoder, pkt_raw, length); +#if DEBUG_LEVEL > 0 t2 = millis(); printf1(TAG_TIME,"make_credential time: %d ms\n", t2-t1); +#endif resp->length = cbor_encoder_get_buffer_size(&encoder, buf); dump_hex1(TAG_DUMP, buf, resp->length); @@ -1404,10 +1409,14 @@ uint8_t ctap_request(uint8_t * pkt_raw, int length, CTAP_RESPONSE * resp) case CTAP_GET_ASSERTION: device_set_status(CTAPHID_STATUS_PROCESSING); printf1(TAG_CTAP,"CTAP_GET_ASSERTION\n"); +#if DEBUG_LEVEL > 0 t1 = millis(); +#endif status = ctap_get_assertion(&encoder, pkt_raw, length); +#if DEBUG_LEVEL > 0 t2 = millis(); printf1(TAG_TIME,"get_assertion time: %d ms\n", t2-t1); +#endif resp->length = cbor_encoder_get_buffer_size(&encoder, buf); diff --git a/fido2/ctaphid.c b/fido2/ctaphid.c index 592dbb6..5343b0f 100644 --- a/fido2/ctaphid.c +++ b/fido2/ctaphid.c @@ -533,13 +533,21 @@ uint8_t ctaphid_handle_packet(uint8_t * pkt_raw) uint8_t cmd; uint32_t cid; int len; +#ifndef DISABLE_CTAPHID_CBOR int status; +#endif static uint8_t is_busy = 0; static CTAPHID_WRITE_BUFFER wb; CTAP_RESPONSE ctap_resp; +#ifndef DISABLE_CTAPHID_PING +#ifndef DISABLE_CTAPHID_CBOR +#if DEBUG_LEVEL > 0 uint32_t t1,t2; +#endif +#endif +#endif int bufstatus = ctaphid_buffer_packet(pkt_raw, &cmd, &cid, &len); @@ -581,11 +589,15 @@ uint8_t ctaphid_handle_packet(uint8_t * pkt_raw) wb.cid = cid; wb.cmd = CTAPHID_PING; wb.bcnt = len; +#if DEBUG_LEVEL > 0 t1 = millis(); +#endif ctaphid_write(&wb, ctap_buffer, len); ctaphid_write(&wb, NULL,0); +#if DEBUG_LEVEL > 0 t2 = millis(); printf1(TAG_TIME,"PING writeback: %d ms\n",(uint32_t)(t2-t1)); +#endif break; #endif #ifndef DISABLE_CTAPHID_WINK @@ -629,12 +641,16 @@ uint8_t ctaphid_handle_packet(uint8_t * pkt_raw) wb.bcnt = (ctap_resp.length+1); +#if DEBUG_LEVEL > 0 t1 = millis(); +#endif ctaphid_write(&wb, &status, 1); ctaphid_write(&wb, ctap_resp.data, ctap_resp.length); ctaphid_write(&wb, NULL, 0); +#if DEBUG_LEVEL > 0 t2 = millis(); printf1(TAG_TIME,"CBOR writeback: %d ms\n",(uint32_t)(t2-t1)); +#endif is_busy = 0; break; #endif diff --git a/fido2/log.h b/fido2/log.h index 4def1a3..a8edf1f 100644 --- a/fido2/log.h +++ b/fido2/log.h @@ -58,9 +58,9 @@ void set_logging_mask(uint32_t mask); #else #define set_logging_mask(mask) -#define printf1(fmt, ...) -#define printf2(fmt, ...) -#define printf3(fmt, ...) +#define printf1(tag,fmt, ...) +#define printf2(tag,fmt, ...) +#define printf3(tag,fmt, ...) #define dump_hex1(tag,data,len) #endif diff --git a/fido2/u2f.c b/fido2/u2f.c index ccd9b57..75f0021 100644 --- a/fido2/u2f.c +++ b/fido2/u2f.c @@ -11,11 +11,16 @@ #include "log.h" #include "device.h" #include "wallet.h" +#ifdef ENABLE_U2F_EXTENSIONS +#include "extensions.h" +#endif #include APP_CONFIG // void u2f_response_writeback(uint8_t * buf, uint8_t len); +#ifdef ENABLE_U2F static int16_t u2f_register(struct u2f_register_request * req); static int16_t u2f_authenticate(struct u2f_authenticate_request * req, uint8_t control); +#endif int8_t u2f_response_writeback(const uint8_t * buf, uint16_t len); void u2f_reset_response(); @@ -25,7 +30,11 @@ static CTAP_RESPONSE * _u2f_resp = NULL; void u2f_request(struct u2f_request_apdu* req, CTAP_RESPONSE * resp) { uint16_t rcode = 0; +#ifdef ENABLE_U2F +#if DEBUG_LEVEL > 0 uint64_t t1,t2; +#endif +#endif uint32_t len = ((req->LC3) | ((uint32_t)req->LC2 << 8) | ((uint32_t)req->LC1 << 16)); uint8_t byte; @@ -53,18 +62,26 @@ void u2f_request(struct u2f_request_apdu* req, CTAP_RESPONSE * resp) } else { +#if DEBUG_LEVEL > 0 t1 = millis(); +#endif rcode = u2f_register((struct u2f_register_request*)req->payload); +#if DEBUG_LEVEL > 0 t2 = millis(); printf1(TAG_TIME,"u2f_register time: %d ms\n", t2-t1); +#endif } break; case U2F_AUTHENTICATE: printf1(TAG_U2F, "U2F_AUTHENTICATE\n"); +#if DEBUG_LEVEL > 0 t1 = millis(); +#endif rcode = u2f_authenticate((struct u2f_authenticate_request*)req->payload, req->p1); +#if DEBUG_LEVEL > 0 t2 = millis(); printf1(TAG_TIME,"u2f_authenticate time: %d ms\n", t2-t1); +#endif break; case U2F_VERSION: printf1(TAG_U2F, "U2F_VERSION\n"); @@ -128,6 +145,7 @@ void u2f_set_writeback_buffer(CTAP_RESPONSE * resp) _u2f_resp = resp; } +#ifdef ENABLE_U2F static void dump_signature_der(uint8_t * sig) { uint8_t sigder[72]; @@ -300,6 +318,7 @@ static int16_t u2f_register(struct u2f_register_request * req) return U2F_SW_NO_ERROR; } +#endif int16_t u2f_version() { diff --git a/targets/stm32l432/Makefile b/targets/stm32l432/Makefile index 9c23cec..d21e521 100644 --- a/targets/stm32l432/Makefile +++ b/targets/stm32l432/Makefile @@ -17,7 +17,7 @@ all-locked: $(MAKE) -f $(APPMAKE) -j8 solo.hex PREFIX=$(PREFIX) EXTRA_DEFINES='-DFLASH_ROP=2' debugboot-app: - $(MAKE) -f $(APPMAKE) -j8 solo.hex DEBUG=2 PREFIX=$(PREFIX)\ + $(MAKE) -f $(APPMAKE) -j8 solo.hex DEBUG=2 PREFIX=$(PREFIX) \ LDSCRIPT=linker/stm32l4xx_extra.ld EXTRA_DEFINES='-DAPPLICATION_START_PAGE=16 -DSOLO_HACKER' debugboot-boot: diff --git a/targets/stm32l432/bootloader/bootloader.c b/targets/stm32l432/bootloader/bootloader.c index 1c619bc..7fe6050 100644 --- a/targets/stm32l432/bootloader/bootloader.c +++ b/targets/stm32l432/bootloader/bootloader.c @@ -95,9 +95,10 @@ int is_bootloader_disabled() int bootloader_bridge(int klen, uint8_t * keyh) { static int has_erased = 0; - int i; BootloaderReq * req = (BootloaderReq * )keyh; +#ifndef SOLO_HACKER uint8_t hash[32]; +#endif uint8_t version = 1; uint16_t len = (req->lenh << 8) | (req->lenl); @@ -107,8 +108,10 @@ int bootloader_bridge(int klen, uint8_t * keyh) return CTAP1_ERR_INVALID_LENGTH; } +#ifndef SOLO_HACKER uint8_t * pubkey = (uint8_t*)"\xd2\xa4\x2f\x8f\xb2\x31\x1c\xc1\xf7\x0c\x7e\x64\x32\xfb\xbb\xb4\xa3\xdd\x32\x20\x0f\x1b\x88\x9c\xda\x62\xc2\x83\x25\x93\xdd\xb8\x75\x9d\xf9\x86\xee\x03\x6c\xce\x34\x47\x71\x36\xb3\xb2\xad\x6d\x12\xb7\xbe\x49\x3e\x20\xa4\x61\xac\xc7\x71\xc7\x1f\xa8\x14\xf2"; const struct uECC_Curve_t * curve = NULL; +#endif uint32_t addr = ((*((uint32_t*)req->addr)) & 0xffffff) | 0x8000000; diff --git a/targets/stm32l432/bootloader/main.c b/targets/stm32l432/bootloader/main.c index eb4d2c8..a49ebdb 100644 --- a/targets/stm32l432/bootloader/main.c +++ b/targets/stm32l432/bootloader/main.c @@ -42,7 +42,9 @@ int main(int argc, char * argv[]) { uint8_t hidmsg[64]; uint32_t t1 = 0; +#ifdef SOLO_HACKER uint32_t stboot_time = 0; +#endif uint32_t boot = 1; set_logging_mask( @@ -102,7 +104,9 @@ int main(int argc, char * argv[]) printf1(TAG_RED,"Not authorized to boot (%08x == %08lx)\r\n", AUTH_WORD_ADDR, *(uint32_t*)AUTH_WORD_ADDR); } +#ifdef SOLO_HACKER start_bootloader: +#endif usbhid_init(); printf1(TAG_GEN,"init usb\n"); diff --git a/targets/stm32l432/build/application.mk b/targets/stm32l432/build/application.mk index 8dd59b1..fdddba2 100644 --- a/targets/stm32l432/build/application.mk +++ b/targets/stm32l432/build/application.mk @@ -69,7 +69,7 @@ all: $(TARGET).elf $(CP) -O ihex $^ $(TARGET).hex clean: - rm -f *.o src/*.o src/*.elf bootloader/*.o $(OBJ) + rm -f *.o src/*.o *.elf bootloader/*.o $(OBJ) cbor: diff --git a/targets/stm32l432/build/bootloader.mk b/targets/stm32l432/build/bootloader.mk index 0849086..d65ac03 100644 --- a/targets/stm32l432/build/bootloader.mk +++ b/targets/stm32l432/build/bootloader.mk @@ -68,4 +68,4 @@ all: $(TARGET).elf $(CP) -O ihex $^ $(TARGET).hex clean: - rm -f *.o src/*.o bootloader/*.o src/*.elf $(OBJ) + rm -f *.o src/*.o bootloader/*.o *.elf $(OBJ) diff --git a/targets/stm32l432/lib/usbd/usbd_cdc.c b/targets/stm32l432/lib/usbd/usbd_cdc.c index 64465e9..58d1301 100644 --- a/targets/stm32l432/lib/usbd/usbd_cdc.c +++ b/targets/stm32l432/lib/usbd/usbd_cdc.c @@ -143,13 +143,13 @@ static uint8_t USBD_CDC_DataOut (USBD_HandleTypeDef *pdev, static uint8_t USBD_CDC_EP0_RxReady (USBD_HandleTypeDef *pdev); -static uint8_t *USBD_CDC_GetFSCfgDesc (uint16_t *length); +//static uint8_t *USBD_CDC_GetFSCfgDesc (uint16_t *length); -static uint8_t *USBD_CDC_GetHSCfgDesc (uint16_t *length); +//static uint8_t *USBD_CDC_GetHSCfgDesc (uint16_t *length); -static uint8_t *USBD_CDC_GetOtherSpeedCfgDesc (uint16_t *length); +//static uint8_t *USBD_CDC_GetOtherSpeedCfgDesc (uint16_t *length); -static uint8_t *USBD_CDC_GetOtherSpeedCfgDesc (uint16_t *length); +//static uint8_t *USBD_CDC_GetOtherSpeedCfgDesc (uint16_t *length); uint8_t *USBD_CDC_GetDeviceQualifierDescriptor (uint16_t *length); @@ -789,12 +789,12 @@ static uint8_t USBD_CDC_EP0_RxReady (USBD_HandleTypeDef *pdev) * @param length : pointer data length * @retval pointer to descriptor buffer */ -static uint8_t *USBD_CDC_GetFSCfgDesc (uint16_t *length) +/*static uint8_t *USBD_CDC_GetFSCfgDesc (uint16_t *length) { *length = sizeof (USBD_CDC_CfgFSDesc); return USBD_CDC_CfgFSDesc; } - +*/ /** * @brief USBD_CDC_GetHSCfgDesc * Return configuration descriptor @@ -802,12 +802,12 @@ static uint8_t *USBD_CDC_GetFSCfgDesc (uint16_t *length) * @param length : pointer data length * @retval pointer to descriptor buffer */ -static uint8_t *USBD_CDC_GetHSCfgDesc (uint16_t *length) +/*static uint8_t *USBD_CDC_GetHSCfgDesc (uint16_t *length) { *length = sizeof (USBD_CDC_CfgHSDesc); return USBD_CDC_CfgHSDesc; } - +*/ /** * @brief USBD_CDC_GetCfgDesc * Return configuration descriptor @@ -815,12 +815,12 @@ static uint8_t *USBD_CDC_GetHSCfgDesc (uint16_t *length) * @param length : pointer data length * @retval pointer to descriptor buffer */ -static uint8_t *USBD_CDC_GetOtherSpeedCfgDesc (uint16_t *length) +/*static uint8_t *USBD_CDC_GetOtherSpeedCfgDesc (uint16_t *length) { *length = sizeof (USBD_CDC_OtherSpeedCfgDesc); return USBD_CDC_OtherSpeedCfgDesc; } - +*/ /** * @brief DeviceQualifierDescriptor * return Device Qualifier descriptor diff --git a/targets/stm32l432/lib/usbd/usbd_hid.c b/targets/stm32l432/lib/usbd/usbd_hid.c index bf32911..f799681 100644 --- a/targets/stm32l432/lib/usbd/usbd_hid.c +++ b/targets/stm32l432/lib/usbd/usbd_hid.c @@ -90,9 +90,9 @@ static uint8_t USBD_HID_DeInit (USBD_HandleTypeDef *pdev, static uint8_t USBD_HID_Setup (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); -static uint8_t *USBD_HID_GetFSCfgDesc (uint16_t *length); +//static uint8_t *USBD_HID_GetFSCfgDesc (uint16_t *length); -static uint8_t *USBD_HID_GetDeviceQualifierDesc (uint16_t *length); +//static uint8_t *USBD_HID_GetDeviceQualifierDesc (uint16_t *length); static uint8_t USBD_HID_DataIn (USBD_HandleTypeDef *pdev, uint8_t epnum); @@ -124,60 +124,60 @@ USBD_ClassTypeDef USBD_HID = #define USBD_HID_CfgFSDesc USBD_HID_OtherSpeedCfgDesc /* USB HID device Other Speed Configuration Descriptor */ -__ALIGN_BEGIN static uint8_t USBD_HID_OtherSpeedCfgDesc[] __ALIGN_END = -{ - 0x09, /* bLength: Configuration Descriptor size */ - USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */ - 9 + 9 + 9+ 7+7, - /* wTotalLength: Bytes returned */ - 0x00, - 0x01, /*bNumInterfaces: 1 interface*/ - 0x01, /*bConfigurationValue: Configuration value*/ - 0x00, /*iConfiguration: Index of string descriptor describing - the configuration*/ - 0x80, /*bmAttributes: bus powered and Support Remote Wake-up */ - 0x32, /*MaxPower 100 mA: this current is used for detecting Vbus*/ - - /************** Descriptor of Joystick Mouse interface ****************/ - /* 09 */ - 0x09, /*bLength: Interface Descriptor size*/ - USB_DESC_TYPE_INTERFACE,/*bDescriptorType: Interface descriptor type*/ - 0x00, /*bInterfaceNumber: Number of Interface*/ - 0x00, /*bAlternateSetting: Alternate setting*/ - 0x02, /*bNumEndpoints*/ - 0x03, /*bInterfaceClass: HID*/ - 0x00, /*bInterfaceSubClass : 1=BOOT, 0=no boot*/ - 0x00, /*nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse*/ - 2, /*iInterface: Index of string descriptor*/ - /******************** Descriptor of Joystick Mouse HID ********************/ - /* 18 */ - 0x09, /*bLength: HID Descriptor size*/ - HID_DESCRIPTOR_TYPE, /*bDescriptorType: HID*/ - 0x11, /*bcdHID: HID Class Spec release number*/ - 0x01, - 0x00, /*bCountryCode: Hardware target country*/ - 0x01, /*bNumDescriptors: Number of HID class descriptors to follow*/ - 0x22, /*bDescriptorType*/ - HID_FIDO_REPORT_DESC_SIZE,/*wItemLength: Total length of Report descriptor*/ - 0x00, - /******************** Descriptor of Mouse endpoint ********************/ - 0x07, /*bLength: Endpoint Descriptor size*/ - USB_DESC_TYPE_ENDPOINT, /*bDescriptorType:*/ - HID_EPIN_ADDR, /*bEndpointAddress: Endpoint Address (IN)*/ - 0x03, /*bmAttributes: Interrupt endpoint*/ - HID_EPIN_SIZE, /*wMaxPacketSize: 4 Byte max */ - 0x00, - HID_BINTERVAL, /*bInterval: Polling Interval */ - - - 0x07, /*bLength: Endpoint Descriptor size*/ - USB_DESC_TYPE_ENDPOINT, /*bDescriptorType:*/ - HID_EPOUT_ADDR, /*bEndpointAddress: Endpoint Address (IN)*/ - 0x03, /*bmAttributes: Interrupt endpoint*/ - HID_EPOUT_SIZE, /*wMaxPacketSize: 4 Byte max */ - 0x00, - HID_BINTERVAL, /*bInterval: Polling Interval */ -}; +//__ALIGN_BEGIN static uint8_t USBD_HID_OtherSpeedCfgDesc[] __ALIGN_END = +//{ +// 0x09, /* bLength: Configuration Descriptor size */ +// USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */ +// 9 + 9 + 9+ 7+7, +// /* wTotalLength: Bytes returned */ +// 0x00, +// 0x01, /*bNumInterfaces: 1 interface*/ +// 0x01, /*bConfigurationValue: Configuration value*/ +// 0x00, /*iConfiguration: Index of string descriptor describing +// the configuration*/ +// 0x80, /*bmAttributes: bus powered and Support Remote Wake-up */ +// 0x32, /*MaxPower 100 mA: this current is used for detecting Vbus*/ +// +// /************** Descriptor of Joystick Mouse interface ****************/ +// /* 09 */ +// 0x09, /*bLength: Interface Descriptor size*/ +// USB_DESC_TYPE_INTERFACE,/*bDescriptorType: Interface descriptor type*/ +// 0x00, /*bInterfaceNumber: Number of Interface*/ +// 0x00, /*bAlternateSetting: Alternate setting*/ +// 0x02, /*bNumEndpoints*/ +// 0x03, /*bInterfaceClass: HID*/ +// 0x00, /*bInterfaceSubClass : 1=BOOT, 0=no boot*/ +// 0x00, /*nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse*/ +// 2, /*iInterface: Index of string descriptor*/ +// /******************** Descriptor of Joystick Mouse HID ********************/ +// /* 18 */ +// 0x09, /*bLength: HID Descriptor size*/ +// HID_DESCRIPTOR_TYPE, /*bDescriptorType: HID*/ +// 0x11, /*bcdHID: HID Class Spec release number*/ +// 0x01, +// 0x00, /*bCountryCode: Hardware target country*/ +// 0x01, /*bNumDescriptors: Number of HID class descriptors to follow*/ +// 0x22, /*bDescriptorType*/ +// HID_FIDO_REPORT_DESC_SIZE,/*wItemLength: Total length of Report descriptor*/ +// 0x00, +// /******************** Descriptor of Mouse endpoint ********************/ +// 0x07, /*bLength: Endpoint Descriptor size*/ +// USB_DESC_TYPE_ENDPOINT, /*bDescriptorType:*/ +// HID_EPIN_ADDR, /*bEndpointAddress: Endpoint Address (IN)*/ +// 0x03, /*bmAttributes: Interrupt endpoint*/ +// HID_EPIN_SIZE, /*wMaxPacketSize: 4 Byte max */ +// 0x00, +// HID_BINTERVAL, /*bInterval: Polling Interval */ +// +// +// 0x07, /*bLength: Endpoint Descriptor size*/ +// USB_DESC_TYPE_ENDPOINT, /*bDescriptorType:*/ +// HID_EPOUT_ADDR, /*bEndpointAddress: Endpoint Address (IN)*/ +// 0x03, /*bmAttributes: Interrupt endpoint*/ +// HID_EPOUT_SIZE, /*wMaxPacketSize: 4 Byte max */ +// 0x00, +// HID_BINTERVAL, /*bInterval: Polling Interval */ +//}; /* USB HID device Configuration Descriptor */ @@ -196,7 +196,7 @@ __ALIGN_BEGIN static uint8_t USBD_HID_Desc[USB_HID_DESC_SIZ] __ALIGN_END = }; /* USB Standard Device Descriptor */ -__ALIGN_BEGIN static uint8_t USBD_HID_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] __ALIGN_END = +/*__ALIGN_BEGIN static uint8_t USBD_HID_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] __ALIGN_END = { USB_LEN_DEV_QUALIFIER_DESC, USB_DESC_TYPE_DEVICE_QUALIFIER, @@ -208,7 +208,7 @@ __ALIGN_BEGIN static uint8_t USBD_HID_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_ 0x40, 0x01, 0x00, -}; +};*/ __ALIGN_BEGIN static uint8_t HID_MOUSE_ReportDesc[HID_FIDO_REPORT_DESC_SIZE] __ALIGN_END = { @@ -456,11 +456,11 @@ static uint8_t USBD_HID_Setup (USBD_HandleTypeDef *pdev, * @param length : pointer data length * @retval pointer to descriptor buffer */ -static uint8_t *USBD_HID_GetFSCfgDesc (uint16_t *length) +/*static uint8_t *USBD_HID_GetFSCfgDesc (uint16_t *length) { *length = sizeof (USBD_HID_CfgFSDesc); return USBD_HID_CfgFSDesc; -} +}*/ /** * @brief USBD_HID_DataIn @@ -493,8 +493,8 @@ static uint8_t USBD_HID_DataOut (USBD_HandleTypeDef *pdev, * @param length : pointer data length * @retval pointer to descriptor buffer */ -static uint8_t *USBD_HID_GetDeviceQualifierDesc (uint16_t *length) +/*static uint8_t *USBD_HID_GetDeviceQualifierDesc (uint16_t *length) { *length = sizeof (USBD_HID_DeviceQualifierDesc); return USBD_HID_DeviceQualifierDesc; -} +}*/ diff --git a/targets/stm32l432/linker/stm32l4xx.ld b/targets/stm32l432/linker/stm32l4xx.ld index bc7424f..d44d5d6 100644 --- a/targets/stm32l432/linker/stm32l4xx.ld +++ b/targets/stm32l432/linker/stm32l4xx.ld @@ -41,7 +41,7 @@ _Min_Stack_Size = 0x400; /* required amount of stack */ /* Specify the memory areas */ MEMORY { -/* First 14 KB is bootloader */ +/* First 20 KB is bootloader */ FLASH (rx) : ORIGIN = 0x08005000, LENGTH = 198K-8 /* Leave out 38 Kb at end for data */ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 48K SRAM2 (rw) : ORIGIN = 0x10000000, LENGTH = 16K diff --git a/targets/stm32l432/src/device.c b/targets/stm32l432/src/device.c index 0318d13..c6dbd90 100644 --- a/targets/stm32l432/src/device.c +++ b/targets/stm32l432/src/device.c @@ -27,6 +27,9 @@ #include "stm32l4xx_ll_iwdg.h" #include "usbd_cdc_if.h" +void wait_for_usb_tether(); + + uint32_t __90_ms = 0; uint32_t __device_status = 0; uint32_t __last_update = 0; @@ -118,12 +121,12 @@ void usbhid_init() void wait_for_usb_tether() { - while (USBD_OK != CDC_Transmit_FS("tethered\r\n", 10) ) + while (USBD_OK != CDC_Transmit_FS((uint8_t*)"tethered\r\n", 10) ) ; - while (USBD_OK != CDC_Transmit_FS("tethered\r\n", 10) ) + while (USBD_OK != CDC_Transmit_FS((uint8_t*)"tethered\r\n", 10) ) ; delay(10); - while (USBD_OK != CDC_Transmit_FS("tethered\r\n", 10) ) + while (USBD_OK != CDC_Transmit_FS((uint8_t*)"tethered\r\n", 10) ) ; } @@ -169,7 +172,9 @@ void main_loop_delay() static int wink_time = 0; static uint32_t winkt1 = 0; +#ifdef LED_WINK_VALUE static uint32_t winkt2 = 0; +#endif void device_wink() { wink_time = 10; @@ -453,7 +458,9 @@ led_rgb(0x001040); delay(50); +#if SKIP_BUTTON_CHECK_WITH_DELAY || SKIP_BUTTON_CHECK_FAST done: +#endif return 1; fail: diff --git a/targets/stm32l432/src/flash.h b/targets/stm32l432/src/flash.h index 5da975c..e5526df 100644 --- a/targets/stm32l432/src/flash.h +++ b/targets/stm32l432/src/flash.h @@ -12,6 +12,7 @@ void flash_write_dword(uint32_t addr, uint64_t data); void flash_write(uint32_t addr, uint8_t * data, size_t sz); void flash_write_fast(uint32_t addr, uint32_t * data); void flash_option_bytes_init(int boot_from_dfu); +void flash_lock(); #define FLASH_PAGE_SIZE 2048 diff --git a/targets/stm32l432/src/init.c b/targets/stm32l432/src/init.c index f9ad733..b5bfedb 100644 --- a/targets/stm32l432/src/init.c +++ b/targets/stm32l432/src/init.c @@ -43,7 +43,9 @@ USBD_HandleTypeDef Solo_USBD_Device; static void LL_Init(void); void SystemClock_Config(void); static void MX_GPIO_Init(void); +#if DEBUG_LEVEL > 0 static void MX_USART1_UART_Init(void); +#endif static void MX_TIM2_Init(void); static void MX_TIM6_Init(void); static void MX_RNG_Init(void); @@ -287,6 +289,7 @@ static void MX_TIM2_Init(void) } +#if DEBUG_LEVEL > 0 /* USART1 init function */ static void MX_USART1_UART_Init(void) { @@ -324,6 +327,7 @@ static void MX_USART1_UART_Init(void) LL_USART_Enable(USART1); } +#endif /** Pinout Configuration */ diff --git a/targets/stm32l432/src/led.c b/targets/stm32l432/src/led.c index 7ecdd0a..219a266 100644 --- a/targets/stm32l432/src/led.c +++ b/targets/stm32l432/src/led.c @@ -53,7 +53,9 @@ void led_test_colors() { // Should produce pulsing of various colors int i = 0; +#if DEBUG_LEVEL > 0 int j = 0; +#endif int inc = 1; uint32_t time = 0; #define update() do {\ From 1dd835d6987a2db23a669a812f152ea843804038 Mon Sep 17 00:00:00 2001 From: yparitcher Date: Sun, 6 Jan 2019 11:41:56 -0500 Subject: [PATCH 02/24] add -Wextra: further code cleanup please fix Wno-unused-parameter -Wno-missing-field-initializers in the future --- fido2/ctap.c | 9 +++++---- fido2/ctap_parse.c | 24 +++++++++++++----------- fido2/ctap_parse.h | 2 +- fido2/ctaphid.c | 10 +++++----- fido2/device.h | 2 +- fido2/log.c | 2 +- fido2/main.c | 2 +- pc/device.c | 2 +- targets/stm32l432/bootloader/main.c | 2 +- targets/stm32l432/build/application.mk | 2 +- targets/stm32l432/build/bootloader.mk | 2 +- targets/stm32l432/src/crypto.c | 4 ++-- targets/stm32l432/src/device.c | 2 +- targets/stm32l432/src/flash.c | 2 +- 14 files changed, 35 insertions(+), 32 deletions(-) diff --git a/fido2/ctap.c b/fido2/ctap.c index bc09e9c..4cbdeb7 100644 --- a/fido2/ctap.c +++ b/fido2/ctap.c @@ -309,7 +309,7 @@ static int is_matching_rk(CTAP_residentKey * rk, CTAP_residentKey * rk2) } -static int ctap_make_auth_data(struct rpId * rp, CborEncoder * map, uint8_t * auth_data_buf, int len, CTAP_userEntity * user, uint8_t credtype, int32_t algtype, int32_t * sz, int store) +static int ctap_make_auth_data(struct rpId * rp, CborEncoder * map, uint8_t * auth_data_buf, unsigned int len, CTAP_userEntity * user, uint8_t credtype, int32_t algtype, int32_t * sz, int store) { CborEncoder cose_key; int auth_data_sz, ret; @@ -380,8 +380,8 @@ static int ctap_make_auth_data(struct rpId * rp, CborEncoder * map, uint8_t * au memmove(&rk.id, &authData->attest.id, sizeof(CredentialId)); memmove(&rk.user, user, sizeof(CTAP_userEntity)); - int index = STATE.rk_stored; - int i; + unsigned int index = STATE.rk_stored; + unsigned int i; for (i = 0; i < index; i++) { ctap_load_rk(i, &rk2); @@ -549,7 +549,8 @@ int ctap_authenticate_credential(struct rpId * rp, CTAP_credentialDescriptor * d uint8_t ctap_make_credential(CborEncoder * encoder, uint8_t * request, int length) { CTAP_makeCredential MC; - int ret, i; + int ret; + unsigned int i; uint8_t auth_data_buf[300]; CTAP_credentialDescriptor * excl_cred = (CTAP_credentialDescriptor *) auth_data_buf; uint8_t * sigbuf = auth_data_buf + 32; diff --git a/fido2/ctap_parse.c b/fido2/ctap_parse.c index ccbbcbb..f76dde7 100644 --- a/fido2/ctap_parse.c +++ b/fido2/ctap_parse.c @@ -79,7 +79,7 @@ uint8_t parse_user(CTAP_makeCredential * MC, CborValue * val) size_t sz, map_length; uint8_t key[24]; int ret; - int i; + unsigned int i; CborValue map; @@ -270,7 +270,7 @@ uint8_t parse_pub_key_cred_params(CTAP_makeCredential * MC, CborValue * val) uint8_t cred_type; int32_t alg_type; int ret; - int i; + unsigned int i; CborValue arr; @@ -319,7 +319,7 @@ uint8_t parse_pub_key_cred_params(CTAP_makeCredential * MC, CborValue * val) return CTAP2_ERR_UNSUPPORTED_ALGORITHM; } -uint8_t parse_fixed_byte_string(CborValue * map, uint8_t * dst, int len) +uint8_t parse_fixed_byte_string(CborValue * map, uint8_t * dst, unsigned int len) { size_t sz; int ret; @@ -344,7 +344,7 @@ uint8_t parse_fixed_byte_string(CborValue * map, uint8_t * dst, int len) uint8_t parse_verify_exclude_list(CborValue * val) { - int i; + unsigned int i; int ret; CborValue arr; size_t size; @@ -393,7 +393,7 @@ uint8_t parse_rp(struct rpId * rp, CborValue * val) size_t sz, map_length; char key[8]; int ret; - int i; + unsigned int i; CborValue map; @@ -481,7 +481,7 @@ uint8_t parse_options(CborValue * val, uint8_t * rk, uint8_t * uv, uint8_t * up) size_t sz, map_length; char key[8]; int ret; - int i; + unsigned int i; _Bool b; CborValue map; @@ -559,7 +559,7 @@ uint8_t parse_options(CborValue * val, uint8_t * rk, uint8_t * uv, uint8_t * up) uint8_t ctap_parse_make_credential(CTAP_makeCredential * MC, CborEncoder * encoder, uint8_t * request, int length) { int ret; - int i; + unsigned int i; int key; size_t map_length; CborParser parser; @@ -775,7 +775,8 @@ uint8_t parse_allow_list(CTAP_getAssertion * GA, CborValue * it) { CborValue arr; size_t len; - int i,ret; + int ret; + unsigned int i; CTAP_credentialDescriptor * cred; if (cbor_value_get_type(it) != CborArrayType) @@ -817,7 +818,7 @@ uint8_t parse_allow_list(CTAP_getAssertion * GA, CborValue * it) uint8_t ctap_parse_get_assertion(CTAP_getAssertion * GA, uint8_t * request, int length) { int ret; - int i; + unsigned int i; int key; size_t map_length; CborParser parser; @@ -943,7 +944,8 @@ uint8_t parse_cose_key(CborValue * it, uint8_t * x, uint8_t * y, int * kty, int { CborValue map; size_t map_length; - int i,ret,key; + int ret,key; + unsigned int i; int xkey = 0,ykey = 0; *kty = 0; *crv = 0; @@ -1038,7 +1040,7 @@ uint8_t parse_cose_key(CborValue * it, uint8_t * x, uint8_t * y, int * kty, int uint8_t ctap_parse_client_pin(CTAP_clientPin * CP, uint8_t * request, int length) { int ret; - int i; + unsigned int i; int key; size_t map_length; size_t sz; diff --git a/fido2/ctap_parse.h b/fido2/ctap_parse.h index f6b1739..3a177af 100644 --- a/fido2/ctap_parse.h +++ b/fido2/ctap_parse.h @@ -24,7 +24,7 @@ const char * cbor_value_get_type_string(const CborValue *value); uint8_t parse_user(CTAP_makeCredential * MC, CborValue * val); uint8_t parse_pub_key_cred_param(CborValue * val, uint8_t * cred_type, int32_t * alg_type); uint8_t parse_pub_key_cred_params(CTAP_makeCredential * MC, CborValue * val); -uint8_t parse_fixed_byte_string(CborValue * map, uint8_t * dst, int len); +uint8_t parse_fixed_byte_string(CborValue * map, uint8_t * dst, unsigned int len); uint8_t parse_rp_id(struct rpId * rp, CborValue * val); uint8_t parse_rp(struct rpId * rp, CborValue * val); uint8_t parse_options(CborValue * val, uint8_t * rk, uint8_t * uv, uint8_t * up); diff --git a/fido2/ctaphid.c b/fido2/ctaphid.c index 5343b0f..3f787ae 100644 --- a/fido2/ctaphid.c +++ b/fido2/ctaphid.c @@ -98,7 +98,7 @@ static uint32_t get_new_cid() static int8_t add_cid(uint32_t cid) { - int i; + uint32_t i; for(i = 0; i < CID_MAX-1; i++) { if (!CIDS[i].busy) @@ -114,7 +114,7 @@ static int8_t add_cid(uint32_t cid) static int8_t cid_exists(uint32_t cid) { - int i; + uint32_t i; for(i = 0; i < CID_MAX-1; i++) { if (CIDS[i].cid == cid) @@ -127,7 +127,7 @@ static int8_t cid_exists(uint32_t cid) static int8_t cid_refresh(uint32_t cid) { - int i; + uint32_t i; for(i = 0; i < CID_MAX-1; i++) { if (CIDS[i].cid == cid) @@ -142,7 +142,7 @@ static int8_t cid_refresh(uint32_t cid) static int8_t cid_del(uint32_t cid) { - int i; + uint32_t i; for(i = 0; i < CID_MAX-1; i++) { if (CIDS[i].cid == cid) @@ -380,7 +380,7 @@ static int ctaphid_buffer_packet(uint8_t * pkt_raw, uint8_t * cmd, uint32_t * ci printf1(TAG_HID, "Recv packet\n"); printf1(TAG_HID, " CID: %08x \n", pkt->cid); printf1(TAG_HID, " cmd: %02x\n", pkt->pkt.init.cmd); - if (!is_cont_pkt(pkt)) printf1(TAG_HID, " length: %d\n", ctaphid_packet_len(pkt)); + if (!is_cont_pkt(pkt)) {printf1(TAG_HID, " length: %d\n", ctaphid_packet_len(pkt));} int ret; uint32_t oldcid; diff --git a/fido2/device.h b/fido2/device.h index 4e02e78..e75f250 100644 --- a/fido2/device.h +++ b/fido2/device.h @@ -46,7 +46,7 @@ void device_manage(); // sets status that's uses for sending status updates ~100ms. // A timer should be set up to call `ctaphid_update_status` -void device_set_status(int status); +void device_set_status(uint32_t status); // Returns if button is currently pressed int device_is_button_pressed(); diff --git a/fido2/log.c b/fido2/log.c index 1840535..c3aadf0 100644 --- a/fido2/log.c +++ b/fido2/log.c @@ -57,7 +57,7 @@ __attribute__((weak)) void set_logging_tag(uint32_t tag) void LOG(uint32_t tag, const char * filename, int num, const char * fmt, ...) { - int i; + unsigned int i; if (((tag & 0x7fffffff) & LOGMASK) == 0) { diff --git a/fido2/main.c b/fido2/main.c index 0b05d83..dbe6301 100644 --- a/fido2/main.c +++ b/fido2/main.c @@ -19,7 +19,7 @@ #if !defined(TEST) -int main(int argc, char * argv[]) +int main() { uint8_t hidmsg[64]; uint32_t t1 = 0; diff --git a/pc/device.c b/pc/device.c index 9747aa4..b4d5379 100644 --- a/pc/device.c +++ b/pc/device.c @@ -26,7 +26,7 @@ void authenticator_initialize(); uint32_t __device_status = 0; -void device_set_status(int status) +void device_set_status(uint32_t status) { if (status != CTAPHID_STATUS_IDLE && __device_status != status) { diff --git a/targets/stm32l432/bootloader/main.c b/targets/stm32l432/bootloader/main.c index a49ebdb..ad5cbf1 100644 --- a/targets/stm32l432/bootloader/main.c +++ b/targets/stm32l432/bootloader/main.c @@ -38,7 +38,7 @@ void BOOT_boot(void) ((pFunction)bootAddress[1])(); } -int main(int argc, char * argv[]) +int main() { uint8_t hidmsg[64]; uint32_t t1 = 0; diff --git a/targets/stm32l432/build/application.mk b/targets/stm32l432/build/application.mk index fdddba2..37c4ea5 100644 --- a/targets/stm32l432/build/application.mk +++ b/targets/stm32l432/build/application.mk @@ -43,7 +43,7 @@ endif DEFINES = -DDEBUG_LEVEL=$(DEBUG) -D$(CHIP) -DAES256=1 -DUSE_FULL_LL_DRIVER -DAPP_CONFIG=\"app.h\" $(EXTRA_DEFINES) # DEFINES += -DTEST_SOLO_STM32 -DTEST -DTEST_FIFO=1 -CFLAGS=$(INC) -c $(DEFINES) -Wall -fdata-sections -ffunction-sections $(HW) -g $(VERSION_FLAGS) +CFLAGS=$(INC) -c $(DEFINES) -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -fdata-sections -ffunction-sections $(HW) -g $(VERSION_FLAGS) LDFLAGS_LIB=$(HW) $(SEARCH) -specs=nano.specs -specs=nosys.specs -Wl,--gc-sections -u _printf_float -lnosys LDFLAGS=$(HW) $(LDFLAGS_LIB) -T$(LDSCRIPT) -Wl,-Map=$(TARGET).map,--cref -Wl,-Bstatic -ltinycbor diff --git a/targets/stm32l432/build/bootloader.mk b/targets/stm32l432/build/bootloader.mk index d65ac03..24f2751 100644 --- a/targets/stm32l432/build/bootloader.mk +++ b/targets/stm32l432/build/bootloader.mk @@ -41,7 +41,7 @@ endif DEFINES = -DDEBUG_LEVEL=$(DEBUG) -D$(CHIP) -DAES256=1 -DUSE_FULL_LL_DRIVER -DAPP_CONFIG=\"bootloader.h\" $(EXTRA_DEFINES) # DEFINES += -DTEST_SOLO_STM32 -DTEST -DTEST_FIFO=1 -CFLAGS=$(INC) -c $(DEFINES) -Wall -fdata-sections -ffunction-sections $(HW) -g $(VERSION_FLAGS) +CFLAGS=$(INC) -c $(DEFINES) -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -fdata-sections -ffunction-sections $(HW) -g $(VERSION_FLAGS) LDFLAGS_LIB=$(HW) $(SEARCH) -specs=nano.specs -specs=nosys.specs -Wl,--gc-sections -lnosys LDFLAGS=$(HW) $(LDFLAGS_LIB) -T$(LDSCRIPT) -Wl,-Map=$(TARGET).map,--cref -Wl,-Bstatic diff --git a/targets/stm32l432/src/crypto.c b/targets/stm32l432/src/crypto.c index 269a1df..7de78fa 100644 --- a/targets/stm32l432/src/crypto.c +++ b/targets/stm32l432/src/crypto.c @@ -99,7 +99,7 @@ void crypto_sha256_final(uint8_t * hash) void crypto_sha256_hmac_init(uint8_t * key, uint32_t klen, uint8_t * hmac) { uint8_t buf[64]; - int i; + unsigned int i; memset(buf, 0, sizeof(buf)); if (key == CRYPTO_MASTER_KEY) @@ -133,7 +133,7 @@ void crypto_sha256_hmac_init(uint8_t * key, uint32_t klen, uint8_t * hmac) void crypto_sha256_hmac_final(uint8_t * key, uint32_t klen, uint8_t * hmac) { uint8_t buf[64]; - int i; + unsigned int i; crypto_sha256_final(hmac); memset(buf, 0, sizeof(buf)); if (key == CRYPTO_MASTER_KEY) diff --git a/targets/stm32l432/src/device.c b/targets/stm32l432/src/device.c index c6dbd90..59b19d6 100644 --- a/targets/stm32l432/src/device.c +++ b/targets/stm32l432/src/device.c @@ -63,7 +63,7 @@ uint32_t millis() return (((uint32_t)TIM6->CNT) + (__90_ms * 90)); } -void device_set_status(int status) +void device_set_status(uint32_t status) { __disable_irq(); __last_update = millis(); diff --git a/targets/stm32l432/src/flash.c b/targets/stm32l432/src/flash.c index 8d64e31..c37439d 100644 --- a/targets/stm32l432/src/flash.c +++ b/targets/stm32l432/src/flash.c @@ -133,7 +133,7 @@ void flash_write_dword(uint32_t addr, uint64_t data) void flash_write(uint32_t addr, uint8_t * data, size_t sz) { - int i; + unsigned int i; uint8_t buf[8]; while (FLASH->SR & (1<<16)) ; From 5afdef463ef1e0707bc680295665ad3b85a99627 Mon Sep 17 00:00:00 2001 From: yparitcher Date: Sun, 6 Jan 2019 14:48:18 -0500 Subject: [PATCH 03/24] add stm32l432 build test --- .travis.yml | 2 ++ Makefile | 18 +++++++++++++----- targets/stm32l432/Makefile | 13 ++++++++++++- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 72ff11a..c3384a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,9 +5,11 @@ addons: apt: sources: - ubuntu-toolchain-r-test + - team-gcc-arm-embedded/ppa packages: - gcc-7 - cppcheck + - gcc-arm-embedded script: - export CC=gcc-7 - make test diff --git a/Makefile b/Makefile index 99beef4..47461c6 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ CFLAGS += -DAES256=1 -DAPP_CONFIG=\"app.h\" name = main -.PHONY: all +.PHONY: all $(LIBCBOR) all: main tinycbor/Makefile crypto/tiny-AES-c/aes.c: @@ -42,9 +42,17 @@ tinycbor/Makefile crypto/tiny-AES-c/aes.c: .PHONY: cbor cbor: $(LIBCBOR) -$(LIBCBOR): tinycbor/Makefile +$(LIBCBOR): cd tinycbor/ && $(MAKE) clean && $(MAKE) -j8 +test: env3 + $(MAKE) clean + $(MAKE) -C . main + $(MAKE) clean + cd ./targets/stm32l432; $(MAKE) test PREFIX=$(PREFIX) VENV=". ../../env3/bin/activate;" + $(MAKE) clean + $(MAKE) cppcheck + .PHONY: efm8prog efm8prog: cd './targets/efm8\Keil 8051 v9.53 - Debug' && $(MAKE) all @@ -97,13 +105,13 @@ cppcheck: cppcheck $(CPPCHECK_FLAGS) fido2 cppcheck $(CPPCHECK_FLAGS) pc -test: main cppcheck - clean: rm -f *.o main.exe main $(obj) - rm -rf env2 env3 for f in crypto/tiny-AES-c/Makefile tinycbor/Makefile ; do \ if [ -f "$$f" ]; then \ (cd `dirname $$f` ; git checkout -- .) ;\ fi ;\ done + +full-clean: clean + rm -rf env2 env3 diff --git a/targets/stm32l432/Makefile b/targets/stm32l432/Makefile index d21e521..8daf962 100644 --- a/targets/stm32l432/Makefile +++ b/targets/stm32l432/Makefile @@ -5,7 +5,7 @@ endif APPMAKE=build/application.mk BOOTMAKE=build/application.mk -merge_hex=python ../../tools/solotool.py mergehex +merge_hex=../../tools/solotool.py mergehex all: $(MAKE) -f $(APPMAKE) -j8 solo.hex PREFIX=$(PREFIX) DEBUG=$(DEBUG) EXTRA_DEFINES='-DFLASH_ROP=1' @@ -40,6 +40,9 @@ build-release: clean2 boot-sig-checking clean all build-hacker: clean2 boot-no-sig clean all-hacker $(merge_hex) solo.hex bootloader.hex all.hex +build-debugboot: clean2 debugboot-boot clean debugboot-app + $(merge_hex) solo.hex bootloader.hex all.hex + clean: $(MAKE) -f $(APPMAKE) clean $(MAKE) -f $(BOOTMAKE) clean @@ -76,3 +79,11 @@ solo.hex: cbor: $(MAKE) -f application.mk -j8 cbor + +test: + $(MAKE) cbor + $(VENV) $(MAKE) build-release-locked + $(VENV) $(MAKE) build-release + $(VENV) $(MAKE) build-hacker + $(VENV) $(MAKE) build-debugboot + $(MAKE) clean2 From 727e1f2fd9c37e7841e1376c65d8de4b59fb25a5 Mon Sep 17 00:00:00 2001 From: yparitcher Date: Sun, 6 Jan 2019 14:54:57 -0500 Subject: [PATCH 04/24] fix travis build --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c3384a8..f54993a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,11 +5,13 @@ addons: apt: sources: - ubuntu-toolchain-r-test - - team-gcc-arm-embedded/ppa packages: - gcc-7 - cppcheck - - gcc-arm-embedded +before_install: + - sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa + - sudo apt-get update -q + - sudo apt-get install -y gcc-arm-embedded script: - export CC=gcc-7 - make test From 9a037279c87a84a84167805b0681cfc0ec0a5cfb Mon Sep 17 00:00:00 2001 From: yparitcher Date: Sun, 6 Jan 2019 15:29:15 -0500 Subject: [PATCH 05/24] fix travis build --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f54993a..355c060 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ addons: - cppcheck before_install: - sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa - - sudo apt-get update -q + - sudo apt-get update -q - sudo apt-get install -y gcc-arm-embedded script: - export CC=gcc-7 From eed418ea330d2c949ace80ddca95a75ac02d89d6 Mon Sep 17 00:00:00 2001 From: yparitcher Date: Sun, 6 Jan 2019 20:42:50 -0500 Subject: [PATCH 06/24] add black to travis build --- Makefile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 47461c6..ffdb36a 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ CFLAGS += -DAES256=1 -DAPP_CONFIG=\"app.h\" name = main -.PHONY: all $(LIBCBOR) +.PHONY: all $(LIBCBOR) env2 env3 black wink2 wink3 fido2-test clean full-clean travis all: main tinycbor/Makefile crypto/tiny-AES-c/aes.c: @@ -49,7 +49,7 @@ test: env3 $(MAKE) clean $(MAKE) -C . main $(MAKE) clean - cd ./targets/stm32l432; $(MAKE) test PREFIX=$(PREFIX) VENV=". ../../env3/bin/activate;" + cd ./targets/stm32l432; $(MAKE) test PREFIX=$(PREFIX) VENV=$(VENV) $(MAKE) clean $(MAKE) cppcheck @@ -86,7 +86,7 @@ env3: # selectively reformat our own code black: env3 - env3/bin/black --skip-string-normalization tools/ + env3/bin/black --skip-string-normalization --check tools/ wink2: env2 env2/bin/python tools/solotool.py solo --wink @@ -115,3 +115,7 @@ clean: full-clean: clean rm -rf env2 env3 + +travis: + $(MAKE) test VENV=". ../../env3/bin/activate;" + $(MAKE) black From a966ea3a582bb3fef6bf9ef2e8569862f558a39b Mon Sep 17 00:00:00 2001 From: yparitcher Date: Sun, 6 Jan 2019 21:17:42 -0500 Subject: [PATCH 07/24] tweak Makefile --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index ffdb36a..23b6308 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ test: env3 $(MAKE) clean $(MAKE) -C . main $(MAKE) clean - cd ./targets/stm32l432; $(MAKE) test PREFIX=$(PREFIX) VENV=$(VENV) + $(MAKE) -C ./targets/stm32l432 test PREFIX=$(PREFIX) "VENV=$(VENV)" $(MAKE) clean $(MAKE) cppcheck @@ -81,8 +81,8 @@ env2: env3: python3 -m venv env3 - env3/bin/pip install --upgrade -r tools/requirements.txt - env3/bin/pip install --upgrade black + env3/bin/pip -q install --upgrade -r tools/requirements.txt + env3/bin/pip -q install --upgrade black # selectively reformat our own code black: env3 From 5862a8a5ac262ae42323554226596311c0275fa8 Mon Sep 17 00:00:00 2001 From: yparitcher Date: Sun, 6 Jan 2019 21:34:04 -0500 Subject: [PATCH 08/24] hacker VID/PID pair --- targets/stm32l432/lib/usbd/usbd_desc.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/targets/stm32l432/lib/usbd/usbd_desc.c b/targets/stm32l432/lib/usbd/usbd_desc.c index 88b920d..9a107a2 100644 --- a/targets/stm32l432/lib/usbd/usbd_desc.c +++ b/targets/stm32l432/lib/usbd/usbd_desc.c @@ -50,14 +50,11 @@ #include APP_CONFIG -#define USBD_VID 0x0483 -#define USBD_PID 0xA2CA #define USBD_LANGID_STRING 0x409 #define USBD_MANUFACTURER_STRING "SoloKeys" #define USBD_PRODUCT_FS_STRING SOLO_PRODUCT_NAME #define USBD_SERIAL_NUM "0123456789ABCDEF" - uint8_t *USBD_HID_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); uint8_t *USBD_HID_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); uint8_t *USBD_HID_ManufacturerStrDescriptor (USBD_SpeedTypeDef speed, uint16_t *length); From 6c6f0a00686f05d171128a5617869e605bff8cfd Mon Sep 17 00:00:00 2001 From: yparitcher Date: Sun, 6 Jan 2019 23:15:43 -0500 Subject: [PATCH 09/24] fix Makefile, Travis make --- .travis.yml | 2 +- Makefile | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 355c060..5a81240 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,4 +14,4 @@ before_install: - sudo apt-get install -y gcc-arm-embedded script: - export CC=gcc-7 - - make test + - make travis diff --git a/Makefile b/Makefile index 23b6308..126cdb6 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ EFM32_DEBUGGER= -s 440083537 --device EFM32JG1B200F128GM32 #EFM32_DEBUGGER= -s 440121060 #dev board src = $(wildcard pc/*.c) $(wildcard fido2/*.c) $(wildcard crypto/sha256/*.c) crypto/tiny-AES-c/aes.c -obj = $(src:.c=.o) uECC.o +obj = $(src:.c=.o) crypto/micro-ecc/uECC.o LIBCBOR = tinycbor/lib/libtinycbor.a @@ -72,7 +72,7 @@ efm32bootprog: efm32com $(name): $(obj) $(LIBCBOR) $(CC) $(LDFLAGS) -o $@ $(obj) $(LDFLAGS) -uECC.o: ./crypto/micro-ecc/uECC.c +crypto/micro-ecc/uECC.o: ./crypto/micro-ecc/uECC.c $(CC) -c -o $@ $^ -O2 -fdata-sections -ffunction-sections -DuECC_PLATFORM=$(ecc_platform) -I./crypto/micro-ecc/ env2: From ee817ea8bb01d938ec7f6bcb5c9be6243b98c124 Mon Sep 17 00:00:00 2001 From: yparitcher Date: Sun, 6 Jan 2019 23:41:12 -0500 Subject: [PATCH 10/24] automate building cbor --- docs/solo/building.md | 6 ------ targets/stm32l432/Makefile | 7 +++---- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/docs/solo/building.md b/docs/solo/building.md index e3f74d0..6da8360 100644 --- a/docs/solo/building.md +++ b/docs/solo/building.md @@ -24,12 +24,6 @@ Enter the `stm32l4xx` target directory. cd targets/stm32l432 ``` -Build the cbor library. - -```bash -make cbor -``` - Now build Solo. ``` diff --git a/targets/stm32l432/Makefile b/targets/stm32l432/Makefile index 8daf962..7de8c2d 100644 --- a/targets/stm32l432/Makefile +++ b/targets/stm32l432/Makefile @@ -30,14 +30,14 @@ boot-sig-checking: boot-no-sig: $(MAKE) -f $(BOOTMAKE) -j8 bootloader.hex PREFIX=$(PREFIX) EXTRA_DEFINES='-DSOLO_HACKER' DEBUG=0 -build-release-locked: clean2 boot-sig-checking clean all-locked +build-release-locked: cbor clean2 boot-sig-checking clean all-locked $(merge_hex) solo.hex bootloader.hex all.hex rm -f solo.hex bootloader.hex # don't program solo.hex ... -build-release: clean2 boot-sig-checking clean all +build-release: cbor clean2 boot-sig-checking clean all $(merge_hex) solo.hex bootloader.hex all.hex -build-hacker: clean2 boot-no-sig clean all-hacker +build-hacker: cbor clean2 boot-no-sig clean all-hacker $(merge_hex) solo.hex bootloader.hex all.hex build-debugboot: clean2 debugboot-boot clean debugboot-app @@ -81,7 +81,6 @@ cbor: $(MAKE) -f application.mk -j8 cbor test: - $(MAKE) cbor $(VENV) $(MAKE) build-release-locked $(VENV) $(MAKE) build-release $(VENV) $(MAKE) build-hacker From be212fd8b1e23fcb4969769b6abc1cd5c3d15206 Mon Sep 17 00:00:00 2001 From: yparitcher Date: Mon, 7 Jan 2019 16:40:11 -0500 Subject: [PATCH 11/24] stm32l432: clean .map files --- targets/stm32l432/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/targets/stm32l432/Makefile b/targets/stm32l432/Makefile index 7de8c2d..793fc63 100644 --- a/targets/stm32l432/Makefile +++ b/targets/stm32l432/Makefile @@ -47,11 +47,10 @@ clean: $(MAKE) -f $(APPMAKE) clean $(MAKE) -f $(BOOTMAKE) clean clean2: - rm -f solo.hex bootloader.hex all.hex + rm -f solo.hex solo.map bootloader.hex bootloader.map all.hex $(MAKE) -f $(APPMAKE) clean $(MAKE) -f $(BOOTMAKE) clean - flash: solo.hex bootloader.hex $(merge_hex) solo.hex bootloader.hex all.hex STM32_Programmer_CLI -c port=SWD -halt -e all --readunprotect From c2342834ddac95a6fdc6b4d49782653ef33709de Mon Sep 17 00:00:00 2001 From: yparitcher Date: Wed, 9 Jan 2019 13:38:41 -0500 Subject: [PATCH 12/24] optimize venv --- targets/stm32l432/Makefile | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/targets/stm32l432/Makefile b/targets/stm32l432/Makefile index 793fc63..ae54730 100644 --- a/targets/stm32l432/Makefile +++ b/targets/stm32l432/Makefile @@ -31,17 +31,17 @@ boot-no-sig: $(MAKE) -f $(BOOTMAKE) -j8 bootloader.hex PREFIX=$(PREFIX) EXTRA_DEFINES='-DSOLO_HACKER' DEBUG=0 build-release-locked: cbor clean2 boot-sig-checking clean all-locked - $(merge_hex) solo.hex bootloader.hex all.hex + $(VENV) $(merge_hex) solo.hex bootloader.hex all.hex rm -f solo.hex bootloader.hex # don't program solo.hex ... build-release: cbor clean2 boot-sig-checking clean all - $(merge_hex) solo.hex bootloader.hex all.hex + $(VENV) $(merge_hex) solo.hex bootloader.hex all.hex build-hacker: cbor clean2 boot-no-sig clean all-hacker - $(merge_hex) solo.hex bootloader.hex all.hex + $(VENV) $(merge_hex) solo.hex bootloader.hex all.hex build-debugboot: clean2 debugboot-boot clean debugboot-app - $(merge_hex) solo.hex bootloader.hex all.hex + $(VENV) $(merge_hex) solo.hex bootloader.hex all.hex clean: $(MAKE) -f $(APPMAKE) clean @@ -52,17 +52,17 @@ clean2: $(MAKE) -f $(BOOTMAKE) clean flash: solo.hex bootloader.hex - $(merge_hex) solo.hex bootloader.hex all.hex + $(VENV) $(merge_hex) solo.hex bootloader.hex all.hex STM32_Programmer_CLI -c port=SWD -halt -e all --readunprotect STM32_Programmer_CLI -c port=SWD -halt -d all.hex -rst flash_dfu: solo.hex bootloader.hex - $(merge_hex) solo.hex bootloader.hex all.hex + $(VENV) $(merge_hex) solo.hex bootloader.hex all.hex # STM32_Programmer_CLI -c port=usb1 -halt -e all --readunprotect STM32_Programmer_CLI -c port=usb1 -halt -rdu -d all.hex flashboot: solo.hex bootloader.hex - $(merge_hex) solo.hex bootloader.hex all.hex + $(VENV) $(merge_hex) solo.hex bootloader.hex all.hex STM32_Programmer_CLI -c port=SWD -halt -e all --readunprotect STM32_Programmer_CLI -c port=SWD -halt -d bootloader.hex -rst @@ -80,8 +80,8 @@ cbor: $(MAKE) -f application.mk -j8 cbor test: - $(VENV) $(MAKE) build-release-locked - $(VENV) $(MAKE) build-release - $(VENV) $(MAKE) build-hacker - $(VENV) $(MAKE) build-debugboot + $(MAKE) build-release-locked + $(MAKE) build-release + $(MAKE) build-hacker + $(MAKE) build-debugboot $(MAKE) clean2 From a4f01c3f237c18f1d4f68d2ea59981b34583a2b3 Mon Sep 17 00:00:00 2001 From: yparitcher Date: Wed, 9 Jan 2019 13:56:48 -0500 Subject: [PATCH 13/24] PHONY targets --- targets/stm32l432/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/targets/stm32l432/Makefile b/targets/stm32l432/Makefile index ae54730..a074d6f 100644 --- a/targets/stm32l432/Makefile +++ b/targets/stm32l432/Makefile @@ -7,6 +7,8 @@ BOOTMAKE=build/application.mk merge_hex=../../tools/solotool.py mergehex +.PHONY: all all-hacker all-locked debugboot-app debugboot-boot boot-sig-checking boot-no-sig build-release-locked build-release build-release build-hacker build-debugboot clean clean2 flash flash_dfu flashboot detach cbor test + all: $(MAKE) -f $(APPMAKE) -j8 solo.hex PREFIX=$(PREFIX) DEBUG=$(DEBUG) EXTRA_DEFINES='-DFLASH_ROP=1' From eba9ce847567d5d6bf6884a2dd6d532b9f7e0a6b Mon Sep 17 00:00:00 2001 From: yparitcher Date: Wed, 9 Jan 2019 14:11:50 -0500 Subject: [PATCH 14/24] fix usbd_hid.c --- targets/stm32l432/lib/usbd/usbd_hid.c | 124 +++++++++++++------------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/targets/stm32l432/lib/usbd/usbd_hid.c b/targets/stm32l432/lib/usbd/usbd_hid.c index f799681..bf32911 100644 --- a/targets/stm32l432/lib/usbd/usbd_hid.c +++ b/targets/stm32l432/lib/usbd/usbd_hid.c @@ -90,9 +90,9 @@ static uint8_t USBD_HID_DeInit (USBD_HandleTypeDef *pdev, static uint8_t USBD_HID_Setup (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); -//static uint8_t *USBD_HID_GetFSCfgDesc (uint16_t *length); +static uint8_t *USBD_HID_GetFSCfgDesc (uint16_t *length); -//static uint8_t *USBD_HID_GetDeviceQualifierDesc (uint16_t *length); +static uint8_t *USBD_HID_GetDeviceQualifierDesc (uint16_t *length); static uint8_t USBD_HID_DataIn (USBD_HandleTypeDef *pdev, uint8_t epnum); @@ -124,60 +124,60 @@ USBD_ClassTypeDef USBD_HID = #define USBD_HID_CfgFSDesc USBD_HID_OtherSpeedCfgDesc /* USB HID device Other Speed Configuration Descriptor */ -//__ALIGN_BEGIN static uint8_t USBD_HID_OtherSpeedCfgDesc[] __ALIGN_END = -//{ -// 0x09, /* bLength: Configuration Descriptor size */ -// USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */ -// 9 + 9 + 9+ 7+7, -// /* wTotalLength: Bytes returned */ -// 0x00, -// 0x01, /*bNumInterfaces: 1 interface*/ -// 0x01, /*bConfigurationValue: Configuration value*/ -// 0x00, /*iConfiguration: Index of string descriptor describing -// the configuration*/ -// 0x80, /*bmAttributes: bus powered and Support Remote Wake-up */ -// 0x32, /*MaxPower 100 mA: this current is used for detecting Vbus*/ -// -// /************** Descriptor of Joystick Mouse interface ****************/ -// /* 09 */ -// 0x09, /*bLength: Interface Descriptor size*/ -// USB_DESC_TYPE_INTERFACE,/*bDescriptorType: Interface descriptor type*/ -// 0x00, /*bInterfaceNumber: Number of Interface*/ -// 0x00, /*bAlternateSetting: Alternate setting*/ -// 0x02, /*bNumEndpoints*/ -// 0x03, /*bInterfaceClass: HID*/ -// 0x00, /*bInterfaceSubClass : 1=BOOT, 0=no boot*/ -// 0x00, /*nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse*/ -// 2, /*iInterface: Index of string descriptor*/ -// /******************** Descriptor of Joystick Mouse HID ********************/ -// /* 18 */ -// 0x09, /*bLength: HID Descriptor size*/ -// HID_DESCRIPTOR_TYPE, /*bDescriptorType: HID*/ -// 0x11, /*bcdHID: HID Class Spec release number*/ -// 0x01, -// 0x00, /*bCountryCode: Hardware target country*/ -// 0x01, /*bNumDescriptors: Number of HID class descriptors to follow*/ -// 0x22, /*bDescriptorType*/ -// HID_FIDO_REPORT_DESC_SIZE,/*wItemLength: Total length of Report descriptor*/ -// 0x00, -// /******************** Descriptor of Mouse endpoint ********************/ -// 0x07, /*bLength: Endpoint Descriptor size*/ -// USB_DESC_TYPE_ENDPOINT, /*bDescriptorType:*/ -// HID_EPIN_ADDR, /*bEndpointAddress: Endpoint Address (IN)*/ -// 0x03, /*bmAttributes: Interrupt endpoint*/ -// HID_EPIN_SIZE, /*wMaxPacketSize: 4 Byte max */ -// 0x00, -// HID_BINTERVAL, /*bInterval: Polling Interval */ -// -// -// 0x07, /*bLength: Endpoint Descriptor size*/ -// USB_DESC_TYPE_ENDPOINT, /*bDescriptorType:*/ -// HID_EPOUT_ADDR, /*bEndpointAddress: Endpoint Address (IN)*/ -// 0x03, /*bmAttributes: Interrupt endpoint*/ -// HID_EPOUT_SIZE, /*wMaxPacketSize: 4 Byte max */ -// 0x00, -// HID_BINTERVAL, /*bInterval: Polling Interval */ -//}; +__ALIGN_BEGIN static uint8_t USBD_HID_OtherSpeedCfgDesc[] __ALIGN_END = +{ + 0x09, /* bLength: Configuration Descriptor size */ + USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */ + 9 + 9 + 9+ 7+7, + /* wTotalLength: Bytes returned */ + 0x00, + 0x01, /*bNumInterfaces: 1 interface*/ + 0x01, /*bConfigurationValue: Configuration value*/ + 0x00, /*iConfiguration: Index of string descriptor describing + the configuration*/ + 0x80, /*bmAttributes: bus powered and Support Remote Wake-up */ + 0x32, /*MaxPower 100 mA: this current is used for detecting Vbus*/ + + /************** Descriptor of Joystick Mouse interface ****************/ + /* 09 */ + 0x09, /*bLength: Interface Descriptor size*/ + USB_DESC_TYPE_INTERFACE,/*bDescriptorType: Interface descriptor type*/ + 0x00, /*bInterfaceNumber: Number of Interface*/ + 0x00, /*bAlternateSetting: Alternate setting*/ + 0x02, /*bNumEndpoints*/ + 0x03, /*bInterfaceClass: HID*/ + 0x00, /*bInterfaceSubClass : 1=BOOT, 0=no boot*/ + 0x00, /*nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse*/ + 2, /*iInterface: Index of string descriptor*/ + /******************** Descriptor of Joystick Mouse HID ********************/ + /* 18 */ + 0x09, /*bLength: HID Descriptor size*/ + HID_DESCRIPTOR_TYPE, /*bDescriptorType: HID*/ + 0x11, /*bcdHID: HID Class Spec release number*/ + 0x01, + 0x00, /*bCountryCode: Hardware target country*/ + 0x01, /*bNumDescriptors: Number of HID class descriptors to follow*/ + 0x22, /*bDescriptorType*/ + HID_FIDO_REPORT_DESC_SIZE,/*wItemLength: Total length of Report descriptor*/ + 0x00, + /******************** Descriptor of Mouse endpoint ********************/ + 0x07, /*bLength: Endpoint Descriptor size*/ + USB_DESC_TYPE_ENDPOINT, /*bDescriptorType:*/ + HID_EPIN_ADDR, /*bEndpointAddress: Endpoint Address (IN)*/ + 0x03, /*bmAttributes: Interrupt endpoint*/ + HID_EPIN_SIZE, /*wMaxPacketSize: 4 Byte max */ + 0x00, + HID_BINTERVAL, /*bInterval: Polling Interval */ + + + 0x07, /*bLength: Endpoint Descriptor size*/ + USB_DESC_TYPE_ENDPOINT, /*bDescriptorType:*/ + HID_EPOUT_ADDR, /*bEndpointAddress: Endpoint Address (IN)*/ + 0x03, /*bmAttributes: Interrupt endpoint*/ + HID_EPOUT_SIZE, /*wMaxPacketSize: 4 Byte max */ + 0x00, + HID_BINTERVAL, /*bInterval: Polling Interval */ +}; /* USB HID device Configuration Descriptor */ @@ -196,7 +196,7 @@ __ALIGN_BEGIN static uint8_t USBD_HID_Desc[USB_HID_DESC_SIZ] __ALIGN_END = }; /* USB Standard Device Descriptor */ -/*__ALIGN_BEGIN static uint8_t USBD_HID_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] __ALIGN_END = +__ALIGN_BEGIN static uint8_t USBD_HID_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] __ALIGN_END = { USB_LEN_DEV_QUALIFIER_DESC, USB_DESC_TYPE_DEVICE_QUALIFIER, @@ -208,7 +208,7 @@ __ALIGN_BEGIN static uint8_t USBD_HID_Desc[USB_HID_DESC_SIZ] __ALIGN_END = 0x40, 0x01, 0x00, -};*/ +}; __ALIGN_BEGIN static uint8_t HID_MOUSE_ReportDesc[HID_FIDO_REPORT_DESC_SIZE] __ALIGN_END = { @@ -456,11 +456,11 @@ static uint8_t USBD_HID_Setup (USBD_HandleTypeDef *pdev, * @param length : pointer data length * @retval pointer to descriptor buffer */ -/*static uint8_t *USBD_HID_GetFSCfgDesc (uint16_t *length) +static uint8_t *USBD_HID_GetFSCfgDesc (uint16_t *length) { *length = sizeof (USBD_HID_CfgFSDesc); return USBD_HID_CfgFSDesc; -}*/ +} /** * @brief USBD_HID_DataIn @@ -493,8 +493,8 @@ static uint8_t USBD_HID_DataOut (USBD_HandleTypeDef *pdev, * @param length : pointer data length * @retval pointer to descriptor buffer */ -/*static uint8_t *USBD_HID_GetDeviceQualifierDesc (uint16_t *length) +static uint8_t *USBD_HID_GetDeviceQualifierDesc (uint16_t *length) { *length = sizeof (USBD_HID_DeviceQualifierDesc); return USBD_HID_DeviceQualifierDesc; -}*/ +} From 2615fd39ac37c47b6c362a46f7aba5f44146fc20 Mon Sep 17 00:00:00 2001 From: yparitcher Date: Fri, 18 Jan 2019 09:21:43 -0500 Subject: [PATCH 15/24] spacing --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5a81240..b0d3497 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,8 +9,8 @@ addons: - gcc-7 - cppcheck before_install: - - sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa - - sudo apt-get update -q + - sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa + - sudo apt-get update -q - sudo apt-get install -y gcc-arm-embedded script: - export CC=gcc-7 From f005ea438c49848999759272deeefd4f578a898f Mon Sep 17 00:00:00 2001 From: yparitcher Date: Fri, 18 Jan 2019 09:28:31 -0500 Subject: [PATCH 16/24] spacing --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b0d3497..0ebdf85 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ addons: before_install: - sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa - sudo apt-get update -q - - sudo apt-get install -y gcc-arm-embedded + - sudo apt-get install -y gcc-arm-embedded script: - export CC=gcc-7 - make travis From ad4e526497b9725a5e7080deaa1c1e04b253bef1 Mon Sep 17 00:00:00 2001 From: yparitcher Date: Fri, 18 Jan 2019 09:33:13 -0500 Subject: [PATCH 17/24] Travis: install toolchain --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0ebdf85..2c4a2d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ addons: - gcc-7 - cppcheck before_install: - - sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa + - sudo add-apt-repository -y ppa:team-gcc-arm-embedded/ppa - sudo apt-get update -q - sudo apt-get install -y gcc-arm-embedded script: From 589b17c596d352d3d87e795befdd5e15da506f72 Mon Sep 17 00:00:00 2001 From: yparitcher Date: Fri, 18 Jan 2019 09:45:56 -0500 Subject: [PATCH 18/24] Travis: install venv --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 2c4a2d6..e285600 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ before_install: - sudo add-apt-repository -y ppa:team-gcc-arm-embedded/ppa - sudo apt-get update -q - sudo apt-get install -y gcc-arm-embedded + - sudo apt-get install -y python3-venv script: - export CC=gcc-7 - make travis From 259020ece0c59bfdb373792e0b71ce26a18568a5 Mon Sep 17 00:00:00 2001 From: yparitcher Date: Fri, 18 Jan 2019 11:41:07 -0500 Subject: [PATCH 19/24] Travis: use python 3.6 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 126cdb6..1f791e8 100644 --- a/Makefile +++ b/Makefile @@ -80,7 +80,7 @@ env2: env2/bin/pip install --upgrade -r tools/requirements.txt env3: - python3 -m venv env3 + python3.6 -m venv env3 env3/bin/pip -q install --upgrade -r tools/requirements.txt env3/bin/pip -q install --upgrade black From c1631c71720cd775ddabd9fefde8f78e8a9cc39e Mon Sep 17 00:00:00 2001 From: yparitcher Date: Fri, 18 Jan 2019 15:23:22 -0500 Subject: [PATCH 20/24] Travis: try to get python to work --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index e285600..4eb33ca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,4 +15,5 @@ before_install: - sudo apt-get install -y python3-venv script: - export CC=gcc-7 + - pyenv shell 3.6.7 - make travis From f2d0e3d275d43f51ebbb1d8debe503fc45f2f0c1 Mon Sep 17 00:00:00 2001 From: yparitcher Date: Mon, 21 Jan 2019 00:00:55 -0500 Subject: [PATCH 21/24] Revert "Travis: use python 3.6" Hopefuly we dont need this This reverts commit e10ad70b2b8e15de5fcace7af3f8e1cc9a6ca2f0. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1f791e8..126cdb6 100644 --- a/Makefile +++ b/Makefile @@ -80,7 +80,7 @@ env2: env2/bin/pip install --upgrade -r tools/requirements.txt env3: - python3.6 -m venv env3 + python3 -m venv env3 env3/bin/pip -q install --upgrade -r tools/requirements.txt env3/bin/pip -q install --upgrade black From f97d9ab34fd67a0c8e85df0387072c22edc3eafc Mon Sep 17 00:00:00 2001 From: yparitcher Date: Tue, 12 Feb 2019 19:22:35 -0500 Subject: [PATCH 22/24] fixes --- targets/stm32l432/Makefile | 2 +- targets/stm32l432/lib/usbd/usbd_desc.c | 3 +++ targets/stm32l432/src/flash.h | 1 - 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/targets/stm32l432/Makefile b/targets/stm32l432/Makefile index a074d6f..f2f7d10 100644 --- a/targets/stm32l432/Makefile +++ b/targets/stm32l432/Makefile @@ -79,7 +79,7 @@ solo.hex: echo "You need to build the application first." cbor: - $(MAKE) -f application.mk -j8 cbor + $(MAKE) -f $(APPMAKE) -j8 cbor test: $(MAKE) build-release-locked diff --git a/targets/stm32l432/lib/usbd/usbd_desc.c b/targets/stm32l432/lib/usbd/usbd_desc.c index 9a107a2..88b920d 100644 --- a/targets/stm32l432/lib/usbd/usbd_desc.c +++ b/targets/stm32l432/lib/usbd/usbd_desc.c @@ -50,11 +50,14 @@ #include APP_CONFIG +#define USBD_VID 0x0483 +#define USBD_PID 0xA2CA #define USBD_LANGID_STRING 0x409 #define USBD_MANUFACTURER_STRING "SoloKeys" #define USBD_PRODUCT_FS_STRING SOLO_PRODUCT_NAME #define USBD_SERIAL_NUM "0123456789ABCDEF" + uint8_t *USBD_HID_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); uint8_t *USBD_HID_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); uint8_t *USBD_HID_ManufacturerStrDescriptor (USBD_SpeedTypeDef speed, uint16_t *length); diff --git a/targets/stm32l432/src/flash.h b/targets/stm32l432/src/flash.h index e5526df..5da975c 100644 --- a/targets/stm32l432/src/flash.h +++ b/targets/stm32l432/src/flash.h @@ -12,7 +12,6 @@ void flash_write_dword(uint32_t addr, uint64_t data); void flash_write(uint32_t addr, uint8_t * data, size_t sz); void flash_write_fast(uint32_t addr, uint32_t * data); void flash_option_bytes_init(int boot_from_dfu); -void flash_lock(); #define FLASH_PAGE_SIZE 2048 From ce92c7634e81a130b7d5c141164a572b6e0a6d7d Mon Sep 17 00:00:00 2001 From: yparitcher Date: Tue, 12 Feb 2019 19:34:22 -0500 Subject: [PATCH 23/24] fix bootloader version --- targets/stm32l432/src/version.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/targets/stm32l432/src/version.h b/targets/stm32l432/src/version.h index ea97314..fcad14d 100644 --- a/targets/stm32l432/src/version.h +++ b/targets/stm32l432/src/version.h @@ -10,6 +10,10 @@ #endif +#define BOOT_VERSION_MAJ 1 +#define BOOT_VERSION_MIN 0 +#define BOOT_VERSION_PATCH 0 + #define __STR_HELPER(x) #x #define __STR(x) __STR_HELPER(x) From bfd8827073e5d5096f783b7322cd77a361a4232e Mon Sep 17 00:00:00 2001 From: yparitcher Date: Tue, 12 Feb 2019 19:35:33 -0500 Subject: [PATCH 24/24] fix Makfile: bootloader --- targets/stm32l432/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targets/stm32l432/Makefile b/targets/stm32l432/Makefile index f2f7d10..8634507 100644 --- a/targets/stm32l432/Makefile +++ b/targets/stm32l432/Makefile @@ -3,7 +3,7 @@ DEBUG=0 endif APPMAKE=build/application.mk -BOOTMAKE=build/application.mk +BOOTMAKE=build/bootloader.mk merge_hex=../../tools/solotool.py mergehex