usb_serial_jtag_write_bytes() doesn't always write all bytes

jmadsenee
Posts: 30
Joined: Tue Apr 19, 2022 1:16 am

usb_serial_jtag_write_bytes() doesn't always write all bytes

Postby jmadsenee » Sun Feb 19, 2023 9:49 pm

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!

ESP_Sprite
Posts: 9764
Joined: Thu Nov 26, 2015 4:08 am

Re: usb_serial_jtag_write_bytes() doesn't always write all bytes

Postby ESP_Sprite » Mon Feb 20, 2023 12:56 am

Is there any particular data that triggers that behaviour?

jmadsenee
Posts: 30
Joined: Tue Apr 19, 2022 1:16 am

Re: usb_serial_jtag_write_bytes() doesn't always write all bytes

Postby jmadsenee » Tue Feb 21, 2023 12:05 am

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.

jmadsenee
Posts: 30
Joined: Tue Apr 19, 2022 1:16 am

Re: usb_serial_jtag_write_bytes() doesn't always write all bytes

Postby jmadsenee » Tue Feb 21, 2023 12:17 am

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.

ESP_Sprite
Posts: 9764
Joined: Thu Nov 26, 2015 4:08 am

Re: usb_serial_jtag_write_bytes() doesn't always write all bytes

Postby ESP_Sprite » Tue Feb 21, 2023 12:57 am

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?

jmadsenee
Posts: 30
Joined: Tue Apr 19, 2022 1:16 am

Re: usb_serial_jtag_write_bytes() doesn't always write all bytes

Postby jmadsenee » Tue Feb 21, 2023 1:21 am

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.

jmadsenee
Posts: 30
Joined: Tue Apr 19, 2022 1:16 am

Re: usb_serial_jtag_write_bytes() doesn't always write all bytes

Postby jmadsenee » Tue Feb 21, 2023 2:32 am

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.
usb_serial_problem.zip
(583.64 KiB) Downloaded 467 times

horatio
Posts: 3
Joined: Thu Feb 23, 2023 1:41 am

Re: usb_serial_jtag_write_bytes() doesn't always write all bytes

Postby horatio » Thu Feb 23, 2023 1:59 am

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?

ESP_Sprite
Posts: 9764
Joined: Thu Nov 26, 2015 4:08 am

Re: usb_serial_jtag_write_bytes() doesn't always write all bytes

Postby ESP_Sprite » Thu Feb 23, 2023 7:12 am

@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.

jmadsenee
Posts: 30
Joined: Tue Apr 19, 2022 1:16 am

Re: usb_serial_jtag_write_bytes() doesn't always write all bytes

Postby jmadsenee » Thu Feb 23, 2023 2:16 pm

hi @ESP_Sprite, any ideas of what might be causing the ring buffer to stop sending? Any thoughts on further troubleshooting?

Who is online

Users browsing this forum: MicroController and 186 guests