logo elektroda
logo elektroda
X
logo elektroda

Qiachip Smart Switch - BK7231N / CB2S - interior, programming

p.kaczmarek2 64296 288
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #31 20124666
    p.kaczmarek2
    Moderator Smart Home
    So it's not even possible to reach the configuration page?

    We have never experienced such an issue before. Safe mode is designed to work even with invalid settings.

    Can you try reading the debug log output on UART 2 pin (TX pin)?

    Dodano po 2 [godziny] 13 [minuty]:

    UPDATE: latest version of firmware has now a "clearConfig" command
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #32 20124834
    00svd00
    Level 8  
    p.kaczmarek2 wrote:
    So it's not even possible to reach the configuration page?

    We have never experienced such an issue before. Safe mode is designed to work even with invalid settings.

    Can you try reading the debug log output on UART 2 pin (TX pin)?

    Done(in attach)
    Maybe this happened because my device have this controller soldered to it's pcb (not as module)
    First boot everything was fully OK. Then i tried to figure out what pins do what and configured some of them(button, led and relay, button was controlling led and relay, looked very promising).
    After that i've rebooted controller and it refused to boot normally. I've rebooted it several times and it booted in safe mod(with AP enabled), I was able to connect, but when I tried to update any pin config - it was rebooting immediatelly. Problems were somehow fixed when I've pressed 'Convert to AP' button in Wifi setiings, after that I was able to update pin settings and Wifi settings - I've even managed to connect it to my home wifi again. But pin settings seemed to be not working anymore, relay and led were not changing their state. And after next reboot it was fully inoperable.
    Also attached PCB photo(with my contact markings) Qiachip Smart Switch - BK7231N / CB2S - interior, programming
  • ADVERTISEMENT
  • #33 20124852
    p.kaczmarek2
    Moderator Smart Home
    This is an interesting crash, I have never seen it before. I would love to debug it, but it's hard to do that remotely.

    The strange thing is it crashes ever before reading the config.

    Have you used the correct file for the flashing? For N version it's QIO.

    Can you do the following steps?
    1. Do a full 2MB read from 0 offset on your device with hid_download_py and send it to me for analysis
    2. Do you have original flash (full 2MB) saved from Tuya? Can you try reflashing device again with original flash 2MB and then flash OBK again?
    3. If you don't have original 2mb dump, then I could send you some of the stock ones for N so you can do step 2 here
    Helpful post? Buy me a coffee.
  • #34 20124958
    00svd00
    Level 8  
    p.kaczmarek2 wrote:
    This is an interesting crash, I have never seen it before. I would love to debug it, but it's hard to do that remotely.

    The strange thing is it crashes ever before reading the config.

    Have you used the correct file for the flashing? For N version it's QIO.

    Can you do the following steps?
    1. Do a full 2MB read from 0 offset on your device with hid_download_py and send it to me for analysis

    Done. But i've tried two times and both were:
    CRC should be f89abb7f
    CRC is f8151622
    CRC check failed
    Wrote 119000 bytes to out.bin
    p.kaczmarek2 wrote:

    2. Do you have original flash (full 2MB) saved from Tuya? Can you try reflashing device again with original flash 2MB and then flash OBK again?

    Unfortunatelly not. I was not interested in stock firmware, I don't trust devices with vendorlock in home automation
    UPD. Tried yor new FW build. New coredump attached
    UPD2 Made second dump with BKwriter at 115200 baud rate
    UPD3 Tried to reflash your FW at 115200 baud rate. Coredump3 is here
    UPD4 Very intresting. I've tried to read FW with python script again(after reflashing firmware), also got this error
    CRC should be ca535d7c
    CRC is e99ff60e
    CRC check failed
    Wrote 119000 bytes to out.bin
    And comared with dump from BKwriter
    And crc32sum is different for this two files!
    Attached out2.bin
    UPD5 Heh, semms that I've found the answer. BKwriter and script uses different length parameter. Set --length 0x12a000 and now CRC32 matches between two dumps. Also tried to reflash your FW with this length bot no luck - controller is not booting
    UPD6 Ooh, understood my mistake. You've asked for FULL 2mb dump. Attached it
  • #35 20125078
    00svd00
    Level 8  
    So as far as I can see my last dump absolutelly matches original FW from 0x0 to 0x129f50
    After that point there is some additional bytes at 0x129f60(CRC checksum?)
    And then nothing till 0x1d0000 where some garbage starts to appear. So, I think if you'll provide same 2Mb dump from your working controller and I'll flash it to mine - it may start to work normally
    Or maybe I can create 2Mb file with your FW and FF till 0x1fffe0 and flash it? Will it work?
    Something like an attached one
  • #36 20125095
    p.kaczmarek2
    Moderator Smart Home
    I don't have time to check the dumps now, but I have found a full BK7231N flash dump from Smart Life Smart WiFi Led Bulb E27 with WBL2_M1 module (which is like WB2L but using BK7231N):
    Smart Life...module.zip Download (2.13 MB)
    Please try flash it to your device and then reflash with OBK.

    This can help if you really have something wrong in your OBK config, but I am not sure if that's the case. Your crash is very strange, it happens so early that I have no idea what could be wrong.

    Have you tried configuring PWM pins before the crash?
    Helpful post? Buy me a coffee.
  • #37 20125110
    00svd00
    Level 8  
    p.kaczmarek2 wrote:
    I don't have time to check the dumps now, but I have found a full BK7231N flash dump from Smart Life Smart WiFi Led Bulb E27 with WBL2_M1 module (which is like WB2L but using BK7231N):

    Please try flash it to your device and then reflash with OBK.

    This can help if you really have something wrong in your OBK config, but I am not sure if that's the case. Your crash is very strange, it happens so early that I have no idea what could be wrong.

    Have you tried configuring PWM pins before the crash?

    Yes, problems started after I've configured pins
    Flshed your dump and controller booted fully OK in Wifi AP mod
    Configured my pins and still OK after reboot
  • #38 20125113
    p.kaczmarek2
    Moderator Smart Home
    Any news? Can you redo configuration and tell me what breaks stuff?

    I'd like to add some kind of failsafe, but I need to know what breaks.

    But it's very, very strange, because after reboot pins are not started if more than 5 reboots fails (safe mode)

    EDIT: maybe a string buffer overflow error? Have you set any lenghty names? I will double-check if all string sizes are kept at bay
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #39 20125170
    00svd00
    Level 8  
    p.kaczmarek2 wrote:
    Any news? Can you redo configuration and tell me what breaks stuff?

    I'd like to add some kind of failsafe, but I need to know what breaks.

    But it's very, very strange, because after reboot pins are not started if more than 5 reboots fails (safe mode)

    EDIT: maybe a string buffer overflow error? Have you set any lenghty names? I will double-check if all string sizes are kept at bay

    Everything was great untill I tried to find which pin corespond to external switch input and tried to restore my original mac address. Marked all channels as dInput, found right config, everything was OK.
    Now I see this in serial
    V:BK7231N_1.0.1
    REG:cpsr spsr r13 r14
    SVC:000000D3 00401C1C 000033AC
    IRQ:000000d2 00000010 00401e0c 85fefcfc
    FIR:000000d1 00000010 00401ffc 75d79dae
    SYS:000000df 0040192c 00000158
    ST:00000000
    J 0x10000
    bk_misc_init_start_type 0 0
    prvHeapInit-start addr:0x411330, size:126160
    [Flash]id:0xeb6015
    sctrl_sta_ps_init
    cset:0 0 0 0
    Entering init log...
    Init log done!
    Commands registered!
    bandgap_calm_in_efuse=0x67
    [load]bandgap_calm=0x67->0x27,vddig=4->5
    [FUNC]
    Device don't connect to wifi and buttons are not working anymore
    After three reboots it' now on safe mod, will try further
    UPD
    After connecting in safe mod I've pressed button "Convert to AP" In wifi settings and this happened in serial
    sta: 0, softap: 1, b/g/n
    softap:ssid=OpenBK7231N_8C000000,channel=1,dhcp=1,cipher_type:OPEN
    Info:MAIN:[SAFE] Time 90, free 76952, MQTT 0, bWifi 0, secondsWithNoPing 29, socks 5/38

    Info:GEN:dhcp=0 ip=0.0.0.0 gate=0.0.0.0 mask=0.0.0.0 mac=00:00:00:00:00:00

    Info:GEN:ip=192.168.4.1,gate=255.255.255.255,mask=255.255.255.0,dns=192.168.4.1

    Info:MAIN:[SAFE] Time 91, free 76952, MQTT 0, bWifi 0, secondsWithNoPing 30, socks 5/38

    Info:MAIN:[SAFE] Time 92, free 76952, MQTT 0, bWifi 0, secondsWithNoPing 31, socks 5/38

    Info:MAIN:[SAFE] Time 93, free 76952, MQTT 0, bWifi 0, secondsWithNoPing 32, socks 5/38

    Info:MAIN:[SAFE] Time 94, free 76952, MQTT 0, bWifi 0, secondsWithNoPing 33, socks 5/38

    Info:MAIN:[SAFE] Time 95, free 76952, MQTT 0, bWifi 0, secondsWithNoPing 34, socks 5/38

    Info:HTTP:HTTP_ProcessPacket: generating cfg_wifi_set

    Info:MAIN:[SAFE] Time 96, free 76952, MQTT 0, bWifi 0, secondsWithNoPing 35, socks 5/38

    Info:MAIN:Module reboot in 2...

    Info:MAIN:[SAFE] Time 97, free 76952, MQTT 0, bWifi 0, secondsWithNoPing 36, socks 5/38

    Info:MAIN:Module reboot in 1...

    bk_reboot
    wdt reboot

    V:BK7231N_1.0.1
    REG:cpsr spsr r13 r14
    SVC:000000D3 00401C1C 000033AC
    IRQ:000000d2 00000010 00401e0c 0006d33c
    FIR:000000d1 00000010 00401ffc 0006d33c
    SYS:000000df 0040192c 00000158
    ST:00010001
    J 0x10000
    bk_misc_init_start_type 1 10001
    prvHeapInit-start addr:0x411330, size:126160
    [Flash]id:0xeb6015
    sctrl_sta_ps_init
    cset:0 0 0 0
    Entering init log...
    Init log done!
    Commands registered!

    And it stuck. Rebooted it with button press
    V:BK7231N_1.0.1
    REG:cpsr spsr r13 r14
    SVC:000000D3 00401C1C 000033AC
    IRQ:000000d2 00000010 00401e0c 85fefcfc
    FIR:000000d1 00000010 00401ffc 75d79dae
    SYS:000000df 0040192c 00000158
    ST:00000000
    J 0x10000
    bk_misc_init_start_type 0 0
    prvHeapInit-start addr:0x411330, size:126160
    [Flash]id:0xeb6015
    sctrl_sta_ps_init
    cset:0 0 0 0
    Entering init log...
    Init log done!
    Commands registered!
    bandgap_calm_in_efuse=0x67
    [load]bandgap_calm=0x67->0x27,vddig=4->5
    And stuck again
    Another reboot
    V:BK7231N_1.0.1
    REG:cpsr spsr r13 r14
    SVC:000000D3 00401C1C 000033AC
    IRQ:000000d2 00000010 00401e0c 85fefcfc
    FIR:000000d1 00000010 00401ffc 75d7bdae
    SYS:000000df 0040192c 00000158
    ST:00000000
    J 0x10000
    bk_misc_init_start_type 0 0
    prvHeapInit-start addr:0x411330, size:126160
    [Flash]id:0xeb6015
    sctrl_sta_ps_init
    cset:0 0 0 0
    Entering init log...
    Init log done!
    Commands registered!
    bandgap_calm_in_efuse=0x67
    [load]bandgap_calm=0x67->0x27,vddig=4->5
    [FUNC]rwnxl_init

    Aaaaand again

    Two reboots more and safe mode

    Added after 10 [minutes]:

    Don't understand how clear config works.

    Debug:CMD:cmd [clearConfig]
    Error:CMD:cmd clearConfig NOT found (args )
    Info:MAIN:[SAFE] Time 103, free 76960, MQTT 0,

    Added after 12 [minutes]:

    So I've reflashed everything from scratch
    1.full dump
    2. Your FW
    3. Connected to AP
    4. Restored Mac
    5. Rebooted
    6. Set Wifi settings
    7. Rebooted
    8. Configured pins which I know I can use
    9. Rebooted
    And now everything is OK, at least all buttons work properly
    I think some pins should not be touched EVER in my device, because while configuring pins with RX1 and TX1 connected I saw some activity from TX pin. God knows which registers I've touched
    UPD Is there any possibility to invert condition of this toggle
    It shows thai it's ON but It's OFF
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    And also can we disable MQTT fuction? I see it's trying to connect to some host, but I'm not planning to use MQTT(I have another realisation for metrics from my sensors - simple webpage in Prometheus format where Prometheus collects It's data)
  • #40 20125226
    jony4t
    Level 8  
    p.kaczmarek2 wrote:
    Hello, I will try my best to help you, but you need to provide more information. There can be multiple reasons for your flashing issues.
    1. Are you doing a proper reboot while the programmer tool is waiting to get bus? You can do this by:
    a) power off and power on the device (NOTE: too large capacitors will overload usb port so it's better to power from external 5V source or remove temporarily said capacitor from board)
    *yes, I use an external power supply*

    b) use CEN pin to RESET (NOTE: this is tricky because it works only if you ground CEN for a certain amount of time, you have to do this for a short while, it always takes me several tries to get right)
    *I have tried in different ways*
    2. Are you connecting to correct RX and TX? Are you connecting RX of USB converter to TX of Beken, and TX of USB to RX of Beken?
    *I have checked*
    3. Are you sure that RX and TX lines used for programming are not "busy"? By "busy" I mean, they could:
    a) be used for TuyaMCU communication. They could have be connected to MCU. In this case you might need to temporary disconnect them, but not always
    b) be used for something like a button with external pull up resistor, and it's the same in this case, you might need to disconnect them temporarily (cut the trace)
    *I don't understand*

    4. Have you tried the second flashing tool? We have bkWriter 1.60 for Windows and the python uartprogram for hid_download_py repository.
    *i am using python uartprogram*
    Please post some photos of your setup. Show how your device look like, how is connected, how you do a reset.

    Qiachip Smart Switch - BK7231N / CB2S - interior, programming Qiachip Smart Switch - BK7231N / CB2S - interior, programming Qiachip Smart Switch - BK7231N / CB2S - interior, programming Qiachip Smart Switch - BK7231N / CB2S - interior, programming Qiachip Smart Switch - BK7231N / CB2S - interior, programming
  • #41 20125240
    00svd00
    Level 8  
    jony4t wrote:

    *I have checked*

    Are you sure about resistor between CEN and GND? Maybe It's resistance too high and controller Is not rebooting at all? I did not use any resistors and everything was OK
    But I also had problems with first flash, so I opened BKwriter, selected BK7231, set rate of CMD conn to 115200 and then pressed "??Flash" button. It erased several blocks and damaged original FW and after that controller could be easilly flashed to the new one.
  • #42 20125248
    p.kaczmarek2
    Moderator Smart Home
    @00svd00 if you could provide information which pin exactly breaks then I would add a failsafe mechanism.

    Regarding other questions....
    - clearConfig is only in latest build, not in earlier ones
    - you can switch On and Off by using the _N version of pin
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    - mqtt tries to connect but it does not hurt, albeit you might try settting mqtt host and names to empty string and tell me if it silences that





    jony4t wrote:

    Qiachip Smart Switch - BK7231N / CB2S - interior, programming

    second photo shows a CB2S (or WB2S, not sure) module connected to SOIC8 chip, most likely BL0937 or BL0942:
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    I am not sure now, but it might be on RX or TX pin and might be interfering with flashing.

    How good are you soldering skills?

    If you're good at soldering, it wouldn't hurt to check programming module separately.

    See, I had this device:
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming Qiachip Smart Switch - BK7231N / CB2S - interior, programming Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    And that didnt work for me:
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming Qiachip Smart Switch - BK7231N / CB2S - interior, programming

    So I did:
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming Qiachip Smart Switch - BK7231N / CB2S - interior, programming Qiachip Smart Switch - BK7231N / CB2S - interior, programming Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    Helpful post? Buy me a coffee.
  • #43 20125341
    jony4t
    Level 8  
    Yes. it is a BL0937.

    I'm not very good at welding. But I have come to learn. thanks. I will try tonight. Let me tell you.

    p.kaczmarek2 wrote:
    @00svd00 if you could provide information which pin exactly breaks then I would add a failsafe mechanism.

    Regarding other questions....
    - clearConfig is only in latest build, not in earlier ones
    - you can switch On and Off by using the _N version of pin
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    - mqtt tries to connect but it does not hurt, albeit you might try settting mqtt host and names to empty string and tell me if it silences that





    jony4t wrote:

    Qiachip Smart Switch - BK7231N / CB2S - interior, programming

    second photo shows a CB2S (or WB2S, not sure) module connected to SOIC8 chip, most likely BL0937 or BL0942:
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    I am not sure now, but it might be on RX or TX pin and might be interfering with flashing.

    How good are you soldering skills?

    If you're good at soldering, it wouldn't hurt to check programming module separately.

    See, I had this device:
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming Qiachip Smart Switch - BK7231N / CB2S - interior, programming Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    And that didnt work for me:
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming Qiachip Smart Switch - BK7231N / CB2S - interior, programming

    So I did:
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming Qiachip Smart Switch - BK7231N / CB2S - interior, programming Qiachip Smart Switch - BK7231N / CB2S - interior, programming Qiachip Smart Switch - BK7231N / CB2S - interior, programming
  • #44 20125354
    00svd00
    Level 8  
    p.kaczmarek2 wrote:
    @00svd00 if you could provide information which pin exactly breaks then I would add a failsafe mechanism.

    Maybe it's not pin-related problem but problem of config commit mechanism.
    Crazy things were hapening when I was trying to find death-trigger for now.
    Ater reloading config page I was sometimes seen things like this
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    And this
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    And this
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    Sometimes config page looked normaly, but was containing numers I've never entered
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    Sometimes fields looked normally but their indexes were totally wrong( First P4 after P3 and Second P4 after P13)
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    Sometimes controller rebooted while I was truing to access /cfg_pins?, and once it fully hanged until hard reset
    I think if I'll try to save config in this condition - it will lead to unpredictible results
    For now I've tested all pins from P0 to P16 and had no problems, but every time I was refreshing page untill it was fully OK. After saving config I was opening cfg_pins? again to be sure that saved config is fully OK. And I've rebooted after every config change.
    Maybe you'll better add some security mechanism - like counting hash sum of normally loaded config page and adding some JS which will hide all fields if hash mismatch? Or change config mechanism to reading json with precalculated hash? For now my best theory is that my promlebs were bounded with corrupted configuration saved to memory.
    UPD Tried to revert back all changes and on config commit it hanged again. After hard reset everything still OK
    UPD2 I've configured P25 as dInput with channell 11. Double checked it, but after reboot it was configured like this
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming
  • #45 20125447
    p.kaczmarek2
    Moderator Smart Home
    I just managed to get the same error, by refreshing the page several times.

    After a small change, I am not able to reproduce the problem any more.

    Can you get latest release from github and check if it still happens for you?

    I am asking because I can't verify myself whether it's just a fluke or my change really helped.
    Helpful post? Buy me a coffee.
  • #46 20125450
    00svd00
    Level 8  
    So for now I can confirm that problem is not bound with pin functions IF config is correct.
    I've managed to configure all pins to do somethong and my device is still able to boot.
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    It was not really easy - it was corrupted so many times.
    I also reproduced case when controller hangs on reading pin config - you should refresh page /cfg_pins? while it's still loading.
    p.kaczmarek2 wrote:
    am asking because I can't verify myself whether it's just a fluke or my change really helped.

    From moment when I'managed to recover my device from death with full dump I was making all my tests on OpenBK7231N_QIO_1.12.6
    UPD. Oh, I see - new build 17 seconds ago. One moment please)
  • #47 20125462
    p.kaczmarek2
    Moderator Smart Home
    I need information whether the behaviour changes with the 1.12.7 release. That one includes my latest change and on my side I can't reproduce the problem any more (but I am testing on T).

    I will try to restart several times more and see what happens.
    Helpful post? Buy me a coffee.
  • #48 20125478
    00svd00
    Level 8  
    p.kaczmarek2 wrote:
    I need information whether the behaviour changes with the 1.12.7 release. That one includes my latest change and on my side I can't reproduce the problem any more (but I am testing on T).

    I will try to restart several times more and see what happens.

    With 1.12.7 still looks not perfectly healthy, but much better now
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    Will test it futher
  • #49 20125484
    p.kaczmarek2
    Moderator Smart Home
    Really? Then I might need to look myself at that on N device, because for me, on T, this page is perfect 100% times and I tried refreshing about 50 times
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #50 20125490
    00svd00
    Level 8  
    p.kaczmarek2 wrote:
    Really? Then I might need to look myself at that on N device, because for me, on T, this page is perfect 100% times and I tried refreshing about 50 times

    Still buggy sometimes.
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    Maybe you should try to add something like this to head
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" >
    <meta http-equiv="Cache-Control" content="post-check=0, pre-check=0" >
    <meta http-equiv="Cache-Control" content="max-age=0" >
    <meta http-equiv="Cache-Control" content="private0" >
    <meta http-equiv="Pragma" content="no-cache" >
    <meta http-equiv="Expires" content="0" >
    ?
    I've noticed that when I refresh page with ctrl+F5 - It works much better
    Also I use this tags in every my ESP32 project with HTTP webserver. It prevents from SO many bugs
  • #51 20125509
    p.kaczmarek2
    Moderator Smart Home
    Are you suggesting that the cache mechanism is responsible for me getting a better results?
    I don't think so, because I also do PHP pages sometimes and I have cache disabled:
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    I will get N deviice (BK7231N) soon and test it as well
    Helpful post? Buy me a coffee.
  • #52 20125523
    00svd00
    Level 8  
    p.kaczmarek2 wrote:
    Are you suggesting that the cache mechanism is responsible for me getting a better results?
    I don't think so, because I also do PHP pages sometimes and I have cache disabled:
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    I will get N deviice (BK7231N) soon and test it as well

    It can be also browser-related thing. I'm using firefox and I can see that favico.ico is marked "cached" for example
    Just tried in Chromium - and it seems to work pretty damn good

    Added after 7 [minutes]:

    Seems that I've found another way to kill it)))
    Just set up MQTT connection as 127.0.0.1:9999
    Aaaand it's done
    ICMP traffic OK
    Button press OK
    HTTP server - not responding
    UPD Just got same bug with chromiuim. So - it works better, but not perfect
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming

    Added after 36 [minutes]:

    And found one more bad thing
    My current working config is here:
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    If I will set startup value for channel 1 to 0 or 1(Doesn't matter) - it will set it during startup. And after that it will hang forever with this in serial
    V:BK7231N_1.0.1
    REG:cpsr spsr r13 r14
    SVC:000000D3 00401C1C 000033AC
    IRQ:000000d2 00000010 00401e0c 0006e670
    FIR:000000d1 00000010 00401ffc 0006d33c
    SYS:000000df 0040192c 00000158
    ST:00010001
    J 0x10000
    bk_misc_init_start_type 1 10001
    prvHeapInit-start addr:0x411330, size:126160
    [Flash]id:0xeb6015
    sctrl_sta_ps_init
    cset:0 0 0 0
    Entering init log...
    Init log done!
    Commands registered!
    bandgap_calm_in_efuse=0x67
    [load]bandgap_calm=0x67->0x27,vddig=4->5
    [FUNC]rwnxl_init

    In safe mod controller will boot normally - bu we can't reset this setting, so it will never boot in normal mode. Only full-dump-reflash helps
  • #53 20125646
    p.kaczmarek2
    Moderator Smart Home
    It seems you're doing a very extensive testing, thanks. No one seems to experienced those exact issues before. Or maybe something happened during one of last releases.
    00svd00 wrote:

    In safe mod controller will boot normally - bu we can't reset this setting, so it will never boot in normal mode. Only full-dump-reflash helps

    Why only full-dump-reflash helps?

    It should be possible to go to settings in AP mode and change back pin settings or startup values of pins.

    Have you tried that?
    Helpful post? Buy me a coffee.
  • #54 20125793
    00svd00
    Level 8  
    p.kaczmarek2 wrote:
    It seems you're doing a very extensive testing, thanks. No one seems to experienced those exact issues before. Or maybe something happened during one of last releases.
    00svd00 wrote:

    In safe mod controller will boot normally - bu we can't reset this setting, so it will never boot in normal mode. Only full-dump-reflash helps

    Why only full-dump-reflash helps?

    It should be possible to go to settings in AP mode and change back pin settings or startup values of pins.

    Have you tried that?

    Yeah, it doesn't matter what startup value I set. It will not boot
    Was so tired because of all that strange things - so tried to flash firmware blown to 2mb size with FF
    dd if=/dev/zero ibs=1M count=2 | tr "\000" "\377" >FullFW.bin
    dd if=OpenBK7231N_QIO_1.12.7.bin of=FullFW.bin conv=notrunc
    I know, it's dirty but I don't care for now))

    Flash ended with CRC not equal, but it booted OK
    Dumped it with bkwriter - and yes, everything looked OK, no garbage in the end, only FF
    After that was tryng to configure it
    1. Restored my MAC - everything OK
    2. Set Wifi - rebooted and connected - OK
    3. Changed device name - reboot -OK
    4. Changed MQTT ip to my routers ip (where I suppress this traffic with firewall rule) - reboot - OK
    5. Enabled TCP console - reboot - DEAD
    bk_reboot
    wdt reboot
    
    V:BK7231N_1.0.1
    REG:cpsr     spsr     r13      r14
    SVC:000000D3          00401C1C 000033AC
    IRQ:000000d2 00000010 00401e0c 0006d33c
    FIR:000000d1 00000010 00401ffc 0006d33c
    SYS:000000df          0040192c 00000158
    ST:00010001
    J 0x10000
    bk_misc_init_start_type 1 10001
    prvHeapInit-start addr:0x411330, size:126160
    [Flash]id:0xeb6015
    sctrl_sta_ps_init
    cset:0 0 0 0
    Entering init log...
    Init log done!
    Commands registered!
    bandgap_calm_in_efuse=0x67
    [load]bandgap_calm=0x67->0x27,vddig=4->5
    [FUNC]rwnxl_init
    [bk]tx_txdesc_flush

    Second reboot - still DEAD
    V:BK7231N_1.0.1
    REG:cpsr     spsr     r13      r14
    SVC:000000D3          00401C1C 000033AC
    IRQ:000000d2 00000010 00401e0c 85fefcfc
    FIR:000000d1 00000010 00401ffc 75d7bcae
    SYS:000000df          0040192c 00000158
    ST:00000000
    J 0x10000
    bk_misc_init_start_type 0 0
    prvHeapInit-start addr:0x411330, size:126160
    [Flash]id:0xeb6015
    sctrl_sta_ps_init
    cset:0 0 0 0
    Entering init log...
    Init log done!
    Commands registered!
    bandgap_calm_in_efuse=0x67
    [load]bandgap_calm=0x67->0x27,vddig=4->5
    [FUNC]rwnxl_init
    [bk]tx_txdesc_flush
    [FUNC]intc_init
    [FUNC]calibration

    Booted to safe mode - disabled TCP console (It was working earlier, I SWEAR, I was testing it)
    Booted OK
    6. Configure module - got my beloved bug(This time in chromium)
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    Reloaded page wtih ctrl+F5 - now it looks normal
    Set my pin config - tested it(Working) - reboot - OK
    7. Set startup value to 0 - reboot - OK (OMG, Why it's working now?)
    8. Rebooted several times with different state - confirmed, it' not a fluke
    9. Set startup value to 1 - reboot - OK (confirmed working now)
    10. Configure watchdog - reboot - OK
    So, seems that for now only really broken thing - is TCP console. Don't know why it was working - maybe some flukes
    And I can cocnlude that garbage from previous FW matters ALOT. Even when I got pin config page bug - the was no symbols from outer space, only broken fields
  • #55 20125906
    jony4t
    Level 8  
    I have desoldered the cb2s component. me
    i managed to flash

    It works now . thank you

    Qiachip Smart Switch - BK7231N / CB2S - interior, programming Qiachip Smart Switch - BK7231N / CB2S - interior, programming Qiachip Smart Switch - BK7231N / CB2S - interior, programming Qiachip Smart Switch - BK7231N / CB2S - interior, programming

    jony4t wrote:
    Yes. it is a BL0937.

    I'm not very good at welding. But I have come to learn. thanks. I will try tonight. Let me tell you.

    p.kaczmarek2 wrote:
    @00svd00 if you could provide information which pin exactly breaks then I would add a failsafe mechanism.

    Regarding other questions....
    - clearConfig is only in latest build, not in earlier ones
    - you can switch On and Off by using the _N version of pin
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    - mqtt tries to connect but it does not hurt, albeit you might try settting mqtt host and names to empty string and tell me if it silences that





    jony4t wrote:

    Qiachip Smart Switch - BK7231N / CB2S - interior, programming

    second photo shows a CB2S (or WB2S, not sure) module connected to SOIC8 chip, most likely BL0937 or BL0942:
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    I am not sure now, but it might be on RX or TX pin and might be interfering with flashing.

    How good are you soldering skills?

    If you're good at soldering, it wouldn't hurt to check programming module separately.

    See, I had this device:
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming Qiachip Smart Switch - BK7231N / CB2S - interior, programming Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    And that didnt work for me:
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming Qiachip Smart Switch - BK7231N / CB2S - interior, programming

    So I did:
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming Qiachip Smart Switch - BK7231N / CB2S - interior, programming Qiachip Smart Switch - BK7231N / CB2S - interior, programming Qiachip Smart Switch - BK7231N / CB2S - interior, programming
  • #56 20126053
    00svd00
    Level 8  
    Found a pretty lifehack. Seems that we can easilly control this with POST and GET requests(at least when we have only one switch configured. If more than one - things become much more complicated)
    For example, if we want to get current switch state - we can do
    curl -s -m 2 -l -r GET 'http://your.device.ip.address/api/channels'
    And if we want for example set this switch to "1" state, we can
    curl -s -m 2 -l -r POST 'http://your.device.ip.address/api/channels' --header 'Content-Type: text/plain' --data-raw '[0,1]'
    For "0" it will be
    curl -s -m 2 -l -r POST 'http://your.device.ip.address/api/channels' --header 'Content-Type: text/plain' --data-raw '[0,0]'
    So I've created example task for Tasker app
    After importing and configuring device ip it could be added as Android home automation widget(Tasker supports this integration)
  • #57 20130528
    p.kaczmarek2
    Moderator Smart Home
    Wow nice, that's a very tricky way of handling the device. I see you discovered the REST API, which is used by our Javascript web panel, which source is here:
    https://github.com/OpenBekenIOT/webapp

    I you'd like anything more to be added to the API, feel free to tell me.

    I will be also trying to improve the mentioned stability issue soon.
    Helpful post? Buy me a coffee.
  • #58 20131672
    djlukas
    Level 27  
    Can someone write in a few steps how to upload this software to bk7231n? I don`t know anything about programming and I don`t know where to type what and how. These commands are black magic to me

    I have rpi 4. Should I do it in the terminal like I uploaded tape to the sockets from the tutorial?
  • #59 20131892
    p.kaczmarek2
    Moderator Smart Home
    Is the problem with connecting the pins or with the console commands?

    Try downloading https://github.com/OpenBekenIOT/hid_download_py , it requires python, and see if it works on your platform. You have a setup file there.
    For Linux it looks like this:
    
    $ apt install python3-hid python3-serial python3-tqdm
    $ python3 setup.py install --user
    
    Helpful post? Buy me a coffee.
  • #60 20132118
    djlukas
    Level 27  
    I have no problem in terms of hardware, the pins are soldered and connected to the programmer
    3.3-3.3
    Gnd-gnd
    Tx-rx
    Tx-rx

    Worse with the program. I don`t know if I should do it on a laptop with Windows or on RPI with Linux. I don`t know anything about Linux and unfortunately I don`t know the commands to use in the terminal to download and install this program.

Topic summary

The discussion revolves around the Qiachip Smart Switch utilizing the BK7231N chip and the CB2S module, focusing on programming, firmware flashing, and integration with Home Assistant. Users share experiences with flashing the device using various tools like hid_download_py and uartprogram, troubleshooting issues such as connection problems, firmware compatibility, and device reboots. Key challenges include configuring WiFi settings, handling relay operations, and ensuring stable operation with different firmware versions. The community provides insights on soldering techniques, pin configurations, and the importance of power supply stability. Additionally, there are discussions about integrating DHT sensors and the need for improved firmware features.
Summary generated by the language model.
ADVERTISEMENT