Skip to content

Commit

Permalink
Merge branch 'feat/p4_support_ec20' into 'master'
Browse files Browse the repository at this point in the history
feat(‎iot_usbh_modem‎): support esp32p4 with cat.4 module

See merge request ae_group/esp-iot-solution!1158
  • Loading branch information
leeebo committed Jan 2, 2025
2 parents 0ddb3b2 + 1d3983f commit 2eebd55
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 36 deletions.
5 changes: 1 addition & 4 deletions .gitlab/ci/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -863,10 +863,7 @@ build_example_usb_host_usb_cdc_4g_module:
extends:
- .build_examples_template
- .rules:build:example_usb_host_usb_cdc_4g_module
parallel:
matrix:
- IMAGE: espressif/idf:release-v4.4
- IMAGE: espressif/idf:release-v5.1
- .build_idf_version_greater_equal_v5_0
variables:
EXAMPLE_DIR: examples/usb/host/usb_cdc_4g_module

Expand Down
5 changes: 4 additions & 1 deletion components/usb/iot_usbh_modem/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# ChangeLog

## v1.1.0 - 2024-11-28

* Support ESP32-P4 with EC20_CE cat.4 module

## v1.0.0 - 2024-11-14

* Use iot_usbh_cdc version 1.0.0
Expand All @@ -15,7 +19,6 @@
* Fix concurrency issue in AT command mode
* Fix memory stamp issue in `common_get_operator_after_mode_format`


## v0.1.6 - 2023-04-17

* Fix PPP mode can not exit gracefully
Expand Down
4 changes: 4 additions & 0 deletions components/usb/iot_usbh_modem/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ menu "IoT USB Host Modem"
bool "BG96MA"
config MODEM_TARGET_MC610_EU
bool "MC610_EU"
config MODEM_TARGET_EC20_CE
bool "EC20_CE"
config MODEM_TARGET_USER
bool "User Defined"
endchoice
Expand All @@ -37,6 +39,7 @@ menu "IoT USB Host Modem"
default "BG95M3" if MODEM_TARGET_BG95_M3
default "BG96MA" if MODEM_TARGET_BG96_MA
default "MC610_EU" if MODEM_TARGET_MC610_EU
default "EC20_CE" if MODEM_TARGET_EC20_CE
default "User Defined" if MODEM_TARGET_USER

config MODEM_SUPPORT_SECONDARY_AT_PORT
Expand All @@ -52,6 +55,7 @@ menu "IoT USB Host Modem"
default 0x04 if MODEM_TARGET_EC600N_CNLC_N06
default 0x06 if MODEM_TARGET_MC610_EU
default 0x05 if MODEM_TARGET_A7600C1
default 0x02 if MODEM_TARGET_EC20_CE
help
USB CDC interface (eg.0x00) used for send AT/data to device

Expand Down
6 changes: 5 additions & 1 deletion components/usb/iot_usbh_modem/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "1.0.0"
version: "1.1.0"
targets:
- esp32s2
- esp32s3
Expand All @@ -13,6 +13,10 @@ dependencies:
iot_usbh_cdc:
version: "1.*"
override_path: "../iot_usbh_cdc"
espressif/esp_wifi_remote:
version: "0.*"
rules:
- if: "target in [esp32p4]"
examples:
- path: ../../../examples/usb/host/usb_cdc_4g_module
sbom:
Expand Down
1 change: 1 addition & 0 deletions components/usb/iot_usbh_modem/src/esp_modem_usb_dte.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ esp_modem_dte_t *esp_modem_dte_new(const esp_modem_dte_config_t *config)
dev_config.cbs.connect = NULL;
dev_config.cbs.disconnect = NULL;
dev_config.cbs.user_data = NULL;
dev_config.cbs.revc_data = NULL;
handle = NULL;
usbh_cdc_create(&dev_config, &handle);
ESP_MODEM_ERR_CHECK(handle != NULL, "usb cdc device create failed", err_usb_config);
Expand Down
27 changes: 13 additions & 14 deletions examples/usb/host/usb_cdc_4g_module/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

# USB CDC 4G Module

This example demonstrates the ESP32-S2, ESP32-S3 series SoC as a USB host to dial-up 4G Cat.1 through PPP to access the Internet, with the help of ESP32-SX Wi-Fi softAP function, share the Internet with IoT devices or mobile devices. Realize low-cost "medium-high-speed" Internet access.It is also equipped with a router management interface, which allows you to configure the router online and view the information of connected devices.
This example demonstrates the **ESP32-S2**, **ESP32-S3** series SoC as a USB host to dial-up 4G Cat.1 through PPP to access the Internet, with the help of ESP32-SX Wi-Fi softAP function, share the Internet with IoT devices or mobile devices. Realize low-cost "medium-high-speed" Internet access.It is also equipped with a router management interface, which allows you to configure the router online and view the information of connected devices.

In addition, the **ESP32-P4** supports the 4G Cat.4 module (EC20) with faster speeds, but it currently only supports internet access for itself.

**Features Supported:**

