File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111from .util .ln882htool import LN882hTool
1212
1313LN882H_GUIDE = [
14- "Connect UART1 of the LN882h to the USB-TTL adapter:" ,
14+ "Connect UART0 of the LN882h to the USB-TTL adapter:" ,
1515 [
1616 ("PC" , "LN882h" ),
17- ("RX" , "TX1 (GPIOA2 / P2)" ),
18- ("TX" , "RX1 (GPIOA3 / P3)" ),
17+ ("RX" , "TX0 (GPIOA2 / P2)" ),
18+ ("TX" , "RX0 (GPIOA3 / P3)" ),
19+ ("GND" , "BOOT (GPIOA9 / P9)" ),
1920 ("" , "" ),
2021 ("GND" , "GND" ),
2122 ],
Original file line number Diff line number Diff line change @@ -169,6 +169,7 @@ def flash_read(
169169 chunk_size : int = 256 , # maximum supported chunk size
170170 ) -> Generator [bytes , None , None ]:
171171 self .link ()
172+ prev_baudrate = self .s .baudrate
172173 if not self .ramcode :
173174 self .ram_boot ()
174175
@@ -177,6 +178,10 @@ def flash_read(
177178 f"Chunk size { chunk_size } exceeds the maximum allowed (256)"
178179 )
179180
181+ self .change_baudrate (LN882H_YM_BAUDRATE )
182+ self .link ()
183+ self .push_timeout (0.02 )
184+
180185 for start in range (offset , offset + length , chunk_size ):
181186 count = min (start + chunk_size , offset + length ) - start
182187 debug (f"Dumping bytes: start=0x{ start :X} , count=0x{ count :X} " )
@@ -186,10 +191,16 @@ def flash_read(
186191
187192 valid , data = self .ym ._verify_recv_checksum (True , data )
188193 if verify and not valid :
194+ self .change_baudrate (prev_baudrate )
195+ self .pop_timeout ()
189196 raise RuntimeError (f"Invalid checksum" )
190197
191198 yield data
192199
200+ self .change_baudrate (prev_baudrate )
201+ self .pop_timeout ()
202+ info ("Flash Read Successful." )
203+
193204 def flash_write (
194205 self ,
195206 offset : int ,
You can’t perform that action at this time.
0 commit comments