From 80825f62a5351a1fd823d50fa50cfc4f907d2757 Mon Sep 17 00:00:00 2001 From: voedipus Date: Tue, 12 Mar 2024 15:08:03 +0500 Subject: [PATCH 1/4] fix(usb) compile tinyusb_net.c when RNDIS is enabled --- usb/esp_tinyusb/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usb/esp_tinyusb/CMakeLists.txt b/usb/esp_tinyusb/CMakeLists.txt index 98fc960e71..131490e120 100644 --- a/usb/esp_tinyusb/CMakeLists.txt +++ b/usb/esp_tinyusb/CMakeLists.txt @@ -27,7 +27,7 @@ if(CONFIG_TINYUSB_MSC_ENABLED) ) endif() # CONFIG_TINYUSB_MSC_ENABLED -if(CONFIG_TINYUSB_NET_MODE_NCM) +if(CONFIG_TINYUSB_NET_MODE_NCM OR CONFIG_TINYUSB_NET_MODE_ECM_RNDIS) list(APPEND srcs tinyusb_net.c ) From 37452a5f7058a13c99615087c040e65b2c31b836 Mon Sep 17 00:00:00 2001 From: Harshit Malpani Date: Thu, 14 Mar 2024 11:38:48 +0530 Subject: [PATCH 2/4] feat: Update expat to v2.6.2 Changelog: https://github.com/libexpat/libexpat/releases/tag/R_2_6_2 --- expat/expat | 2 +- expat/idf_component.yml | 2 +- expat/port/include/expat_config.h | 6 +++--- expat/sbom_libexpat.yml | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/expat/expat b/expat/expat index 849da3e3fe..fa75b96546 160000 --- a/expat/expat +++ b/expat/expat @@ -1 +1 @@ -Subproject commit 849da3e3fe727fccef5e96ef35482d66447f06a2 +Subproject commit fa75b96546c069d17b8f80d91e0f4ef0cde3790d diff --git a/expat/idf_component.yml b/expat/idf_component.yml index 49b11ea204..a3bf796c73 100644 --- a/expat/idf_component.yml +++ b/expat/idf_component.yml @@ -1,4 +1,4 @@ -version: "2.6.0" +version: "2.6.2" description: "Expat - XML Parsing C Library" url: https://github.com/espressif/idf-extra-components/tree/master/expat dependencies: diff --git a/expat/port/include/expat_config.h b/expat/port/include/expat_config.h index 1cc66d63e4..d3360eb365 100644 --- a/expat/port/include/expat_config.h +++ b/expat/port/include/expat_config.h @@ -67,7 +67,7 @@ #define PACKAGE_NAME "expat" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "expat 2.6.0" +#define PACKAGE_STRING "expat 2.6.2" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "expat" @@ -76,13 +76,13 @@ #define PACKAGE_URL "" /* Define to the version of this package. */ -#define PACKAGE_VERSION "2.6.0" +#define PACKAGE_VERSION "2.6.2" /* Define to 1 if you have the ANSI C header files. */ #define STDC_HEADERS 1 /* Version number of package */ -#define VERSION "2.6.0" +#define VERSION "2.6.2" /* whether byteorder is bigendian */ /* #undef WORDS_BIGENDIAN */ diff --git a/expat/sbom_libexpat.yml b/expat/sbom_libexpat.yml index 49642117d1..ae651ecf68 100644 --- a/expat/sbom_libexpat.yml +++ b/expat/sbom_libexpat.yml @@ -1,7 +1,7 @@ name: libexpat -version: 2.6.0 +version: 2.6.2 cpe: cpe:2.3:a:libexpat_project:libexpat:{}:*:*:*:*:*:*:* supplier: 'Organization: libexpat_project' description: Fast streaming XML parser written in C99 url: https://github.com/libexpat/libexpat/ -hash: 849da3e3fe727fccef5e96ef35482d66447f06a2 +hash: fa75b96546c069d17b8f80d91e0f4ef0cde3790d From a6d21616905e74188181acf64cdba21a8c49992b Mon Sep 17 00:00:00 2001 From: voedipus Date: Tue, 26 Mar 2024 21:45:01 +0500 Subject: [PATCH 3/4] make RNDIS and ECM work --- usb/esp_tinyusb/CMakeLists.txt | 2 +- usb/esp_tinyusb/Kconfig | 9 ++++++--- usb/esp_tinyusb/include/tusb_config.h | 10 +++++++--- usb/esp_tinyusb/tinyusb.c | 4 ++-- usb/esp_tinyusb/tinyusb_net.c | 8 ++++++++ usb/esp_tinyusb/usb_descriptors.c | 26 +++++++++++++++++++------- 6 files changed, 43 insertions(+), 16 deletions(-) diff --git a/usb/esp_tinyusb/CMakeLists.txt b/usb/esp_tinyusb/CMakeLists.txt index 98fc960e71..085fc619a7 100644 --- a/usb/esp_tinyusb/CMakeLists.txt +++ b/usb/esp_tinyusb/CMakeLists.txt @@ -27,7 +27,7 @@ if(CONFIG_TINYUSB_MSC_ENABLED) ) endif() # CONFIG_TINYUSB_MSC_ENABLED -if(CONFIG_TINYUSB_NET_MODE_NCM) +if(CONFIG_TINYUSB_NET_MODE_NCM OR CONFIG_TINYUSB_NET_MODE_RNDIS OR CONFIG_TINYUSB_NET_MODE_ECM) list(APPEND srcs tinyusb_net.c ) diff --git a/usb/esp_tinyusb/Kconfig b/usb/esp_tinyusb/Kconfig index a4adc141a3..392a7b76e2 100644 --- a/usb/esp_tinyusb/Kconfig +++ b/usb/esp_tinyusb/Kconfig @@ -259,12 +259,15 @@ menu "TinyUSB Stack" help Select network driver you want to use. - config TINYUSB_NET_MODE_ECM_RNDIS - bool "ECM/RNDIS" - config TINYUSB_NET_MODE_NCM bool "NCM" + config TINYUSB_NET_MODE_RNDIS + bool "RNDIS" + + config TINYUSB_NET_MODE_ECM + bool "ECM" + config TINYUSB_NET_MODE_NONE bool "None" endchoice diff --git a/usb/esp_tinyusb/include/tusb_config.h b/usb/esp_tinyusb/include/tusb_config.h index fbca2be481..962382215f 100644 --- a/usb/esp_tinyusb/include/tusb_config.h +++ b/usb/esp_tinyusb/include/tusb_config.h @@ -57,8 +57,12 @@ extern "C" { # define CONFIG_TINYUSB_CUSTOM_CLASS_ENABLED 0 #endif -#ifndef CONFIG_TINYUSB_NET_MODE_ECM_RNDIS -# define CONFIG_TINYUSB_NET_MODE_ECM_RNDIS 0 +#ifndef CONFIG_TINYUSB_NET_MODE_ECM +# define CONFIG_TINYUSB_NET_MODE_ECM 0 +#endif + +#ifndef CONFIG_TINYUSB_NET_MODE_RNDIS +# define CONFIG_TINYUSB_NET_MODE_RNDIS 0 #endif #ifndef CONFIG_TINYUSB_NET_MODE_NCM @@ -142,7 +146,7 @@ extern "C" { #define CFG_TUD_HID CONFIG_TINYUSB_HID_COUNT #define CFG_TUD_MIDI CONFIG_TINYUSB_MIDI_COUNT #define CFG_TUD_CUSTOM_CLASS CONFIG_TINYUSB_CUSTOM_CLASS_ENABLED -#define CFG_TUD_ECM_RNDIS CONFIG_TINYUSB_NET_MODE_ECM_RNDIS +#define CFG_TUD_ECM_RNDIS (CONFIG_TINYUSB_NET_MODE_RNDIS || CONFIG_TINYUSB_NET_MODE_ECM) #define CFG_TUD_NCM CONFIG_TINYUSB_NET_MODE_NCM #define CFG_TUD_DFU CONFIG_TINYUSB_DFU_MODE_DFU #define CFG_TUD_DFU_RUNTIME CONFIG_TINYUSB_DFU_MODE_DFU_RUNTIME diff --git a/usb/esp_tinyusb/tinyusb.c b/usb/esp_tinyusb/tinyusb.c index a43a304cf5..1762243afa 100644 --- a/usb/esp_tinyusb/tinyusb.c +++ b/usb/esp_tinyusb/tinyusb.c @@ -60,8 +60,8 @@ esp_err_t tinyusb_driver_install(const tinyusb_config_t *config) if (config->configuration_descriptor) { cfg_descriptor = config->configuration_descriptor; } else { - // Default configuration descriptor is provided only for CDC, MSC and NCM classes -#if (CFG_TUD_HID > 0 || CFG_TUD_MIDI > 0 || CFG_TUD_CUSTOM_CLASS > 0 || CFG_TUD_ECM_RNDIS > 0 || CFG_TUD_DFU > 0 || CFG_TUD_DFU_RUNTIME > 0 || CFG_TUD_BTH > 0) + // Default configuration descriptor is provided only for CDC, MSC, ECM, RNDIS and NCM classes +#if (CFG_TUD_HID > 0 || CFG_TUD_MIDI > 0 || CFG_TUD_CUSTOM_CLASS > 0 || CFG_TUD_DFU > 0 || CFG_TUD_DFU_RUNTIME > 0 || CFG_TUD_BTH > 0) ESP_RETURN_ON_FALSE(config->configuration_descriptor, ESP_ERR_INVALID_ARG, TAG, "Configuration descriptor must be provided for this device"); #else cfg_descriptor = descriptor_cfg_kconfig; diff --git a/usb/esp_tinyusb/tinyusb_net.c b/usb/esp_tinyusb/tinyusb_net.c index f7390d7632..e68aa4b4f0 100644 --- a/usb/esp_tinyusb/tinyusb_net.c +++ b/usb/esp_tinyusb/tinyusb_net.c @@ -36,6 +36,10 @@ const static int TX_FINISHED_BIT = BIT0; static struct tinyusb_net_handle s_net_obj = { }; static const char *TAG = "tusb_net"; +#if CONFIG_TINYUSB_NET_MODE_RNDIS || CONFIG_TINYUSB_NET_MODE_ECM +uint8_t tud_network_mac_address[6] = {0}; // for RNDIS (net_device.h, rndis_reports.c) +#endif + static void do_send_sync(void *ctx) { (void) ctx; @@ -130,12 +134,16 @@ esp_err_t tinyusb_net_init(tinyusb_usbdev_t usb_dev, const tinyusb_net_config_t s_net_obj.tx_buff_free_cb = cfg->free_tx_buffer; s_net_obj.ctx = cfg->user_context; +#if CONFIG_TINYUSB_NET_MODE_RNDIS + memcpy(tud_network_mac_address, cfg->mac_addr, MAC_ADDR_LEN); +#elif CONFIG_TINYUSB_NET_MODE_ECM || CONFIG_TINYUSB_NET_MODE_NCM const uint8_t *mac = &cfg->mac_addr[0]; snprintf(s_net_obj.mac_str, sizeof(s_net_obj.mac_str), "%02X%02X%02X%02X%02X%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); uint8_t mac_id = tusb_get_mac_string_id(); // Pass it to Descriptor control module tinyusb_set_str_descriptor(s_net_obj.mac_str, mac_id); +#endif s_net_obj.initialized = true; diff --git a/usb/esp_tinyusb/usb_descriptors.c b/usb/esp_tinyusb/usb_descriptors.c index 1c6e1ce577..971868794a 100644 --- a/usb/esp_tinyusb/usb_descriptors.c +++ b/usb/esp_tinyusb/usb_descriptors.c @@ -17,7 +17,7 @@ */ #define _PID_MAP(itf, n) ((CFG_TUD_##itf) << (n)) #define USB_TUSB_PID (0x4000 | _PID_MAP(CDC, 0) | _PID_MAP(MSC, 1) | _PID_MAP(HID, 2) | \ - _PID_MAP(MIDI, 3) ) //| _PID_MAP(AUDIO, 4) | _PID_MAP(VENDOR, 5) ) + _PID_MAP(MIDI, 3) | _PID_MAP(AUDIO, 4) | _PID_MAP(NCM, 5) | _PID_MAP(ECM_RNDIS, 6)) /**** Kconfig driven Descriptor ****/ @@ -82,7 +82,7 @@ const char *descriptor_str_kconfig[] = { "", #endif -#if CONFIG_TINYUSB_NET_MODE_ECM_RNDIS || CONFIG_TINYUSB_NET_MODE_NCM +#if CONFIG_TINYUSB_NET_MODE_NCM || CONFIG_TINYUSB_NET_MODE_RNDIS || CONFIG_TINYUSB_NET_MODE_ECM "USB net", // 6. NET Interface "", // 7. MAC #endif @@ -105,7 +105,7 @@ enum { ITF_NUM_MSC, #endif -#if CFG_TUD_NCM +#if CFG_TUD_NCM || CFG_TUD_ECM_RNDIS ITF_NUM_NET, ITF_NUM_NET_DATA, #endif @@ -117,7 +117,13 @@ enum { TUSB_DESC_TOTAL_LEN = TUD_CONFIG_DESC_LEN + CFG_TUD_CDC * TUD_CDC_DESC_LEN + CFG_TUD_MSC * TUD_MSC_DESC_LEN + +#if CONFIG_TINYUSB_NET_MODE_ECM + CFG_TUD_ECM_RNDIS * TUD_CDC_ECM_DESC_LEN +#elif CONFIG_TINYUSB_NET_MODE_RNDIS + CFG_TUD_ECM_RNDIS * TUD_RNDIS_DESC_LEN +#elif CONFIG_TINYUSB_NET_MODE_NCM CFG_TUD_NCM * TUD_CDC_NCM_DESC_LEN +#endif }; //------------- USB Endpoint numbers -------------// @@ -138,7 +144,7 @@ enum { EPNUM_MSC, #endif -#if CFG_TUD_NCM +#if CFG_TUD_NCM || CFG_TUD_ECM_RNDIS EPNUM_NET_NOTIF, EPNUM_NET_DATA, #endif @@ -158,7 +164,7 @@ enum { STRID_MSC_INTERFACE, #endif -#if CFG_TUD_NCM +#if CFG_TUD_NCM || CFG_TUD_ECM_RNDIS STRID_NET_INTERFACE, STRID_MAC, #endif @@ -185,13 +191,19 @@ uint8_t const descriptor_cfg_kconfig[] = { TUD_MSC_DESCRIPTOR(ITF_NUM_MSC, STRID_MSC_INTERFACE, EPNUM_MSC, 0x80 | EPNUM_MSC, 64), // highspeed 512 #endif -#if CFG_TUD_NCM +#if CONFIG_TINYUSB_NET_MODE_NCM // Interface number, description string index, MAC address string index, EP notification address and size, EP data address (out, in), and size, max segment size. TUD_CDC_NCM_DESCRIPTOR(ITF_NUM_NET, STRID_NET_INTERFACE, STRID_MAC, (0x80 | EPNUM_NET_NOTIF), 64, EPNUM_NET_DATA, (0x80 | EPNUM_NET_DATA), CFG_TUD_NET_ENDPOINT_SIZE, CFG_TUD_NET_MTU), +#elif CONFIG_TINYUSB_NET_MODE_RNDIS + // Interface number, string index, EP notification address and size, EP data address (out, in) and size. + TUD_RNDIS_DESCRIPTOR(ITF_NUM_NET, STRID_NET_INTERFACE, (0x80 | EPNUM_NET_NOTIF), 8, EPNUM_NET_DATA, (0x80 | EPNUM_NET_DATA), CFG_TUD_NET_ENDPOINT_SIZE), +#elif CONFIG_TINYUSB_NET_MODE_ECM + // Interface number, description string index, MAC address string index, EP notification address and size, EP data address (out, in), and size, max segment size. + TUD_CDC_ECM_DESCRIPTOR(ITF_NUM_NET, STRID_NET_INTERFACE, STRID_MAC, (0x80 | EPNUM_NET_NOTIF), 64, EPNUM_NET_DATA, (0x80 | EPNUM_NET_DATA), CFG_TUD_NET_ENDPOINT_SIZE, CFG_TUD_NET_MTU), #endif }; -#if CFG_TUD_NCM +#if CFG_TUD_NCM || CFG_TUD_ECM_RNDIS uint8_t tusb_get_mac_string_id(void) { return STRID_MAC; From 19cde109634818ad95399cee8cb79b516e244993 Mon Sep 17 00:00:00 2001 From: voedipus Date: Wed, 27 Mar 2024 20:51:54 +0500 Subject: [PATCH 4/4] fix build for usb test app --- usb/esp_tinyusb/usb_descriptors.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/usb/esp_tinyusb/usb_descriptors.c b/usb/esp_tinyusb/usb_descriptors.c index 971868794a..42e855da9b 100644 --- a/usb/esp_tinyusb/usb_descriptors.c +++ b/usb/esp_tinyusb/usb_descriptors.c @@ -116,13 +116,13 @@ enum { enum { TUSB_DESC_TOTAL_LEN = TUD_CONFIG_DESC_LEN + CFG_TUD_CDC * TUD_CDC_DESC_LEN + - CFG_TUD_MSC * TUD_MSC_DESC_LEN + + CFG_TUD_MSC * TUD_MSC_DESC_LEN #if CONFIG_TINYUSB_NET_MODE_ECM - CFG_TUD_ECM_RNDIS * TUD_CDC_ECM_DESC_LEN + + CFG_TUD_ECM_RNDIS * TUD_CDC_ECM_DESC_LEN #elif CONFIG_TINYUSB_NET_MODE_RNDIS - CFG_TUD_ECM_RNDIS * TUD_RNDIS_DESC_LEN + + CFG_TUD_ECM_RNDIS * TUD_RNDIS_DESC_LEN #elif CONFIG_TINYUSB_NET_MODE_NCM - CFG_TUD_NCM * TUD_CDC_NCM_DESC_LEN + + CFG_TUD_NCM * TUD_CDC_NCM_DESC_LEN #endif };