Expand All @@ -20,10 +22,11 @@ This example demonstrates the ESP32-S2, ESP32-S3 series SoC as a USB host to dia

## Hardware requirement

**Supported ESP Soc:**
**Supported ESP Soc:**

* ESP32-S2
* ESP32-S3
* ESP32-P4

> We recommend using ESP modules or chips that integrate 4MB above Flash, and 2MB above PSRAM. The example does not enable PSRAM by default, but users can add to tests by themselves. In theory, increasing the Wi-Fi buffer size can increase the average data throughput rate.
Expand Down Expand Up @@ -116,8 +119,8 @@ I (9659) esp-modem: --------- Modem PreDefined Info ------------------
I (9666) esp-modem: Model: ML302-DNLM/CNLM
I (9671) esp-modem: Modem itf: IN Addr:0x81, OUT Addr:0x01
I (9677) esp-modem: ----------------------------------------------------
I (9684) gpio: GPIO[12]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (9694) gpio: GPIO[13]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (9684) gpio: GPIO[12]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (9694) gpio: GPIO[13]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
W (9704) USB_HCDC: rx0 flush -0 = 0
W (9707) modem_board: DTE reconnect, reconnecting ...
Expand Down Expand Up @@ -188,11 +191,11 @@ I (15948) modem_wifi: softap ssid: esp_4g_router password: 12345678
I (15954) modem_wifi: NAT is enabled
```

## Debugging method
## Debugging method

**1. Debugging mode**

Enable the `4G Modem Configuration -> Dump system task status` option in `menuconfig` to print task detailed information, or open the `Component config → USB Host CDC ->Trace internal memory status` option to print usb internal buffer usage information.
Enable the `4G Modem Configuration -> Dump system task status` option in `menuconfig` to print task detailed information.

```
I (79530) main: Task dump
Expand All @@ -211,14 +214,6 @@ Enable the `4G Modem Configuration -> Dump system task status` option in `menuco
I (79577) main: 0.00 1092 sys_evt 20
I (79582) main: Free heap=37088 bigst=16384, internal=36968 bigst=16384
I (79589) main: ..............
I (79593) USB_HCDC: USBH CDC Transfer Buffer Dump:
I (79599) USB_HCDC: usb transfer Buffer size, out = 3000, in = 1500
I (79606) USB_HCDC: usb transfer Max packet size, out = 46, in = 48
I (79613) USB_HCDC: USBH CDC Ringbuffer Dump:
I (79618) USB_HCDC: usb ringbuffer size, out = 15360, in = 15360
I (79625) USB_HCDC: usb ringbuffer High water mark, out = 46, in = 48
```

