nodemcu-firmware: ESP32: uart.write() doesn't send long chunk via CONSOLE_USB_SERIAL_JTAG

Expected behavior

Currently, to send a data fragment larger than 256 bytes via CONSOLE_USB_SERIAL_JTAG, a forced insertion of \n between 256-byte fragments is required.

I would like the behavior to match the behavior when sending a long sequence via UART_DEFAULT. That is, data should be sent continuously without adding \n

In the nodemcu-tool and nodemcu-tools utilities, uniterrupted sending is used to download a file from the ESP32. Forcing \n to each piece will break the exchange protocol.

Moreover, the size of the response to a request from the utility can exceed 256 bytes. And in this case, I can’t even add \n

Actual behavior

When sending a chunk longer than 256 bytes, only the first 256 bytes are sent. The remaining bytes will be sent only if you add \n at the end of the chunk.

Test code

This code works

s = string.rep('a', 256)
uart.write(0, s)
uart.write(0,'\n')
uart.write(0, s)
print'\n'

This code does not work

s = string.rep('a', 256)
uart.write(0, s)
uart.write(0, s)
print'\n'

NodeMCU startup banner

Startup banner

ESP-ROM:esp32c3-api1-20210207 Build:Feb 7 2021 rst:0x3 (RTC_SW_SYS_RST),boot:0xd (SPI_FAST_FLASH_BOOT) Saved PC:0x40048b82 SPIWP:0xee mode:DIO, clock div:1 load:0x3fcd5820,len:0x1704 load:0x403cc710,len:0x938 load:0x403ce710,len:0x2ee8 entry 0x403cc710 I (24) boot: ESP-IDF v5.1.3 2nd stage bootloader I (24) boot: compile time Jul 29 2024 20:30:34 I (24) boot: chip revision: v0.4 I (27) boot.esp32c3: SPI Speed : 80MHz I (32) boot.esp32c3: SPI Mode : DIO I (36) boot.esp32c3: SPI Flash Size : 4MB I (41) boot: Enabling RNG early entropy source… I (46) boot: Partition Table: I (50) boot: ## Label Usage Type ST Offset Length I (57) boot: 0 nvs WiFi data 01 02 00009000 00006000 I (65) boot: 1 phy_init RF data 01 01 0000f000 00001000 I (72) boot: 2 factory factory app 00 00 00010000 00180000 I (80) boot: 3 lfs unknown c2 01 00190000 00010000 I (87) boot: 4 storage Unknown data 01 82 001a0000 00070000 I (95) boot: End of partition table I (99) esp_image: segment 0: paddr=00010020 vaddr=3c0e0020 size=2d748h (186184) map I (137) esp_image: segment 1: paddr=0003d770 vaddr=3fc92400 size=028a8h ( 10408) load I (139) esp_image: segment 2: paddr=00040020 vaddr=42000020 size=d19b8h (858552) map I (279) esp_image: segment 3: paddr=001119e0 vaddr=3fc94ca8 size=001ach ( 428) load I (280) esp_image: segment 4: paddr=00111b94 vaddr=40380000 size=1237ch ( 74620) load I (299) esp_image: segment 5: paddr=00123f18 vaddr=50000000 size=00018h ( 24) load I (305) boot: Loaded app from partition at offset 0x10000 I (306) boot: Disabling RNG early entropy source… I (308) cpu_start: Unicore app I (312) cpu_start: Pro cpu up. I (327) cpu_start: Pro cpu start user code I (327) cpu_start: cpu freq: 160000000 Hz I (327) cpu_start: Application information: I (330) cpu_start: Project name: nodemcu I (335) cpu_start: App version: tmr-libmain-binpatch150-888-gca I (342) cpu_start: Compile time: Jul 29 2024 20:32:43 I (348) cpu_start: ELF file SHA256: b3501ddbd7970a59… I (354) cpu_start: ESP-IDF: v5.1.3 I (359) cpu_start: Min chip rev: v0.3 I (364) cpu_start: Max chip rev: v1.99 I (369) cpu_start: Chip rev: v0.4 I (373) heap_init: Initializing. RAM available for dynamic allocation: I (381) heap_init: At 3FC997B0 len 00026850 (154 KiB): DRAM I (387) heap_init: At 3FCC0000 len 0001C710 (113 KiB): DRAM/RETENTION I (394) heap_init: At 3FCDC710 len 00002950 (10 KiB): DRAM/RETENTION/STACK I (402) heap_init: At 50000018 len 00001FD0 (7 KiB): RTCRAM I (409) spi_flash: detected chip: generic I (412) spi_flash: flash io: dio W (417) rmt(legacy): legacy driver is deprecated, please migrate to driver/rmt_tx.h and/or driver/rmt_rx.h W (427) ADC: legacy driver is deprecated, please migrate to esp_adc/adc_oneshot.h I (436) sleep: Configure to isolate all GPIO pins in sleep state I (442) sleep: Enable automatic switching of GPIO sleep configuration I (449) app_start: Starting scheduler on CPU0 I (454) main_task: Started on CPU0 I (454) main_task: Calling app_main()

