clean up build: GCC warnings
This commit is contained in:
parent
23c140fd99
commit
400b37a96a
13
fido2/ctap.c
13
fido2/ctap.c
@ -1358,8 +1358,9 @@ uint8_t ctap_request(uint8_t * pkt_raw, int length, CTAP_RESPONSE * resp)
|
|||||||
CborEncoder encoder;
|
CborEncoder encoder;
|
||||||
uint8_t status = 0;
|
uint8_t status = 0;
|
||||||
uint8_t cmd = *pkt_raw;
|
uint8_t cmd = *pkt_raw;
|
||||||
uint64_t t1;
|
#if DEBUG_LEVEL > 0
|
||||||
uint64_t t2;
|
uint64_t t1,t2;
|
||||||
|
#endif
|
||||||
pkt_raw++;
|
pkt_raw++;
|
||||||
length--;
|
length--;
|
||||||
|
|
||||||
@ -1392,10 +1393,14 @@ uint8_t ctap_request(uint8_t * pkt_raw, int length, CTAP_RESPONSE * resp)
|
|||||||
case CTAP_MAKE_CREDENTIAL:
|
case CTAP_MAKE_CREDENTIAL:
|
||||||
device_set_status(CTAPHID_STATUS_PROCESSING);
|
device_set_status(CTAPHID_STATUS_PROCESSING);
|
||||||
printf1(TAG_CTAP,"CTAP_MAKE_CREDENTIAL\n");
|
printf1(TAG_CTAP,"CTAP_MAKE_CREDENTIAL\n");
|
||||||
|
#if DEBUG_LEVEL > 0
|
||||||
t1 = millis();
|
t1 = millis();
|
||||||
|
#endif
|
||||||
status = ctap_make_credential(&encoder, pkt_raw, length);
|
status = ctap_make_credential(&encoder, pkt_raw, length);
|
||||||
|
#if DEBUG_LEVEL > 0
|
||||||
t2 = millis();
|
t2 = millis();
|
||||||
printf1(TAG_TIME,"make_credential time: %d ms\n", t2-t1);
|
printf1(TAG_TIME,"make_credential time: %d ms\n", t2-t1);
|
||||||
|
#endif
|
||||||
|
|
||||||
resp->length = cbor_encoder_get_buffer_size(&encoder, buf);
|
resp->length = cbor_encoder_get_buffer_size(&encoder, buf);
|
||||||
dump_hex1(TAG_DUMP, buf, resp->length);
|
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:
|
case CTAP_GET_ASSERTION:
|
||||||
device_set_status(CTAPHID_STATUS_PROCESSING);
|
device_set_status(CTAPHID_STATUS_PROCESSING);
|
||||||
printf1(TAG_CTAP,"CTAP_GET_ASSERTION\n");
|
printf1(TAG_CTAP,"CTAP_GET_ASSERTION\n");
|
||||||
|
#if DEBUG_LEVEL > 0
|
||||||
t1 = millis();
|
t1 = millis();
|
||||||
|
#endif
|
||||||
status = ctap_get_assertion(&encoder, pkt_raw, length);
|
status = ctap_get_assertion(&encoder, pkt_raw, length);
|
||||||
|
#if DEBUG_LEVEL > 0
|
||||||
t2 = millis();
|
t2 = millis();
|
||||||
printf1(TAG_TIME,"get_assertion time: %d ms\n", t2-t1);
|
printf1(TAG_TIME,"get_assertion time: %d ms\n", t2-t1);
|
||||||
|
#endif
|
||||||
|
|
||||||
resp->length = cbor_encoder_get_buffer_size(&encoder, buf);
|
resp->length = cbor_encoder_get_buffer_size(&encoder, buf);
|
||||||
|
|
||||||
|
@ -533,13 +533,21 @@ uint8_t ctaphid_handle_packet(uint8_t * pkt_raw)
|
|||||||
uint8_t cmd;
|
uint8_t cmd;
|
||||||
uint32_t cid;
|
uint32_t cid;
|
||||||
int len;
|
int len;
|
||||||
|
#ifndef DISABLE_CTAPHID_CBOR
|
||||||
int status;
|
int status;
|
||||||
|
#endif
|
||||||
|
|
||||||
static uint8_t is_busy = 0;
|
static uint8_t is_busy = 0;
|
||||||
static CTAPHID_WRITE_BUFFER wb;
|
static CTAPHID_WRITE_BUFFER wb;
|
||||||
CTAP_RESPONSE ctap_resp;
|
CTAP_RESPONSE ctap_resp;
|
||||||
|
|
||||||
|
#ifndef DISABLE_CTAPHID_PING
|
||||||
|
#ifndef DISABLE_CTAPHID_CBOR
|
||||||
|
#if DEBUG_LEVEL > 0
|
||||||
uint32_t t1,t2;
|
uint32_t t1,t2;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
int bufstatus = ctaphid_buffer_packet(pkt_raw, &cmd, &cid, &len);
|
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.cid = cid;
|
||||||
wb.cmd = CTAPHID_PING;
|
wb.cmd = CTAPHID_PING;
|
||||||
wb.bcnt = len;
|
wb.bcnt = len;
|
||||||
|
#if DEBUG_LEVEL > 0
|
||||||
t1 = millis();
|
t1 = millis();
|
||||||
|
#endif
|
||||||
ctaphid_write(&wb, ctap_buffer, len);
|
ctaphid_write(&wb, ctap_buffer, len);
|
||||||
ctaphid_write(&wb, NULL,0);
|
ctaphid_write(&wb, NULL,0);
|
||||||
|
#if DEBUG_LEVEL > 0
|
||||||
t2 = millis();
|
t2 = millis();
|
||||||
printf1(TAG_TIME,"PING writeback: %d ms\n",(uint32_t)(t2-t1));
|
printf1(TAG_TIME,"PING writeback: %d ms\n",(uint32_t)(t2-t1));
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#ifndef DISABLE_CTAPHID_WINK
|
#ifndef DISABLE_CTAPHID_WINK
|
||||||
@ -629,12 +641,16 @@ uint8_t ctaphid_handle_packet(uint8_t * pkt_raw)
|
|||||||
wb.bcnt = (ctap_resp.length+1);
|
wb.bcnt = (ctap_resp.length+1);
|
||||||
|
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL > 0
|
||||||
t1 = millis();
|
t1 = millis();
|
||||||
|
#endif
|
||||||
ctaphid_write(&wb, &status, 1);
|
ctaphid_write(&wb, &status, 1);
|
||||||
ctaphid_write(&wb, ctap_resp.data, ctap_resp.length);
|
ctaphid_write(&wb, ctap_resp.data, ctap_resp.length);
|
||||||
ctaphid_write(&wb, NULL, 0);
|
ctaphid_write(&wb, NULL, 0);
|
||||||
|
#if DEBUG_LEVEL > 0
|
||||||
t2 = millis();
|
t2 = millis();
|
||||||
printf1(TAG_TIME,"CBOR writeback: %d ms\n",(uint32_t)(t2-t1));
|
printf1(TAG_TIME,"CBOR writeback: %d ms\n",(uint32_t)(t2-t1));
|
||||||
|
#endif
|
||||||
is_busy = 0;
|
is_busy = 0;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
@ -58,9 +58,9 @@ void set_logging_mask(uint32_t mask);
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
#define set_logging_mask(mask)
|
#define set_logging_mask(mask)
|
||||||
#define printf1(fmt, ...)
|
#define printf1(tag,fmt, ...)
|
||||||
#define printf2(fmt, ...)
|
#define printf2(tag,fmt, ...)
|
||||||
#define printf3(fmt, ...)
|
#define printf3(tag,fmt, ...)
|
||||||
#define dump_hex1(tag,data,len)
|
#define dump_hex1(tag,data,len)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
19
fido2/u2f.c
19
fido2/u2f.c
@ -11,11 +11,16 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
#include "wallet.h"
|
#include "wallet.h"
|
||||||
|
#ifdef ENABLE_U2F_EXTENSIONS
|
||||||
|
#include "extensions.h"
|
||||||
|
#endif
|
||||||
#include APP_CONFIG
|
#include APP_CONFIG
|
||||||
|
|
||||||
// void u2f_response_writeback(uint8_t * buf, uint8_t len);
|
// 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_register(struct u2f_register_request * req);
|
||||||
static int16_t u2f_authenticate(struct u2f_authenticate_request * req, uint8_t control);
|
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);
|
int8_t u2f_response_writeback(const uint8_t * buf, uint16_t len);
|
||||||
void u2f_reset_response();
|
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)
|
void u2f_request(struct u2f_request_apdu* req, CTAP_RESPONSE * resp)
|
||||||
{
|
{
|
||||||
uint16_t rcode = 0;
|
uint16_t rcode = 0;
|
||||||
|
#ifdef ENABLE_U2F
|
||||||
|
#if DEBUG_LEVEL > 0
|
||||||
uint64_t t1,t2;
|
uint64_t t1,t2;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
uint32_t len = ((req->LC3) | ((uint32_t)req->LC2 << 8) | ((uint32_t)req->LC1 << 16));
|
uint32_t len = ((req->LC3) | ((uint32_t)req->LC2 << 8) | ((uint32_t)req->LC1 << 16));
|
||||||
uint8_t byte;
|
uint8_t byte;
|
||||||
|
|
||||||
@ -53,18 +62,26 @@ void u2f_request(struct u2f_request_apdu* req, CTAP_RESPONSE * resp)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#if DEBUG_LEVEL > 0
|
||||||
t1 = millis();
|
t1 = millis();
|
||||||
|
#endif
|
||||||
rcode = u2f_register((struct u2f_register_request*)req->payload);
|
rcode = u2f_register((struct u2f_register_request*)req->payload);
|
||||||
|
#if DEBUG_LEVEL > 0
|
||||||
t2 = millis();
|
t2 = millis();
|
||||||
printf1(TAG_TIME,"u2f_register time: %d ms\n", t2-t1);
|
printf1(TAG_TIME,"u2f_register time: %d ms\n", t2-t1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case U2F_AUTHENTICATE:
|
case U2F_AUTHENTICATE:
|
||||||
printf1(TAG_U2F, "U2F_AUTHENTICATE\n");
|
printf1(TAG_U2F, "U2F_AUTHENTICATE\n");
|
||||||
|
#if DEBUG_LEVEL > 0
|
||||||
t1 = millis();
|
t1 = millis();
|
||||||
|
#endif
|
||||||
rcode = u2f_authenticate((struct u2f_authenticate_request*)req->payload, req->p1);
|
rcode = u2f_authenticate((struct u2f_authenticate_request*)req->payload, req->p1);
|
||||||
|
#if DEBUG_LEVEL > 0
|
||||||
t2 = millis();
|
t2 = millis();
|
||||||
printf1(TAG_TIME,"u2f_authenticate time: %d ms\n", t2-t1);
|
printf1(TAG_TIME,"u2f_authenticate time: %d ms\n", t2-t1);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case U2F_VERSION:
|
case U2F_VERSION:
|
||||||
printf1(TAG_U2F, "U2F_VERSION\n");
|
printf1(TAG_U2F, "U2F_VERSION\n");
|
||||||
@ -128,6 +145,7 @@ void u2f_set_writeback_buffer(CTAP_RESPONSE * resp)
|
|||||||
_u2f_resp = resp;
|
_u2f_resp = resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_U2F
|
||||||
static void dump_signature_der(uint8_t * sig)
|
static void dump_signature_der(uint8_t * sig)
|
||||||
{
|
{
|
||||||
uint8_t sigder[72];
|
uint8_t sigder[72];
|
||||||
@ -300,6 +318,7 @@ static int16_t u2f_register(struct u2f_register_request * req)
|
|||||||
|
|
||||||
return U2F_SW_NO_ERROR;
|
return U2F_SW_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int16_t u2f_version()
|
int16_t u2f_version()
|
||||||
{
|
{
|
||||||
|
@ -95,9 +95,10 @@ int is_bootloader_disabled()
|
|||||||
int bootloader_bridge(int klen, uint8_t * keyh)
|
int bootloader_bridge(int klen, uint8_t * keyh)
|
||||||
{
|
{
|
||||||
static int has_erased = 0;
|
static int has_erased = 0;
|
||||||
int i;
|
|
||||||
BootloaderReq * req = (BootloaderReq * )keyh;
|
BootloaderReq * req = (BootloaderReq * )keyh;
|
||||||
|
#ifndef SOLO_HACKER
|
||||||
uint8_t hash[32];
|
uint8_t hash[32];
|
||||||
|
#endif
|
||||||
uint8_t version = 1;
|
uint8_t version = 1;
|
||||||
uint16_t len = (req->lenh << 8) | (req->lenl);
|
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;
|
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";
|
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;
|
const struct uECC_Curve_t * curve = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
uint32_t addr = ((*((uint32_t*)req->addr)) & 0xffffff) | 0x8000000;
|
uint32_t addr = ((*((uint32_t*)req->addr)) & 0xffffff) | 0x8000000;
|
||||||
|
|
||||||
|
@ -42,7 +42,9 @@ int main(int argc, char * argv[])
|
|||||||
{
|
{
|
||||||
uint8_t hidmsg[64];
|
uint8_t hidmsg[64];
|
||||||
uint32_t t1 = 0;
|
uint32_t t1 = 0;
|
||||||
|
#ifdef SOLO_HACKER
|
||||||
uint32_t stboot_time = 0;
|
uint32_t stboot_time = 0;
|
||||||
|
#endif
|
||||||
uint32_t boot = 1;
|
uint32_t boot = 1;
|
||||||
|
|
||||||
set_logging_mask(
|
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);
|
printf1(TAG_RED,"Not authorized to boot (%08x == %08lx)\r\n", AUTH_WORD_ADDR, *(uint32_t*)AUTH_WORD_ADDR);
|
||||||
}
|
}
|
||||||
|
#ifdef SOLO_HACKER
|
||||||
start_bootloader:
|
start_bootloader:
|
||||||
|
#endif
|
||||||
usbhid_init();
|
usbhid_init();
|
||||||
printf1(TAG_GEN,"init usb\n");
|
printf1(TAG_GEN,"init usb\n");
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ all: $(TARGET).elf
|
|||||||
$(CP) -O ihex $^ $(TARGET).hex
|
$(CP) -O ihex $^ $(TARGET).hex
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o src/*.o src/*.elf bootloader/*.o $(OBJ)
|
rm -f *.o src/*.o *.elf bootloader/*.o $(OBJ)
|
||||||
|
|
||||||
|
|
||||||
cbor:
|
cbor:
|
||||||
|
@ -68,4 +68,4 @@ all: $(TARGET).elf
|
|||||||
$(CP) -O ihex $^ $(TARGET).hex
|
$(CP) -O ihex $^ $(TARGET).hex
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o src/*.o bootloader/*.o src/*.elf $(OBJ)
|
rm -f *.o src/*.o bootloader/*.o *.elf $(OBJ)
|
||||||
|
@ -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_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);
|
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
|
* @param length : pointer data length
|
||||||
* @retval pointer to descriptor buffer
|
* @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);
|
*length = sizeof (USBD_CDC_CfgFSDesc);
|
||||||
return USBD_CDC_CfgFSDesc;
|
return USBD_CDC_CfgFSDesc;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
* @brief USBD_CDC_GetHSCfgDesc
|
* @brief USBD_CDC_GetHSCfgDesc
|
||||||
* Return configuration descriptor
|
* Return configuration descriptor
|
||||||
@ -802,12 +802,12 @@ static uint8_t *USBD_CDC_GetFSCfgDesc (uint16_t *length)
|
|||||||
* @param length : pointer data length
|
* @param length : pointer data length
|
||||||
* @retval pointer to descriptor buffer
|
* @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);
|
*length = sizeof (USBD_CDC_CfgHSDesc);
|
||||||
return USBD_CDC_CfgHSDesc;
|
return USBD_CDC_CfgHSDesc;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
* @brief USBD_CDC_GetCfgDesc
|
* @brief USBD_CDC_GetCfgDesc
|
||||||
* Return configuration descriptor
|
* Return configuration descriptor
|
||||||
@ -815,12 +815,12 @@ static uint8_t *USBD_CDC_GetHSCfgDesc (uint16_t *length)
|
|||||||
* @param length : pointer data length
|
* @param length : pointer data length
|
||||||
* @retval pointer to descriptor buffer
|
* @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);
|
*length = sizeof (USBD_CDC_OtherSpeedCfgDesc);
|
||||||
return USBD_CDC_OtherSpeedCfgDesc;
|
return USBD_CDC_OtherSpeedCfgDesc;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
* @brief DeviceQualifierDescriptor
|
* @brief DeviceQualifierDescriptor
|
||||||
* return Device Qualifier descriptor
|
* return Device Qualifier descriptor
|
||||||
|
@ -90,9 +90,9 @@ static uint8_t USBD_HID_DeInit (USBD_HandleTypeDef *pdev,
|
|||||||
static uint8_t USBD_HID_Setup (USBD_HandleTypeDef *pdev,
|
static uint8_t USBD_HID_Setup (USBD_HandleTypeDef *pdev,
|
||||||
USBD_SetupReqTypedef *req);
|
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);
|
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
|
#define USBD_HID_CfgFSDesc USBD_HID_OtherSpeedCfgDesc
|
||||||
|
|
||||||
/* USB HID device Other Speed Configuration Descriptor */
|
/* USB HID device Other Speed Configuration Descriptor */
|
||||||
__ALIGN_BEGIN static uint8_t USBD_HID_OtherSpeedCfgDesc[] __ALIGN_END =
|
//__ALIGN_BEGIN static uint8_t USBD_HID_OtherSpeedCfgDesc[] __ALIGN_END =
|
||||||
{
|
//{
|
||||||
0x09, /* bLength: Configuration Descriptor size */
|
// 0x09, /* bLength: Configuration Descriptor size */
|
||||||
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
|
// USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
|
||||||
9 + 9 + 9+ 7+7,
|
// 9 + 9 + 9+ 7+7,
|
||||||
/* wTotalLength: Bytes returned */
|
// /* wTotalLength: Bytes returned */
|
||||||
0x00,
|
// 0x00,
|
||||||
0x01, /*bNumInterfaces: 1 interface*/
|
// 0x01, /*bNumInterfaces: 1 interface*/
|
||||||
0x01, /*bConfigurationValue: Configuration value*/
|
// 0x01, /*bConfigurationValue: Configuration value*/
|
||||||
0x00, /*iConfiguration: Index of string descriptor describing
|
// 0x00, /*iConfiguration: Index of string descriptor describing
|
||||||
the configuration*/
|
// the configuration*/
|
||||||
0x80, /*bmAttributes: bus powered and Support Remote Wake-up */
|
// 0x80, /*bmAttributes: bus powered and Support Remote Wake-up */
|
||||||
0x32, /*MaxPower 100 mA: this current is used for detecting Vbus*/
|
// 0x32, /*MaxPower 100 mA: this current is used for detecting Vbus*/
|
||||||
|
//
|
||||||
/************** Descriptor of Joystick Mouse interface ****************/
|
// /************** Descriptor of Joystick Mouse interface ****************/
|
||||||
/* 09 */
|
// /* 09 */
|
||||||
0x09, /*bLength: Interface Descriptor size*/
|
// 0x09, /*bLength: Interface Descriptor size*/
|
||||||
USB_DESC_TYPE_INTERFACE,/*bDescriptorType: Interface descriptor type*/
|
// USB_DESC_TYPE_INTERFACE,/*bDescriptorType: Interface descriptor type*/
|
||||||
0x00, /*bInterfaceNumber: Number of Interface*/
|
// 0x00, /*bInterfaceNumber: Number of Interface*/
|
||||||
0x00, /*bAlternateSetting: Alternate setting*/
|
// 0x00, /*bAlternateSetting: Alternate setting*/
|
||||||
0x02, /*bNumEndpoints*/
|
// 0x02, /*bNumEndpoints*/
|
||||||
0x03, /*bInterfaceClass: HID*/
|
// 0x03, /*bInterfaceClass: HID*/
|
||||||
0x00, /*bInterfaceSubClass : 1=BOOT, 0=no boot*/
|
// 0x00, /*bInterfaceSubClass : 1=BOOT, 0=no boot*/
|
||||||
0x00, /*nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse*/
|
// 0x00, /*nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse*/
|
||||||
2, /*iInterface: Index of string descriptor*/
|
// 2, /*iInterface: Index of string descriptor*/
|
||||||
/******************** Descriptor of Joystick Mouse HID ********************/
|
// /******************** Descriptor of Joystick Mouse HID ********************/
|
||||||
/* 18 */
|
// /* 18 */
|
||||||
0x09, /*bLength: HID Descriptor size*/
|
// 0x09, /*bLength: HID Descriptor size*/
|
||||||
HID_DESCRIPTOR_TYPE, /*bDescriptorType: HID*/
|
// HID_DESCRIPTOR_TYPE, /*bDescriptorType: HID*/
|
||||||
0x11, /*bcdHID: HID Class Spec release number*/
|
// 0x11, /*bcdHID: HID Class Spec release number*/
|
||||||
0x01,
|
// 0x01,
|
||||||
0x00, /*bCountryCode: Hardware target country*/
|
// 0x00, /*bCountryCode: Hardware target country*/
|
||||||
0x01, /*bNumDescriptors: Number of HID class descriptors to follow*/
|
// 0x01, /*bNumDescriptors: Number of HID class descriptors to follow*/
|
||||||
0x22, /*bDescriptorType*/
|
// 0x22, /*bDescriptorType*/
|
||||||
HID_FIDO_REPORT_DESC_SIZE,/*wItemLength: Total length of Report descriptor*/
|
// HID_FIDO_REPORT_DESC_SIZE,/*wItemLength: Total length of Report descriptor*/
|
||||||
0x00,
|
// 0x00,
|
||||||
/******************** Descriptor of Mouse endpoint ********************/
|
// /******************** Descriptor of Mouse endpoint ********************/
|
||||||
0x07, /*bLength: Endpoint Descriptor size*/
|
// 0x07, /*bLength: Endpoint Descriptor size*/
|
||||||
USB_DESC_TYPE_ENDPOINT, /*bDescriptorType:*/
|
// USB_DESC_TYPE_ENDPOINT, /*bDescriptorType:*/
|
||||||
HID_EPIN_ADDR, /*bEndpointAddress: Endpoint Address (IN)*/
|
// HID_EPIN_ADDR, /*bEndpointAddress: Endpoint Address (IN)*/
|
||||||
0x03, /*bmAttributes: Interrupt endpoint*/
|
// 0x03, /*bmAttributes: Interrupt endpoint*/
|
||||||
HID_EPIN_SIZE, /*wMaxPacketSize: 4 Byte max */
|
// HID_EPIN_SIZE, /*wMaxPacketSize: 4 Byte max */
|
||||||
0x00,
|
// 0x00,
|
||||||
HID_BINTERVAL, /*bInterval: Polling Interval */
|
// HID_BINTERVAL, /*bInterval: Polling Interval */
|
||||||
|
//
|
||||||
|
//
|
||||||
0x07, /*bLength: Endpoint Descriptor size*/
|
// 0x07, /*bLength: Endpoint Descriptor size*/
|
||||||
USB_DESC_TYPE_ENDPOINT, /*bDescriptorType:*/
|
// USB_DESC_TYPE_ENDPOINT, /*bDescriptorType:*/
|
||||||
HID_EPOUT_ADDR, /*bEndpointAddress: Endpoint Address (IN)*/
|
// HID_EPOUT_ADDR, /*bEndpointAddress: Endpoint Address (IN)*/
|
||||||
0x03, /*bmAttributes: Interrupt endpoint*/
|
// 0x03, /*bmAttributes: Interrupt endpoint*/
|
||||||
HID_EPOUT_SIZE, /*wMaxPacketSize: 4 Byte max */
|
// HID_EPOUT_SIZE, /*wMaxPacketSize: 4 Byte max */
|
||||||
0x00,
|
// 0x00,
|
||||||
HID_BINTERVAL, /*bInterval: Polling Interval */
|
// HID_BINTERVAL, /*bInterval: Polling Interval */
|
||||||
};
|
//};
|
||||||
|
|
||||||
|
|
||||||
/* USB HID device Configuration Descriptor */
|
/* 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 */
|
/* 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_LEN_DEV_QUALIFIER_DESC,
|
||||||
USB_DESC_TYPE_DEVICE_QUALIFIER,
|
USB_DESC_TYPE_DEVICE_QUALIFIER,
|
||||||
@ -208,7 +208,7 @@ __ALIGN_BEGIN static uint8_t USBD_HID_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_
|
|||||||
0x40,
|
0x40,
|
||||||
0x01,
|
0x01,
|
||||||
0x00,
|
0x00,
|
||||||
};
|
};*/
|
||||||
__ALIGN_BEGIN static uint8_t HID_MOUSE_ReportDesc[HID_FIDO_REPORT_DESC_SIZE] __ALIGN_END =
|
__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
|
* @param length : pointer data length
|
||||||
* @retval pointer to descriptor buffer
|
* @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);
|
*length = sizeof (USBD_HID_CfgFSDesc);
|
||||||
return USBD_HID_CfgFSDesc;
|
return USBD_HID_CfgFSDesc;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_HID_DataIn
|
* @brief USBD_HID_DataIn
|
||||||
@ -493,8 +493,8 @@ static uint8_t USBD_HID_DataOut (USBD_HandleTypeDef *pdev,
|
|||||||
* @param length : pointer data length
|
* @param length : pointer data length
|
||||||
* @retval pointer to descriptor buffer
|
* @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);
|
*length = sizeof (USBD_HID_DeviceQualifierDesc);
|
||||||
return USBD_HID_DeviceQualifierDesc;
|
return USBD_HID_DeviceQualifierDesc;
|
||||||
}
|
}*/
|
||||||
|
@ -41,7 +41,7 @@ _Min_Stack_Size = 0x400; /* required amount of stack */
|
|||||||
/* Specify the memory areas */
|
/* Specify the memory areas */
|
||||||
MEMORY
|
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 */
|
FLASH (rx) : ORIGIN = 0x08005000, LENGTH = 198K-8 /* Leave out 38 Kb at end for data */
|
||||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 48K
|
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 48K
|
||||||
SRAM2 (rw) : ORIGIN = 0x10000000, LENGTH = 16K
|
SRAM2 (rw) : ORIGIN = 0x10000000, LENGTH = 16K
|
||||||
|
@ -27,6 +27,9 @@
|
|||||||
#include "stm32l4xx_ll_iwdg.h"
|
#include "stm32l4xx_ll_iwdg.h"
|
||||||
#include "usbd_cdc_if.h"
|
#include "usbd_cdc_if.h"
|
||||||
|
|
||||||
|
void wait_for_usb_tether();
|
||||||
|
|
||||||
|
|
||||||
uint32_t __90_ms = 0;
|
uint32_t __90_ms = 0;
|
||||||
uint32_t __device_status = 0;
|
uint32_t __device_status = 0;
|
||||||
uint32_t __last_update = 0;
|
uint32_t __last_update = 0;
|
||||||
@ -118,12 +121,12 @@ void usbhid_init()
|
|||||||
|
|
||||||
void wait_for_usb_tether()
|
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);
|
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 int wink_time = 0;
|
||||||
static uint32_t winkt1 = 0;
|
static uint32_t winkt1 = 0;
|
||||||
|
#ifdef LED_WINK_VALUE
|
||||||
static uint32_t winkt2 = 0;
|
static uint32_t winkt2 = 0;
|
||||||
|
#endif
|
||||||
void device_wink()
|
void device_wink()
|
||||||
{
|
{
|
||||||
wink_time = 10;
|
wink_time = 10;
|
||||||
@ -453,7 +458,9 @@ led_rgb(0x001040);
|
|||||||
delay(50);
|
delay(50);
|
||||||
|
|
||||||
|
|
||||||
|
#if SKIP_BUTTON_CHECK_WITH_DELAY || SKIP_BUTTON_CHECK_FAST
|
||||||
done:
|
done:
|
||||||
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
|
@ -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(uint32_t addr, uint8_t * data, size_t sz);
|
||||||
void flash_write_fast(uint32_t addr, uint32_t * data);
|
void flash_write_fast(uint32_t addr, uint32_t * data);
|
||||||
void flash_option_bytes_init(int boot_from_dfu);
|
void flash_option_bytes_init(int boot_from_dfu);
|
||||||
|
void flash_lock();
|
||||||
|
|
||||||
#define FLASH_PAGE_SIZE 2048
|
#define FLASH_PAGE_SIZE 2048
|
||||||
|
|
||||||
|
@ -43,7 +43,9 @@ USBD_HandleTypeDef Solo_USBD_Device;
|
|||||||
static void LL_Init(void);
|
static void LL_Init(void);
|
||||||
void SystemClock_Config(void);
|
void SystemClock_Config(void);
|
||||||
static void MX_GPIO_Init(void);
|
static void MX_GPIO_Init(void);
|
||||||
|
#if DEBUG_LEVEL > 0
|
||||||
static void MX_USART1_UART_Init(void);
|
static void MX_USART1_UART_Init(void);
|
||||||
|
#endif
|
||||||
static void MX_TIM2_Init(void);
|
static void MX_TIM2_Init(void);
|
||||||
static void MX_TIM6_Init(void);
|
static void MX_TIM6_Init(void);
|
||||||
static void MX_RNG_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 */
|
/* USART1 init function */
|
||||||
static void MX_USART1_UART_Init(void)
|
static void MX_USART1_UART_Init(void)
|
||||||
{
|
{
|
||||||
@ -324,6 +327,7 @@ static void MX_USART1_UART_Init(void)
|
|||||||
LL_USART_Enable(USART1);
|
LL_USART_Enable(USART1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/** Pinout Configuration
|
/** Pinout Configuration
|
||||||
*/
|
*/
|
||||||
|
@ -53,7 +53,9 @@ void led_test_colors()
|
|||||||
{
|
{
|
||||||
// Should produce pulsing of various colors
|
// Should produce pulsing of various colors
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
#if DEBUG_LEVEL > 0
|
||||||
int j = 0;
|
int j = 0;
|
||||||
|
#endif
|
||||||
int inc = 1;
|
int inc = 1;
|
||||||
uint32_t time = 0;
|
uint32_t time = 0;
|
||||||
#define update() do {\
|
#define update() do {\
|
||||||
|
Loading…
x
Reference in New Issue
Block a user