Skip to content

Commit ff5c1b2

Browse files
committed
Merge branch 'feat/add_usb_host_eth' into 'master'
feat(usb_host_eth): support connect through usb ethernet chips Closes AEG-2270 See merge request ae_group/esp-iot-solution!1265
2 parents 2090d71 + 5d9c9f7 commit ff5c1b2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2419
-218
lines changed

.github/workflows/upload_component.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ jobs:
9898
components/usb/usb_device_uac;
9999
components/usb/usb_device_uvc;
100100
components/usb/iot_usbh_rndis;
101+
components/usb/iot_usbh_ecm;
101102
components/usb/usb_stream;
102103
components/utilities/adc_tp_calibration;
103104
components/utilities/xz;

.gitlab/ci/build.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,14 @@ build_example_usb_host_usb_hub_dual_camera:
966966
variables:
967967
EXAMPLE_DIR: examples/usb/host/usb_hub_dual_camera
968968

969+
build_example_usb_host_usb_ecm_4g_module:
970+
extends:
971+
- .build_examples_template
972+
- .rules:build:example_usb_host_usb_ecm_4g_module
973+
- .build_idf_version_greater_equal_v5_0
974+
variables:
975+
EXAMPLE_DIR: examples/usb/host/usb_ecm_4g_module
976+
969977
build_example_usb_host_usb_msc_ota:
970978
extends:
971979
- .build_examples_template
@@ -981,12 +989,7 @@ build_example_usb_host_usb_rndis_4g_module:
981989
extends:
982990
- .build_examples_template
983991
- .rules:build:example_usb_host_usb_rndis_4g_module
984-
parallel:
985-
matrix:
986-
- IMAGE: espressif/idf:release-v5.1
987-
- IMAGE: espressif/idf:release-v5.2
988-
- IMAGE: espressif/idf:release-v5.3
989-
- IMAGE: espressif/idf:release-v5.4
992+
- .build_idf_version_greater_equal_v5_0
990993
variables:
991994
EXAMPLE_DIR: examples/usb/host/usb_rndis_4g_module
992995

.gitlab/ci/rules.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,10 @@
319319
- "components/usb/iot_usbh_modem/**/*"
320320
- "tools/cmake_utilities/package_manager.cmake"
321321

322+
.patterns-components_usb_iot_usbh_ecm: &patterns-components_usb_iot_usbh_ecm
323+
- "components/usb/iot_usbh_ecm/**/*"
324+
- "tools/cmake_utilities/package_manager.cmake"
325+
322326
.patterns-components_usb_usb_host_rndis_test_apps: &patterns-components_usb_usb_host_rndis_test_apps
323327
- "components/usb/usb_host_rndis/test_apps/**/*"
324328
- "tools/cmake_utilities/package_manager.cmake"
@@ -418,6 +422,8 @@
418422
- "components/usb/esp_msc_ota/include/esp_msc_ota.h"
419423
- "components/usb/esp_tinyuf2/esp_tinyuf2.h"
420424
- "components/usb/iot_usbh_cdc/include/iot_usbh_cdc.h"
425+
- "components/usb/iot_usbh_ecm/include/iot_usbh_ecm.h"
426+
- "components/usb/iot_usbh_rndis/include/iot_usbh_rndis.h"
421427
- "components/usb/usb_device_uac/include/usb_device_uac.h"
422428
- "components/usb/usb_device_uvc/include/usb_device_uvc.h"
423429
- "components/usb/usb_stream/include/usb_stream.h"
@@ -652,6 +658,9 @@
652658
.patterns-example_usb_host_usb_rndis_4g_module: &patterns-example_usb_host_usb_rndis_4g_module
653659
- "examples/usb/host/usb_rndis_4g_module/**/*"
654660

661+
.patterns-example_usb_host_usb_ecm_4g_module: &patterns-example_usb_host_usb_ecm_4g_module
662+
- "examples/usb/host/usb_ecm_4g_module/**/*"
663+
655664
.patterns-example_usb_otg_usb_host_device_mode_manual_switch: &patterns-example_usb_otg_usb_host_device_mode_manual_switch
656665
- "examples/usb/otg/usb_host_device_mode_manual_switch/**/*"
657666

