logo elektroda
logo elektroda
X
logo elektroda

[Youtube] LN882H module pinout and setup for flashing - step by step video guide

p.kaczmarek2 5295 172
ADVERTISEMENT
📢 Listen (AI):
  • #121 21607742
    insmod
    Level 25  
    Another combination, where i reduced reading size to 16 bytes (+2 bytes crc), and increased baud rate to 1500000
    Tried once and it worked, it was very fast.
  • ADVERTISEMENT
  • #122 21607746
    divadiow
    Level 34  
    divadiow wrote:
    I'll do 10

    Success 7
    Fail 3

    Added after 2 [minutes]:

    insmod wrote:
    it was very fast

    18s. nice
  • ADVERTISEMENT
  • #123 21607755
    p.kaczmarek2
    Moderator Smart Home
    Very nice, can you open PR to flasher or do you want me to integrate it?
    Helpful post? Buy me a coffee.
  • #124 21607766
    insmod
    Level 25  
    >>21607755
    Up to you, since i've commented out everything but dumping.
    I can create several other baud/buffer combinations though. The one i posted earlier, with 1500000baud/16buf, i got crc error 4 out of 5 times.
    The lower the baud, the more chance for success there is.
    Now i've had a successful reading with 115200/512.
    With higher baud rates, it is probably failing at flushing TX buffer.
  • #125 21607781
    divadiow
    Level 34  
    divadiow wrote:
    will do proper dump then convert from hex

    I'll wait to see what v17 is?
  • ADVERTISEMENT
  • #127 21607804
    divadiow
    Level 34  
    oh god 😭. I don't think I have the energy to do 10 rounds on each of those.
    Just give the user all the options in IoTFlasher? 😁🤣
  • #128 21607806
    p.kaczmarek2
    Moderator Smart Home
    But we can do it automatically. As long as we have flashing tool with RTS/DTS and connect RESET to it, I guess. LN882H requires reboot between flash attempts, it seems.
    Helpful post? Buy me a coffee.
  • #129 21607883
    divadiow
    Level 34  
    I know we've mostly seen this but I thought I'd listen in to what official flasher sends (and module replies with) for erase and then program

    erase send to module
    Code: Text
    Log in, to see the code

    erase receive from module
    Code: Text
    Log in, to see the code


    program send to module
    Code: Text
    Log in, to see the code

    program receive from module
    Code: Text
    Log in, to see the code
  • #130 21607908
    p.kaczmarek2
    Moderator Smart Home
    I am trying to help that guy with AC : https://www.elektroda.com/rtvforum/viewtopic.php?p=21607906#21607906 , so @insmod, if you can, just open PR to Sharp LN882H flasher, replace flash read code, maybe rename old function so it's left as reference
    Helpful post? Buy me a coffee.
  • #131 21608190
    insmod
    Level 25  
    It's still in progress.
    But, i've changed UART from TX interrupt to polling, and now i've done 5 for 5 successful readings with 1500000 baud.
    2000000 baud attached. Succeeds for me in 12.5sec
    Is there a function to reboot to bootloader? (Never mind, hal_misc_reset_all does the trick)

    And did anyone tried to flash a backup back?
  • #132 21608214
    p.kaczmarek2
    Moderator Smart Home
    I am not sure if I tested that, but here is a run of your binary:
    [Youtube] LN882H module pinout and setup for flashing - step by step video guide
    [Youtube] LN882H module pinout and setup for flashing - step by step video guide
    but binary looks correct in the end
    Helpful post? Buy me a coffee.
  • #133 21608220
    insmod
    Level 25  
    >>21608214
    If CRF FAIL - then it is for sure incorrect. And even final binary size is 2047kb, not 2048.
  • #138 21608239
    divadiow
    Level 34  
    >>21608233

    Code: Text
    Log in, to see the code



    Window of SharpLN882HTool.exe showing data transfer and dump process via COM6 port.
  • #140 21608274
    p.kaczmarek2
    Moderator Smart Home
    merged, I will test it few times and probably later begin merge with Easy Flasher
    Helpful post? Buy me a coffee.
  • #141 21608281
    insmod
    Level 25  
    You can later play with ramcode yourself.
    Since final binary is about 10kb, there is no need to buy keil license (free maximum binary size is 32kb)
    Main code:
    int main(int argc, char* argv[])
    {
    		SetSysClock();
    		set_interrupt_priority();
    		__enable_irq();
    
    		hal_flash_init();
    		flash_cache_disable();
    
    		//bootram_ctrl_init();
    		//bootram_ctrl_loop();
    	
    		bootram_serial_init();
    		bootram_serial_setbaudrate(921600);
    		uint32_t		flash_size				 = 0;
    		uint32_t		startAddr				 = 0;
    		uint32_t		readLen				 = 512;
    		uint8_t buf[readLen+2];
    		uint32_t ret = bootram_flash_info();
    
    		flash_size = ((1 << ((ret & 0xFF) - 0x11)) / 8) * 0x100000;
    		bootram_serial_write(&flash_size, sizeof(flash_size));
    		for(int k = 0; k < 0x10000; k++)
    		{
    			__ASM("nop");
    		}
    		for(uint32_t remaining =	flash_size; remaining > 0; remaining -= readLen){
    			hal_flash_read(startAddr, readLen, buf);
    			uint16_t crc = crc16_ccitt(buf, readLen);
    			memcpy(&buf[readLen], &crc, sizeof(crc));
    			startAddr += readLen;
    			size_t sent = 0;
    			bootram_serial_write(buf, readLen + 2);
    			memset(buf, 0, readLen + 2);
    		}
    		for(int k = 0; k < 0x10000; k++)
    		{
    			__ASM("nop");
    		}
    		hal_misc_reset_all();
    		while (1)
    			__ASM("nop");
    }

    Most importantly, comment out this line https://github.com/openshwprojects/OpenLN882H...oject/bootcode/ramcode_dl/bsp/serial_hw.c#L72
    Replace #if 0 with #if 1 here https://github.com/openshwprojects/OpenLN882H...oject/bootcode/ramcode_dl/bsp/serial_hw.c#L93
    And replace https://github.com/openshwprojects/OpenLN882H...ject/bootcode/ramcode_dl/bsp/serial_hw.c#L161
    with
    .txStart     = hw_uart_tx_start_polling,


    Added after 36 [minutes]:

    On another note, newer sdk
    https://gitee.com/lightningsemi/ln882h
  • ADVERTISEMENT
  • #143 21608687
    p.kaczmarek2
    Moderator Smart Home
    How do you build it in keil? I think I did some basic stuff in uVision, but I don't even know the basics well (my related topic about APM32F003F6 - Mini Board i Geehy Programmer)

    Added after 53 [seconds]:

    Also, can you PR latest ramcode to SDK?
    Helpful post? Buy me a coffee.
  • #144 21608690
    insmod
    Level 25  
    [postid:0dd1c57eee][/postid:0dd1c57eee]
    I already did a git reset.
    I've never before used keil, but it was rather straightforward.
    Just open uvprojx and build

    Added after 47 [minutes]:

    I see easyflash header (EF40 and KV40) in dump at 0x1E4000, even if there is no easyflash in sdk.
    Will we adopt it later? Assuming that EF get adopted by flasher.
    And its not hard to implement backwards compatibility (just keep writing at an offset, at least for several major releases).
  • #145 21609056
    p.kaczmarek2
    Moderator Smart Home
    Nice trick with single blob for multiple bauds:
    Code: C / C++
    Log in, to see the code

    I cleared up code a bit, @divadiow can you soon check if it's release-ready? Then I will merge it with main flasher.

    @insmod so it must be Tuya's or of manufacturer? Well, it's better to preserve all data, in case we can extract GPIO configs later.
    Helpful post? Buy me a coffee.
  • #146 21609063
    insmod
    Level 25  
    >>21609056
    My module is LN-02 from some cozylife switch.
    But, there is nothing important stored there from what i can see
  • #147 21609065
    p.kaczmarek2
    Moderator Smart Home
    Btw, any potential suggestions for next flashing tool that is relatively easy to port so that I can do it within few days at most?
    Helpful post? Buy me a coffee.
  • #148 21609074
    insmod
    Level 25  
    >>21609065
    AmebaZ? It basically uses the same protocol as AmebaD.

    The most important is AmebaZ2, but its protocol is somewhat different - even requires separate flash tool, while even AmebaZ is supported by latest flash tools.
  • #149 21609078
    divadiow
    Level 34  
    p.kaczmarek2 wrote:
    can you soon check if it's release-ready?

    will try asap.

    insmod wrote:
    AmebaZ? It basically uses the same protocol as AmebaD.

    agreed. a logical next choice
  • #150 21609082
    p.kaczmarek2
    Moderator Smart Home
    I've had to add few fixes, for example, it seems that either myself or @insmod changed flash size to read to baud :D so I had to update batch scripts

    We still probably need a "read at offset", either fake it with current quick reader, or just use old slow read code
    Helpful post? Buy me a coffee.