E (464) mmap: esp_mmu_paddr_to_vaddr(752): paddr isn’t mapped LFS image loaded I (474) pp: pp rom version: 9387209 I (474) net80211: net80211 rom version: 9387209 I (484) wifi:wifi driver task: 3fca87a4, prio:23, stack:6656, core=0 I (484) wifi:wifi firmware version: 0016c4d I (484) wifi:wifi certification version: v7.0 I (484) wifi:config NVS flash: enabled I (484) wifi:config nano formating: disabled I (484) wifi:Init data frame dynamic rx buffer num: 32 I (484) wifi:Init static rx mgmt buffer num: 5 I (484) wifi:Init management short buffer num: 32 I (484) wifi:Init dynamic tx buffer num: 32 I (484) wifi:Init static tx FG buffer num: 2 I (484) wifi:Init static rx buffer size: 1600 I (484) wifi:Init static rx buffer num: 10 I (484) wifi:Init dynamic rx buffer num: 32 I (484) wifi_init: rx ba win: 6 I (494) wifi_init: tcpip mbox: 32 I (494) wifi_init: udp mbox: 6 I (494) wifi_init: tcp mbox: 6 I (494) wifi_init: tcp tx win: 5760 I (494) wifi_init: tcp rx win: 5760 I (494) wifi_init: tcp mss: 1440 I (494) wifi_init: WiFi IRAM OP enabled I (494) wifi_init: WiFi RX IRAM OP enabled

NodeMCU ESP32 build 2024-07-29 20:32 powered by Lua 5.3.5 [5.3-int32-singlefp] on IDF v5.1.3 cannot open init.lua: No such file or directory

Hardware

esp32c3 and esp32c6 via CONSOLE_USB_SERIAL_JTAG

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 48 (21 by maintainers)

Commits related to this issue

Most upvoted comments

I tested uploading and downloading files using console.on, console.mode and console.write and found no errors.

Also I reworked nodemcu-tools VSCode extension and NodeMCU-Tool CLI utility to support the new firmware. They now support all firmware versions, including the legacy idf3 branch (with file module), the version that uses uart.start/stop and the latest console version.

I am not (currently) able to reproduce the “once only” issue on my s2 here.

I connected the ESP32-S2 (using usb-cdc ) to a USB port on another machine and both upload-file.py and the utilities worked as expected, without errors. I have very wierd USB ports on my Lenovo ideapad. 😡 Sorry for noice 😕

You are right, there is no need to change the default value, since the USB CDC RX buffer size depends on the specific utility or IDE. In particular, for nodemcu-tools and NodeMCU-Tool the setting is CONFIG_ESP_CONSOLE_USB_CDC_RX_BUF_SIZE=256 I think the setting value should be specified in the documentation of an utility or IDE.

It might make sense to mention the setting CONFIG_ESP_CONSOLE_USB_CDC_RX_BUF_SIZE in console.md.

Regardless of the configured RX buffer size, the CDC-ACM is at risk of being overrun it seems. I’ve pushed an updated upload-file.py script which adds an ack scheme and chunks the file contents. It’s tuned to work with the default 64 byte RX buffer, but can be told to use a larger block size if so desired.

Can confirm weirdness on my S2 CDC-ACM. I have started looking into it, and I keep finding more weirdness 😩

Ugh, my bad 🤦‍♀️. Fixed now. (I based the console module off the uart module, but then failed to fully update the module registration macro, leading the console module to claim to be the uart module. Remarkably silly mistake to make.)

I apologize, I didn’t pull the last changes. 😦

I have tested downloading large files from esp-s3. It’s working now! I will test it more thoroughly on other chips.

Okay, I have a workaround that seems to do the trick reliably here on my c3. See if it works for your setup too @serg3295 ?

I’ve almost finished the necessary refactoring, but I’m out of time for today. I’ll try to have something tomorrow.