libretiny-eu / libretiny

PlatformIO development platform for IoT modules
http://docs.libretiny.eu/
MIT License
415 stars 62 forks source link

support for BK7231M(CB2S) #262

Open shzlww opened 8 months ago

shzlww commented 8 months ago

Describe the bug I have a smart plug(not Tuya version) with cb2s module ,but the module is using a BK7231M. I try to flash it with ltchiptool,but i get CRC error at 28%, never success,then I try to flash it with bk7231flasher of OpenBeken, When selecting BK7231N, the Module would flash just fine, but when power cycling it, it would not boot and the AP would not come up.

So, Could BK7231M be support by libretiny?

Screenshots cb2s_bk7231m

Additional context Original firmware dump by bk7231flasher_1.1.6 readResult_BK7231N_QIO_2024-02-3-18-21-04.bin.gz

logs from bk7231flasher_1.1.6:

Backup name has not been set, so output file will only contain flash type/date.

Starting read! Now is: 2024年3月2日 18:17:31. Flasher mode: BK7231N Going to open port: COM3. Serial port open! Getting bus... (now, please do reboot by CEN or by power off/on) Getting bus failed, will try again - 0/100! Getting bus success! Going to set baud rate setting (921600)! Failed to set baud rate! There was no result to save. Backup name has not been set, so output file will only contain flash type/date. Starting read! Now is: 2024年3月2日 18:17:50. Flasher mode: BK7231N Going to open port: COM3. Serial port open! Getting bus... (now, please do reboot by CEN or by power off/on) Getting bus success! Going to set baud rate setting (115200)! Will try to read device flash MID (for unprotect N): Flash MID loaded: 1560EB Will now search for Flash def in out database... Flash def found! For: 1560EB Flash information: mid: 1560EB, icName: TH25Q_16HB, manufacturer: TH, szMem: 1000000, szSR: 2, cwUnp: 0, cwEnp: 7, cwMsk: 407C, sb: 2, lb: 5, cwdRd: 05-35-FF-FF, cwdWr: 01-FF-FF-FF Entering SetProtectState(True)... sr: 4 sr: 4004 final sr: 4004 msk: 407c cw: 0, sb: 2, lb: 5 bfd: 0 sr: 0 sr: 0 final sr: 0 msk: 407c cw: 0, sb: 2, lb: 5 bfd: 0 SetProtectState(True) success! Going to start reading at offset 0x00... Reading 0x00... Ok! Reading 0x1000... Ok! Reading 0x2000... Ok! Reading 0x3000... Ok! Reading 0x4000... Ok! Reading 0x5000... Ok! Reading 0x6000... Ok! Reading 0x7000... Ok! Reading 0x8000... Ok! Reading 0x9000... Ok! Reading 0xA000... Ok! Reading 0xB000... Ok! Reading 0xC000... Ok! Reading 0xD000... Ok! Reading 0xE000... Ok! Reading 0xF000... Ok! Reading 0x10000... Ok! Reading 0x11000... Ok! Reading 0x12000... Ok! Reading 0x13000... Ok! Reading 0x14000... Ok! Reading 0x15000... Ok! Reading 0x16000... Ok! Reading 0x17000... Ok! Reading 0x18000... Ok! Reading 0x19000... Ok! Reading 0x1A000... Ok! Reading 0x1B000... Ok! Reading 0x1C000... Ok! Reading 0x1D000... Ok! Reading 0x1E000... Ok! Reading 0x1F000... Ok! Reading 0x20000... Ok! Reading 0x21000... Ok! Reading 0x22000... Ok! Reading 0x23000... Ok! Reading 0x24000... Ok! Reading 0x25000... Ok! Reading 0x26000... Ok! Reading 0x27000... Ok! Reading 0x28000... Ok! Reading 0x29000... Ok! Reading 0x2A000... Ok! Reading 0x2B000... Ok! Reading 0x2C000... Ok! Reading 0x2D000... Ok! Reading 0x2E000... Ok! Reading 0x2F000... Ok! Reading 0x30000... Ok! Reading 0x31000... Ok! Reading 0x32000... Ok! Reading 0x33000... Ok! Reading 0x34000... Ok! Reading 0x35000... Ok! Reading 0x36000... Ok! Reading 0x37000... Ok! Reading 0x38000... Ok! Reading 0x39000... Ok! Reading 0x3A000... Ok! Reading 0x3B000... Ok! Reading 0x3C000... Ok! Reading 0x3D000... Ok! Reading 0x3E000... Ok! Reading 0x3F000... Ok! Reading 0x40000... Ok! Reading 0x41000... Ok! Reading 0x42000... Ok! Reading 0x43000... Ok! Reading 0x44000... Ok! Reading 0x45000... Ok! Reading 0x46000... Ok! Reading 0x47000... Ok! Reading 0x48000... Ok! Reading 0x49000... Ok! Reading 0x4A000... Ok! Reading 0x4B000... Ok! Reading 0x4C000... Ok! Reading 0x4D000... Ok! Reading 0x4E000... Ok! Reading 0x4F000... Ok! Reading 0x50000... Ok! Reading 0x51000... Ok! Reading 0x52000... Ok! Reading 0x53000... Ok! Reading 0x54000... Ok! Reading 0x55000... Ok! Reading 0x56000... Ok! Reading 0x57000... Ok! Reading 0x58000... Ok! Reading 0x59000... Ok! Reading 0x5A000... Ok! Reading 0x5B000... Ok! Reading 0x5C000... Ok! Reading 0x5D000... Ok! Reading 0x5E000... Ok! Reading 0x5F000... Ok! Reading 0x60000... Ok! Reading 0x61000... Ok! Reading 0x62000... Ok! Reading 0x63000... Ok! Reading 0x64000... Ok! Reading 0x65000... Ok! Reading 0x66000... Ok! Reading 0x67000... Ok! Reading 0x68000... Ok! Reading 0x69000... Ok! Reading 0x6A000... Ok! Reading 0x6B000... Ok! Reading 0x6C000... Ok! Reading 0x6D000... Ok! Reading 0x6E000... Ok! Reading 0x6F000... Ok! Reading 0x70000... Ok! Reading 0x71000... Ok! Reading 0x72000... Ok! Reading 0x73000... Ok! Reading 0x74000... Ok! Reading 0x75000... Ok! Reading 0x76000... Ok! Reading 0x77000... Ok! Reading 0x78000... Ok! Reading 0x79000... Ok! Reading 0x7A000... Ok! Reading 0x7B000... Ok! Reading 0x7C000... Ok! Reading 0x7D000... Ok! Reading 0x7E000... Ok! Reading 0x7F000... Ok! Reading 0x80000... Ok! Reading 0x81000... Ok! Reading 0x82000... Ok! Reading 0x83000... Ok! Reading 0x84000... Ok! Reading 0x85000... Ok! Reading 0x86000... Ok! Reading 0x87000... Ok! Reading 0x88000... Ok! Reading 0x89000... Ok! Reading 0x8A000... Ok! Reading 0x8B000... Ok! Reading 0x8C000... Ok! Reading 0x8D000... Ok! Reading 0x8E000... Ok! Reading 0x8F000... Ok! Reading 0x90000... Ok! Reading 0x91000... Ok! Reading 0x92000... Ok! Reading 0x93000... Ok! Reading 0x94000... Ok! Reading 0x95000... Ok! Reading 0x96000... Ok! Reading 0x97000... Ok! Reading 0x98000... Ok! Reading 0x99000... Ok! Reading 0x9A000... Ok! Reading 0x9B000... Ok! Reading 0x9C000... Ok! Reading 0x9D000... Ok! Reading 0x9E000... Ok! Reading 0x9F000... Ok! Reading 0xA0000... Ok! Reading 0xA1000... Ok! Reading 0xA2000... Ok! Reading 0xA3000... Ok! Reading 0xA4000... Ok! Reading 0xA5000... Ok! Reading 0xA6000... Ok! Reading 0xA7000... Ok! Reading 0xA8000... Ok! Reading 0xA9000... Ok! Reading 0xAA000... Ok! Reading 0xAB000... Ok! Reading 0xAC000... Ok! Reading 0xAD000... Ok! Reading 0xAE000... Ok! Reading 0xAF000... Ok! Reading 0xB0000... Ok! Reading 0xB1000... Ok! Reading 0xB2000... Ok! Reading 0xB3000... Ok! Reading 0xB4000... Ok! Reading 0xB5000... Ok! Reading 0xB6000... Ok! Reading 0xB7000... Ok! Reading 0xB8000... Ok! Reading 0xB9000... Ok! Reading 0xBA000... Ok! Reading 0xBB000... Ok! Reading 0xBC000... Ok! Reading 0xBD000... Ok! Reading 0xBE000... Ok! Reading 0xBF000... Ok! Reading 0xC0000... Ok! Reading 0xC1000... Ok! Reading 0xC2000... Ok! Reading 0xC3000... Ok! Reading 0xC4000... Ok! Reading 0xC5000... Ok! Reading 0xC6000... Ok! Reading 0xC7000... Ok! Reading 0xC8000... Ok! Reading 0xC9000... Ok! Reading 0xCA000... Ok! Reading 0xCB000... Ok! Reading 0xCC000... Ok! Reading 0xCD000... Ok! Reading 0xCE000... Ok! Reading 0xCF000... Ok! Reading 0xD0000... Ok! Reading 0xD1000... Ok! Reading 0xD2000... Ok! Reading 0xD3000... Ok! Reading 0xD4000... Ok! Reading 0xD5000... Ok! Reading 0xD6000... Ok! Reading 0xD7000... Ok! Reading 0xD8000... Ok! Reading 0xD9000... Ok! Reading 0xDA000... Ok! Reading 0xDB000... Ok! Reading 0xDC000... Ok! Reading 0xDD000... Ok! Reading 0xDE000... Ok! Reading 0xDF000... Ok! Reading 0xE0000... Ok! Reading 0xE1000... Ok! Reading 0xE2000... Ok! Reading 0xE3000... Ok! Reading 0xE4000... Ok! Reading 0xE5000... Ok! Reading 0xE6000... Ok! Reading 0xE7000... Ok! Reading 0xE8000... Ok! Reading 0xE9000... Ok! Reading 0xEA000... Ok! Reading 0xEB000... Ok! Reading 0xEC000... Ok! Reading 0xED000... Ok! Reading 0xEE000... Ok! Reading 0xEF000... Ok! Reading 0xF0000... Ok! Reading 0xF1000... Ok! Reading 0xF2000... Ok! Reading 0xF3000... Ok! Reading 0xF4000... Ok! Reading 0xF5000... Ok! Reading 0xF6000... Ok! Reading 0xF7000... Ok! Reading 0xF8000... Ok! Reading 0xF9000... Ok! Reading 0xFA000... Ok! Reading 0xFB000... Ok! Reading 0xFC000... Ok! Reading 0xFD000... Ok! Reading 0xFE000... Ok! Reading 0xFF000... Ok! Reading 0x100000... Ok! Reading 0x101000... Ok! Reading 0x102000... Ok! Reading 0x103000... Ok! Reading 0x104000... Ok! Reading 0x105000... Ok! Reading 0x106000... Ok! Reading 0x107000... Ok! Reading 0x108000... Ok! Reading 0x109000... Ok! Reading 0x10A000... Ok! Reading 0x10B000... Ok! Reading 0x10C000... Ok! Reading 0x10D000... Ok! Reading 0x10E000... Ok! Reading 0x10F000... Ok! Reading 0x110000... Ok! Reading 0x111000... Ok! Reading 0x112000... Ok! Reading 0x113000... Ok! Reading 0x114000... Ok! Reading 0x115000... Ok! Reading 0x116000... Ok! Reading 0x117000... Ok! Reading 0x118000... Ok! Reading 0x119000... Ok! Reading 0x11A000... Ok! Reading 0x11B000... Ok! Reading 0x11C000... Ok! Reading 0x11D000... Ok! Reading 0x11E000... Ok! Reading 0x11F000... Ok! Reading 0x120000... Ok! Reading 0x121000... Ok! Reading 0x122000... Ok! Reading 0x123000... Ok! Reading 0x124000... Ok! Reading 0x125000... Ok! Reading 0x126000... Ok! Reading 0x127000... Ok! Reading 0x128000... Ok! Reading 0x129000... Ok! Reading 0x12A000... Ok! Reading 0x12B000... Ok! Reading 0x12C000... Ok! Reading 0x12D000... Ok! Reading 0x12E000... Ok! Reading 0x12F000... Ok! Reading 0x130000... Ok! Reading 0x131000... Ok! Reading 0x132000... Ok! Reading 0x133000... Ok! Reading 0x134000... Ok! Reading 0x135000... Ok! Reading 0x136000... Ok! Reading 0x137000... Ok! Reading 0x138000... Ok! Reading 0x139000... Ok! Reading 0x13A000... Ok! Reading 0x13B000... Ok! Reading 0x13C000... Ok! Reading 0x13D000... Ok! Reading 0x13E000... Ok! Reading 0x13F000... Ok! Reading 0x140000... Ok! Reading 0x141000... Ok! Reading 0x142000... Ok! Reading 0x143000... Ok! Reading 0x144000... Ok! Reading 0x145000... Ok! Reading 0x146000... Ok! Reading 0x147000... Ok! Reading 0x148000... Ok! Reading 0x149000... Ok! Reading 0x14A000... Ok! Reading 0x14B000... Ok! Reading 0x14C000... Ok! Reading 0x14D000... Ok! Reading 0x14E000... Ok! Reading 0x14F000... Ok! Reading 0x150000... Ok! Reading 0x151000... Ok! Reading 0x152000... Ok! Reading 0x153000... Ok! Reading 0x154000... Ok! Reading 0x155000... Ok! Reading 0x156000... Ok! Reading 0x157000... Ok! Reading 0x158000... Ok! Reading 0x159000... Ok! Reading 0x15A000... Ok! Reading 0x15B000... Ok! Reading 0x15C000... Ok! Reading 0x15D000... Ok! Reading 0x15E000... Ok! Reading 0x15F000... Ok! Reading 0x160000... Ok! Reading 0x161000... Ok! Reading 0x162000... Ok! Reading 0x163000... Ok! Reading 0x164000... Ok! Reading 0x165000... Ok! Reading 0x166000... Ok! Reading 0x167000... Ok! Reading 0x168000... Ok! Reading 0x169000... Ok! Reading 0x16A000... Ok! Reading 0x16B000... Ok! Reading 0x16C000... Ok! Reading 0x16D000... Ok! Reading 0x16E000... Ok! Reading 0x16F000... Ok! Reading 0x170000... Ok! Reading 0x171000... Ok! Reading 0x172000... Ok! Reading 0x173000... Ok! Reading 0x174000... Ok! Reading 0x175000... Ok! Reading 0x176000... Ok! Reading 0x177000... Ok! Reading 0x178000... Ok! Reading 0x179000... Ok! Reading 0x17A000... Ok! Reading 0x17B000... Ok! Reading 0x17C000... Ok! Reading 0x17D000... Ok! Reading 0x17E000... Ok! Reading 0x17F000... Ok! Reading 0x180000... Ok! Reading 0x181000... Ok! Reading 0x182000... Ok! Reading 0x183000... Ok! Reading 0x184000... Ok! Reading 0x185000... Ok! Reading 0x186000... Ok! Reading 0x187000... Ok! Reading 0x188000... Ok! Reading 0x189000... Ok! Reading 0x18A000... Ok! Reading 0x18B000... Ok! Reading 0x18C000... Ok! Reading 0x18D000... Ok! Reading 0x18E000... Ok! Reading 0x18F000... Ok! Reading 0x190000... Ok! Reading 0x191000... Ok! Reading 0x192000... Ok! Reading 0x193000... Ok! Reading 0x194000... Ok! Reading 0x195000... Ok! Reading 0x196000... Ok! Reading 0x197000... Ok! Reading 0x198000... Ok! Reading 0x199000... Ok! Reading 0x19A000... Ok! Reading 0x19B000... Ok! Reading 0x19C000... Ok! Reading 0x19D000... Ok! Reading 0x19E000... Ok! Reading 0x19F000... Ok! Reading 0x1A0000... Ok! Reading 0x1A1000... Ok! Reading 0x1A2000... Ok! Reading 0x1A3000... Ok! Reading 0x1A4000... Ok! Reading 0x1A5000... Ok! Reading 0x1A6000... Ok! Reading 0x1A7000... Ok! Reading 0x1A8000... Ok! Reading 0x1A9000... Ok! Reading 0x1AA000... Ok! Reading 0x1AB000... Ok! Reading 0x1AC000... Ok! Reading 0x1AD000... Ok! Reading 0x1AE000... Ok! Reading 0x1AF000... Ok! Reading 0x1B0000... Ok! Reading 0x1B1000... Ok! Reading 0x1B2000... Ok! Reading 0x1B3000... Ok! Reading 0x1B4000... Ok! Reading 0x1B5000... Ok! Reading 0x1B6000... Ok! Reading 0x1B7000... Ok! Reading 0x1B8000... Ok! Reading 0x1B9000... Ok! Reading 0x1BA000... Ok! Reading 0x1BB000... Ok! Reading 0x1BC000... Ok! Reading 0x1BD000... Ok! Reading 0x1BE000... Ok! Reading 0x1BF000... Ok! Reading 0x1C0000... Ok! Reading 0x1C1000... Ok! Reading 0x1C2000... Ok! Reading 0x1C3000... Ok! Reading 0x1C4000... Ok! Reading 0x1C5000... Ok! Reading 0x1C6000... Ok! Reading 0x1C7000... Ok! Reading 0x1C8000... Ok! Reading 0x1C9000... Ok! Reading 0x1CA000... Ok! Reading 0x1CB000... Ok! Reading 0x1CC000... Ok! Reading 0x1CD000... Ok! Reading 0x1CE000... Ok! Reading 0x1CF000... Ok! Reading 0x1D0000... Ok! Reading 0x1D1000... Ok! Reading 0x1D2000... Ok! Reading 0x1D3000... Ok! Reading 0x1D4000... Ok! Reading 0x1D5000... Ok! Reading 0x1D6000... Ok! Reading 0x1D7000... Ok! Reading 0x1D8000... Ok! Reading 0x1D9000... Ok! Reading 0x1DA000... Ok! Reading 0x1DB000... Ok! Reading 0x1DC000... Ok! Reading 0x1DD000... Ok! Reading 0x1DE000... Ok! Reading 0x1DF000... Ok! Reading 0x1E0000... Ok! Reading 0x1E1000... Ok! Reading 0x1E2000... Ok! Reading 0x1E3000... Ok! Reading 0x1E4000... Ok! Reading 0x1E5000... Ok! Reading 0x1E6000... Ok! Reading 0x1E7000... Ok! Reading 0x1E8000... Ok! Reading 0x1E9000... Ok! Reading 0x1EA000... Ok! Reading 0x1EB000... Ok! Reading 0x1EC000... Ok! Reading 0x1ED000... Ok! Reading 0x1EE000... Ok! Reading 0x1EF000... Ok! Reading 0x1F0000... Ok! Reading 0x1F1000... Ok! Reading 0x1F2000... Ok! Reading 0x1F3000... Ok! Reading 0x1F4000... Ok! Reading 0x1F5000... Ok! Reading 0x1F6000... Ok! Reading 0x1F7000... Ok! Reading 0x1F8000... Ok! Reading 0x1F9000... Ok! Reading 0x1FA000... Ok! Reading 0x1FB000... Ok! Reading 0x1FC000... Ok! Reading 0x1FD000... Ok! Reading 0x1FE000... Ok! Reading 0x1FF000... Ok! Basic read operation finished, but now it's time to verify... Starting CRC check for 512 sectors, starting at offset 00 CRC matches 0x420DE8B4! All read! Loaded total 0x200000 bytes Wrote 2097152 to readResult_BK7231N_QIO_2024-02-3-18-21-04.bin Backup 2MB created, now will attempt to extract OBK config. It's not an OBK config, header is bad OBK config not found. Backup 2MB created, now will attempt to extract Tuya config. Failed to extract Tuya keys - magic constant header not found in binary Sorry, failed to find Tuya Config in backup binary.

