frank-zago / isp55e0

An ISP flashing tool for the WCH CH55x, CH579, CH32F103 under linux
GNU General Public License v3.0
52 stars 18 forks source link

serial port communication is broken with SG2002 cpu native uart #20

Open nikitos1550 opened 4 days ago

nikitos1550 commented 4 days ago

Hi!

Before I made patch, that add serial port communications and it was worked well. But I tested it with usb serial adapter. Recently I used sg2002 based system with native hw uart and faced that serial communication is broken with ch573f. read() request returns less data then expected.

Now I made local patch

diff --git a/isp55e0.c b/isp55e0.c
index 3811166..70de7e0 100644
--- a/isp55e0.c
+++ b/isp55e0.c
@@ -137,7 +137,7 @@ static void open_serial_device(struct device *dev, char *port)
        /* Disable any special handling of received bytes */
        options.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL);

-       options.c_cc [VMIN]  = 0;
+       options.c_cc [VMIN]  = 64;
        options.c_cc [VTIME] = SERIAL_TIMEOUT;

        ret = tcsetattr(dev->fd, TCSANOW, &options) ;

I am posting this here now as a memo, after I will complete all tests, I think I will have a time to put full PR.

nikitos1550 commented 3 days ago
MYSERIAL:~# isp55e0 -p /dev/ttyS1 -f /lib/firmware/blepowermanager-ch57xf-test-uart1-echo.bin 
Found device CH573
Bootloader version 2.9.0
Unique chip ID dd-cf-57-7b-54-50-88-9b
Code flashing successful
Firmware is good

Seems patch is ok.