乐鑫技术交流
直播中

杨海清

7年用户 1756经验值
私信 关注
[问答]

ESP32-S2使用USB引脚作为UART模块不断重启求解

我需要使用 ESP32-S2 引脚 GPIO19 (USB_DM) 和 GPIO20 (USB_DP) 作为 UART,但是当我尝试时,模块不断重启。我认为是由于 USB 内部引脚上拉。
ESP32-C3 datasheet 中直接说USB 引脚的上拉电阻由USB_SERIAL_JTAG_DP_PULLUP 位控制,我们可以清除它来工作:
代码:
CLEAR_PERI_REG_MASK(USB_SERIAL_JTAG_CONF0_REG, USB_SERIAL_JTAG_DP_PULLUP);
ESP32-S3 数据表什么也没说,但在这个论坛上我找到了一个解决方案(经过测试和工作):
代码:
CLEAR_PERI_REG_MASK(USB_DEVICE_CONF0_REG, USB_DEVICE_USB_PAD_ENABLE);
ESP32-S2 应该怎么办?
我还注意到,如果不使用额外的系统调用,这可以部分工作,但仅在使用 TX 时有效。一旦我连接 RX,Wi-Fi 驱动程序就无法初始化。我正在使用外部 UART-USB 适配器来测试这种情况。

回帖(1)

胡楚翘

2023-3-1 14:23:09
这是一个日志:
代码:
I (24) boot: ESP-IDF 4.4.2 2nd stage bootloader
I (24) boot: compile time 12:10:53
I (24) boot: chip revision: 0
I (25) boot.esp32s2: SPI Speed      : 80MHz
I (30) boot.esp32s2: SPI Mode       : DIO
I (35) boot.esp32s2: SPI Flash Size : 4MB
I (40) boot: Enabling RNG early entropy source...
I (45) boot: Partition Table:
I (49) boot: ## Label            Usage          Type ST Offset   Length
I (56) boot:  0 otadata          OTA data         01 00 00009000 00002000
I (63) boot:  1 phy_init         RF data          01 01 0000b000 00001000
I (71) boot:  2 app0             OTA app          00 10 00010000 001c0000
I (78) boot:  3 app1             OTA app          00 11 001d0000 001c0000
I (86) boot:  4 nvs              WiFi data        01 02 00390000 0006d000
I (93) boot: End of partition table
I (98) esp_image: segment 0: paddr=00010020 vaddr=3f000020 size=1c750h (116560) map
I (129) esp_image: segment 1: paddr=0002c778 vaddr=3ffc4c00 size=0337ch ( 13180) load
I (132) esp_image: segment 2: paddr=0002fafc vaddr=40022000 size=0051ch (  1308) load
I (135) esp_image: segment 3: paddr=00030020 vaddr=40080020 size=84b28h (543528) map
I (252) esp_image: segment 4: paddr=000b4b50 vaddr=4002251c size=126e4h ( 75492) load
I (271) esp_image: segment 5: paddr=000c723c vaddr=50000000 size=00010h (    16) load
I (280) boot: Loaded app from partition at offset 0x10000
I (280) boot: Disabling RNG early entropy source...
I (293) cache: Instruction cache    : size 8KB, 4Ways, cache line size 32Byte
I (293) cpu_start: Pro cpu up.
I (307) cpu_start: Pro cpu start user code
I (307) cpu_start: cpu freq: 160000000
I (307) cpu_start: Application information:
I (312) cpu_start: Project name:     tion4s-hw-s2
I (317) cpu_start: App version:      2022.12.7
I (322) cpu_start: Compile time:     Jan 27 2023 12:41:34
I (328) cpu_start: ELF file SHA256:  f10cb940b7cc9d52...
I (334) cpu_start: ESP-IDF:          4.4.2
I (339) heap_init: Initializing. RAM available for dynamic allocation:
I (346) heap_init: At 3FFCC480 len 0002FB80 (190 KiB): DRAM
I (353) heap_init: At 3FFFC000 len 00003A10 (14 KiB): DRAM
I (359) heap_init: At 3FF9E000 len 00002000 (8 KiB): RTCRAM
I (366) spi_flash: detected chip: generic
I (370) spi_flash: flash io: dio
I (378) cpu_start: Starting scheduler on PRO CPU.
I (561) system_api: Base MAC address is not set
I (566) system_api: read default base MAC address from EFUSE
I (594) wifi:wifi firmware version: eeaa27d
I (595) wifi:wifi certification version: v7.0
I (596) wifi:config NVS flash: enabled
I (600) wifi:config nano formating: disabled
I (604) wifi:Init data frame dynamic rx buffer num: 32
I (608) wifi:Init management frame dynamic rx buffer num: 32
I (614) wifi:Init management short buffer num: 32
I (618) wifi:Init dynamic tx buffer num: 32
I (622) wifi:Init static rx buffer size: 1600
I (626) wifi:Init static rx buffer num: 10
I (630) wifi:Init dynamic rx buffer num: 32
I (634) wifi_init: rx ba win: 6
I (638) wifi_init: tcpip mbox: 32
I (642) wifi_init: udp mbox: 6
I (646) wifi_init: tcp mbox: 6
I (649) wifi_init: tcp tx win: 5744
I (653) wifi_init: tcp rx win: 5744
I (658) wifi_init: tcp mss: 1440
I (662) wifi_init: WiFi IRAM OP enabled
I (666) wifi_init: WiFi RX IRAM OP enabled
I (673) phy_init: phy_version 2300,d67cf06,Feb 10 2022,10:03:07
I (693) phy: pll_cap_ext 10
I (695) phy: pll_cap_ext 10
I (698) phy: pll_cap_ext 10
I (702) phy: pll_cap_ext 10
I (705) phy: pll_cap_ext 10
I (709) phy: pll_cap_ext 10
I (712) phy: pll_cap_ext 10
I (716) phy: pll_cap_ext 10
I (719) phy: pll_cap_ext 10
I (723) phy: pll_cap_ext 10
I (726) phy: pll_cap_ext 10
I (738) phy: pll_cap_ext 10
I (740) phy: pll_cap_ext 10
I (744) phy: pll_cap_ext 10
I (744) phy: pll_cap_ext 10
I (745) phy: pll_cap_ext 10
I (747) phy: pll_cap_ext 10
I (760) phy: pll_cap_ext 10
I (767) phy: pll_cap_ext 10
I (769) phy: pll_cap_ext 10
I (769) phy: pll_cap_ext 10
I (770) phy: pll_cap_ext 10
I (772) phy: pll_cap_ext 10
I (776) phy: pll_cap_ext 10
I (779) phy: pll_cap_ext 10
I (783) phy: pll_cap_ext 10
I (786) phy: pll_cap_ext 10
I (789) phy: pll_cap_ext 10
I (793) phy: pll_cap_ext 10
I (797) phy: pll_cap_ext 10
I (800) phy: pll_cap_ext 10
I (803) phy: pll_cap_ext 10
abort() was called at PC 0x40024977 on core 0