Starting read! Now is: 2024年3月2日 18:23:50. Flasher mode: BK7231N Going to open port: COM3. Serial port open! Getting bus... (now, please do reboot by CEN or by power off/on) Getting bus success! Going to set baud rate setting (115200)! Will try to read device flash MID (for unprotect N): Flash MID loaded: 1560EB Will now search for Flash def in out database... Flash def found! For: 1560EB Flash information: mid: 1560EB, icName: TH25Q_16HB, manufacturer: TH, szMem: 1000000, szSR: 2, cwUnp: 0, cwEnp: 7, cwMsk: 407C, sb: 2, lb: 5, cwdRd: 05-35-FF-FF, cwdWr: 01-FF-FF-FF Entering SetProtectState(True)... sr: 0 sr: 0 final sr: 0 msk: 407c cw: 0, sb: 2, lb: 5 bfd: 0 SetProtectState(True) success! Going to start reading at offset 0x1D1000... Reading 0x1D1000... Ok! Basic read operation finished, but now it's time to verify... Starting CRC check for 1 sectors, starting at offset 1D1000 CRC matches 0xEAB98F5! All read! Loaded total 0x1000 bytes It's not an OBK config, header is bad OBK config load failed. Starting flash new (no backup)! Now is: 2024年3月2日 18:24:52. Flasher mode: BK7231N Going to open port: COM3. Serial port open! Getting bus... (now, please do reboot by CEN or by power off/on) Getting bus success! Going to set baud rate setting (115200)! Will try to read device flash MID (for unprotect N): Flash MID loaded: 1560EB Will now search for Flash def in out database... Flash def found! For: 1560EB Flash information: mid: 1560EB, icName: TH25Q_16HB, manufacturer: TH, szMem: 1000000, szSR: 2, cwUnp: 0, cwEnp: 7, cwMsk: 407C, sb: 2, lb: 5, cwdRd: 05-35-FF-FF, cwdWr: 01-FF-FF-FF Entering SetProtectState(True)... sr: 0 sr: 0 final sr: 0 msk: 407c cw: 0, sb: 2, lb: 5 bfd: 0 SetProtectState(True) success! Reading file firmwares/OpenBK7231N_QIO_1.17.308.bin... Loaded 1220464 bytes from firmwares/OpenBK7231N_QIO_1.17.308.bin... Preparing to write data file to chip - resetting bus and baud... Getting bus... (now, please do reboot by CEN or by power off/on) Getting bus success! Going to set baud rate setting (115200)! Will try to read device flash MID (for unprotect N): Flash MID loaded: 1560EB Will now search for Flash def in out database... Flash def found! For: 1560EB Flash information: mid: 1560EB, icName: TH25Q_16HB, manufacturer: TH, szMem: 1000000, szSR: 2, cwUnp: 0, cwEnp: 7, cwMsk: 407C, sb: 2, lb: 5, cwdRd: 05-35-FF-FF, cwdWr: 01-FF-FF-FF Entering SetProtectState(True)... sr: 0 sr: 0 final sr: 0 msk: 407c cw: 0, sb: 2, lb: 5 bfd: 0 SetProtectState(True) success! Going to do erase, start 0, sec count 298! Erasing sector 0... ok! Erasing sector 4096... ok! Erasing sector 8192... ok! Erasing sector 12288... ok! Erasing sector 16384... ok! Erasing sector 20480... ok! Erasing sector 24576... ok! Erasing sector 28672... ok! Erasing sector 32768... ok! Erasing sector 36864... ok! Erasing sector 40960... ok! Erasing sector 45056... ok! Erasing sector 49152... ok! Erasing sector 53248... ok! Erasing sector 57344... ok! Erasing sector 61440... ok! Erasing sector 65536... ok! Erasing sector 69632... ok! Erasing sector 73728... ok! Erasing sector 77824... ok! Erasing sector 81920... ok! Erasing sector 86016... ok! Erasing sector 90112... ok! Erasing sector 94208... ok! Erasing sector 98304... ok! Erasing sector 102400... ok! Erasing sector 106496... ok! Erasing sector 110592... ok! Erasing sector 114688... ok! Erasing sector 118784... ok! Erasing sector 122880... ok! Erasing sector 126976... ok! Erasing sector 131072... ok! Erasing sector 135168... ok! Erasing sector 139264... ok! Erasing sector 143360... ok! Erasing sector 147456... ok! Erasing sector 151552... ok! Erasing sector 155648... ok! Erasing sector 159744... ok! Erasing sector 163840... ok! Erasing sector 167936... ok! Erasing sector 172032... ok! Erasing sector 176128... ok! Erasing sector 180224... ok! Erasing sector 184320... ok! Erasing sector 188416... ok! Erasing sector 192512... ok! Erasing sector 196608... ok! Erasing sector 200704... ok! Erasing sector 204800... ok! Erasing sector 208896... ok! Erasing sector 212992... ok! Erasing sector 217088... ok! Erasing sector 221184... ok! Erasing sector 225280... ok! Erasing sector 229376... ok! Erasing sector 233472... ok! Erasing sector 237568... ok! Erasing sector 241664... ok! Erasing sector 245760... ok! Erasing sector 249856... ok! Erasing sector 253952... ok! Erasing sector 258048... ok! Erasing sector 262144... ok! Erasing sector 266240... ok! Erasing sector 270336... ok! Erasing sector 274432... ok! Erasing sector 278528... ok! Erasing sector 282624... ok! Erasing sector 286720... ok! Erasing sector 290816... ok! Erasing sector 294912... ok! Erasing sector 299008... ok! Erasing sector 303104... ok! Erasing sector 307200... ok! Erasing sector 311296... ok! Erasing sector 315392... ok! Erasing sector 319488... ok! Erasing sector 323584... ok! Erasing sector 327680... ok! Erasing sector 331776... ok! Erasing sector 335872... ok! Erasing sector 339968... ok! Erasing sector 344064... ok! Erasing sector 348160... ok! Erasing sector 352256... ok! Erasing sector 356352... ok! Erasing sector 360448... ok! Erasing sector 364544... ok! Erasing sector 368640... ok! Erasing sector 372736... ok! Erasing sector 376832... ok! Erasing sector 380928... ok! Erasing sector 385024... ok! Erasing sector 389120... ok! Erasing sector 393216... ok! Erasing sector 397312... ok! Erasing sector 401408... ok! Erasing sector 405504... ok! Erasing sector 409600... ok! Erasing sector 413696... ok! Erasing sector 417792... ok! Erasing sector 421888... ok! Erasing sector 425984... ok! Erasing sector 430080... ok! Erasing sector 434176... ok! Erasing sector 438272... ok! Erasing sector 442368... ok! Erasing sector 446464... ok! Erasing sector 450560... ok! Erasing sector 454656... ok! Erasing sector 458752... ok! Erasing sector 462848... ok! Erasing sector 466944... ok! Erasing sector 471040... ok! Erasing sector 475136... ok! Erasing sector 479232... ok! Erasing sector 483328... ok! Erasing sector 487424... ok! Erasing sector 491520... ok! Erasing sector 495616... ok! Erasing sector 499712... ok! Erasing sector 503808... ok! Erasing sector 507904... ok! Erasing sector 512000... ok! Erasing sector 516096... ok! Erasing sector 520192... ok! Erasing sector 524288... ok! Erasing sector 528384... ok! Erasing sector 532480... ok! Erasing sector 536576... ok! Erasing sector 540672... ok! Erasing sector 544768... ok! Erasing sector 548864... ok! Erasing sector 552960... ok! Erasing sector 557056... ok! Erasing sector 561152... ok! Erasing sector 565248... ok! Erasing sector 569344... ok! Erasing sector 573440... ok! Erasing sector 577536... ok! Erasing sector 581632... ok! Erasing sector 585728... ok! Erasing sector 589824... ok! Erasing sector 593920... ok! Erasing sector 598016... ok! Erasing sector 602112... ok! Erasing sector 606208... ok! Erasing sector 610304... ok! Erasing sector 614400... ok! Erasing sector 618496... ok! Erasing sector 622592... ok! Erasing sector 626688... ok! Erasing sector 630784... ok! Erasing sector 634880... ok! Erasing sector 638976... ok! Erasing sector 643072... ok! Erasing sector 647168... ok! Erasing sector 651264... ok! Erasing sector 655360... ok! Erasing sector 659456... ok! Erasing sector 663552... ok! Erasing sector 667648... ok! Erasing sector 671744... ok! Erasing sector 675840... ok! Erasing sector 679936... ok! Erasing sector 684032... ok! Erasing sector 688128... ok! Erasing sector 692224... ok! Erasing sector 696320... ok! Erasing sector 700416... ok! Erasing sector 704512... ok! Erasing sector 708608... ok! Erasing sector 712704... ok! Erasing sector 716800... ok! Erasing sector 720896... ok! Erasing sector 724992... ok! Erasing sector 729088... ok! Erasing sector 733184... ok! Erasing sector 737280... ok! Erasing sector 741376... ok! Erasing sector 745472... ok! Erasing sector 749568... ok! Erasing sector 753664... ok! Erasing sector 757760... ok! Erasing sector 761856... ok! Erasing sector 765952... ok! Erasing sector 770048... ok! Erasing sector 774144... ok! Erasing sector 778240... ok! Erasing sector 782336... ok! Erasing sector 786432... ok! Erasing sector 790528... ok! Erasing sector 794624... ok! Erasing sector 798720... ok! Erasing sector 802816... ok! Erasing sector 806912... ok! Erasing sector 811008... ok! Erasing sector 815104... ok! Erasing sector 819200... ok! Erasing sector 823296... ok! Erasing sector 827392... ok! Erasing sector 831488... ok! Erasing sector 835584... ok! Erasing sector 839680... ok! Erasing sector 843776... ok! Erasing sector 847872... ok! Erasing sector 851968... ok! Erasing sector 856064... ok! Erasing sector 860160... ok! Erasing sector 864256... ok! Erasing sector 868352... ok! Erasing sector 872448... ok! Erasing sector 876544... ok! Erasing sector 880640... ok! Erasing sector 884736... ok! Erasing sector 888832... ok! Erasing sector 892928... ok! Erasing sector 897024... ok! Erasing sector 901120... ok! Erasing sector 905216... ok! Erasing sector 909312... ok! Erasing sector 913408... ok! Erasing sector 917504... ok! Erasing sector 921600... ok! Erasing sector 925696... ok! Erasing sector 929792... ok! Erasing sector 933888... ok! Erasing sector 937984... ok! Erasing sector 942080... ok! Erasing sector 946176... ok! Erasing sector 950272... ok! Erasing sector 954368... ok! Erasing sector 958464... ok! Erasing sector 962560... ok! Erasing sector 966656... ok! Erasing sector 970752... ok! Erasing sector 974848... ok! Erasing sector 978944... ok! Erasing sector 983040... ok! Erasing sector 987136... ok! Erasing sector 991232... ok! Erasing sector 995328... ok! Erasing sector 999424... ok! Erasing sector 1003520... ok! Erasing sector 1007616... ok! Erasing sector 1011712... ok! Erasing sector 1015808... ok! Erasing sector 1019904... ok! Erasing sector 1024000... ok! Erasing sector 1028096... ok! Erasing sector 1032192... ok! Erasing sector 1036288... ok! Erasing sector 1040384... ok! Erasing sector 1044480... ok! Erasing sector 1048576... ok! Erasing sector 1052672... ok! Erasing sector 1056768... ok! Erasing sector 1060864... ok! Erasing sector 1064960... ok! Erasing sector 1069056... ok! Erasing sector 1073152... ok! Erasing sector 1077248... ok! Erasing sector 1081344... ok! Erasing sector 1085440... ok! Erasing sector 1089536... ok! Erasing sector 1093632... ok! Erasing sector 1097728... ok! Erasing sector 1101824... ok! Erasing sector 1105920... ok! Erasing sector 1110016... ok! Erasing sector 1114112... ok! Erasing sector 1118208... ok! Erasing sector 1122304... ok! Erasing sector 1126400... ok! Erasing sector 1130496... ok! Erasing sector 1134592... ok! Erasing sector 1138688... ok! Erasing sector 1142784... ok! Erasing sector 1146880... ok! Erasing sector 1150976... ok! Erasing sector 1155072... ok! Erasing sector 1159168... ok! Erasing sector 1163264... ok! Erasing sector 1167360... ok! Erasing sector 1171456... ok! Erasing sector 1175552... ok! Erasing sector 1179648... ok! Erasing sector 1183744... ok! Erasing sector 1187840... ok! Erasing sector 1191936... ok! Erasing sector 1196032... ok! Erasing sector 1200128... ok! Erasing sector 1204224... ok! Erasing sector 1208320... ok! Erasing sector 1212416... ok! Erasing sector 1216512... ok! All selected sectors erased! Writing sector 0x00... ok! Writing sector 0x1000... ok! Writing sector 0x2000... ok! Writing sector 0x3000... ok! Writing sector 0x4000... ok! Writing sector 0x5000... ok! Writing sector 0x6000... ok! Writing sector 0x7000... ok! Writing sector 0x8000... ok! Writing sector 0x9000... ok! Writing sector 0xA000... ok! Writing sector 0xB000... ok! Writing sector 0xC000... ok! Writing sector 0xD000... ok! Writing sector 0xE000... ok! Writing sector 0xF000... ok! Writing sector 0x10000... ok! Writing sector 0x11000... ok! Writing sector 0x12000... ok! Writing sector 0x13000... ok! Writing sector 0x14000... ok! Writing sector 0x15000... ok! Writing sector 0x16000... ok! Writing sector 0x17000... ok! Writing sector 0x18000... ok! Writing sector 0x19000... ok! Writing sector 0x1A000... ok! Writing sector 0x1B000... ok! Writing sector 0x1C000... ok! Writing sector 0x1D000... ok! Writing sector 0x1E000... ok! Writing sector 0x1F000... ok! Writing sector 0x20000... ok! Writing sector 0x21000... ok! Writing sector 0x22000... ok! Writing sector 0x23000... ok! Writing sector 0x24000... ok! Writing sector 0x25000... ok! Writing sector 0x26000... ok! Writing sector 0x27000... ok! Writing sector 0x28000... ok! Writing sector 0x29000... ok! Writing sector 0x2A000... ok! Writing sector 0x2B000... ok! Writing sector 0x2C000... ok! Writing sector 0x2D000... ok! Writing sector 0x2E000... ok! Writing sector 0x2F000... ok! Writing sector 0x30000... ok! Writing sector 0x31000... ok! Writing sector 0x32000... ok! Writing sector 0x33000... ok! Writing sector 0x34000... ok! Writing sector 0x35000... ok! Writing sector 0x36000... ok! Writing sector 0x37000... ok! Writing sector 0x38000... ok! Writing sector 0x39000... ok! Writing sector 0x3A000... ok! Writing sector 0x3B000... ok! Writing sector 0x3C000... ok! Writing sector 0x3D000... ok! Writing sector 0x3E000... ok! Writing sector 0x3F000... ok! Writing sector 0x40000... ok! Writing sector 0x41000... ok! Writing sector 0x42000... ok! Writing sector 0x43000... ok! Writing sector 0x44000... ok! Writing sector 0x45000... ok! Writing sector 0x46000... ok! Writing sector 0x47000... ok! Writing sector 0x48000... ok! Writing sector 0x49000... ok! Writing sector 0x4A000... ok! Writing sector 0x4B000... ok! Writing sector 0x4C000... ok! Writing sector 0x4D000... ok! Writing sector 0x4E000... ok! Writing sector 0x4F000... ok! Writing sector 0x50000... ok! Writing sector 0x51000... ok! Writing sector 0x52000... ok! Writing sector 0x53000... ok! Writing sector 0x54000... ok! Writing sector 0x55000... ok! Writing sector 0x56000... ok! Writing sector 0x57000... ok! Writing sector 0x58000... ok! Writing sector 0x59000... ok! Writing sector 0x5A000... ok! Writing sector 0x5B000... ok! Writing sector 0x5C000... ok! Writing sector 0x5D000... ok! Writing sector 0x5E000... ok! Writing sector 0x5F000... ok! Writing sector 0x60000... ok! Writing sector 0x61000... ok! Writing sector 0x62000... ok! Writing sector 0x63000... ok! Writing sector 0x64000... ok! Writing sector 0x65000... ok! Writing sector 0x66000... ok! Writing sector 0x67000... ok! Writing sector 0x68000... ok! Writing sector 0x69000... ok! Writing sector 0x6A000... ok! Writing sector 0x6B000... ok! Writing sector 0x6C000... ok! Writing sector 0x6D000... ok! Writing sector 0x6E000... ok! Writing sector 0x6F000... ok! Writing sector 0x70000... ok! Writing sector 0x71000... ok! Writing sector 0x72000... ok! Writing sector 0x73000... ok! Writing sector 0x74000... ok! Writing sector 0x75000... ok! Writing sector 0x76000... ok! Writing sector 0x77000... ok! Writing sector 0x78000... ok! Writing sector 0x79000... ok! Writing sector 0x7A000... ok! Writing sector 0x7B000... ok! Writing sector 0x7C000... ok! Writing sector 0x7D000... ok! Writing sector 0x7E000... ok! Writing sector 0x7F000... ok! Writing sector 0x80000... ok! Writing sector 0x81000... ok! Writing sector 0x82000... ok! Writing sector 0x83000... ok! Writing sector 0x84000... ok! Writing sector 0x85000... ok! Writing sector 0x86000... ok! Writing sector 0x87000... ok! Writing sector 0x88000... ok! Writing sector 0x89000... ok! Writing sector 0x8A000... ok! Writing sector 0x8B000... ok! Writing sector 0x8C000... ok! Writing sector 0x8D000... ok! Writing sector 0x8E000... ok! Writing sector 0x8F000... ok! Writing sector 0x90000... ok! Writing sector 0x91000... ok! Writing sector 0x92000... ok! Writing sector 0x93000... ok! Writing sector 0x94000... ok! Writing sector 0x95000... ok! Writing sector 0x96000... ok! Writing sector 0x97000... ok! Writing sector 0x98000... ok! Writing sector 0x99000... ok! Writing sector 0x9A000... ok! Writing sector 0x9B000... ok! Writing sector 0x9C000... ok! Writing sector 0x9D000... ok! Writing sector 0x9E000... ok! Writing sector 0x9F000... ok! Writing sector 0xA0000... ok! Writing sector 0xA1000... ok! Writing sector 0xA2000... ok! Writing sector 0xA3000... ok! Writing sector 0xA4000... ok! Writing sector 0xA5000... ok! Writing sector 0xA6000... ok! Writing sector 0xA7000... ok! Writing sector 0xA8000... ok! Writing sector 0xA9000... ok! Writing sector 0xAA000... ok! Writing sector 0xAB000... ok! Writing sector 0xAC000... ok! Writing sector 0xAD000... ok! Writing sector 0xAE000... ok! Writing sector 0xAF000... ok! Writing sector 0xB0000... ok! Writing sector 0xB1000... ok! Writing sector 0xB2000... ok! Writing sector 0xB3000... ok! Writing sector 0xB4000... ok! Writing sector 0xB5000... ok! Writing sector 0xB6000... ok! Writing sector 0xB7000... ok! Writing sector 0xB8000... ok! Writing sector 0xB9000... ok! Writing sector 0xBA000... ok! Writing sector 0xBB000... ok! Writing sector 0xBC000... ok! Writing sector 0xBD000... ok! Writing sector 0xBE000... ok! Writing sector 0xBF000... ok! Writing sector 0xC0000... ok! Writing sector 0xC1000... ok! Writing sector 0xC2000... ok! Writing sector 0xC3000... ok! Writing sector 0xC4000... ok! Writing sector 0xC5000... ok! Writing sector 0xC6000... ok! Writing sector 0xC7000... ok! Writing sector 0xC8000... ok! Writing sector 0xC9000... ok! Writing sector 0xCA000... ok! Writing sector 0xCB000... ok! Writing sector 0xCC000... ok! Writing sector 0xCD000... ok! Writing sector 0xCE000... ok! Writing sector 0xCF000... ok! Writing sector 0xD0000... ok! Writing sector 0xD1000... ok! Writing sector 0xD2000... ok! Writing sector 0xD3000... ok! Writing sector 0xD4000... ok! Writing sector 0xD5000... ok! Writing sector 0xD6000... ok! Writing sector 0xD7000... ok! Writing sector 0xD8000... ok! Writing sector 0xD9000... ok! Writing sector 0xDA000... ok! Writing sector 0xDB000... ok! Writing sector 0xDC000... ok! Writing sector 0xDD000... ok! Writing sector 0xDE000... ok! Writing sector 0xDF000... ok! Writing sector 0xE0000... ok! Writing sector 0xE1000... ok! Writing sector 0xE2000... ok! Writing sector 0xE3000... ok! Writing sector 0xE4000... ok! Writing sector 0xE5000... ok! Writing sector 0xE6000... ok! Writing sector 0xE7000... ok! Writing sector 0xE8000... ok! Writing sector 0xE9000... ok! Writing sector 0xEA000... ok! Writing sector 0xEB000... ok! Writing sector 0xEC000... ok! Writing sector 0xED000... ok! Writing sector 0xEE000... ok! Writing sector 0xEF000... ok! Writing sector 0xF0000... ok! Writing sector 0xF1000... ok! Writing sector 0xF2000... ok! Writing sector 0xF3000... ok! Writing sector 0xF4000... ok! Writing sector 0xF5000... ok! Writing sector 0xF6000... ok! Writing sector 0xF7000... ok! Writing sector 0xF8000... ok! Writing sector 0xF9000... ok! Writing sector 0xFA000... ok! Writing sector 0xFB000... ok! Writing sector 0xFC000... ok! Writing sector 0xFD000... ok! Writing sector 0xFE000... ok! Writing sector 0xFF000... ok! Writing sector 0x100000... ok! Writing sector 0x101000... ok! Writing sector 0x102000... ok! Writing sector 0x103000... ok! Writing sector 0x104000... ok! Writing sector 0x105000... ok! Writing sector 0x106000... ok! Writing sector 0x107000... ok! Writing sector 0x108000... ok! Writing sector 0x109000... ok! Writing sector 0x10A000... ok! Writing sector 0x10B000... ok! Writing sector 0x10C000... ok! Writing sector 0x10D000... ok! Writing sector 0x10E000... ok! Writing sector 0x10F000... ok! Writing sector 0x110000... ok! Writing sector 0x111000... ok! Writing sector 0x112000... ok! Writing sector 0x113000... ok! Writing sector 0x114000... ok! Writing sector 0x115000... ok! Writing sector 0x116000... ok! Writing sector 0x117000... ok! Writing sector 0x118000... ok! Writing sector 0x119000... ok! Writing sector 0x11A000... ok! Writing sector 0x11B000... ok! Writing sector 0x11C000... ok! Writing sector 0x11D000... ok! Writing sector 0x11E000... ok! Writing sector 0x11F000... ok! Writing sector 0x120000... ok! Writing sector 0x121000... ok! Writing sector 0x122000... ok! Writing sector 0x123000... ok! Writing sector 0x124000... ok! Writing sector 0x125000... ok! Writing sector 0x126000... ok! Writing sector 0x127000... ok! Writing sector 0x128000... ok! Writing sector 0x129000... ok! Starting CRC check for 298 sectors, starting at offset 00 CRC matches 0x5A99C1C1!

