Skip to content

Commit 9ee1f0e

Browse files
authored
[ln882h] Change flashing baudrate, fix connection guide (#72)
* [ln882h] improve flash read speed by changing baudrate * [ln882h] fix UART number in help tip
1 parent 92c3bec commit 9ee1f0e

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

ltchiptool/soc/ln882h/flash.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111
from .util.ln882htool import LN882hTool
1212

1313
LN882H_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
],

ltchiptool/soc/ln882h/util/ln882htool.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff 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,

0 commit comments

Comments
 (0)