Backtrace:0x40023e7e:0x3ffd9aa00x40029f05:0x3ffd9ac0 0x40030012:0x3ffd9ae0 0x40024977:0x3ffd9b50 0x40024ab1:0x3ffd9b80 0x40024b2a:0x3ffd9ba0 0x400f73ba:0x3ffd9bd0 0x400fa3ed:0x3ffd9ee0 0x40104b2d:0x3ffd9f10 0x4002ec21:0x3ffd9f40 0x400f0ae2:0x3ffd9f90 0x400f0b0b:0x3ffda010 0x400268db:0x3ffda060 0x400ea46b:0x3ffda0c0 0x400ea503:0x3ffda0e0 0x400ea574:0x3ffda100 0x400ec02f:0x3ffda120 0x400ec0ea:0x3ffda140 0x400f0efb:0x3ffda160 0x400f0f82:0x3ffda190 0x400d3236:0x3ffda1b0 0x400d3961:0x3ffda1d0 0x400d23ea:0x3ffda1f0 0x400317c1:0x3ffda210
ELF file SHA256: f10cb940b7cc9d52
Rebooting...
并解码回溯:
代码:
0x40023e7e: panic_abort at /Users/dentra/.platformio/packages/framework-espidf/components/esp_system/panic.c:402
0x40030012: abort at /Users/dentra/.platformio/packages/framework-espidf/components/newlib/abort.c:46
0x40024977: lock_acquire_generic at /Users/dentra/.platformio/packages/framework-espidf/components/newlib/locks.c:139
0x40024ab1: _lock_acquire_recursive at /Users/dentra/.platformio/packages/framework-espidf/components/newlib/locks.c:167
0x40024b2a: __retarget_lock_acquire_recursive at /Users/dentra/.platformio/packages/framework-espidf/components/newlib/locks.c:323
0x400f73ba: _vfprintf_r at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32s2-elf/src/newlib/newlib/libc/stdio/vfprintf.c:853 (discriminator 2)
0x400fa3ed: vprintf at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32s2-elf/src/newlib/newlib/libc/stdio/vprintf.c:34 (discriminator 5)
0x40104b2d: esp_log_writev at /Users/dentra/.platformio/packages/framework-espidf/components/log/log.c:200
0x4002ec21: esp_log_write at /Users/dentra/.platformio/packages/framework-espidf/components/log/log.c:210
0x400f0ae2: lib_printf at /Users/dentra/.platformio/packages/framework-espidf/components/esp_phy/src/lib_printf.c:39 (discriminator 13)
0x400f0b0b: phy_printf at /Users/dentra/.platformio/packages/framework-espidf/components/esp_phy/src/lib_printf.c:49
0x400268db: pll_vol_cal at ??:?
0x400ea46b: set_chan_freq_sw_start at ??:?
0x400ea503: set_channel_rfpll_freq at ??:?
0x400ea574: chip_v7_set_chan at ??:?
0x400ec02f: bb_init at ??:?
0x400ec0ea: register_chipv7_phy at ??:?
0x400f0efb: esp_phy_load_cal_and_init at /Users/dentra/.platformio/packages/framework-espidf/components/esp_phy/src/phy_init.c:716
0x400f0f82: esp_phy_enable at /Users/dentra/.platformio/packages/framework-espidf/components/esp_phy/src/phy_init.c:236
0x400d3236: wifi_hw_start at ??:?
0x400d3961: wifi_start_process at ??:?
0x400d23ea: ieee80211_ioctl_process at ??:?
0x400317c1: ppTask at ??:?
举报

更多回帖

发帖
×
20
完善资料,
赚取积分