NOTE: the OBK config writing is disabled, so not writing anything extra. Writing file data to chip successs.

Cossid commented 8 months ago

Well, that certainly is an oddity. That firmware is unencrypted, and appears to have the BK7231N 1.0.11 bootloader, and doesn't have Tuya firmware, but some other 3rd party. I'm not sure if the M is a misprint or not, but there are references to both BK7231N and BK7231M in the strings.

I'm guessing this would already work with a custom coeff for unencrypted, but I'm unsure what that looks like (and the corresponding ota key/iv and possible ota offset), so I'll leave that to @kuba2k2 to advise on.

kuba2k2 commented 8 months ago

This device indeed appears to be unencrypted. ESPHome config for this device:

esphome:
  name: my-device
  platformio_options:
    board_build.bkcrypt_coeffs: 00000000000000000000000000000000
    board_build.bkota.key: 0123456789ABCDEF0123456789ABCDEF
    board_build.bkota.iv: 0123­456789ABCDEF
    board_flash.download: "0x132000+0xAE000"
shzlww commented 8 months ago

@kuba2k2 compile and flash well,but can not run.No wifi connection and No ap .

Linking .pioenvs/bk7231m/raw_firmware.elf
|-- Image 1: raw_firmware.elf
|   |-- image_bk7231n_app.0x011000.rbl
|   |   |-- raw_firmware.bin
|   |-- image_bk7231n_app.0x011000.crc
|   |-- image_bk7231n_app.0x129F0A.rblh
|   |-- image_bk7231n_app.ota.rbl
|   |-- image_bk7231n_app.ota.ug.bin
RAM:   [====      ]  35.8% (used 93944 bytes from 262144 bytes)
Flash: [=======   ]  72.3% (used 783240 bytes from 1083136 bytes)
Building UF2 OTA image
|-- esphome_2023.12.5_generic-bk7231n-qfn32-tuya_bk7231n_lt1.4.1.uf2
|-- firmware.uf2
|-- firmware.bin
esphome:
  name: bk7231m
  platformio_options:
    board_build.bkcrypt_coeffs: "00000000000000000000000000000000"
    board_build.bkota.key: "0123456789ABCDEF0123456789ABCDEF"
    board_build.bkota.iv: "0123456789ABCDEF"
    board_flash.download: "0x132000+0xAE000"
    #board_flash.download: "0x1E0000"
