diff --git a/ltchiptool/soc/ln882h/flash.py b/ltchiptool/soc/ln882h/flash.py index 95cb3be..57b4fc6 100644 --- a/ltchiptool/soc/ln882h/flash.py +++ b/ltchiptool/soc/ln882h/flash.py @@ -11,11 +11,12 @@ from .util.ln882htool import LN882hTool LN882H_GUIDE = [ - "Connect UART1 of the LN882h to the USB-TTL adapter:", + "Connect UART0 of the LN882h to the USB-TTL adapter:", [ ("PC", "LN882h"), - ("RX", "TX1 (GPIOA2 / P2)"), - ("TX", "RX1 (GPIOA3 / P3)"), + ("RX", "TX0 (GPIOA2 / P2)"), + ("TX", "RX0 (GPIOA3 / P3)"), + ("GND", "BOOT (GPIOA9 / P9)"), ("", ""), ("GND", "GND"), ], diff --git a/ltchiptool/soc/ln882h/util/ln882htool.py b/ltchiptool/soc/ln882h/util/ln882htool.py index 99f5381..c038168 100644 --- a/ltchiptool/soc/ln882h/util/ln882htool.py +++ b/ltchiptool/soc/ln882h/util/ln882htool.py @@ -169,6 +169,7 @@ def flash_read( chunk_size: int = 256, # maximum supported chunk size ) -> Generator[bytes, None, None]: self.link() + prev_baudrate = self.s.baudrate if not self.ramcode: self.ram_boot() @@ -177,6 +178,10 @@ def flash_read( f"Chunk size {chunk_size} exceeds the maximum allowed (256)" ) + self.change_baudrate(LN882H_YM_BAUDRATE) + self.link() + self.push_timeout(0.02) + for start in range(offset, offset + length, chunk_size): count = min(start + chunk_size, offset + length) - start debug(f"Dumping bytes: start=0x{start:X}, count=0x{count:X}") @@ -186,10 +191,16 @@ def flash_read( valid, data = self.ym._verify_recv_checksum(True, data) if verify and not valid: + self.change_baudrate(prev_baudrate) + self.pop_timeout() raise RuntimeError(f"Invalid checksum") yield data + self.change_baudrate(prev_baudrate) + self.pop_timeout() + info("Flash Read Successful.") + def flash_write( self, offset: int,