📢 Listen (AI):

Topic summary

The discussion centers on flashing the LN882H (specifically LN882HKI) module using open-source tools and firmware such as OpenBeken and OpenBK7231T_App, with detailed guides and video tutorials available. Flashing involves grounding the BOOT pin and using UART communication, which employs ASCII commands and the YMODEM protocol for data transfer. Several tools have been developed and shared, including LN882Loader (Linux-based) and Windows GUI wrappers, with ongoing improvements to support faster flash reading and dumping via commands like "fdump." Users report challenges with UART adapters, power supply stability, and correct COM port usage, highlighting the importance of proper hardware setup (e.g., CH340G vs. FTDI232 UART adapters). SSDP support and Home Assistant integration are discussed, with SSDP requiring IGMP flag enabling and driver activation in firmware. GPIO pin behavior and limitations are examined, noting that certain pins (A13 to B2) are reserved for QSPI flash and should not be used as GPIO outputs. Firmware versions and SDK updates are tracked, with reverse engineering efforts revealing internal flash structures and configuration data. WiFi stability issues on LN882H modules are reported, potentially linked to power supply quality or environmental factors, distinct from BK7231N platform behavior. Pinout details for LN882HK1 modules are clarified, identifying UART TX and RX pins and the BOOT pin for flashing mode entry. Overall, the community collaborates on improving flashing tools, firmware features, and hardware understanding to enable cloud-free operation and integration with smart home systems.
Summary generated by the language model.
ADVERTISEMENT