bk72xx:
  board: generic-bk7231n-qfn32-tuya

logger:

web_server:

captive_portal:

mdns:

api:
  password: ""

ota:
  password: ""
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  ap:
kuba2k2 commented 8 months ago

How did you flash the firmware, and what file did you flash?

Please connect UART to TX2 and capture log outputs from the device. Otherwise we can't even tell if it's running or not.

shzlww commented 8 months ago

@kuba2k2 I try to flash the bk7231m by using many ways, same result: no wifi,no ap,no uart log 1.flash bk7231m.uf2 by ltchiptool 2.flash bk7231m-0x011000.rbl by bk7231_flasher finally,I flash it back to the original factory firmware by bk7231_flasher, I got the uart log,BTW the original factory firmware use BLE to config the wifi by default ,it do not launch an AP to config wifi ,this seems different from other tuya cb2s devices, .

bk_misc_init_start_type 0 0
prvHeapInit-start addr:0x40c328, size:146648
[Flash]id:0xeb6015
[Flash]init over
sctrl_sta_ps_init
SDK Rev: 3.0.56 fa12785
[THD]app:[tcb]40ccf8 [stack]40c4f0-40ccf0:2048:5
[THD]extended_app:[tcb]40d568 [stack]40cd60-40d560:2048:4
[THD]idle:[tcb]40d9d8 [stack]40d5d0-40d9d0:1024:0
[THD]timer_thd:[tcb]40e360 [stack]40db58-40e358:2048:2
OSK Rev: F-3.0.35 fa12785
cset:0 0 0 0
bandgap_calm_in_efuse=0x3e
[load]bandgap_calm=0x20->0x1e,vddig=4->5
[FUNC]rwnxl_init
chip id=7231c device id=20521028
IP Rev: W4-3.0.56-P0
txdesc flush
[FUNC]intc_init
[FUNC]calibration_main
get rfcali_mode:1
device_id=0x20521028
calibration_main over
flash txpwr table:0x1f
dif g and n20 ID in flash:4
dif g and n40 ID in flash:4
load txpwr tabe n20 in flash
read txpwr tab from flash success
uncali adc value:[00 00 00]
temp in flash is:321
[THD]temp_detct:[tcb]40e950 [stack]40e548-40e948:1024:3
lpf_i & q in flash is:113, 107
found flash XTAL:66
xtal in flash is:66
xtal_cali:66
--init_xtal = 66
[FUNC]ps_init
int watchdog enabled, period=10000
task watchdog enabled, period=60000
[FUNC]func_init_extended OVER!!!

start_type:0
[THD]kmsgbk:[tcb]40f218 [stack]40ea10-40f210:2048:6
[THD]init_thread:[tcb]40fa58 [stack]40f280-40fa50:2000:5
Initializing TCP/IP stack
tcp_port:62049
[THD]tcp/ip:[tcb]4104a8 [stack]40fca0-4104a0:2048:7
[THD]wpas_thread:[tcb]411970 [stack]410968-411968:4096:4
bk_wlan_app_init finished
[THD]core_thread:[tcb]4128d0 [stack]4120c8-4128c8:2048:7
[THD]rf_arbitrate:[tcb]413238 [stack]412a30-413230:2048:8
rf_thread_init ok
[THD]ble:[tcb]413b50 [stack]413348-413b48:2048:5
ble mac:bc-fd-0c-78-5d-df
xvr_reg_init
h4tl_init-1 ok
hci_init ok
!!!!!!init_type=0
rwble_hl_init ok
BLE Rev: B5-3.0.56-P0
rwble_init ok
rwip_driver_init ok
enter normal mode
EM_BLE_END:0x1b40
!!!!!!init_type=1
llm_init:312
[gapm_cmp_evt_handler] conidx:0,operation:0x1,status:0x0
cmd->addr.addr[5] :0
!!!!!!init_type=2
[gapm_cmp_evt_handler] conidx:0,operation:0x3,status:0x0
gapm_cmp_evt:GAPM_SET_DEV_CONFIG
gapm_cmp_evt:wait GAPM_GEN_RAND_NB
[gapm_cmp_evt_handler] conidx:0,operation:0x1a,status:0x0
gapm_cmp_evt:GAPM_GEN_RAND_NB
[gapm_cmp_evt_handler] conidx:0,operation:0x1a,status:0x0
gapm_cmp_evt:GAPM_GEN_RAND_NB
[gapm_cmp_evt_handler] conidx:0,operation:0x28,status:0x0
gapm_cmp_evt:BLE_STACK_OK
[THD]cli:[tcb]414eb0 [stack]4146a8-414ea8:2048:3
======>> INIT COMPLETE
ENTRY app MAIN
[THD]app_main:[tcb]415f20 [stack]414f18-415f18:4096:5
[I MAIN][app_main.c:37]Prod: 1, Version: 1.0.4, Compile time: 07:54:13 Sep 13 2023
[MAGIC_HEX]
4A 58 4D 41 47 49 43 4E 
[MAGIC_HEX]
4A 58 4D 41 47 49 43 4E 
[I ELEC][bll_elec.c:272]Use elec part 0, num: 1, int_val: 0, f_val: 0
[I MAIN][bll_dev_prod_test.c:640]15min flag is true, ignore auth test
[THD]key_detect_thread:[tcb]416508 [stack]416100-416500:1024:6
[THD]key_process_thread:[tcb]416b78 [stack]416570-416b70:1536:6
[THD]led_thread:[tcb]417140 [stack]416c38-417138:1280:6
[D  MNG][bll_dev_common.c:147]load burning info
[D  MNG][bll_dev_common.c:148]burninfo.cmei: 111092600011649
[D  MNG][bll_dev_common.c:149]burninfo.sn: 1716059038400011648
[D  MNG][bll_dev_common.c:150]burninfo.manu_data: 2023-09
[D  MNG][bll_dev_common.c:151]burninfo.wifimac: bc-fd-0c-78-5d-de
[D  MNG][bll_dev_common.c:154]burninfo.blemac: bc-fd-0c-78-5d-df
[I MAIN][bll_dev_prod_test.c:666]cali test IN
[THD]app_main:[tcb]40d550 [stack]40c548-40d548:4096:5
[D MAIN][bll_dev_prod_test.c:847]15 min flag is true
[I MAIN][bll_dev_prod_test.c:668]cali test OUT
[D BL0937][fml_bl0937b_int.c:709]user cali
[D BL0937][fml_bl0937b_int.c:717]work mode: 16
[D BL0937][fml_bl0937b_int.c:718]cali, p_ref: 870, v_ref: 2200, i_ref: 395, e_ref: 260
[D BL0937][fml_bl0937b_int.c:719]cali, p_ref_time: 15734, v_ref_time: 569, i_ref_time: 29028
[I BLE_PROTO][device.c:59]Create dev_g_mutex suc
[I ELEC][bll_elec.c:350]READ node, part: 8, num: 1, int_val: 0, f_val: 0
[I  MNG][bll_dev_common.c:256]Use the last config
[I  MNG][bll_dev_common.c:262]Read childrenLock fail, use default
[I  MNG][bll_dev_common.c:284]pwCutMemory: 1, signalLight: 1, childrenLock, 0
[I  MNG][bll_dev_common.c:285]energy: 0.000000, relay: 0
[I  MNG][bll_dev_common.c:286]userBind: 0
[THD]elec_manage_thread:[tcb]40f310 [stack]417218-417c18:2560:6
[I ELEC][bll_elec_manage.c:186]get elec last: 0.000000
[THD]bll_dev_manage:[tcb]40f3d0 [stack]417c20-419220:5632:6
[D  MNG][bll_fota.c:415]next_chktime: 0
[THD]fota_thread:[tcb]40f438 [stack]419228-41a228:4096:6
[W MAIN][fml_led.c:113]set LED: 2, 4
temperature_type=2
temp_code:12 - adc_code:346 - adc_trend:[13]:321->[10]:348
init_xtal:66, delta:5, last_xtal:66
[W  NET][bll_ble_network.c:592]+++>> app ble is ready
[D  NET][bll_ble_network.c:574]+++>> app main entry <<+++
[THD]ble_net_thread:[tcb]40c548 [stack]41a230-41ba30:6144:6
ble create new db
ble_env->start_hdl = 0x10
[gapm_profile_added_ind_handler] prf_task_id:0x78,prf_task_nb:9,start_hdl:16,state:0x1
conidx:0x0,role:0x0,dest_id:0x3,src_id:0x7,param->status:0x0
[D  NET][bll_ble_network.c:130]+++>> ble notice, 8
[D  NET][bll_ble_network.c:198]BLE_5_CREATE_DB: prf_id:0, status:0
[gapm_cmp_evt_handler] conidx:0,operation:0x1b,status:0x0
[gapm_cmp_evt_handler] conidx:0,operation:0xa0,status:0x0
[D  NET][bll_ble_network.c:279]cmd:1 idx:0 status:0
[gapm_cmp_evt_handler] conidx:0,operation:0xa9,status:0x0
[D  NET][bll_ble_network.c:279]cmd:2 idx:0 status:0
[gapm_cmp_evt_handler] conidx:0,operation:0xaa,status:0x0
[D  NET][bll_ble_network.c:279]cmd:3 idx:0 status:0
[gapm_cmp_evt_handler] conidx:0,operation:0xa4,status:0x0
[D  NET][bll_ble_network.c:279]cmd:4 idx:0 status:0
temp_code:14 - adc_code:341 - adc_trend:[10]:348->[11]:339
init_xtal:66, delta:4, last_xtal:71
[gapc_connection_req_ind_handler]ble_slave conn_idx:0
[D  NET][bll_ble_network.c:130]+++>> ble notice, 5
[D  NET][bll_ble_network.c:178]BLE_5_CONNECT_EVENT: conn_idx:0, addr_type:1, peer_addr:f4:c0:10:25:b9:53
[gapm_activity_stopped_ind_handler]conidx:0
gapc_le_pkt_size_ind_handler msgid:0xe2c,dest_id:0x3,src_id:0x8
conidx:0,1max_rx_octets = 251
1max_rx_time = 2120
1max_tx_octets = 251
1max_tx_time = 2120
[D  NET][bll_ble_network.c:130]+++>> ble notice, 4
[D  NET][bll_ble_network.c:173]BLE_5_MTU_CHANGE: conn_idx:0, mtu_size:527
gapc_get_dev_info_req_ind_handler,req:0x0
length:0,name:
[D  NET][bll_ble_network.c:130]+++>> ble notice, 1
[D  NET][bll_ble_network.c:512]BLE_5_WRITE_EVENT: conn_idx:0, prf_id:0, add_id:5, len:2, data[0]:01
[NET_HEX]
01 00 
[D  NET][bll_ble_network.c:130]+++>> ble notice, 1
[D  NET][bll_ble_network.c:512]BLE_5_WRITE_EVENT: conn_idx:0, prf_id:0, add_id:8, len:2, data[0]:02
[NET_HEX]
02 00 
[D  NET][bll_ble_network.c:130]+++>> ble notice, 2
[D  NET][bll_ble_network.c:155]BLE_5_READ_EVENT: conn_idx:0, prf_id:0, add_id:12
[D  NET][bll_ble_network.c:130]+++>> ble notice, 2
[D  NET][bll_ble_network.c:155]BLE_5_READ_EVENT: conn_idx:0, prf_id:0, add_id:14
[D  NET][bll_ble_network.c:130]+++>> ble notice, 1
[D  NET][bll_ble_network.c:512]BLE_5_WRITE_EVENT: conn_idx:0, prf_id:0, add_id:2, len:11, data[0]:00
[NET_HEX]
00 00 10 00 0F 01 04 57 60 4E 99 
[D BLE_PROTO][fml_ble_protol.c:227]ble config timer start
[I BLE_PROTO][fml_ble_protol.c:271]pid: 0, fid: 0, t: 1000, tfrm: 15, plen: 260
[D  NET][bll_ble_network.c:130]+++>> ble notice, 1
[D  NET][bll_ble_network.c:512]BLE_5_WRITE_EVENT: conn_idx:0, prf_id:0, add_id:2, len:20, data[0]:00
[NET_HEX]
00 00 7B 22 6F 70 22 3A 22 73 65 6E 64 57 69 66 69 43 6F 6E 
[D  NET][bll_ble_network.c:130]+++>> ble notice, 1
[D  NET][bll_ble_network.c:512]BLE_5_WRITE_EVENT: conn_idx:0, prf_id:0, add_id:2, len:20, data[0]:00
[NET_HEX]
00 01 66 69 67 22 2C 22 76 65 72 73 69 6F 6E 22 3A 22 31 2E 
[D  NET][bll_ble_network.c:130]+++>> ble notice, 1
[D  NET][bll_ble_network.c:512]BLE_5_WRITE_EVENT: conn_idx:0, prf_id:0, add_id:2, len:20, data[0]:00
[NET_HEX]
00 02 30 22 2C 22 64 61 74 61 22 3A 7B 22 70 61 73 73 77 6F 
[D  NET][bll_ble_network.c:130]+++>> ble notice, 1
[D  NET][bll_ble_network.c:512]BLE_5_WRITE_EVENT: conn_idx:0, prf_id:0, add_id:2, len:20, data[0]:00
[NET_HEX]
00 03 72 64 22 3A 22 31 39 38 38 31 30 32 35 22 2C 22 65 6E 
[D  NET][bll_ble_network.c:130]+++>> ble notice, 1
[D  NET][bll_ble_network.c:512]BLE_5_WRITE_EVENT: conn_idx:0, prf_id:0, add_id:2, len:20, data[0]:00
[NET_HEX]
00 04 63 72 79 70 74 22 3A 22 22 2C 22 43 47 57 22 3A 7B 22 
[D  NET][bll_ble_network.c:130]+++>> ble notice, 1
[D  NET][bll_ble_network.c:512]BLE_5_WRITE_EVENT: conn_idx:0, prf_id:0, add_id:2, len:20, data[0]:00
[NET_HEX]
00 05 67 77 41 64 64 72 65 73 73 22 3A 22 63 67 77 2E 6B 6F 
[D  NET][bll_ble_network.c:130]+++>> ble notice, 1
[D  NET][bll_ble_network.c:512]BLE_5_WRITE_EVENT: conn_idx:0, prf_id:0, add_id:2, len:20, data[0]:00
[NET_HEX]
00 06 6D 65 63 74 2E 63 6F 6D 3A 35 36 38 33 22 2C 22 67 77 
[D  NET][bll_ble_network.c:130]+++>> ble notice, 1
[D  NET][bll_ble_network.c:512]BLE_5_WRITE_EVENT: conn_idx:0, prf_id:0, add_id:2, len:20, data[0]:00
[NET_HEX]
00 07 41 64 64 72 65 73 73 32 22 3A 22 68 74 74 70 73 3A 2F 
[D  NET][bll_ble_network.c:130]+++>> ble notice, 1
[D  NET][bll_ble_network.c:512]BLE_5_WRITE_EVENT: conn_idx:0, prf_id:0, add_id:2, len:20, data[0]:00
[NET_HEX]
00 08 2F 63 67 77 2E 6B 6F 6D 65 63 74 2E 63 6F 6D 3A 34 34 
[D  NET][bll_ble_network.c:130]+++>> ble notice, 1
[D  NET][bll_ble_network.c:512]BLE_5_WRITE_EVENT: conn_idx:0, prf_id:0, add_id:2, len:20, data[0]:00
[NET_HEX]
00 09 33 22 2C 22 75 73 65 72 5F 6B 65 79 22 3A 22 61 62 66 
[D  NET][bll_ble_network.c:130]+++>> ble notice, 1
[D  NET][bll_ble_network.c:512]BLE_5_WRITE_EVENT: conn_idx:0, prf_id:0, add_id:2, len:20, data[0]:00
[NET_HEX]
00 0A 64 63 33 65 36 38 66 32 32 34 36 65 62 61 35 33 34 34 
[D  NET][bll_ble_network.c:130]+++>> ble notice, 1
[D  NET][bll_ble_network.c:512]BLE_5_WRITE_EVENT: conn_idx:0, prf_id:0, add_id:2, len:20, data[0]:00
[NET_HEX]
00 0B 63 39 31 30 64 37 35 33 66 32 37 22 7D 2C 22 63 68 61 
[D  NET][bll_ble_network.c:130]+++>> ble notice, 1
[D  NET][bll_ble_network.c:512]BLE_5_WRITE_EVENT: conn_idx:0, prf_id:0, add_id:2, len:20, data[0]:00
[NET_HEX]
00 0C 6E 6E 65 6C 22 3A 22 30 22 2C 22 65 78 74 72 61 22 3A 
[D  NET][bll_ble_network.c:130]+++>> ble notice, 1
[D  NET][bll_ble_network.c:512]BLE_5_WRITE_EVENT: conn_idx:0, prf_id:0, add_id:2, len:20, data[0]:00
[NET_HEX]
00 0D 7B 7D 2C 22 53 53 49 44 22 3A 22 4C 69 6E 6B 73 79 73 
[D  NET][bll_ble_network.c:130]+++>> ble notice, 1
[D  NET][bll_ble_network.c:512]BLE_5_WRITE_EVENT: conn_idx:0, prf_id:0, add_id:2, len:10, data[0]:00
[NET_HEX]
00 0E 30 33 32 36 35 22 7D 7D 
[D BLE_PROTO][fml_ble_protol.c:237]ble config timer stop
[I BLE_PROTO][fml_ble_protol.c:338]do handle a pkg
[D BLE_PROTO][fml_ble_protol.c:121]WIFI: 
[D BLE_PROTO][fml_ble_protol.c:122]wifi.ssid: ******
[D BLE_PROTO][fml_ble_protol.c:123]wifi.pass_word: ******
[D BLE_PROTO][fml_ble_protol.c:124]wifi.encrypt: 
[D BLE_PROTO][fml_ble_protol.c:125]wifi.channel: 0
[D BLE_PROTO][fml_ble_protol.c:126]CGW: 
[D BLE_PROTO][fml_ble_protol.c:127]cgw.user_key: abfdc3e68f2246eba5344c910d753f27
[D BLE_PROTO][fml_ble_protol.c:128]cgw.gw_address: cgw.******.com:5683
[D BLE_PROTO][fml_ble_protol.c:129]cgw.gw_address2: https://cgw.******.com:443
timer  has deleted
[I  MNG][bll_dev_manage.c:650]dev manage task start
[D  NET][bll_ble_network.c:130]+++>> ble notice, 9
[D  NET][bll_ble_network.c:497]===>> notify complete
[D  MNG][bll_dev_manage.c:70]wifi connect timer start
[THD]wifi_state_thread_handle:[tcb]40ccb0 [stack]40c8a8-40cca8:1024:6
[sa_sta]MM_RESET_REQ
txdesc flush
[sa_sta]ME_CONFIG_REQ
[sa_sta]ME_CHAN_CONFIG_REQ
[sa_sta]MM_START_REQ
[THD]pskc:[tcb]40d150 [stack]40cd48-40d148:1024:4
PSKCsize: ssid of(wpa_supplicant)=848
******, passphras
mm_add_if_req_handler:0
e ******
hapd_intf_add_vif,type:2, s:0, id:0
wpa_dInit
wpa S: DISCONNECTED -> INACTIVE
wpa S: INACTIVE -> DISCONNECTED
enter low level!
mac bc:fd: c:78:5d:de
leave low level!
[net]addvif_idx:0
wpa_supplicant_req_scan
Setting scan request: 0.000000 sec
wpa_supplicant_scan
wpa S: DISCONNECTED -> SCANNING
wpa_drv_scan
wpa_send_scan_req
no ht in scan
scan_start_req_handler
wpa_driver_scan_start_cb
wpa rx E SCAN_STARTED
temp_code:21 - adc_code:329 - adc_trend:[11]:339->[12]:330
init_xtal:66, delta:3, last_xtal:70
wpa_driver_scan_cb
wpa rx E SCAN_RESULTS
Scan completed in 1.124000 seconds
wpa_get_scan_rst:1
cipher2security 2 2 16 16
cipher2security 2 2 16 16
PSKC: end
cipher2security 2 2 16 16
cipher2security 2 2 16 16
wpa_supplicant_connect
Cancelling scan request
wpa S: SCANNING -> ASSOCIATING
wpa_driver_associate: auth_alg 0x1
found scan rst rssi -43 > -50 0
sta_mgmt_register: mac 6a:db:54:e6:04:93
sm_auth_send:1
sm_auth_handler
in assoc req 40000000 1
sm_assoc_rsp_handler
rc_init: station_id=0 format_mod=0 pre_type=0 short_gi=0 max_bw=0
rc_init: nss_max=0 mcs_max=255 r_idx_min=0 r_idx_max=11 no_samples=10
mm_set_vif_state_req_handler
chan_bcn_detect_start
---------SM_CONNECT_IND_ok, aid 40, bssid 6a:db:54:e6:04:93
wpa rx E ASSOC
wpa S: ASSOCIATING -> ASSOCIATED
Cancelling scan request