@@ -1634,6 +1643,22 @@
16341643
- <<: *if-dev-push
16351644
changes: *patterns-example_usb_host_usb_msc_ota
16361645

1646+
.rules:build:example_usb_host_usb_ecm_4g_module:
1647+
rules:
1648+
- <<: *if-protected
1649+
- <<: *if-label-build
1650+
- <<: *if-trigger-job
1651+
- <<: *if-dev-push
1652+
changes: *patterns-build_system
1653+
- <<: *if-dev-push
1654+
changes: *patterns-components_usb_iot_usbh_ecm
1655+
- <<: *if-dev-push
1656+
changes: *patterns-example_usb_host_usb_ecm_4g_module
1657+
- <<: *if-dev-push
1658+
changes: *patterns-components_usb_iot_usbh_cdc
1659+
- <<: *if-dev-push
1660+
changes: *patterns-components_iot_eth
1661+
16371662
.rules:build:example_usb_host_usb_rndis_4g_module:
16381663
rules:
16391664
- <<: *if-protected

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ The registered components in ESP-IoT-Solution are listed below:
112112
| [iot_eth](https://components.espressif.com/components/espressif/iot_eth) | [![Component Registry](https://components.espressif.com/components/espressif/iot_eth/badge.svg)](https://components.espressif.com/components/espressif/iot_eth) |
113113
| [iot_usbh](https://components.espressif.com/components/espressif/iot_usbh) | [![Component Registry](https://components.espressif.com/components/espressif/iot_usbh/badge.svg)](https://components.espressif.com/components/espressif/iot_usbh) |
114114
| [iot_usbh_cdc](https://components.espressif.com/components/espressif/iot_usbh_cdc) | [![Component Registry](https://components.espressif.com/components/espressif/iot_usbh_cdc/badge.svg)](https://components.espressif.com/components/espressif/iot_usbh_cdc) |
115+
| [iot_usbh_ecm](https://components.espressif.com/components/espressif/iot_usbh_ecm) | [![Component Registry](https://components.espressif.com/components/espressif/iot_usbh_ecm/badge.svg)](https://components.espressif.com/components/espressif/iot_usbh_ecm) |
115116
| [iot_usbh_modem](https://components.espressif.com/components/espressif/iot_usbh_modem) | [![Component Registry](https://components.espressif.com/components/espressif/iot_usbh_modem/badge.svg)](https://components.espressif.com/components/espressif/iot_usbh_modem) |
116117
| [iot_usbh_rndis](https://components.espressif.com/components/espressif/iot_usbh_rndis) | [![Component Registry](https://components.espressif.com/components/espressif/iot_usbh_rndis/badge.svg)](https://components.espressif.com/components/espressif/iot_usbh_rndis) |
117118
| [ir_learn](https://components.espressif.com/components/espressif/ir_learn) | [![Component Registry](https://components.espressif.com/components/espressif/ir_learn/badge.svg)](https://components.espressif.com/components/espressif/ir_learn) |

README_CN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ ESP-IoT-Solution 中注册的组件如下:
112112
| [iot_eth](https://components.espressif.com/components/espressif/iot_eth) | [![Component Registry](https://components.espressif.com/components/espressif/iot_eth/badge.svg)](https://components.espressif.com/components/espressif/iot_eth) |
113113
| [iot_usbh](https://components.espressif.com/components/espressif/iot_usbh) | [![Component Registry](https://components.espressif.com/components/espressif/iot_usbh/badge.svg)](https://components.espressif.com/components/espressif/iot_usbh) |
114114
| [iot_usbh_cdc](https://components.espressif.com/components/espressif/iot_usbh_cdc) | [![Component Registry](https://components.espressif.com/components/espressif/iot_usbh_cdc/badge.svg)](https://components.espressif.com/components/espressif/iot_usbh_cdc) |
115+
| [iot_usbh_ecm](https://components.espressif.com/components/espressif/iot_usbh_ecm) | [![Component Registry](https://components.espressif.com/components/espressif/iot_usbh_ecm/badge.svg)](https://components.espressif.com/components/espressif/iot_usbh_ecm) |
115116
| [iot_usbh_modem](https://components.espressif.com/components/espressif/iot_usbh_modem) | [![Component Registry](https://components.espressif.com/components/espressif/iot_usbh_modem/badge.svg)](https://components.espressif.com/components/espressif/iot_usbh_modem) |
116117
| [iot_usbh_rndis](https://components.espressif.com/components/espressif/iot_usbh_rndis) | [![Component Registry](https://components.espressif.com/components/espressif/iot_usbh_rndis/badge.svg)](https://components.espressif.com/components/espressif/iot_usbh_rndis) |
117118
| [ir_learn](https://components.espressif.com/components/espressif/ir_learn) | [![Component Registry](https://components.espressif.com/components/espressif/ir_learn/badge.svg)](https://components.espressif.com/components/espressif/ir_learn) |

components/usb/iot_usbh_cdc/CHANGELOG.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
# ChangeLog
22

3-
## v1.1.0 - 2025-05-13
3+
## v2.0.0 - 2025-05-20
4+
5+
### Features:
6+
7+
* Support no internal ring buffer mode..
8+
9+
### Break Changes:
10+
11+
* Set rx_buffer_size to 0 to disable internal ring buffer.
12+
13+
* Remove macro IN_RINGBUFFER_SIZE and OUT_RINGBUFFER_SIZE.
14+
15+
## v1.1.1 - 2025-05-13
416

517
### Features:
618

components/usb/iot_usbh_cdc/Kconfig

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,6 @@ menu "IoT USB Host CDC"
3131
help
3232
usb host OUT transfer buffer size
3333

34-
config IN_RINGBUFFER_SIZE
35-
int "usbh IN ringbuffer size"
36-
default 1024
37-
help
38-
usb host IN ringbuffer size
39-
40-
config OUT_RINGBUFFER_SIZE
41-
int "usbh OUT ringbuffer size"
42-
default 1024
43-
help
44-
usb host OUT ringbuffer size
45-
4634
config DEVICE_ADDRESS_LIST_NUM
4735
int "usbh device address list num"
4836
default 10

components/usb/iot_usbh_cdc/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "1.1.1"
1+
version: "2.0.0"
22
targets:
33
- esp32s2
44
- esp32s3

components/usb/iot_usbh_cdc/include/iot_usbh_cdc.h

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77

88
#include <stdint.h>
99
#include "esp_err.h"
10+
#include "freertos/FreeRTOS.h"
1011
#include "usb/usb_host.h"
1112
#include "iot_usbh_cdc_type.h"
13+
1214
#ifdef __cplusplus
1315
extern "C" {
1416
#endif
@@ -95,8 +97,8 @@ typedef struct usbh_cdc_config {
9597
uint16_t pid; /*!< Product ID: If set, the `vid` parameter must be configured
9698
If not set, it will default to opening the first connected device */
9799
int itf_num; /*!< interface numbers */
98-
size_t rx_buffer_size; /*!< Size of the receive buffer, default is 1024 bytes if set to 0 */
99-
size_t tx_buffer_size; /*!< Size of the transmit buffer, default is 1024 bytes if set to 0 */
100+
size_t rx_buffer_size; /*!< Size of the receive ringbuffer size, if set to 0, not use ringbuffer */
101+
size_t tx_buffer_size; /*!< Size of the transmit ringbuffer size, if set to 0, not use ringbuffer */
100102
usbh_cdc_event_callbacks_t cbs; /*!< Event callbacks for the CDC device */
101103
} usbh_cdc_device_config_t;
102104

@@ -205,9 +207,12 @@ esp_err_t usbh_cdc_send_custom_request(usbh_cdc_handle_t cdc_handle, uint8_t bmR
205207
/**
206208
* @brief Write data to the USB CDC device
207209
*
208-
* This function writes data to the specified USB CDC device by pushing the data into the output ring buffer.
210+
* With internal ring buffer, this function writes data to the specified USB CDC device by pushing the data into the output ring buffer.
209211
* If the buffer is full or the device is not connected, the write will fail.
210212
*
213+
* Without internal ring buffer, this function writes data to the specified USB CDC device by sending data directly to the device.
214+
* Please set the ticks_to_wait for blocking write.
215+
*
211216
* @param[in] cdc_handle The CDC device handle
212217
* @param[in] buf Pointer to the data buffer to write
213218
* @param[in] length Pointer to the length of data to write. On success, it remains unchanged, otherwise set to 0.
@@ -223,9 +228,12 @@ esp_err_t usbh_cdc_write_bytes(usbh_cdc_handle_t cdc_handle, const uint8_t *buf,
223228
/**
224229
* @brief Read data from the USB CDC device
225230
*
226-
* This function reads data from the specified USB CDC device by popping data from the input ring buffer.
231+
* With internal ring buffer, this function reads data from the specified USB CDC device by popping data from the input ring buffer.
227232
* If no data is available or the device is not connected, the read will fail.
228233
*
234+
* Without internal ring buffer, this function reads data from the specified USB CDC device by receiving data directly from the device. You can call this function in the recv_data callback function.
235+
* Please set ticks_to_wait to zero for non-blocking read.
236+
*
229237
* @param[in] cdc_handle The CDC device handle
230238
* @param[out] buf Pointer to the buffer where the read data will be stored
231239
* @param[inout] length Pointer to the length of data to read. On success, it is updated with the actual bytes read.
@@ -237,18 +245,21 @@ esp_err_t usbh_cdc_write_bytes(usbh_cdc_handle_t cdc_handle, const uint8_t *buf,
237245
* - ESP_ERR_INVALID_ARG: Invalid argument (NULL handle, buffer, or length)
238246
* - ESP_ERR_INVALID_STATE: Device is not connected
239247
*/
240-
esp_err_t usbh_cdc_read_bytes(usbh_cdc_handle_t cdc_handle, const uint8_t *buf, size_t *length, TickType_t ticks_to_wait);
248+
esp_err_t usbh_cdc_read_bytes(usbh_cdc_handle_t cdc_handle, uint8_t *buf, size_t *length, TickType_t ticks_to_wait);
241249

242250
/**
243251
* @brief Flush the receive buffer of the USB CDC device
244252
*
245253
* This function clears the receive buffer, discarding any data currently in the buffer.
246254
*
255+
* Not supported for no internal ring buffer mode.
256+
*
247257
* @param[in] cdc_handle The CDC device handle
248258
*
249259
* @return
250260
* - ESP_OK: Receive buffer flushed successfully
251261
* - ESP_ERR_INVALID_ARG: Invalid CDC handle provided
262+
* - ESP_ERR_NOT_SUPPORTED: Not supported for no internal ring buffer mode
252263
*/
253264
esp_err_t usbh_cdc_flush_rx_buffer(usbh_cdc_handle_t cdc_handle);
254265

@@ -257,11 +268,14 @@ esp_err_t usbh_cdc_flush_rx_buffer(usbh_cdc_handle_t cdc_handle);
257268
*
258269
* This function clears the transmit buffer, discarding any data currently in the buffer.
259270
*
271+
* Not supported for no internal ring buffer mode.
272+
*
260273
* @param[in] cdc_handle The CDC device handle
261274
*
262275
* @return
263276
* - ESP_OK: Transmit buffer flushed successfully
264277
* - ESP_ERR_INVALID_ARG: Invalid CDC handle provided
278+
* - ESP_ERR_NOT_SUPPORTED: Not supported for no internal ring buffer mode
265279
*/
266280
esp_err_t usbh_cdc_flush_tx_buffer(usbh_cdc_handle_t cdc_handle);
267281

@@ -270,6 +284,8 @@ esp_err_t usbh_cdc_flush_tx_buffer(usbh_cdc_handle_t cdc_handle);
270284
*
271285
* This function retrieves the current size of the receive buffer in bytes.
272286
*
287+
* For no internal ring buffer, you can call this function in the recv_data callback function.
288+
*
273289
* @param[in] cdc_handle The CDC device handle
274290
* @param[out] size Pointer to store the size of the receive buffer
275291
*

components/usb/iot_usbh_cdc/include/iot_usbh_cdc_type.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ extern "C" {
1313

1414
typedef struct {
1515
uint8_t bmRequestType;
16-
int32_t bNotificationCode;
16+
uint8_t bNotificationCode;
1717
uint16_t wValue;
1818
uint16_t wIndex;
1919
uint16_t wLength;

0 commit comments

Comments
 (0)