Open evadim opened 1 year ago
bk7231tools write_flash -d /dev/ttyUSB1
|-- ttyUSB0 | |-- Selecting this port.
Do you have multiple UART adapters plugged in? It seems that bk7231tools uses ttyUSB1
as you specified on command line, but ltchiptool tries to use ttyUSB0, because that's what it finds suitable.
Do you have multiple UART adapters plugged in?
Only one at time. I just copy logs from long console history. At some point they start to use ttyUSB1 name not sure why. I still have in dmesg that moment, where we can see this change in names:
[Oct 5 05:32] traps: ltchiptool[29437] general protection fault ip:7fdc3cfb1180 sp:7ffdf85c1cd0 error:0 in libpango-1.0.so.0.5000.14[7fdc3cf95000+37000]
[Oct 5 05:36] ltchiptool[31613]: segfault at fffffffffffffffc ip 00007f544d0f427e sp 00007f5440c0d678 error 5 in libgtk-3.so.0.2406.32[7f544ce78000+37d000] likely on CPU 1 (core 1, socket 0)
[ +0.000034] Code: 83 f9 01 7e 19 44 8d 49 ff 31 c0 90 45 8b 14 80 44 39 14 87 75 c6 48 ff c0 49 39 c1 75 ee 48 c1 e1 02 4d 8d 44 08 fc 41 8b 00 <39> 44 0f fc 7f ac ff c0 41 89 00 48 8b 52 08 48 85 d2 75 a7 c3 66
[Oct 5 06:23] traps: xxdiff[24197] general protection fault ip:7f867b7041d6 sp:7fff13cbd868 error:0 in libQt5Gui.so.5.15.10[7f867b522000+3df000]
[Oct 5 06:55] traps: ltchiptool[4712] general protection fault ip:7f3a39a9b180 sp:7f3a17ffe2d0 error:0 in libpango-1.0.so.0.5000.14[7f3a39a7f000+37000]
[Oct 5 08:14] usb 1-1: USB disconnect, device number 34
[ +0.000420] cp210x ttyUSB0: cp210x converter now disconnected from ttyUSB0
[ +0.000096] cp210x 1-1:1.0: device disconnected
[ +2.868990] usb 1-1: new full-speed USB device number 35 using xhci_hcd
[ +0.158941] usb 1-1: New USB device found, idVendor=10c4, idProduct=ea60, bcdDevice= 1.00
[ +0.000020] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ +0.000007] usb 1-1: Product: CP2102 USB to UART Bridge Controller
[ +0.000005] usb 1-1: Manufacturer: Silicon Labs
[ +0.000029] usb 1-1: SerialNumber: 0001
[ +0.009953] cp210x 1-1:1.0: cp210x converter detected
[ +0.001248] usb 1-1: cp210x converter now attached to ttyUSB0
[Oct 5 08:16] usb 1-1: USB disconnect, device number 35
[ +0.000213] cp210x ttyUSB0: failed set request 0x7 status: -19
[ +0.000015] cp210x ttyUSB0: failed set request 0x12 status: -19
[ +0.000007] cp210x ttyUSB0: failed set request 0x0 status: -19
[ +0.000266] cp210x ttyUSB0: cp210x converter now disconnected from ttyUSB0
[ +0.000059] cp210x 1-1:1.0: device disconnected
[Oct 5 08:18] usb 1-1: new full-speed USB device number 36 using xhci_hcd
[ +0.157955] usb 1-1: New USB device found, idVendor=10c4, idProduct=ea60, bcdDevice= 1.00
[ +0.000021] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ +0.000008] usb 1-1: Product: CP2102 USB to UART Bridge Controller
[ +0.000007] usb 1-1: Manufacturer: Silicon Labs
[ +0.000006] usb 1-1: SerialNumber: 0001
[ +0.009782] cp210x 1-1:1.0: cp210x converter detected
[ +0.001015] usb 1-1: cp210x converter now attached to ttyUSB1
[Oct 5 08:30] ltchiptool[22389]: segfault at fffffffffffffffc ip 00007fddfdbaa27e sp 00007fddea101678 error 5 in libgtk-3.so.0.2406.32[7fddfd92e000+37d000] likely on CPU 5 (core 1, socket 0)
[ +0.000020] Code: 83 f9 01 7e 19 44 8d 49 ff 31 c0 90 45 8b 14 80 44 39 14 87 75 c6 48 ff c0 49 39 c1 75 ee 48 c1 e1 02 4d 8d 44 08 fc 41 8b 00 <39> 44 0f fc 7f ac ff c0 41 89 00 48 8b 52 08 48 85 d2 75 a7 c3 66
[Oct 5 08:31] ltchiptool[22416]: segfault at 10008 ip 00007fcf8fc07e2f sp 00007ffc28052a30 error 4 in libpango-1.0.so.0.5000.14[7fcf8fbf6000+37000] likely on CPU 2 (core 2, socket 0)
[ +0.000065] Code: 1f 84 00 00 00 00 00 0f 1f 40 00 55 53 48 83 ec 08 48 85 ff 74 45 48 89 fb e8 bd ff ff ff 48 8b 7b 08 48 89 c5 48 85 ff 74 07 <8b> 47 08 85 c0 75 0a 48 83 c4 08 5b 48 89 e8 5d c3 48 8d 35 19 ef
[Oct 5 10:07] usb 1-1: USB disconnect, device number 36
[ +0.000464] cp210x ttyUSB1: cp210x converter now disconnected from ttyUSB1
[ +0.000136] cp210x 1-1:1.0: device disconnected
[Oct 5 11:05] elogind-daemon[1643]: Suspending system...
IIRC after experiments with BK7231Flasher. Today after resume from hibernation they again use ttyUSB0. Below logs from ltchiptool gui run, it just have a lot more noise in console:
(ltchiptool) evadim@t480 ~/ltchiptool $ ./bin/ltchiptool gui
21:29:35: Debug: Adding duplicate image handler for 'Windows bitmap file'
21:29:35: Debug: Adding duplicate animation handler for '1' type
21:29:35: Debug: Adding duplicate animation handler for '2' type
(ltchiptool:23023): Gtk-WARNING **: 21:29:35.366: Negative content height -3 (allocation 7, extents 5x5) while allocating gadget (node scrollbar, owner GtkScrollbar)
(ltchiptool:23023): Gtk-CRITICAL **: 21:29:35.366: gtk_box_gadget_distribute: assertion 'size >= 0' failed in GtkScrollbar
E: wxAssertionError: C++ assertion ""start >= 0 && end <= l"" failed at /tmp/pip-install-s8d5w2tf/wxpython_dac74386d5414e4b8cbdb95bc2a81cf9/ext/wxWidgets/src/gtk/textctrl.cpp(1980) in SetStyle(): invalid range in wxTextCtrl::SetStyle
E: |-- File "/home/evadim/ltchiptool/lib/python3.11/site-packages/ltchiptool/gui/colors.py", line 128, in apply
I: Found new device: ttyUSB1 - CP2102 USB to UART Bridge Controller - CP2102 USB to UART Bridge Controller - Silicon Labs (10C4/EA60)
I: Connect UART1 of the BK7231 to the USB-TTL adapter:
I:
I: --------+ +------------------------
I: PC | | BK7231
I: --------+ +------------------------
I: RX | ------ | TX1 (GPIO11 / P11)
I: TX | ------ | RX1 (GPIO10 / P10)
I: RTS | ------ | CEN (or RST, optional)
I: | |
I: GND | ------ | GND
I: --------+ +------------------------
I:
I: Make sure to use a good 3.3V power supply, otherwise the adapter might
I: lose power during chip reset. Usually, the adapter's power regulator
I: is not enough and an external power supply is needed (like AMS1117).
I:
I: If you didn't connect RTS to CEN, after running the command you have
I: around 20 seconds to reset the chip manually. In order to do that,
I: you need to bridge CEN to GND with a wire.
**
Gtk:ERROR:../gtk+-3.24.38/gtk/gtkcssinheritvalue.c:33:gtk_css_value_inherit_free: code should not be reached
**
Gtk:ERROR:../gtk+-3.24.38/gtk/gtkcssinheritvalue.c:33:gtk_css_value_inherit_free: code should not be reached
Bail out! Gtk:ERROR:../gtk+-3.24.38/gtk/gtkcssinheritvalue.c:33:gtk_css_value_inherit_free: code should not be reached
Bail out! Gtk:ERROR:../gtk+-3.24.38/gtk/gtkcssinheritvalue.c:33:gtk_css_value_inherit_free: code should not be reached
Аварийный останов
(ltchiptool) evadim@t480 ~/ltchiptool $
And log with ttyUSB0 when I create dumps with bk7231tools:
bk7231tools read_flash -d /dev/ttyUSB0 -s 0 -l 0x200000 dump3.bin Connected! Chip info: BK7231S_1.0.5 / Flash ID: 00 00 00 / Protocol: BASIC_TUYA Reading 2097152 bytes from 0x0 Reading 4k page at 0x200000 (0.00%) Reading 4k page at 0x201000 (0.20%) Reading 4k page at 0x202000 (0.39%) Reading 4k page at 0x203000 (0.59%) Reading 4k page at 0x204000 (0.78%) Reading 4k page at 0x205000 (0.98%) Reading 4k page at 0x206000 (1.17%) Reading 4k page at 0x207000 (1.37%) Reading 4k page at 0x208000 (1.56%) Reading 4k page at 0x209000 (1.76%) Reading 4k page at 0x20A000 (1.95%) Reading 4k page at 0x20B000 (2.15%) Reading 4k page at 0x20C000 (2.34%) Reading 4k page at 0x20D000 (2.54%) Reading 4k page at 0x20E000 (2.73%) Reading 4k page at 0x20F000 (2.93%) Reading 4k page at 0x210000 (3.12%) Reading 4k page at 0x211000 (3.32%) Reading 4k page at 0x212000 (3.52%) Reading 4k page at 0x213000 (3.71%) Reading 4k page at 0x214000 (3.91%) Reading 4k page at 0x215000 (4.10%) Reading 4k page at 0x216000 (4.30%) Reading 4k page at 0x217000 (4.49%) Reading 4k page at 0x218000 (4.69%) Reading 4k page at 0x219000 (4.88%) .... Reading 4k page at 0x3E8000 (95.31%) Reading 4k page at 0x3E9000 (95.51%) Reading 4k page at 0x3EA000 (95.70%) Reading 4k page at 0x3EB000 (95.90%) Reading 4k page at 0x3EC000 (96.09%) Reading 4k page at 0x3ED000 (96.29%) Reading 4k page at 0x3EE000 (96.48%) Reading 4k page at 0x3EF000 (96.68%) Reading 4k page at 0x3F0000 (96.88%) Reading 4k page at 0x3F1000 (97.07%) Reading 4k page at 0x3F2000 (97.27%) Reading 4k page at 0x3F3000 (97.46%) Reading 4k page at 0x3F4000 (97.66%) Reading 4k page at 0x3F5000 (97.85%) Reading 4k page at 0x3F6000 (98.05%) Reading 4k page at 0x3F7000 (98.24%) Reading 4k page at 0x3F8000 (98.44%) Reading 4k page at 0x3F9000 (98.63%) Reading 4k page at 0x3FA000 (98.83%) Reading 4k page at 0x3FB000 (99.02%) Reading 4k page at 0x3FC000 (99.22%) Reading 4k page at 0x3FD000 (99.41%) Reading 4k page at 0x3FE000 (99.61%) Reading 4k page at 0x3FF000 (99.80%) (ltchiptool) evadim@t480 ~/ltchiptool $
@kuba2k2 1) Is ltchiptool requesting MCU reset when connected to USB-TTL or just show this request at start? 2) Is there way to enable kind of debug USB-TTL connection, set speed etc?
With bk7231tools auto reset works 100% time for me. With ltchiptool it not work and disconnecting +3.3 also not help.
I will try to get time, solder wires back and try to debug.
I successfully converted noname RGBCW (3+3+3+10+10 w) led downlight which have bare BK7231T chip on led driver pcb with test points.
The issue is, what only one flasher reliably work with it is bk7231tools, but there are no clear manual how to use with ESPHome. Finally I found what I should flash image_bk7231t_app.0x011000.rbl via write app firmware (from app-only binary file) from examples in github page.
I used 3 different usb-ttl adapters which works for ESP* modules without any issues with same test-clip wires. There are no difference if I use onboard power or separate HiLink 3.3V power supply (ground connected to adapter). At the end I use 6-in-1 USB/TTL/232/485 (yellow 2 row pin header) one as it have RTS pin which I connected to CEN pin.
All things tested in Gentoo Linux.
ltchiptool - show message about resetting board and no reaction:
In GUI mode I got random segfaults after flash timeout or similar app crashed errors. (And 100% if I open plugins tab) Apps istalled via pip in wheel for user, as well as bk7231tools. Same behavior I see while flashing via ESPHome v2023.9.2 release: timeout.
I also try BK7231Flasher with Mono. It show CRC errors, but kind of fixed with increasing UART timeouts in settings. reads fine but write failed after erasing (and nothing erased I suspect).
bk7231tools in same wheel-pip env works without any issues: full log bk7231tools_flash.log