new ie: 0 : 4c 69 6e 6b 73 79 73 30 33 32 36 35 
new ie: 1 : 2 4 b 16 12 24 48 6c 
new ie: 3 : b 
new ie: 30 : 1 0 0 f ac 4 1 0 0 f ac 4 1 0 0 f ac 2 0 0 

wpa S: ASSOCIATED -> 4WAY_HANDSHAKE
WPA: TK 444180255d6f806dea97eb16c19a8d02
wpa S: 4WAY_HANDSHAKE -> 4WAY_HANDSHAKE
----------------------------------abs2_timeout_reset_agc
__l2_packet_send: send failed
hapd_intf_add_key CCMP
add sta_mgmt_get_sta
sta:0, vif:0, key:0
sta_mgmt_add_key
add hw key idx:24
wpa S: 4WAY_HANDSHAKE -> GROUP_HANDSHAKE
WPA: GTK acb8b537cab6737361912732080ccfc5
hapd_intf_add_key CCMP
add is_broadcast_ether_addr
sta:255, vif:0, key:1
add hw key idx:1
wpa S: GROUP_HANDSHAKE -> COMPLETED
ctrl_port_hdl:1
me_set_ps_disable:906 0 0 0 0 1
dis set ps 1!!
WLAN_EVENT_CONNECTED
sta_ip_start

configuring interface mlan (with DHCP client)
dhcp_check_status_init_timer:20000
writed fci to flash
wpa S: COMPLETED -> 4WAY_HANDSHAKE
wpa S: 4WAY_HANDSHAKE -> GROUP_HANDSHAKE
WPA: GTK acb8b537cab6737361912732080ccfc5
wpa S: GROUP_HANDSHAKE -> COMPLETED
IP up: 192.168.1.153
[I  MNG][bll_dev_manage.c:321]connect wifi success
[D  NET][bll_ble_network.c:130]+++>> ble notice, 9
[D  NET][bll_ble_network.c:497]===>> notify complete
[I  MNG][bll_dev_manage.c:460]bootstrap start
[D HTTP][fml_http.c:106]post len: 617
[SSL]ssl create session,url:cgw.******.com,port:443
[TLS]mbedtls client struct init success...
[TLS]Loading the CA root certificate success...
[TLS][MBEDTLS]mbedtls_client_context,139 
[TLS]mbedtls client context init success...

ssl socket timeout:6s-10sec
[TLS]Connected cgw.******.com:443 success...
[TLS]Certificate verified success...
[D HTTP][fml_http.c:118]http send ok
[I  MNG][bll_dev_manage.c:857]set regist information
[D  MNG][bll_dev_manage.c:861]reg_info.andlink_token: 5VCkKALqeXWd1ysO
[D  MNG][bll_dev_manage.c:862]reg_info.device_id: CMCC-590384-BCFD0C785DDE
[D  MNG][bll_dev_manage.c:863]reg_info.device_token: 80f6c18c61884d11
[D  MNG][bll_dev_manage.c:864]reg_info.dm_token: KVGF0rNlq85xSFayyAo2EdH8V6m1pEtG3S0L0zYi0XA=
[D  MNG][bll_dev_manage.c:865]reg_info.gw_token: 14T/qrPZ1CiK8TkN
[D  MNG][bll_dev_manage.c:866]reg_info.user_id: 280982658
[D  MNG][bll_dev_manage.c:869]device bootstrap success
[D  MNG][bll_dev_manage.c:873]FreeHeapSize 84944
[D  MNG][bll_dev_manage.c:883]FreeHeapSize 87528
[I  MNG][bll_dev_manage.c:462]bootstrap success
[D  NET][bll_ble_network.c:130]+++>> ble notice, 9
[D  NET][bll_ble_network.c:497]===>> notify complete
[I  MNG][bll_dev_manage.c:480]boot start
[D  MNG][bll_dev_manage.c:930]FreeHeapSize 84944
[D HTTP][fml_http.c:106]post len: 411
[SSL]ssl create session,url:cgw.******.com,port:443
[TLS]mbedtls client struct init success...
[TLS]Loading the CA root certificate success...
[TLS][MBEDTLS]mbedtls_client_context,139 
[TLS]mbedtls client context init success...

ssl socket timeout:6s-10sec
[TLS]Connected cgw.******.com:443 success...
[TLS]Certificate verified success...
[D HTTP][fml_http.c:118]http send ok
[D  MNG][bll_dev_manage.c:1030]FreeHeapSize 84944
[I  MNG][bll_dev_manage.c:1084]time synchronized 17099639050
[I  UTC][fml_time.c:104]SET Time: 1709963905, last_time: 0
[D  MNG][bll_dev_manage.c:1089]mng_info.device_manage_url: https://cgw.******.com/device-manage/device/inform/dmReport
[D  MNG][bll_dev_manage.c:1090]mng_info.mqtt_url: ssl://cgw.******.com:8883
[D  MNG][bll_dev_manage.c:1091]mng_info.mqtt_user: deviceOfALC2018
[D  MNG][bll_dev_manage.c:1092]mng_info.mqtt_pass_word: 4kAVHkSjPNKzX1zE
[D  MNG][bll_dev_manage.c:1093]mng_info.mqtt_client_id: CMCC-590384-BCFD0C785DDE
[D  MNG][bll_dev_manage.c:1107]FreeHeapSize 87528
[I  MNG][bll_dev_manage.c:484]boot success
[D  NET][bll_ble_network.c:130]+++>> ble notice, 9
[D  NET][bll_ble_network.c:497]===>> notify complete
[D  NET][bll_ble_network.c:130]+++>> ble notice, 9
[D  NET][bll_ble_network.c:497]===>> notify complete
[W MAIN][fml_led.c:113]set LED: 2, 1
[D  MNG][bll_dev_manage.c:81]wifi connect timer stop
send msg to ble thread exit
ble thread exit
timer  has [THD]ble:[tcb]40ce80 [stack]415658-415e58:2048:5
[I MQTT][bll_dev_mqtt.c:863]mqtt init start
[D MQTT][bll_dev_mqtt.c:864]FreeHeapSize 92008
[THD]mqtt-core:[tcb]40c548 [stack]41a230-41b230:4096:3
[THD]MQTT_recv:[tcb]40c780 [stack]41b238-41b838:1536:6
[THD]MQTT_send:[tcb]40c7e8 [stack]41b840-41c440:3072:6
[I MQTT][bll_dev_mqtt.c:900]mqtt session init success
[D MQTT][bll_dev_mqtt.c:204]mqtt host: cgw.******.com, port: 8883
[SSL]ssl create session,url:cgw.******.com,port:8883
[TLS]mbedtls client struct init success...
[TLS]Loading the CA root certificate success...
[TLS][MBEDTLS]mbedtls_client_context,139 
[TLS]mbedtls client context init success...

