From 5e3405fe3987b05866a6ef5d128a1f558a961ef2 Mon Sep 17 00:00:00 2001 From: lamauny Date: Sat, 7 Jun 2025 07:46:32 +0200 Subject: [PATCH 1/3] [ln882h] reduce transfer baudrate to improve reliability --- ltchiptool/soc/ln882h/util/ln882htool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ltchiptool/soc/ln882h/util/ln882htool.py b/ltchiptool/soc/ln882h/util/ln882htool.py index 777c32f..4b2704b 100644 --- a/ltchiptool/soc/ln882h/util/ln882htool.py +++ b/ltchiptool/soc/ln882h/util/ln882htool.py @@ -14,7 +14,7 @@ _T_YmodemCB = Optional[Callable[[int, str, int, int], None]] -LN882H_YM_BAUDRATE = 2000000 +LN882H_YM_BAUDRATE = 1000000 LN882H_ROM_BAUDRATE = 115200 LN882H_FLASH_ADDRESS = 0x0000000 LN882H_RAM_ADDRESS = 0x20000000 From 4c5f2e37e992be068690d05baf38331b4bcb4fa9 Mon Sep 17 00:00:00 2001 From: lamauny Date: Fri, 25 Jul 2025 15:45:39 +0200 Subject: [PATCH 2/3] fix ln882x flash write on Windows platform --- ltchiptool/soc/ln882h/util/ln882htool.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/ltchiptool/soc/ln882h/util/ln882htool.py b/ltchiptool/soc/ln882h/util/ln882htool.py index 4b2704b..f3318ab 100644 --- a/ltchiptool/soc/ln882h/util/ln882htool.py +++ b/ltchiptool/soc/ln882h/util/ln882htool.py @@ -207,18 +207,17 @@ def flash_write( self.command(f"startaddr 0x{offset:X}") # Convert stream to temporary file before sending with YMODEM - tmp_file = NamedTemporaryFile() - with open(tmp_file.name, "wb") as f: + with NamedTemporaryFile(delete=False) as f: f.write(stream.getbuffer()) - self.command(f"upgrade", waitresp=False) + self.command(f"upgrade", waitresp=False) - self.push_timeout(3) - debug(f"YMODEM: transmitting to 0x{offset:X}") - if not self.ym.send([f.name], callback=callback): - self.change_baudrate(prev_baudrate) - self.pop_timeout() - raise RuntimeError("YMODEM transmission failed") + self.push_timeout(3) + debug(f"YMODEM: transmitting to 0x{offset:X}") + if not self.ym.send([f.name], callback=callback): + self.change_baudrate(prev_baudrate) + self.pop_timeout() + raise RuntimeError("YMODEM transmission failed") self.link() From b2c0bbe264f0f4902cf01bb689668146ec8a2993 Mon Sep 17 00:00:00 2001 From: lamauny Date: Fri, 25 Jul 2025 15:52:55 +0200 Subject: [PATCH 3/3] black reformat --- ltchiptool/soc/ln882h/util/ln882htool.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ltchiptool/soc/ln882h/util/ln882htool.py b/ltchiptool/soc/ln882h/util/ln882htool.py index f3318ab..99f5381 100644 --- a/ltchiptool/soc/ln882h/util/ln882htool.py +++ b/ltchiptool/soc/ln882h/util/ln882htool.py @@ -215,9 +215,9 @@ def flash_write( self.push_timeout(3) debug(f"YMODEM: transmitting to 0x{offset:X}") if not self.ym.send([f.name], callback=callback): - self.change_baudrate(prev_baudrate) - self.pop_timeout() - raise RuntimeError("YMODEM transmission failed") + self.change_baudrate(prev_baudrate) + self.pop_timeout() + raise RuntimeError("YMODEM transmission failed") self.link()