**2. Performance optimization**
Expand Down Expand Up @@ -249,3 +244,7 @@ Enable the `4G Modem Configuration -> Dump system task status` option in `menuco
> **4G Cat.1 theoretical peak download rate is 10 Mbps, peak upload rate is 5 Mbps**
> The actual communication rate is affected by the operator's network, test software, Wi-Fi interference, and the number of terminal connections, etc.

## Known Issues

* ESP32-P4 currently does not support enabling the softAP function via `esp_wifi_remote`.
25 changes: 12 additions & 13 deletions examples/usb/host/usb_cdc_4g_module/README_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

# USB CDC 4G Module

该示例程序可实现 ESP32-S2,ESP32-S3 系列 SoC 作为 USB 主机驱动 4G Cat.1 模组 PPP 拨号上网,同时可开启 ESP32-SX Wi-Fi AP 功能,分享互联网给物联网设备或手持设备,实现低成本 “中高速” 互联网接入。同时配有路由器管理界面,可以在线进行路由器配置和查看已连接设备信息。
该示例程序可实现 **ESP32-S2****ESP32-S3** 系列 SoC 作为 USB 主机驱动 4G Cat.1 模组 PPP 拨号上网,同时可开启 ESP32-SX Wi-Fi AP 功能,分享互联网给物联网设备或手持设备,实现低成本 “中高速” 互联网接入。同时配有路由器管理界面,可以在线进行路由器配置和查看已连接设备信息。

此外对于 **ESP32-P4** 支持了 4G Cat.4 模组(EC20),速率更快,暂时仅支持自身上网功能。

**已实现功能:**

Expand All @@ -20,10 +22,11 @@

## 硬件准备

**已支持 ESP 芯片型号:**
**已支持 ESP 芯片型号:**

* ESP32-S2
* ESP32-S3
* ESP32-P4

> 建议使用集成 4MB 及以上 Flash,2MB 及以上 PSRAM 的 ESP 模组或芯片。示例程序默认不开启 PSRAM,用户可自行添加测试,理论上增大缓冲区大小可以提高数据平均吞吐率
Expand Down Expand Up @@ -121,8 +124,8 @@ I (9659) esp-modem: --------- Modem PreDefined Info ------------------
I (9666) esp-modem: Model: ML302-DNLM/CNLM
I (9671) esp-modem: Modem itf: IN Addr:0x81, OUT Addr:0x01
I (9677) esp-modem: ----------------------------------------------------
I (9684) gpio: GPIO[12]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (9694) gpio: GPIO[13]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (9684) gpio: GPIO[12]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (9694) gpio: GPIO[13]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
W (9704) USB_HCDC: rx0 flush -0 = 0
W (9707) modem_board: DTE reconnect, reconnecting ...

Expand Down Expand Up @@ -197,7 +200,7 @@ I (15954) modem_wifi: NAT is enabled
**1. 调试模式**
可在 `menuconfig` 打开 `4G Modem Configuration -> Dump system task status` 选项打印 task 详细信息,也可打开 `Component config → USB Host CDC ->Trace internal memory status ` 选项打印 usb 内部 buffer 使用信息
可在 `menuconfig` 打开 `4G Modem Configuration -> Dump system task status` 选项打印 task 详细信息。
```
I (79530) main: Task dump
Expand All @@ -216,14 +219,6 @@ I (15954) modem_wifi: NAT is enabled
I (79577) main: 0.00 1092 sys_evt 20
I (79582) main: Free heap=37088 bigst=16384, internal=36968 bigst=16384
I (79589) main: ..............
I (79593) USB_HCDC: USBH CDC Transfer Buffer Dump:
I (79599) USB_HCDC: usb transfer Buffer size, out = 3000, in = 1500
I (79606) USB_HCDC: usb transfer Max packet size, out = 46, in = 48
I (79613) USB_HCDC: USBH CDC Ringbuffer Dump:
I (79618) USB_HCDC: usb ringbuffer size, out = 15360, in = 15360
I (79625) USB_HCDC: usb ringbuffer High water mark, out = 46, in = 48
```
**2. 性能优化**
Expand Down Expand Up @@ -255,3 +250,7 @@ I (15954) modem_wifi: NAT is enabled
> **4G Cat.1 理论峰值下载速率 10 Mbps,峰值上传速率 5 Mbps**
> 实际通信速率受运营商网络、测试软件、Wi-Fi 干扰情况、终端连接数影响,以实际使用为准
## 已知问题
* ESP32-P4 暂不支持通过 esp_wifi_remote 开启 softAP 功能。
2 changes: 1 addition & 1 deletion examples/usb/host/usb_cdc_4g_module/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ if(CONFIG_EXAMPLE_ENABLE_WEB_ROUTER)
else()
idf_component_register(SRC_DIRS "."
INCLUDE_DIRS "."
EXCLUDE_SRCS "modem_http_config.c" "modem_http_config.h" )
EXCLUDE_SRCS "modem_http_config.c")
endif()
1 change: 1 addition & 0 deletions examples/usb/host/usb_cdc_4g_module/main/Kconfig.projbuild
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ menu "4G Modem Example Config"
config EXAMPLE_AUTO_UPDATE_DNS
bool "Auto update Wi-Fi soft ap DNS address"
default y
default n if IDF_TARGET_ESP32P4
help
If true using dns address got from ppp

Expand Down
5 changes: 5 additions & 0 deletions examples/usb/host/usb_cdc_4g_module/main/app_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,12 @@ void app_main(void)
modem_http_get_nvs_wifi_config(&s_modem_wifi_config);
modem_http_init(&s_modem_wifi_config);
#endif

#if !CONFIG_IDF_TARGET_ESP32P4
esp_netif_t *ap_netif = modem_wifi_ap_init();
assert(ap_netif != NULL);
ESP_ERROR_CHECK(modem_wifi_set(&s_modem_wifi_config));
#endif

#ifdef CONFIG_EXAMPLE_PING_NETWORK
ip_addr_t target_addr;
Expand Down Expand Up @@ -282,7 +285,9 @@ void app_main(void)
esp_ping_new_session(&ping_config, &cbs, &ping);
#endif

#ifdef CONFIG_EXAMPLE_AUTO_UPDATE_DNS
uint32_t ap_dns_addr = 0;
#endif
while (1) {

#if !defined(CONFIG_EXAMPLE_ENTER_PPP_DURING_INIT) || defined(CONFIG_MODEM_SUPPORT_SECONDARY_AT_PORT)
Expand Down
4 changes: 2 additions & 2 deletions examples/usb/host/usb_cdc_4g_module/partitions.csv
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
nvs, data, nvs, 0x9000, 0x6000,
phy_init, data, phy, 0xf000, 0x1000,
factory, app, factory, , 1M,
storage, data, spiffs, , 1M,
factory, app, factory, , 1M,
storage, data, spiffs, , 1M,
6 changes: 6 additions & 0 deletions examples/usb/host/usb_cdc_4g_module/partitions_2m_app.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Name, Type, SubType, Offset, Size, Flags
# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
nvs, data, nvs, 0x9000, 0x6000,
phy_init, data, phy, 0xf000, 0x1000,
factory, app, factory, , 2M,
storage, data, spiffs, , 1M,
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_EXAMPLE_AUTO_UPDATE_DNS=n
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_2m_app.csv"

0 comments on commit 2eebd55

Please sign in to comment.