ble mac:bc-fd-0c-78-5d-df
xvr_reg_init
h4tl_init-1 ok
hci_init ok
!!!!!!init_type=0
rwble_hl_init ok
BLE Rev: B5-3.0.56-P0
rwble_init ok
rwip_driver_init ok
enter normal mode
EM_BLE_END:0x1b40
69:mqtt_core_handler_thd
deleted
ssl socket timeout:6s-10sec
[TLS]Connected cgw.******.com:8883 success...
[TLS]Certificate verified success...
ssl connect succeed
netport.socket:0
[D MQTT][bll_dev_mqtt.c:314]mqtt_client_id: CMCC-590384-BCFD0C785DDE
[D MQTT][bll_dev_mqtt.c:315]mqtt_user: deviceOfALC2018
[D MQTT][bll_dev_mqtt.c:316]mqtt_pass_word: 4kAVHkSjPNKzX1zE
[D MQTT][bll_dev_mqtt.c:317]mqtt_keep_alive: 60
netport.socket:0
[D MQTT][bll_dev_mqtt.c:144]inter mqtt_connect_callback!
Subscribe #0 /device/CMCC-590384-BCFD0C785DDE/downward OK!
[D MQTT][bll_dev_mqtt.c:148]inter mqtt_online_callback!
[D  MNG[I MQTT][bll_dev][bll_fota.c:295]check _mqtt.c:529]MQTT send: fota states
0, i: 0
[I MQTT][bll_dev_mqtt.c:327]mqtt connect success
packet_type:4
[D MQTT][bll_dev_mqtt.c:181]mqtt nitice event 2
[I MQTT][bll_dev_mqtt.c:623]MQTT send ret: 0
[D MQTT][bll_dev_mqtt.c:636]FreeHeapSize 56552
[I MQTT][bll_dev_mqtt.c:908]mqtt online success
[D MQTT][bll_dev_mqtt.c:914]FreeHeapSize 56464
[D ELEC][bll_elec_manage.c:246]upload CHECK
[D ELEC][bll_elec_manage.c:266]up  all, engy: 0.000 Kwh, vol: 0.000 V, cur: 0.000 A, power: 0.000 W
[I MQTT][bll_dev_mqtt.c:529]MQTT send: 5, i: 0
len: [371]
{"data":{"params":[{"paramCode":"power","paramValue":"0.000"},{"paramCode":"volts","paramValue":"0.000"},{"paramCode":"current","paramValue":"0.000"},{"paramCode":"powerConsumption","paramValue":"0.000"}]},"deviceId":"CMCC-590384-BCFD0C785DDE","childDeviceId":"","eventType":"ParamChange","timestamp":1.709963907e+12,"deviceType":"590384","seqId":"DEV_28098265808197294"}
packet_type:4
[D MQTT][bll_dev_mqtt.c:181]mqtt nitice event 2
[I MQTT][bll_dev_mqtt.c:623]MQTT send ret: 0
[D MQTT][bll_dev_mqtt.c:636]FreeHeapSize 56552
temp_code:24 - adc_code:323 - adc_trend:[12]:330->[13]:321
init_xtal:66, delta:0, last_xtal:69
[I  MNG][bll_dev_manage.c:523]dmreport start
[V  MNG][bll_dev_manage.c:1178]dmreport content
[D  MNG][bll_dev_manage.c:1185]FreeHeapSize 53456
[D HTTP][fml_http.c:106]post len: 885
[SSL]ssl create session,url:cgw.******.com,port:443
[TLS]mbedtls client struct init success...
[TLS]Loading the CA root certificate success...
[TLS][MBEDTLS]mbedtls_client_context,139 
[TLS]mbedtls client context init success...

ssl socket timeout:6s-10sec
[TLS]Connected cgw.******.com:443 success...
[TLS]Certificate verified success...
[D HTTP][fml_http.c:118]http send ok
[W MAIN][fml_led.c:113]set LED: 2, 2
timer  has deleted
[D  MNG][bll_dev_manage.c:1238]FreeHeapSize 53512
[D  MNG][bll_dev_manage.c:1298]dm report success
[D  MNG][bll_dev_manage.c:1310]FreeHeapSize 56608
[I  MNG][bll_dev_manage.c:526]dmreport success
[D  MNG][bll_dev_manage.c:575]dmreport next, 43611 sec
[D  MNG][bll_dev_manage.c:182]sync last status, pwCutMemory, signalLight, childrenLock, outletStatus
[I MQTT][bll_dev_mqtt.c:529]MQTT send: 3, i: 0
len: [363]
{"data":{"params":[{"paramCode":"pwCutMemory","paramValue":"1"},{"paramCode":"signalLight","paramValue":"1"},{"paramCode":"childrenLock","paramValue":"0"},{"paramCode":"outletStatus","paramValue":"0"}]},"deviceId":"CMCC-590384-BCFD0C785DDE","childDeviceId":"","eventType":"Inform","timestamp":1.709963908e+12,"deviceType":"590384","seqId":"DEV_28098265879901289"}
packet_type:4
[D MQTT][bll_dev_mqtt.c:181]mqtt nitice event 2
[I MQTT][bll_dev_mqtt.c:623]MQTT send ret: 0
[D MQTT][bll_dev_mqtt.c:636]FreeHeapSize 56592
timer  has stopped
[I  MNG][bll_fota.c:335]next upgrade check, 1709964501
[D ELEC][bll_elec_manage.c:246]upload CHECK
MQTT RECV {"data":{"params":[{"paramCode":"outletStatus","paramValue":"1"}]},"function":"Control","deviceId":"CMCC-590384-BCFD0C785DDE","seqId":"HJQI_17605323062_8d235a37"}
[D MPRT][fml_mqtt_protocol.c:115]funcion: Control
[D MPRT][fml_mqtt_protocol.c:134]paramCode: outletStatus, paramValue: 1
[D MQTT][bll_dev_mqtt.c:748]handle: 0
[W MAIN][fml_led.c:113]set LED: 2, 1
[I MQTT][bll_dev_mqtt.c:529]MQTT send: 4, i: 0
len: [210]
{"data":{"params":[{"paramCode":"outletStatus","paramValue":"1"}]},"deviceId":"CMCC-590384-BCFD0C785DDE","childDeviceId":"","eventType":"ParamChange","timestamp":1.709963929e+12,"seqId":"DEV_28098265869987103"}
packet_type:4
[D MQTT][bll_dev_mqtt.c:181]mqtt nitice event 2
[I MQTT][bll_dev_mqtt.c:623]MQTT send ret: 0
[D MQTT][bll_dev_mqtt.c:636]FreeHeapSize 56592
MQTT RECV {"data":{"params":[{"paramCode":"outletStatus","paramValue":"0"}]},"function":"Control","deviceId":"CMCC-590384-BCFD0C785DDE","seqId":"HJQI_17605323062_67007637"}
[D MPRT][fml_mqtt_protocol.c:115]funcion: Control
[D MPRT][fml_mqtt_protocol.c:134]paramCode: outletStatus, paramValue: 0
[D MQTT][bll_dev_mqtt.c:748]handle: 0
[W MAIN][fml_led.c:113]set LED: 2, 2
[I MQTT][bll_dev_mqtt.c:529]MQTT send: 4, i: 0
len: [209]
{"data":{"params":[{"paramCode":"outletStatus","paramValue":"0"}]},"deviceId":"CMCC-590384-BCFD0C785DDE","childDeviceId":"","eventType":"ParamChange","timestamp":1.70996393e+12,"seqId":"DEV_28098265830419824"}
packet_type:4
[D MQTT][bll_dev_mqtt.c:181]mqtt nitice event 2
[I MQTT][bll_dev_mqtt.c:623]MQTT send ret: 0
[D MQTT][bll_dev_mqtt.c:636]FreeHeapSize 56592

kuba2k2 commented 8 months ago

I didn't mean UART log of the stock firmware, it's not useful. If it's not Tuya, it's not unusual that it doesn't use AP mode to connect.

We need UART logs after flashing either the UF2 file by ltchiptool or the RBL file by bkflasher. So, choose either of these methods (one that works), flash the file, then dump the flash again. Attach here the UART log after flashing and the resulting dump file after flashing.

shzlww commented 8 months ago

@kuba2k2 no uart log by normal flash the uf2 or rbl . So I did some hex trick on the dumped flash bin file (pre-flashed with uf2), I copy the stock firmware bin [0x0~ 0x00011115] to the dumped uf2[0x0 ~ 0x00011115] , and then flash the modified uf2 bin file into bk7231m by bkflasher ,It actually started running!!!!! The hex area is bootloader?? uf2 dump file: ltchiptool_bk72xx_2024-03-09_19-17-01-bk7231m.bin.gz modified uf2 dump file: ltchiptool_bk72xx_2024-03-09_19-17-01-bk7231m-mod.bin.gz

log:

