diff --git a/src/fs/otp.c b/src/fs/otp.c index 5c98517..adc5c8a 100644 --- a/src/fs/otp.c +++ b/src/fs/otp.c @@ -110,9 +110,6 @@ void init_otp_files() { random_gen(NULL, mkek, sizeof(mkek)); otp_write_data(OTP_KEY_1, mkek, sizeof(mkek)); } - else { - DEBUG_DATA(otp_buffer(OTP_KEY_1), 32); - } otp_key_1 = otp_buffer(OTP_KEY_1); otp_lock_page(page); @@ -167,7 +164,6 @@ void init_otp_files() { if (esp_efuse_key_block_unused(OTP_KEY_1)) { uint8_t mkek[32] = {0}; random_gen(NULL, mkek, sizeof(mkek)); - DEBUG_DATA(mkek, 32); esp_err_t ret = esp_efuse_write_key(OTP_KEY_1, ESP_EFUSE_KEY_PURPOSE_USER, mkek, sizeof(mkek)); if (ret != ESP_OK) { printf("Error writing OTP key 1 [%d]\n", ret); @@ -185,9 +181,6 @@ void init_otp_files() { if (ret != ESP_OK) { printf("Error reading OTP key 1 [%d]\n", ret); } - else { - DEBUG_DATA(_otp_key_1, 32); - } otp_key_1 = _otp_key_1; #endif diff --git a/src/fs/phy.c b/src/fs/phy.c index 48f6a60..17a9dbe 100644 --- a/src/fs/phy.c +++ b/src/fs/phy.c @@ -87,7 +87,6 @@ int phy_init() { memset(&phy_data, 0, sizeof(phy_data_t)); if (file_has_data(ef_phy)) { const uint8_t *data = file_get_data(ef_phy); - DEBUG_DATA(data, file_get_size(ef_phy)); int ret = phy_unserialize_data(data, file_get_size(ef_phy), &phy_data); if (ret != PICOKEY_OK) { return ret; diff --git a/src/main.c b/src/main.c index 8852e53..541dbeb 100644 --- a/src/main.c +++ b/src/main.c @@ -317,9 +317,8 @@ int main(void) { gpio_pulldown_dis(BOOT_PIN); tusb_cfg.string_descriptor[3] = pico_serial_str; - if (phy_data.opts & PHY_OPT_WCID) { - tusb_cfg.configuration_descriptor = desc_config; - } + tusb_cfg.configuration_descriptor = desc_config; + tinyusb_driver_install(&tusb_cfg); #else tusb_init(); diff --git a/src/usb/usb_descriptors.c b/src/usb/usb_descriptors.c index 9fbbb78..8e0e166 100644 --- a/src/usb/usb_descriptors.c +++ b/src/usb/usb_descriptors.c @@ -80,22 +80,15 @@ uint8_t const *tud_descriptor_device_cb(void) { #define TUSB_SMARTCARD_WCID_DESC_LEN (TUD_INTERFACE_DESC_LEN + TUSB_SMARTCARD_LEN + 2 * TUD_ENDPOINT_DESC_LEN) enum { - TUSB_DESC_TOTAL_LEN_NOWCID = TUD_CONFIG_DESC_LEN + TUSB_DESC_TOTAL_LEN = TUD_CONFIG_DESC_LEN #ifdef USB_ITF_HID - + TUD_HID_INOUT_DESC_LEN + TUD_HID_DESC_LEN + + TUD_HID_INOUT_DESC_LEN + + TUD_HID_DESC_LEN #endif #ifdef USB_ITF_CCID + TUSB_SMARTCARD_CCID_DESC_LEN -#endif -}; - -enum { - TUSB_DESC_TOTAL_LEN = TUSB_DESC_TOTAL_LEN_NOWCID -#ifdef USB_ITF_CCID -#ifdef USB_ITF_WCID + TUSB_SMARTCARD_WCID_DESC_LEN #endif -#endif }; #ifdef USB_ITF_HID @@ -109,13 +102,11 @@ uint8_t const desc_hid_report_kb[] = { #endif #ifdef USB_ITF_CCID -#ifdef USB_ITF_WCID #define TUD_SMARTCARD_DESCRIPTOR_WEB(_itf, _strix, _epout, _epin, _epsize) \ 9, TUSB_DESC_INTERFACE, _itf, 0, 2, 0xFF, 0, 0, _strix, \ 54, 0x21, U16_TO_U8S_LE(0x0110), 0, 0x1, U32_TO_U8S_LE(0x01|0x2), U32_TO_U8S_LE(0xDFC), U32_TO_U8S_LE(0xDFC), 0, U32_TO_U8S_LE(0x2580), U32_TO_U8S_LE(0x2580), 0, U32_TO_U8S_LE(0xFE), U32_TO_U8S_LE(0), U32_TO_U8S_LE(0), U32_TO_U8S_LE(0x40840), U32_TO_U8S_LE(65544+10), 0xFF, 0xFF, U16_TO_U8S_LE(0x0), 0, 0x1, \ 7, TUSB_DESC_ENDPOINT, _epout, TUSB_XFER_BULK, U16_TO_U8S_LE(_epsize), 0, \ 7, TUSB_DESC_ENDPOINT, _epin, TUSB_XFER_BULK, U16_TO_U8S_LE(_epsize), 0 -#endif #define TUD_SMARTCARD_DESCRIPTOR(_itf, _strix, _epout, _epin, _epint, _epsize) \ 9, TUSB_DESC_INTERFACE, _itf, 0, 3, TUSB_CLASS_SMART_CARD, 0, 0, _strix, \ 54, 0x21, U16_TO_U8S_LE(0x0110), 0, 0x1, U32_TO_U8S_LE(0x01|0x2), U32_TO_U8S_LE(0xDFC), U32_TO_U8S_LE(0xDFC), 0, U32_TO_U8S_LE(0x2580), U32_TO_U8S_LE(0x2580), 0, U32_TO_U8S_LE(0xFE), U32_TO_U8S_LE(0), U32_TO_U8S_LE(0), U32_TO_U8S_LE(0x40840), U32_TO_U8S_LE(65544+10), 0xFF, 0xFF, U16_TO_U8S_LE(0x0), 0, 0x1, \ @@ -124,21 +115,6 @@ uint8_t const desc_hid_report_kb[] = { 7, TUSB_DESC_ENDPOINT, _epint, TUSB_XFER_INTERRUPT, U16_TO_U8S_LE(_epsize), 0 #endif -const uint8_t desc_config_nowcid[] = { -#ifdef USB_ITF_CCID - TUD_CONFIG_DESCRIPTOR(1, ITF_TOTAL-1, 4, TUSB_DESC_TOTAL_LEN_NOWCID, USB_CONFIG_ATT_ONE | TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, MAX_USB_POWER), -#else - TUD_CONFIG_DESCRIPTOR(1, ITF_TOTAL, 4, TUSB_DESC_TOTAL_LEN_NOWCID, USB_CONFIG_ATT_ONE | TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, MAX_USB_POWER), -#endif -#ifdef USB_ITF_HID - TUD_HID_INOUT_DESCRIPTOR(ITF_HID, ITF_HID + 5, HID_ITF_PROTOCOL_NONE, sizeof(desc_hid_report), EPNUM_HID, TUSB_DIR_IN_MASK | EPNUM_HID, CFG_TUD_HID_EP_BUFSIZE, 10), - TUD_HID_DESCRIPTOR(ITF_KEYBOARD, ITF_KEYBOARD + 5, HID_ITF_PROTOCOL_NONE, sizeof(desc_hid_report_kb), TUSB_DIR_IN_MASK | (EPNUM_HID + 1), 16, 5), -#endif -#ifdef USB_ITF_CCID - TUD_SMARTCARD_DESCRIPTOR(ITF_CCID, ITF_CCID+5, 1, TUSB_DIR_IN_MASK | 1, TUSB_DIR_IN_MASK | 2, 64), -#endif -}; - const uint8_t desc_config[] = { TUD_CONFIG_DESCRIPTOR(1, ITF_TOTAL, 4, TUSB_DESC_TOTAL_LEN, USB_CONFIG_ATT_ONE | TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, MAX_USB_POWER), #ifdef USB_ITF_HID @@ -147,16 +123,13 @@ const uint8_t desc_config[] = { #endif #ifdef USB_ITF_CCID TUD_SMARTCARD_DESCRIPTOR(ITF_CCID, ITF_CCID+5, 1, TUSB_DIR_IN_MASK | 1, TUSB_DIR_IN_MASK | 2, 64), -#ifdef USB_ITF_WCID TUD_SMARTCARD_DESCRIPTOR_WEB(ITF_WCID, ITF_WCID+5, 3, TUSB_DIR_IN_MASK | 3, 64), #endif -#endif }; #ifdef USB_ITF_HID uint8_t const *tud_hid_descriptor_report_cb(uint8_t itf) { printf("report_cb %d\n", itf); - DEBUG_DATA(desc_hid_report, sizeof(desc_hid_report)); if (itf == ITF_HID_CTAP) { return desc_hid_report; } @@ -169,14 +142,10 @@ uint8_t const *tud_hid_descriptor_report_cb(uint8_t itf) { #ifndef ESP_PLATFORM uint8_t const *tud_descriptor_configuration_cb(uint8_t index) { (void) index; // for multiple configurations - if (phy_data.opts & PHY_OPT_WCID) { - return desc_config; - } - return desc_config_nowcid; + return desc_config; } #endif -#ifdef USB_ITF_WCID #define BOS_TOTAL_LEN (TUD_BOS_DESC_LEN + TUD_BOS_WEBUSB_DESC_LEN + TUD_BOS_MICROSOFT_OS_DESC_LEN) #define MS_OS_20_DESC_LEN 0xB2 @@ -276,12 +245,9 @@ uint8_t const desc_bos[] = { }; uint8_t const *tud_descriptor_bos_cb(void) { - if (phy_data.opts & PHY_OPT_WCID) { - return desc_bos; - } - return NULL; + return desc_bos; } -#endif + //--------------------------------------------------------------------+ // String Descriptors //--------------------------------------------------------------------+ @@ -299,10 +265,8 @@ char const *string_desc_arr [] = { #endif #ifdef USB_ITF_CCID , "Pico Key CCID Interface" -#ifdef USB_ITF_WCID , "Pico Key WebCCID Interface" #endif -#endif }; #ifdef ESP_PLATFORM