Page 1 of 2
usb_serial_jtag_write_bytes() doesn't always write all bytes
Posted: Sun Feb 19, 2023 9:49 pm
by jmadsenee
I am using esp_idf V4.4. When I run usb_serial_jtag_write_bytes() in a loop to transfer data to my PC running Tera Term, it works well for random amounts of data, then only sends part of the data buffer. I try to run:
Code: Select all
for (n = 0; n < 500; n++)
{
sentbytes = usb_serial_jtag_write_bytes((char *)packet_data, 1029, 1000/portTICK_RATE_MS);
// wait for ACK
}
After some number (could be n = 10 or could be n = 234) it does not write all 1029 bytes. sentbytes always = 1029, but the number of bytes received by the PC is something less than that.
Does anyone have some idea what might be going wrong, or how to troubleshoot further?
Thanks!
Re: usb_serial_jtag_write_bytes() doesn't always write all bytes
Posted: Mon Feb 20, 2023 12:56 am
by ESP_Sprite
Is there any particular data that triggers that behaviour?
Re: usb_serial_jtag_write_bytes() doesn't always write all bytes
Posted: Tue Feb 21, 2023 12:05 am
by jmadsenee
Not as far as I can tell. I have had problems transferring a few different file types, jpg, txt, csv. Most of my testing has been with a plain text file, no formatting. It stops in random places in the middle of the text file, sending 204kB one time, 96kB then next, then 159kB, etc. Looking at the parts of files transferred, it stops at different letters, different parts of words, etc.
Re: usb_serial_jtag_write_bytes() doesn't always write all bytes
Posted: Tue Feb 21, 2023 12:17 am
by jmadsenee
A little more info: If, after the ESP32-S3 stops sending data part way through (char *)packet_data, I send a space character:
Code: Select all
usb_serial_jtag_write_bytes(" ", 1, 1000/portTICK_RATE_MS);
the remainder of packet_data is transmitted with the space appended to the end. It picked up exactly where it left off; no missing characters.
Re: usb_serial_jtag_write_bytes() doesn't always write all bytes
Posted: Tue Feb 21, 2023 12:57 am
by ESP_Sprite
What chip is this on? Any chance you can whittle down your code to the smallest project that still exhibits it and post that here?
Re: usb_serial_jtag_write_bytes() doesn't always write all bytes
Posted: Tue Feb 21, 2023 1:21 am
by jmadsenee
I am using a heavily modified ESP32-S3 Korvo-2 board with a ESP32-WROOM-1 MON16R8 module. The UART was disconnected and the USB Serial JTAG connected to the UART connector. The code is pretty complex at this point, but I can try to whittle it down.
Another thing I tried: I looked at the value being returned by xRingbufferSend() in usb_serial_jtag_write_bytes(). It doesn't indicate failure when the buffer stops sending.
Re: usb_serial_jtag_write_bytes() doesn't always write all bytes
Posted: Tue Feb 21, 2023 2:32 am
by jmadsenee
Attached is usb_serial_problem.zip the whittled down code in the FortisKap folder and test.txt, my test file. test.txt goes on an SD card on the korvo-2 board. In a terminal program (I'm using Tera Term) type "send test.txt" at the FortisKap> prompt and and start YModem receive on host.
Re: usb_serial_jtag_write_bytes() doesn't always write all bytes
Posted: Thu Feb 23, 2023 1:59 am
by horatio
Serial comms can be pretty slow. I don't have a lot of experience with esp boards, but I have seen it on STM32 projects where not all the data would be transmitted, despite saying it had. 1000+ bytes is a reasonable chunk of data, and depending on the speed of your serial line, that could potentially be taking too long to send before something is cutting it off?
also do you have a scope? could you probe the lines to see if it is actually being sent or not?
Re: usb_serial_jtag_write_bytes() doesn't always write all bytes
Posted: Thu Feb 23, 2023 7:12 am
by ESP_Sprite
@horatio Note that there's no physical serial line involved here. The USB-serial-JTAG acts as USB on the side of the PC and (kinda) ESP32, but the communication is all over USB. Things like baud rate can be set, but transmissions are always as-fast-as-USB-allows.
Re: usb_serial_jtag_write_bytes() doesn't always write all bytes
Posted: Thu Feb 23, 2023 2:16 pm
by jmadsenee
hi @ESP_Sprite, any ideas of what might be causing the ring buffer to stop sending? Any thoughts on further troubleshooting?