I [      0.000] LibreTiny v1.4.1 on generic-bk7231n-qfn32-tuya, compiled at Mar  8 2024 21:48:43, GCC 10.3.1 (-O1)
[I][logger:399]: Log initialized
[C][ota:473]: There have been 2 suspected unsuccessful boot attempts.
[D][lt.preferences:104]: Saving 1 preferences to flash...
[D][lt.preferences:132]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[I][app:029]: Running through setup()...
[C][wifi:038]: Setting up WiFi...
[C][wifi:051]: Starting WiFi...
[C][wifi:052]:   Local聽MAC: C8:47:8C:42:00:48
€I [      0.000] LibreTiny v1.4.1 on generic-bk7231n-qfn32-tuya, compiled at Mar  8 2024 21:48:43, GCC 10.3.1 (-O1)
[I][logger:399]: Log initialized
[C][ota:473]: There have been 3 suspected unsuccessful boot attempts.
[D][lt.preferences:104]: Saving 1 preferences to flash...
[D][lt.preferences:132]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[I][app:029]: Running through setup()...
[C][wifi:038]: Setting up WiFi...
[C][wifi:051]: Starting WiFi...
[C][wifi:052]:   Local聽MAC: C8:47:8C:42:00:48
[C][wifi:250]: Setting up AP...
[C][wifi:252]:   AP SSID: 'bk7231m hotspot'
[C][wifi:253]:   AP Password: '******'
[C][wifi:262]:   IP Address: 192.168.4.1
[D][wifi:455]: Starting scan...
[C][web_server:123]: Setting up web server...
[C][ota:097]: Over-The-Air Updates:
[C][ota:098]:   Address: bk7231m.local:8892
[W][ota:106]: Last Boot was an unhandled reset, will proceed to safe mode in 7 restarts
[C][api:025]: Setting up Home Assistant API server...
[I][app:062]: setup() finished successfully!
[I][app:102]: ESPHome version 2023.12.5 compiled on Mar  8 2024, 21:47:48
[C][logger:443]: Logger:
[C][logger:444]:   Level: DEBUG
[C][logger:445]:   Log Baud Rate: 115200
[C][logger:447]:   Hardware UART: UART2
[C][captive_portal:088]: Captive Portal:
[C][wifi:573]: WiFi:
[C][wifi:405]:   Local MAC: C8:47:8C:42:00:48
[C][wifi:410]:   SSID: ''
[C][wifi:411]:   IP Address: 0.0.0.0
[C][wifi:412]:   BSSID: 00:00:00:00:00:00
[C][wifi:414]:   Hostname: 'bk7231m'
[C][wifi:416]:   Signal strength: 0 dB 鈻傗杽鈻嗏枅
[C][wifi:420]:   Channel: 0
[C][wifi:421]:   Subnet: 0.0.0.0
[C][wifi:422]:   Gateway: 0.0.0.0
[C][wifi:423]:   DNS1: 0.0.0.0
[C][wifi:424]:   DNS2: 0.0.0.0
[C][web_server:168]: Web Server:
[C][web_server:169]:   Address: bk7231m.local:80
[C][mdns:115]: mDNS:
[C][mdns:116]:   Hostname: bk7231m
[C][ota:097]: Over-The-Air Updates:
[C][ota:098]:   Address: bk7231m.local:8892
[W][ota:106]: Last Boot was an unhandled reset, will proceed to safe mode in 7 restarts
[C][api:139]: API Server:
[C][api:140]:   Address: bk7231m.local:6053
[C][api:144]:   Using noise encryption: NO
[C][lt.component:013]: LibreTiny:
[C][lt.component:014]:   Version: v1.4.1 on generic-bk7231n-qfn32-tuya, compiled at Mar  8 2024 21:47:00, GCC 10.3.1 (-O1)
[C][lt.component:015]:   Loglevel: 3
W [    181.394] rx timeout 4
[I][captive_portal:031]: Captive Portal Requested WiFi Settings Change:
[I][captive_portal:032]:   SSID='******'
[I][captive_portal:033]:   Password='******'
[D][lt.preferences:104]: Saving 1 preferences to flash...
[D][lt.preferences:132]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[D][wifi:455]: Starting scan...
W [    185.518] rx timeout 4
[W][wifi_lt:286]: Event: Disconnected ssid='' bssid=00:00:00:00:00:00 reason='Association Leave'
W [    190.894] ack timeout 4
[I][captive_portal:031]: Captive Portal Requested WiFi Settings Change:
[I][captive_portal:032]:   SSID='******'
[I][captive_portal:033]:   Password='******'
[D][lt.preferences:104]: Saving 1 preferences to flash...
[D][lt.preferences:132]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[D][wifi:455]: Starting scan...
[D][wifi:470]: Found networks:
[I][wifi:513]: - '******' (6A:DB:54:E6:04:93) 鈻傗杽鈻嗏枅
[D][wifi:515]:     Channel: 11
[D][wifi:516]:     RSSI: -44 dB
[D][wifi:518]: - 'QQ' (30:A1:FA:14:AA:DC) 鈻傗杽鈻嗏枅
[D][wifi:518]: - 'chao' (28:77:77:0D:98:5E) 鈻傗杽鈻嗏枅
[D][wifi:518]: - 'CMCC-S53F' (50:6F:77:D1:4A:8C) 鈻傗杽鈻嗏枅
[D][wifi:518]: - '360WiFi-D6E8' (C8:5B:A0:18:D6:E8) 鈻傗杽鈻嗏枅
[D][wifi:518]: - 'xiaobai' (68:77:24:C8:0C:EB) 鈻傗杽鈻嗏枅
[D][wifi:518]: - '' (72:77:24:C8:0C:EB) 鈻傗杽鈻嗏枅
[D][wifi:518]: - 'TP-LINK_4D54' (18:F2:2C:97:4D:54) 鈻傗杽鈻嗏枅
[D][wifi:518]: - 'skwang' (14:59:C0:87:FC:5F) 鈻傗杽鈻嗏枅
[D][wifi:518]: - 'TP-LINK_5F85瀛? (78:44:FD:8B:5F:85) 鈻傗杽鈻嗏枅
[D][wifi:518]: - '9-1001' (98:00:6A:28:EF:6E) 鈻傗杽鈻嗏枅
[D][wifi:518]: - '' (44:55:C4:DC:D8:91) 鈻傗杽鈻嗏枅
[D][wifi:518]: - '@PHICOMM_E1' (76:7D:24:92:83:E3) 鈻傗杽鈻嗏枅
[D][wifi:518]: - '' (A6:A9:30:A0:92:AA) 鈻傗杽鈻嗏枅
[D][wifi:518]: - 'Jiang' (34:F7:16:E5:3F:98) 鈻傗杽鈻嗏枅
[D][wifi:518]: - 'CU_XDDY' (E0:A1:CE:0D:D2:98) 鈻傗杽鈻嗏枅
[D][wifi:518]: - 'ChinaNet-R5xz' (C0:B1:01:89:00:78) 鈻?[0;37m鈻勨枂鈻?[0m
[I][wifi:300]: WiFi Connecting to '******'...
[W][component:214]: Component wifi took a long time for an operation (0.16 s).
[W][component:215]: Components should block for at most 20-30ms.
[I][wifi:587]: WiFi Connected!
[C][wifi:405]:   Local MAC: C8:47:8C:42:00:48
[C][wifi:410]:   SSID: '******'
[C][wifi:411]:   IP Address: 192.168.1.125
[C][wifi:412]:   BSSID: 6A:DB:54:E6:04:93
[C][wifi:414]:   Hostname: 'bk7231m'
[C][wifi:416]:   Signal strength: -42 dB 鈻傗杽鈻嗏枅
[C][wifi:420]:   Channel: 11
[C][wifi:421]:   Subnet: 255.255.255.0
[C][wifi:422]:   Gateway: 192.168.1.1
[C][wifi:423]:   DNS1: 192.168.1.1
[C][wifi:424]:   DNS2: 192.168.1.1
[D][wifi:596]: Disabling AP...
[W][component:214]: Component wifi took a long time for an operation (0.06 s).
[W][component:215]: Components should block for at most 20-30ms.
[I][ota:117]: Boot seems successful, resetting boot loop counter.
[D][lt.preferences:104]: Saving 1 preferences to flash...
[D][lt.preferences:132]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
kuba2k2 commented 8 months ago

Interesting, the UF2 file doesn't modify the bootloader area. Have you been flashing OpenBeken QIO binary in the meantime? The QIO contains an encrypted bootloader, which will not work on your device and will prevent any firmware from running, unless you reflash the stock bin file.

Also, can you attach a screenshot of "Read chip info" from ltchiptool? This might help troubleshoot the CRC errors you were getting.

shzlww commented 8 months ago

@kuba2k2 bk7231m_chipinfo_20240309211431

Have you been flashing OpenBeken QIO binary in the meantime?

OpenBeken QIO binary do not work,same as uf2 binary, no wifi/no ap/no uart log I always flash back to stock firmware ,then flash the new 3rd party firmware

I use ltchiptool to flash back to stock firmware(ps:the name of stockfirmware in the picture has been renamed,it is not the OpenBeken QIO binary) ,it tell me the chip is Realtek.... so I can only use bkflasher to flash stock firmware. ltchiptool_flash_stock_firmware_20240309213455

I'm not sure if those hex tricks have bugs, because I saw some errors from the esphome logs,like:

�[0;35m[C][wifi:411]:   IP Address: 0.0.0.0�[0m
�[0;35m[C][wifi:412]:   BSSID: �[5m00:00:00:00:00:00�[6m�[0m
�[0;35m[C][wifi:414]:   Hostname: 'bk7231m'�[0m
�[0;35m[C][wifi:416]:   Signal strength: 0 dB �[0;32m鈻傗杽鈻嗏枅�[0m�[0m
�[0;35m[C][wifi:420]:   Channel: 0�[0m
�[0;35m[C][wifi:421]:   Subnet: 0.0.0.0�[0m
�[0;35m[C][wifi:422]:   Gateway: 0.0.0.0�[0m
�[0;35m[C][wifi:423]:   DNS1: 0.0.0.0�[0m
�[0;35m[C][wifi:424]:   DNS2: 0.0.0.0�[0m
 There have been 2 suspected unsuccessful boot attempts
Last Boot was an unhandled reset, will proceed to safe mode in 7 restarts
kuba2k2 commented 8 months ago

You should be able to flash the .bin file by ltchiptool if you uncheck the "auto detect" box and clear the start address, skip offset and writing length boxes. Also set the chip family to BK72xx.

That being said, because your chip is unrecognized, it will fail all CRC checks because BK7231N does this differently. There is a pending update of bk7231tools that addresses this issue.

shzlww commented 8 months ago

@kuba2k2

You should be able to flash the .bin file by ltchiptool if you uncheck the "auto detect" box and clear the start address, skip offset and writing length boxes. Also set the chip family to BK72xx.

I just use ltchiptool to flash back to stock firmware ,process 100%,get crc error,but the stock firmware can work normally.May be the way of crc different between ltchiptool and bkflasher,this stock firmware was dumped by bkflasher, I think this crc error does not matter. ltchiptool_flash_error_20240309215428

shzlww commented 8 months ago

@kuba2k2 After re-flashed a new device with bk7231m, I think my previous description about flashing was wrong. I should re-describe about it: 1.At the beginning, I use ltchiptool to flash .uf2 into bk7231m,but always get an CRC error. 2.Then, I use bkflasher to flash OpenBK7231N_QIO.bin into it , flash successfully ,but it can not work. 3.After then,I use ltchiptool to flash .uf2, flash successfully without CRC error. it can not work,either. 4.In step 3, I notice that ltchiptool flash .uf2 starting from 0x011000, so I think the hex data before 0x011000 should be bootloader,then I dump the flash of bk7231m by bkflasher. 5.I copy the bootloader of stock firmware (0x0~0x010FFF) to the same area of dumped binary file. 6.At last,I flash this strange combination binary file into bk7231m.Out of my expectation,all components work well, including wifi,ap,dhcp,uartlog,webserver,ota,etc.. 7.The only issue is that all mac addresses of bk7231m are the same after flashed. I solved it by using bkflasher(Restore RF) to generate a new random mac address.

kuba2k2 commented 8 months ago

In step 2, where you flashed OpenBeken QIO - that's the mistake. OpenBeken's files currently will not work with your device. Doing that, you overwrite the bootloader (0x0-0x11000) with the wrong one, which makes your device fail to boot.

ad. 7.: your device might be using a different RF partition address. BkFlasher's "Restore RF" function might indeed generate a random MAC address, however it will NOT write the correct Wi-Fi calibration data. You might get reduced Wi-Fi range and/or performance, or other issues.

The correct solution would be to update ESPHome/LibreTiny's partition layout:

esphome:
  name: my-device
  platformio_options:
    board_build.bkcrypt_coeffs: 00000000000000000000000000000000
    board_build.bkota.key: 0123456789ABCDEF0123456789ABCDEF
    board_build.bkota.iv: 0123­456789ABCDEF
    board_flash.download: "0x132000+0xA6000"
    board_flash.kvs: "0x1D8000+0x8000"
    board_flash.calibration: "0x1E0000+0x1000"
    board_flash.tlv: "0x1E1000+0x1000"
    board_flash.net: "0x1E2000+0x1000"
    board_flash.userdata: "0x1E3000+0x1D000"

(taken from BK7231T default partition layout, offsets match your device)

If that doesn't work, restore the stock firmware and try again.

shzlww commented 8 months ago

@kuba2k2 Should I modify the board_flash.app? I found there are some data before 0x132000 in the stock firmware binary file. stock_firmware_20240312000351

board_config_20240312000832

kuba2k2 commented 8 months ago

No, this is part of the app partition. This is the RBL header, it's not even important for running the app. You don't need to change the app partition.

shzlww commented 8 months ago

@kuba2k2 it always get a CRC error when flash the uf2 file with ltchiptool, so I copy all data of bk7231m-1-0x011000.rbl to the stock firmware(2M),and then flash this new 2Mb file to the bk7231m. I just tried this method: ap work ok, but it can not scan wifi. ap_20240312021325

UART LOG : local mac address is correct,but wifi scan timeout.

I [      0.000] LibreTiny v1.4.1 on generic-bk7231n-qfn32-tuya, compiled at Mar 12 2024 02:00:25, GCC 10.3.1 (-O1)
[I][logger:399]: Log initialized
[C][status_led:014]: Setting up Status LED...
[C][ota:473]: There have been 0 suspected unsuccessful boot attempts.
[D][lt.preferences:104]: Saving 1 preferences to flash...
[D][lt.preferences:132]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[I][app:029]: Running through setup()...
[C][switch.gpio:011]: Setting up GPIO Switch 'Relay 1'...
[D][switch:016]: 'Relay 1' Turning OFF.
[D][switch:055]: 'Relay 1': Sending state OFF
[D][light:036]: 'id_light_relay' Setting:
[D][light:041]:   Color mode: 
[D][switch:016]: 'Relay 1' Turning OFF.
[D][binary_sensor:034]: 'binary_switch': Sending initial state OFF
[C][light:035]: Setting up light 'id_light_relay'...
[D][light:036]: 'id_light_relay' Setting:
[C][hlw8012:014]: Setting up HLW8012...
[C][wifi:038]: Setting up WiFi...
[C][wifi:051]: Starting WiFi...
[C][wifi:052]:   Local聽MAC: BC:FD:0C:78:77:8C
[C][wifi:250]: Setting up AP...
[C][wifi:252]:   AP SSID: 'bk7231m-1'
[C][wifi:253]:   AP Password: ''
[C][wifi:262]:   IP Address: 192.168.4.1
[D][wifi:455]: Starting scan...
[C][web_server:123]: Setting up web server...
[C][ota:097]: Over-The-Air Updates:
[C][ota:098]:   Address: bk7231m-1.local:8892
[C][api:025]: Setting up Home Assistant API server...
[I][app:062]: setup() finished successfully!
[D][sensor:093]: 'Uptime': Sending state 0.44000 s with 0 decimals of accuracy
[D][sensor:093]: 'Heap Free': Sending state 25240.00000 B with 0 decimals of accuracy
[D][sensor:093]: 'Heap Max Block': Sending state 0.00000 B with 0 decimals of accuracy
[I][app:102]: ESPHome version 2023.12.5 compiled on Mar 12 2024, 01:59:52
[C][logger:443]: Logger:
[C][logger:444]:   Level: DEBUG
[C][logger:445]:   Log Baud Rate: 115200
[C][logger:447]:   Hardware UART: UART2
[C][status_led:019]: Status LED:
[C][status_led:020]:   Pin: 11
[C][gpio.output:010]: GPIO Binary Output:
[C][gpio.output:011]:   Pin: 10
[C][switch.gpio:068]: GPIO Switch 'Relay 1'
[C][switch.gpio:090]:   Restore Mode: always OFF
[C][switch.gpio:031]:   Pin: 8
[C][uptime.sensor:031]: Uptime Sensor 'Uptime'
[C][uptime.sensor:031]:   Device Class: 'duration'
[C][uptime.sensor:031]:   State Class: 'total_increasing'
[C][uptime.sensor:031]:   Unit of Measurement: 's'
[C][uptime.sensor:031]:   Accuracy Decimals: 0
[C][uptime.sensor:031]:   Icon: 'mdi:timer-outline'
[C][gpio.binary_sensor:015]: GPIO Binary Sensor 'binary_switch'
[C][gpio.binary_sensor:016]:   Pin: 24
[C][light:103]: Light 'id_light_relay'
[C][restart:068]: Restart Switch 'Restart Switch'
[C][restart:070]:   Icon: 'mdi:restart'
[C][restart:090]:   Restore Mode: always OFF
[C][hlw8012:037]: HLW8012:
[C][hlw8012:038]:   SEL Pin: 26
[C][hlw8012:039]:   CF Pin: 6
[C][hlw8012:040]:   CF1 Pin: 7
[C][hlw8012:041]:   Change measurement mode every 8
[C][hlw8012:042]:   Current resistor: 1.0 m鈩?[0m
[C][hlw8012:043]:   Voltage Divider: 800.0
[C][hlw8012:044]:   Update Interval: 5.0s
[C][hlw8012:045]:   Voltage 'BL0937 Voltage'
[C][hlw8012:045]:     Device Class: 'voltage'
[C][hlw8012:045]:     State Class: 'measurement'
[C][hlw8012:045]:     Unit of Measurement: 'V'
[C][hlw8012:045]:     Accuracy Decimals: 1
[C][hlw8012:046]:   Current 'BL0937 Current'
[C][hlw8012:046]:     Device Class: 'current'
[C][hlw8012:046]:     State Class: 'measurement'
[C][hlw8012:046]:     Unit of Measurement: 'A'
[C][hlw8012:046]:     Accuracy Decimals: 2
[C][hlw8012:047]:   Power 'BL0937 Power'
[C][hlw8012:047]:     Device Class: 'power'
[C][hlw8012:047]:     State Class: 'measurement'
[C][hlw8012:047]:     Unit of Measurement: 'W'
[C][hlw8012:047]:     Accuracy Decimals: 1
[C][hlw8012:048]:   Energy 'BL0937 Energy'
[C][hlw8012:048]:     Device Class: 'energy'
[C][hlw8012:048]:     State Class: 'total_increasing'
[C][hlw8012:048]:     Unit of Measurement: 'Wh'
[C][hlw8012:048]:     Accuracy Decimals: 1
[C][captive_portal:088]: Captive Portal:
[C][wifi:573]: WiFi:
[C][wifi:405]:   Local MAC: BC:FD:0C:78:77:8C
[C][wifi:410]:   SSID: ''
[C][wifi:411]:   IP Address: 0.0.0.0
[C][wifi:412]:   BSSID: 00:00:00:00:00:00
[C][wifi:414]:   Hostname: 'bk7231m-1'
[C][wifi:416]:   Signal strength: 0 dB 鈻傗杽鈻嗏枅
[C][wifi:420]:   Channel: 0
[C][wifi:421]:   Subnet: 0.0.0.0
[C][wifi:422]:   Gateway: 0.0.0.0
[C][wifi:423]:   DNS1: 0.0.0.0
[C][wifi:424]:   DNS2: 0.0.0.0
[C][web_server:168]: Web Server:
[C][web_server:169]:   Address: bk7231m-1.local:80
[C][mdns:115]: mDNS:
[C][mdns:116]:   Hostname: bk7231m-1
[C][ota:097]: Over-The-Air Updates:
[C][ota:098]:   Address: bk7231m-1.local:8892
[C][api:139]: API Server:
[C][api:140]:   Address: bk7231m-1.local:6053
[C][api:144]:   Using noise encryption: NO
[C][lt.component:013]: LibreTiny:
[C][lt.component:014]:   Version: v1.4.1 on generic-bk7231n-qfn32-tuya, compiled at Mar 12 2024 01:58:58, GCC 10.3.1 (-O1)
[C][lt.component:015]:   Loglevel: 3
[D][text_sensor:064]: 'LibreTiny Version': Sending state 'v1.4.1 on generic-bk7231n-qfn32-tuya, compiled at Mar 12 2024 01:58:58, GCC 10.3.1 (-O1)'
[C][debug:064]: Debug component:
[C][debug:066]:   Device info 'Device Info'
[C][debug:066]:     Icon: 'mdi:chip'
[C][debug:069]:   Free space on heap 'Heap Free'
[C][debug:069]:     State Class: ''
[C][debug:069]:     Unit of Measurement: 'B'
[C][debug:069]:     Accuracy Decimals: 0
[C][debug:069]:     Icon: 'mdi:counter'
[C][debug:070]:   Largest free heap block 'Heap Max Block'
[C][debug:070]:     State Class: ''
[C][debug:070]:     Unit of Measurement: 'B'
[C][debug:070]:     Accuracy Decimals: 0
[C][debug:070]:     Icon: 'mdi:counter'
[D][debug:076]: ESPHome version 2023.12.5
[D][debug:080]: Free Heap Size: 14744 bytes
[D][debug:356]: LibreTiny Version: 1.4.1
[D][debug:357]: Chip: BK7231N (7b1c) @ 120 MHz
[D][debug:358]: Chip ID: 0x8C7778
[D][debug:359]: Board: generic-bk7231n-qfn32-tuya
[D][debug:360]: Flash: 2048 KiB / RAM: 256 KiB
[D][debug:361]: Reset Reason: Power-On
[D][text_sensor:064]: 'Device Info': Sending state '2023.12.5|Version: v1.4.1 on generic-bk7231n-qfn32-tuya, compiled at Mar 12 2024 01:58:53, GCC 10.3.1 (-O1)|Reset Reason: Power-On|Chip Name: BK7231N|Chip ID: 0x008c7778|Flash: 2048 KiB|RAM: 256 KiB'
[D][text_sensor:064]: 'Reset Reason': Sending state 'Power-On'
I [      0.000] LibreTiny v1.4.1 on generic-bk7231n-qfn32-tuya, compiled at Mar 12 2024 02:00:25, GCC 10.3.1 (-O1)
[I][logger:399]: Log initialized
[C][status_led:014]: Setting up Status LED...
[C][ota:473]: There have been 1 suspected unsuccessful boot attempts.
[D][lt.preferences:104]: Saving 1 preferences to flash...
[D][lt.preferences:132]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[I][app:029]: Running through setup()...
[C][switch.gpio:011]: Setting up GPIO Switch 'Relay 1'...
[D][switch:016]: 'Relay 1' Turning OFF.
[D][switch:055]: 'Relay 1': Sending state OFF
[D][light:036]: 'id_light_relay' Setting:
[D][light:041]:   Color mode: 
[D][switch:016]: 'Relay 1' Turning OFF.
[D][binary_sensor:034]: 'binary_switch': Sending initial state OFF
[C][light:035]: Setting up light 'id_light_relay'...
[D][light:036]: 'id_light_relay' Setting:
[C][hlw8012:014]: Setting up HLW8012...
[C][wifi:038]: Setting up WiFi...
[C][wifi:051]: Starting WiFi...
[C][wifi:052]:   Local聽MAC: BC:FD:0C:78:77:8C
[C][wifi:250]: Setting up AP...
[C][wifi:252]:   AP SSID: 'bk7231m-1'
[C][wifi:253]:   AP Password: ''
[C][wifi:262]:   IP Address: 192.168.4.1
[D][wifi:455]: Starting scan...
[C][web_server:123]: Setting up web server...
[C][ota:097]: Over-The-Air Updates:
[C][ota:098]:   Address: bk7231m-1.local:8892
[C][api:025]: Setting up Home Assistant API server...
[I][app:062]: setup() finished successfully!
[D][sensor:093]: 'Uptime': Sending state 0.44000 s with 0 decimals of accuracy
[D][sensor:093]: 'Heap Free': Sending state 25224.00000 B with 0 decimals of accuracy
[D][sensor:093]: 'Heap Max Block': Sending state 0.00000 B with 0 decimals of accuracy
[I][app:102]: ESPHome version 2023.12.5 compiled on Mar 12 2024, 01:59:52
[C][logger:443]: Logger:
[C][logger:444]:   Level: DEBUG
[C][logger:445]:   Log Baud Rate: 115200
[C][logger:447]:   Hardware UART: UART2
[C][status_led:019]: Status LED:
[C][status_led:020]:   Pin: 11
[C][gpio.output:010]: GPIO Binary Output:
[C][gpio.output:011]:   Pin: 10
[C][switch.gpio:068]: GPIO Switch 'Relay 1'
[C][switch.gpio:090]:   Restore Mode: always OFF
[C][switch.gpio:031]:   Pin: 8
[C][uptime.sensor:031]: Uptime Sensor 'Uptime'
[C][uptime.sensor:031]:   Device Class: 'duration'
[C][uptime.sensor:031]:   State Class: 'total_increasing'
[C][uptime.sensor:031]:   Unit of Measurement: 's'
[C][uptime.sensor:031]:   Accuracy Decimals: 0
[C][uptime.sensor:031]:   Icon: 'mdi:timer-outline'
[C][gpio.binary_sensor:015]: GPIO Binary Sensor 'binary_switch'
[C][gpio.binary_sensor:016]:   Pin: 24
[C][light:103]: Light 'id_light_relay'
[C][restart:068]: Restart Switch 'Restart Switch'
[C][restart:070]:   Icon: 'mdi:restart'
[C][restart:090]:   Restore Mode: always OFF
[C][hlw8012:037]: HLW8012:
[C][hlw8012:038]:   SEL Pin: 26
[C][hlw8012:039]:   CF Pin: 6
[C][hlw8012:040]:   CF1 Pin: 7
[C][hlw8012:041]:   Change measurement mode every 8
[C][hlw8012:042]:   Current resistor: 1.0 m鈩?[0m
[C][hlw8012:043]:   Voltage Divider: 800.0
[C][hlw8012:044]:   Update Interval: 5.0s
[C][hlw8012:045]:   Voltage 'BL0937 Voltage'
[C][hlw8012:045]:     Device Class: 'voltage'
[C][hlw8012:045]:     State Class: 'measurement'
[C][hlw8012:045]:     Unit of Measurement: 'V'
[C][hlw8012:045]:     Accuracy Decimals: 1
[C][hlw8012:046]:   Current 'BL0937 Current'
[C][hlw8012:046]:     Device Class: 'current'
[C][hlw8012:046]:     State Class: 'measurement'
[C][hlw8012:046]:     Unit of Measurement: 'A'
[C][hlw8012:046]:     Accuracy Decimals: 2
[C][hlw8012:047]:   Power 'BL0937 Power'
[C][hlw8012:047]:     Device Class: 'power'
[C][hlw8012:047]:     State Class: 'measurement'
[C][hlw8012:047]:     Unit of Measurement: 'W'
[C][hlw8012:047]:     Accuracy Decimals: 1
[C][hlw8012:048]:   Energy 'BL0937 Energy'
[C][hlw8012:048]:     Device Class: 'energy'
[C][hlw8012:048]:     State Class: 'total_increasing'
[C][hlw8012:048]:     Unit of Measurement: 'Wh'
[C][hlw8012:048]:     Accuracy Decimals: 1
[C][captive_portal:088]: Captive Portal:
[C][wifi:573]: WiFi:
[C][wifi:405]:   Local MAC: BC:FD:0C:78:77:8C
[C][wifi:410]:   SSID: ''
[C][wifi:411]:   IP Address: 0.0.0.0
[C][wifi:412]:   BSSID: 00:00:00:00:00:00
[C][wifi:414]:   Hostname: 'bk7231m-1'
[C][wifi:416]:   Signal strength: 0 dB 鈻傗杽鈻嗏枅
[C][wifi:420]:   Channel: 0
[C][wifi:421]:   Subnet: 0.0.0.0
[C][wifi:422]:   Gateway: 0.0.0.0
[C][wifi:423]:   DNS1: 0.0.0.0
[C][wifi:424]:   DNS2: 0.0.0.0
[C][web_server:168]: Web Server:
[C][web_server:169]:   Address: bk7231m-1.local:80
[C][mdns:115]: mDNS:
[C][mdns:116]:   Hostname: bk7231m-1
[C][ota:097]: Over-The-Air Updates:
[C][ota:098]:   Address: bk7231m-1.local:8892
[C][api:139]: API Server:
[C][api:140]:   Address: bk7231m-1.local:6053
[C][api:144]:   Using noise encryption: NO
[C][lt.component:013]: LibreTiny:
[C][lt.component:014]:   Version: v1.4.1 on generic-bk7231n-qfn32-tuya, compiled at Mar 12 2024 01:58:58, GCC 10.3.1 (-O1)
[C][lt.component:015]:   Loglevel: 3
[D][text_sensor:064]: 'LibreTiny Version': Sending state 'v1.4.1 on generic-bk7231n-qfn32-tuya, compiled at Mar 12 2024 01:58:58, GCC 10.3.1 (-O1)'
[C][debug:064]: Debug component:
[C][debug:066]:   Device info 'Device Info'
[C][debug:066]:     Icon: 'mdi:chip'
[C][debug:069]:   Free space on heap 'Heap Free'
[C][debug:069]:     State Class: ''
[C][debug:069]:     Unit of Measurement: 'B'
[C][debug:069]:     Accuracy Decimals: 0
[C][debug:069]:     Icon: 'mdi:counter'
[C][debug:070]:   Largest free heap block 'Heap Max Block'
[C][debug:070]:     State Class: ''
[C][debug:070]:     Unit of Measurement: 'B'
[C][debug:070]:     Accuracy Decimals: 0
[C][debug:070]:     Icon: 'mdi:counter'
[D][debug:076]: ESPHome version 2023.12.5
[D][debug:080]: Free Heap Size: 16464 bytes
[D][debug:356]: LibreTiny Version: 1.4.1
[D][debug:357]: Chip: BK7231N (7b1c) @ 120 MHz
[D][debug:358]: Chip ID: 0x8C7778
[D][debug:359]: Board: generic-bk7231n-qfn32-tuya
[D][debug:360]: Flash: 2048 KiB / RAM: 256 KiB
[D][debug:361]: Reset Reason: WDT Reset
[D][text_sensor:064]: 'Device Info': Sending state '2023.12.5|Version: v1.4.1 on generic-bk7231n-qfn32-tuya, compiled at Mar 12 2024 01:58:53, GCC 10.3.1 (-O1)|Reset Reason: WDT Reset|Chip Name: BK7231N|Chip ID: 0x008c7778|Flash: 2048 KiB|RAM: 256 KiB'
[I][captive_portal:031]: Captive Portal Requested WiFi Settings Change:
[I][captive_portal:032]:   SSID='Linksys03265'
[I][captive_portal:033]:   Password='12345678'
[D][lt.preferences:104]: Saving 1 preferences to flash...
[D][lt.preferences:132]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[D][wifi:455]: Starting scan...
W [     41.462] WIFI: Scan timeout, discarding
[E][wifi:463]: Scan timeout!
[D][wifi:455]: Starting scan...
W [     76.490] WIFI: Scan timeout, discarding
[W][component:214]: Component wifi took a long time for an operation (5.00 s).
[W][component:215]: Components should block for at most 20-30ms.
kuba2k2 commented 7 months ago

@shzlww are you able to test this BK7231M with the latest version of ltchiptool? In particular, I'm curious if the flashing succeeds now, as well as the "Chip ID" from "Read chip info". I'd appreciate a screenshot of the chip info dialog.

shzlww commented 7 months ago

@kuba2k2 1.screenshot of the chip info. 20240420141842

2.The stock firmware plug ,Flash uf2 success,no CRC error.Here is the yaml

esphome:
  name: bk7231m-1
  name_add_mac_suffix: false
  platformio_options:
    board_build.bkcrypt_coeffs: "00000000000000000000000000000000"
    board_build.bkota.key: "0123456789ABCDEF0123456789ABCDEF"
    board_build.bkota.iv: "0123456789ABCDEF"
    board_flash.download: "0x132000+0xA6000"
    board_flash.kvs: "0x1D8000+0x8000"
    board_flash.calibration: "0x1E0000+0x1000"
    board_flash.tlv: "0x1E1000+0x1000"
    board_flash.net: "0x1E2000+0x1000"
    board_flash.userdata: "0x1E3000+0x1D000"

bk72xx:
  board: generic-bk7231n-qfn32-tuya

logger:

web_server:

captive_portal:

mdns:

api:
  reboot_timeout: 0s

ota:

wifi:
  reboot_timeout: 0s
  ap:

3.It can launch ap hotspot ,but no wifi results found in 192.168.4.1 bk7231m-uart.log update: After short circuit the CEN and GND, wifi scan normally,but can not connect. bk7231m-uart-2.log

78757838 commented 6 months ago

有没有后续了?

agittins commented 4 months ago

The pcb design in the photo looks very much like the Arlec PC191HA Series 2 Smart plug with energy monitoring, which is sold by Bunnings in Australia (yours I am guessing is probably a different brand etc, and the Arlec ones have tuya on them, however...).

Your board layout looks familiar, plus the symptoms of flashing are also similar, in that folks with the PC191HA plugs often find that the flashing appears to go through OK, but then the device still boots up with the old firmware. This is happening even after the initial flash to esphome/libretiny using cloudcutter, and on subsequent OTA flashes.

What someone else discovered and I've found works reliably is that after successfully flashing, you need to remove power from the device, then hold down the button while applying power again (then releasing). This seems to cause the unit to take a while longer to boot, during which time it appears to apply the new firmware image.

I don't know if perhaps it's keeping separate firmware partitions or something, but it seems that without the button held down during power-on it's quite random as to whether the new firmware just flashed will "stick".

I don't know if this will actually relate to your issues since your device is definitely different in some ways, but given the board layout similarity it might be worth trying that procedure to see if it improves things for you.