logo elektroda
logo elektroda
X
logo elektroda

[BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

p.kaczmarek2 177432 1242
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #271 19902817
    boozeman
    Level 11  
    pepesuriano wrote:
    boozeman wrote:
    pepesuriano wrote:
    Any ideas on how to continue?


    What kind of device you are trying to flash? Can you check with multimeter if there is some pull-up or pull-down resistors in RX1 or TX1 pins.

    I have one smart plug where RX1 is pulled up to 3.3V because it is used for relay activating button. This prevents flashing for me.


    Here are some pictures:

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant


    Can you follow the copper trace from RX1 marked as K. Where it goes and what components this path contain. Is there's pull-up resistors to 3.3V that might prevent the flashing. I have one type where I have to remove one resistor/jump wire, but 2 other types I can flash without any modifications.

    When you try to flash this device (Start programming and then sort CEN to GND), does the leds flicker and/or relay klicking? Or is that just 15sec of nothing?

    What kind of USB2Serial device you have? Check the chip and do some seaching if it is cabable of 921600 bps.
  • ADVERTISEMENT
  • #272 19902947
    ExploWare
    Level 10  
    1: in your first post, you mention you've connected the bkwriter to the 2tx and 2rx lines. In my experience that would not work.
    2: I've used a original FTDI UART dongle on the 1RX and 1TX lines, these were able to read perfectly on 115200, but failed to write. It did not work at all at 921600
    At the same time I had a CH340G dongle on the 2RX/2TX pair.
    I swapped them over and that device did write and read at 921600 without complaining.
    I have programmed 5 Bk7231T chips, multiple times, succesfully. Just sharing my experiences
  • #273 19902951
    MustangMatt
    Level 8  
    Oh I must have mistyped. I was on tx1 and tx2. I can never get the com port to show in bxwriter. I was hoping to try putting the resistor between cen and 3.3 but I ran out of time last night.
  • #274 19902960
    ExploWare
    Level 10  
    MustangMatt wrote:
    Oh I must have mistyped. I was on tx1 and tx2. I can never get the com port to show in bxwriter. I was hoping to try putting the resistor between cen and 3.3 but I ran out of time last night.


    If you connected one dongle between 1tx and 2tx, your connecting to two Transmitter lines. There, you'll receive the data towards your USB dongles. The pairs per dongle should be identical numbers, and an RX/TX pair. RX is to receive data onto the device. That is: RX on the USB dongle will receive data, that should be coming from TX from the sender: 1TX or 2TX from the Beken module. From that same serial USB device. The TX should send data onto the RX partner on the Beken module.
  • #275 19902963
    MustangMatt
    Level 8  
    I apologize I should only type from keyboard instead of phone. Tx1 and rx1!
  • ADVERTISEMENT
  • #276 19902966
    ferbulous
    Level 18  
    @boozeman @p.kaczmarek2
    on my first few attempts, I did get the AP with successful flashing, but not anymore
    then I tried just soldering the pins, but still the same

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
  • #277 19903018
    pepesuriano
    Level 9  
    boozeman wrote:

    Can you follow the copper trace from RX1 marked as K. Where it goes and what components this path contain. Is there's pull-up resistors to 3.3V that might prevent the flashing. I have one type where I have to remove one resistor/jump wire, but 2 other types I can flash without any modifications.

    When you try to flash this device (Start programming and then sort CEN to GND), does the leds flicker and/or relay klicking? Or is that just 15sec of nothing?

    What kind of USB2Serial device you have? Check the chip and do some seaching if it is cabable of 921600 bps.


    I tried to follow but I am not sure, here are some pictures that might be helpful, highlighting what I suppose to be the path

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    Maybe it ends on R1?

    It's just 15 seconds of nothing, but I did this order: Click read flash (with cen already to GND), then plug VCC and after that unplug CEN, is that correct?

    My usb2serial is a PL2303, in previous posts it was already checkd and it's capable of 921600bps

    Cheers
  • #278 19903080
    boozeman
    Level 11  
    pepesuriano wrote:
    It's just 15 seconds of nothing, but I did this order: Click read flash (with cen already to GND), then plug VCC and after that unplug CEN, is that correct?


    In my devices the read flash worked only 115200. Writing the firmware with program button needs that 921600
  • #279 19903108
    ExploWare
    Level 10  
    pepesuriano wrote:


    It's just 15 seconds of nothing, but I did this order: Click read flash (with cen already to GND), then plug VCC and after that unplug CEN, is that correct?


    The CEN (Chip Enable) is like a reset switch. Pulling it to ground resets the chip. As long as you hold it down,it does not start again (it's not Enabled). Releasing CEN from ground, or pulling it High with a resistor to 3v3 is Enabling the chip to start.

    VCC can be supplied all the time. Once you press Read Flash, the serial device will search with a timeout of 15sec for the boot sequence on the serial line. That means, if you reset the device, it will detect that.
    So: boot everything, start Read Flash, pull CEN to Ground and release that, then (if everything is wired correctly) the device will be sending the flash data to the computer.
  • #280 19903522
    pepesuriano
    Level 9  
    ExploWare wrote:

    The CEN (Chip Enable) is like a reset switch. Pulling it to ground resets the chip. As long as you hold it down,it does not start again (it's not Enabled). Releasing CEN from ground, or pulling it High with a resistor to 3v3 is Enabling the chip to start.

    VCC can be supplied all the time. Once you press Read Flash, the serial device will search with a timeout of 15sec for the boot sequence on the serial line. That means, if you reset the device, it will detect that.
    So: boot everything, start Read Flash, pull CEN to Ground and release that, then (if everything is wired correctly) the device will be sending the flash data to the computer.


    Ok I did just that, I hear the relay clicking when I put CEN to GND, but still there is nothing on beken writer (just like my previous picture), I inverted TX1 and RX1, tried read flash with 115200 and 15000000, read in BK7231N but nothing got me a different message from failed. While I put CEN to GND I see on debug output that device restarts just fine, what could be missing? I also changed the PL2303 adapter and got the same.
  • #281 19903560
    ExploWare
    Level 10  
    I see one thing:
    When I flashed my SmartPlug, I needed to supply 5volt to the LDO In, where I could do with 3v3 to for my relay-modules. Maybe you could desolder the VBAT line and supply 5v to the AMS1117 chip on your module. Advisable: not the 5v from the USB to Serial device. Maybe a spare phonecharger, and combine the ground with the ground from the USB to Serial, to make sure they reference to the same 0v
  • #282 19903590
    p.kaczmarek2
    Moderator Smart Home
    Important note: If I have skipped someone's question/issue related to my firmware and the problem is not resolved, feel free to repeat this. I will do everything i can to help you.

    ferbulous wrote:
    @boozeman @p.kaczmarek2
    on my first few attempts, I did get the AP with successful flashing, but not anymore
    then I tried just soldering the pins, but still the same

    Are you saying that you're still not getting AP showing up on N version chip? But it showed before? Is that correct?

    Can you check logs and paste full log here?
    The log on UART 2 should tell you whether:
    a) device fails to boot/fails to start
    b) device starts in your WiFi client mode and tries to connect to your wifi network but fails (maybe you've set bad SSID or passport?)
    c) device starts in AP mode for but some reasons AP creation fails
    I need to know which scenario happens (a, b or c) and see full log before taking next step towards resolving your issue.

    If you set a wrong SSID/password on your Beken device and haven't configured any buttons, then you will have to reflash it with recovery mode flash to access it again.

    pepesuriano wrote:
    While I put CEN to GND I see on debug output that device restarts just fine, what could be missing? I also changed the PL2303 adapter and got the same.

    This suggests that you might have a resistor on TX or RX line as some people said, but it's hard to debug remotely. Do you know any online shops like eBay where I could buy the device you have? I'd do a teardown and test myself what's wrong.
    ALSO... maybe take a multimeter in a sound/buzzer continuity test mode, put one probe on programming TX port of Beken chip and then check with second probe one by one parts on board is it connected anywhere, maybe to some resistor? And then do the same for RX....


    @ExploWare , what's the state of your build fails issue? Is the building working for you now? I tried to build with a clean copy of both repos and it works for me.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #283 19903596
    ExploWare
    Level 10  
    p.kaczmarek2 wrote:
    @ExploWare , what's the state of your build fails issue? Is the building working for you now? I tried to build with a clean copy of both repos and it works for me.

    I will try right now.

    Meanwhile: @btsimonh @p.kaczmarek2
    I've added a RCWL-0516 module to the PWM5 (Pin26) which actually does work, partly.
    The contact is able to switch the relay. But I run into two issues, and I've not been able to jump in the source that deep yet, so I wanted to ask if one of you maybe already did this:
    1: I wanted to view the MQTT state of any Pin which is configured
    2: A Push signal, or Edge Detect signal, instead of State Switch function, so when the button is pushed, state is 1, when de button is released, state is 0, unlike the current function: Push and Release is State Change.
    Could this actually be done? I think so, as the original firmware is triggered by holding a button down.
    3: The btn and btn_n do not seem to make a difference, is that correct? I can trigger both by pulling to ground
  • #284 19903615
    p.kaczmarek2
    Moderator Smart Home
    ExploWare wrote:

    1: I wanted to view the MQTT state of any Pin which is configured

    If I understand correctly, it's easy to do, I can add such functionality right away, watch for the App commit in the next hours.

    ExploWare wrote:

    2: A Push signal, or Edge Detect signal, instead of State Switch function, so when the button is pushed, state is 1, when de button is released, state is 0, unlike the current function: Push and Release is State Change.
    Could this actually be done? I think so, as the original firmware is triggered by holding a button down.

    see new_pins.c the PIN_Input_Handler function.
    We have BTN_PRESS_UP, BTN_LONG_PRESS_START, BTN_PRESS_DOWN, BTN_PRESS_REPEAT, BTN_SINGLE_CLICK, BTN_DOUBLE_CLICK.
    It's just they are not accessible from user GUI yet.
    I will add such functionality to gui soon. [EDIT] it sounds like you want something simpler - just let the relay state reflect the button state, right?
    But note that I also am going to add ability to create more advanced scripts for buttons soon, something like:
    Code: C / C++
    Log in, to see the code

    etc, just a pseudocode. Maybe something like LUA or maybe my own scripting language, I already wrote about 5 scripting language interpreters in the past so maybe I could create something that would fit our purpose better than LUA...
    But of course I also used LUA with C in the past as well. But not on MCUs.

    ExploWare wrote:

    3: The btn and btn_n do not seem to make a difference, is that correct? I can trigger both by pulling to ground

    Really? That is very possible.
    It seems you are correct.
    There is a missing logic value invert from button_generic_get_gpio_value . I shall add it there soon.
    Helpful post? Buy me a coffee.
  • #285 19903674
    ExploWare
    Level 10  
    I cannot yet build it.
    If I look at the console log, it seems that it takes the toolchain binaries, so that should all be fine. I have no clue what could be the issue.
    I am working on an up to date Debian Linux installation.
    I will go to my Windows system to give that a shot.

    $ git clone https://github.com/openshwprojects/OpenBK7231T.git && cd OpenBK7231T && (cd apps/ && git clone https://github.com/openshwprojects/OpenBK7231T_App.git) && ./build_app.sh apps/OpenBK7231T_App ExploWareApp

    ... (see https://pastebin.com/fxUmVNLr for full log ) ...
    Debug/obj/app_bk.o: In function `init_app_thread':
    /home/me/tuya/OpenBK7231T/platforms/bk7231t/bk7231t_os/beken378/app/app_bk.c:717: undefined reference to `user_main'
    collect2: error: ld returned 1 exit status
    make[1]: *** [application.mk:640: application] Error 1
    make[1]: Leaving directory '/home/me/tuya/OpenBK7231T/platforms/bk7231t/bk7231t_os'
    make: *** [Makefile:5: mp] Error 2
    make: Leaving directory '/home/me/tuya/OpenBK7231T/platforms/bk7231t/bk7231t_os'
    [/code]

    Dodano po 3 [minuty]:

    Wonderful!
    As soon as my building will work, I will get on these pin definitions. And when I get it working I'll make a pull request for it.
  • #286 19903683
    p.kaczmarek2
    Moderator Smart Home
    It cannot possibly build that way, @ExploWare .
    As it says in log:
    
    
    make: Entering directory '/home/me/tuya/OpenBK7231T/platforms/bk7231t/bk7231t_os'
    make[1]: Entering directory '/home/me/tuya/OpenBK7231T/platforms/bk7231t/bk7231t_os'
    find: ‘../../../apps/ExploWareApp/src’: No such file or directory
    find: ‘../../../apps/ExploWareApp/src’: No such file or directory
    find: ‘../../../apps/ExploWareApp/src’: No such file or directory
    find: ‘../../../apps/ExploWareApp/src’: No such file or directory
    find: ‘../../../apps/ExploWareApp/src’: No such file or directory
    find: ‘../../../apps/ExploWareApp/src’: No such file or directory
    find: ‘../../../apps/ExploWareApp/src’: No such file or directory
    find: ‘../../../apps/ExploWareApp/src’: No such file or directory
    find: ‘../../../apps/ExploWareApp/src’: No such file or directory
    

    You should give the name of directory, not the "ExploWareApp" (unless you've created yourself a directo:ry with such a name!)
    I use:
    
    $ ./build_app.sh apps/OpenBK7231T_App/ OpenBK7231T_App
    


    So you see guys, posting whole log is crucial when you're trying to get help...


    PS: but I admit, I see the logic behind your command syntax, you just have to realize that Tuya SDK is not logical, in the N version they were using seemingly the same Flash area for two purposes (thus people were losing config, they left old NET_PARTITION code enabled but not referenced), and, for example, they even had typos in file names....
    Helpful post? Buy me a coffee.
  • #287 19903700
    ExploWare
    Level 10  
    AAaaah, wow, I did miss that part. Wonderful, its working now. And indeed: it's always better to give more information in text, then to hide it when the poster 'thinks it cannot be as important' :) I blame myself for that also sometimes. But also that's why I made the full log available this time.

    Spoiler:

    $ ./build_app.sh apps/OpenBK7231T_App/ OpenBK7231T_App
    APP_PATH=apps/OpenBK7231T_App/
    APP_NAME=OpenBK7231T_App
    APP_VERSION=32ebba46
    USER_CMD=
    APP_BIN_NAME=OpenBK7231T_App
    APP_VERSION=32ebba46
    TARGET_PLATFORM=bk7231t
    USER_CMD=
    Start Compile
    system:Linux
    removing .o files from our folders, and OUR .o and .d files from Debug
    not rm -rf ../tuya_common/src/gpio_test.o
    not rm -rf ../tuya_common/src/driver/tuya_gpio.o ../tuya_common/src/driver/tuya_key.o ../tuya_common/src/driver/tuya_led.o ../tuya_common/src/driver/tuya_uart.o
    find: ‘../../../components’: No such file or directory
    not is ci build
    make: Entering directory '/home/me/tuya/OpenBK7231T/platforms/bk7231t/bk7231t_os'
    make[1]: Entering directory '/home/me/tuya/OpenBK7231T/platforms/bk7231t/bk7231t_os'
    echo prerequirement0
    prerequirement0
    ===========================================================
    Build OpenBK7231T_App
    ===========================================================
    echo prerequirement1
    prerequirement1
    mkdir -p Debug/obj
    mkdir -p Debug/bin
    echo prerequirement2
    prerequirement2
    ../../../apps/OpenBK7231T_App/src/httpserver/new_http.c: In function 'hexdigit':
    ../../../apps/OpenBK7231T_App/src/httpserver/new_http.c:462:27: warning: array subscript has type 'char' [-Wchar-subscripts]
                               toupper(hex) - 'A' + 10 ;
                               ^
    ../../../apps/OpenBK7231T_App/src/httpserver/new_http.c: In function 'HTTP_ProcessPacket':
    ../../../apps/OpenBK7231T_App/src/httpserver/new_http.c:702:4: warning: implicit declaration of function 'config_dump_table' [-Wimplicit-function-declaration]
        config_dump_table();
        ^
    ../../../apps/OpenBK7231T_App/src/httpserver/new_http.c:835:40: warning: missing terminating " character
        poststr(request,Unknown platform<br>");
                                            ^
    ../../../apps/OpenBK7231T_App/src/httpserver/new_http.c:947:5: warning: implicit declaration of function 'bekken_hal_flash_read' [-Wimplicit-function-declaration]
         res = bekken_hal_flash_read (nowOfs, buffer,now);
         ^
    ../../../apps/OpenBK7231T_App/src/httpserver/new_http.c:1118:3: warning: implicit declaration of function 'config_get_tableOffsets' [-Wimplicit-function-declaration]
       k = config_get_tableOffsets(BK_PARTITION_NET_PARAM,&i,&j);
       ^
    ../toolchain/gcc-arm-none-eabi-4_9-2015q1/bin/arm-none-eabi-gcc  -g -Wl,--gc-sections -marm -mcpu=arm968e-s -mthumb-interwork -nostdlib -Xlinker -Map=tuya.map  -Wl,-wrap,malloc -Wl,-wrap,free  -Wl,-wrap,zalloc -o ../../../apps/OpenBK7231T_App/output/32ebba46/OpenBK7231T_App_32ebba46.axf  Debug/obj/app_bk.o Debug/obj/ate_app.o Debug/obj/param_config.o Debug/obj/sa_ap.o Debug/obj/sa_station.o Debug/obj/ieee802_11_demo.o Debug/obj/dd.o Debug/obj/drv_model.o Debug/obj/dma.o Debug/obj/driver.o Debug/obj/arch_main.o Debug/obj/fft.o Debug/obj/flash.o Debug/obj/general_dma.o Debug/obj/gpio.o Debug/obj/i2s.o Debug/obj/icu.o Debug/obj/intc.o Debug/obj/irda.o Debug/obj/mac_phy_bypass.o Debug/obj/phy_trident.o Debug/obj/pwm.o Debug/obj/mcu_ps_timer.o Debug/obj/bk_timer.o Debug/obj/rw_platf_pub.o Debug/obj/saradc.o Debug/obj/spi.o Debug/obj/spidma.o Debug/obj/sys_ctrl.o Debug/obj/Retarget.o Debug/obj/uart_bk.o Debug/obj/wdt.o Debug/obj/ble.o Debug/obj/prf.o Debug/obj/sdp_service.o Debug/obj/sdp_service_task.o Debug/obj/comm.o Debug/obj/comm_task.o Debug/obj/app_ble.o Debug/obj/app_task.o Debug/obj/app_sdp.o Debug/obj/app_sec.o Debug/obj/app_comm.o Debug/obj/common_list.o Debug/obj/common_utils.o Debug/obj/RomCallFlash.o Debug/obj/dbg.o Debug/obj/dbg_mwsgen.o Debug/obj/dbg_swdiag.o Debug/obj/dbg_task.o Debug/obj/rwip.o Debug/obj/ble_rf_xvr.o Debug/obj/ecc_p256.o Debug/obj/uart.o Debug/obj/func.o Debug/obj/bk7231U_cal.o Debug/obj/manual_cal_bk7231U.o Debug/obj/role_launch.o Debug/obj/hostapd_intf.o Debug/obj/ddrv.o Debug/obj/signal.o Debug/obj/sk_intf.o Debug/obj/fake_socket.o Debug/obj/main_none.o Debug/obj/aes-internal.o Debug/obj/aes-internal-dec.o Debug/obj/aes-internal-enc.o Debug/obj/aes-unwrap.o Debug/obj/aes-wrap.o Debug/obj/bk_md5.o Debug/obj/md5-internal.o Debug/obj/rc4.o Debug/obj/bk_sha1.o Debug/obj/sha1-internal.o Debug/obj/sha1-pbkdf2.o Debug/obj/sha1-prf.o Debug/obj/tls_none.o Debug/obj/ap_config.o Debug/obj/ap_drv_ops.o Debug/obj/ap_list.o Debug/obj/ap_mlme.o Debug/obj/beacon.o Debug/obj/drv_callbacks.o Debug/obj/hostapd.o Debug/obj/hw_features.o Debug/obj/ieee802_11_auth.o Debug/obj/ieee802_11.o Debug/obj/ieee802_11_ht.o Debug/obj/ieee802_11_shared.o Debug/obj/ieee802_1x.o Debug/obj/sta_info.o Debug/obj/tkip_countermeasures.o Debug/obj/utils.o Debug/obj/wmm.o Debug/obj/wpa_auth.o Debug/obj/wpa_auth_glue.o Debug/obj/wpa_auth_ie.o Debug/obj/hw_features_common.o Debug/obj/ieee802_11_common.o Debug/obj/wpa_common.o Debug/obj/driver_beken.o Debug/obj/driver_common.o Debug/obj/drivers.o Debug/obj/l2_packet_none.o Debug/obj/wpa.o Debug/obj/wpa_ie.o Debug/obj/common.o Debug/obj/eloop.o Debug/obj/os_none.o Debug/obj/wpabuf.o Debug/obj/blacklist.o Debug/obj/bss.o Debug/obj/config.o Debug/obj/config_none.o Debug/obj/events.o Debug/obj/main_supplicant.o Debug/obj/notify.o Debug/obj/wmm_ac.o Debug/obj/wpa_scan.o Debug/obj/wpas_glue.o Debug/obj/wpa_supplicant.o Debug/obj/ethernetif.o Debug/obj/net.o Debug/obj/sys_arch.o Debug/obj/api_lib.o Debug/obj/api_msg.o Debug/obj/err.o Debug/obj/netbuf.o Debug/obj/netdb.o Debug/obj/netifapi.o Debug/obj/sockets.o Debug/obj/tcpip.o Debug/obj/def.o Debug/obj/dns.o Debug/obj/inet_chksum.o Debug/obj/init.o Debug/obj/ip.o Debug/obj/autoip.o Debug/obj/dhcp.o Debug/obj/etharp.o Debug/obj/icmp.o Debug/obj/igmp.o Debug/obj/ip4_addr.o Debug/obj/ip4.o Debug/obj/ip4_frag.o Debug/obj/dhcp6.o Debug/obj/ethip6.o Debug/obj/icmp6.o Debug/obj/inet6.o Debug/obj/ip6_addr.o Debug/obj/ip6.o Debug/obj/ip6_frag.o Debug/obj/mld6.o Debug/obj/nd6.o Debug/obj/mem.o Debug/obj/memp.o Debug/obj/netif.o Debug/obj/pbuf.o Debug/obj/raw.o Debug/obj/stats.o Debug/obj/sys.o Debug/obj/tcp.o Debug/obj/tcp_in.o Debug/obj/tcp_out.o Debug/obj/timeouts.o Debug/obj/udp.o Debug/obj/ethernet.o Debug/obj/httpd.o Debug/obj/fs.o Debug/obj/mqtt.o Debug/obj/dhcp-server.o Debug/obj/dhcp-server-main.o Debug/obj/fake_clock.o Debug/obj/target_util.o Debug/obj/net_param.o Debug/obj/multi_button.o Debug/obj/key_main.o Debug/obj/start_type.o Debug/obj/power_save.o Debug/obj/manual_ps.o Debug/obj/mcu_ps.o Debug/obj/rx_sensitivity.o Debug/obj/tx_evm.o Debug/obj/rw_ieee80211.o Debug/obj/rw_msdu.o Debug/obj/rw_msg_rx.o Debug/obj/rw_msg_tx.o Debug/obj/gpio_uart.o Debug/obj/pwm_uart.o Debug/obj/spidma_intf.o Debug/obj/temp_detect.o Debug/obj/cmd_evm.o Debug/obj/cmd_help.o Debug/obj/cmd_reg.o Debug/obj/cmd_rx_sensitivity.o Debug/obj/command_line.o Debug/obj/command_table.o Debug/obj/udebug.o Debug/obj/BkDriverFlash.o Debug/obj/BkDriverRng.o Debug/obj/BkDriverGpio.o Debug/obj/BkDriverPwm.o Debug/obj/BkDriverUart.o Debug/obj/BkDriverWdg.o Debug/obj/BkDriverTimer.o Debug/obj/wlan_cli.o Debug/obj/wlan_ui.o Debug/obj/tuya_pwm.o Debug/obj/mem_arch.o Debug/obj/str_arch.o Debug/obj/gpio_test.o Debug/obj/tuya_uart.o Debug/obj/tuya_gpio.o Debug/obj/tuya_key.o Debug/obj/tuya_led.o Debug/obj/tiny_crc8.o Debug/obj/new_pins.o Debug/obj/win_stubs.o Debug/obj/new_cfg.o Debug/obj/user_main.o Debug/obj/win_main.o Debug/obj/new_builtin_devices.o Debug/obj/new_common.o Debug/obj/http_client.o Debug/obj/utils_timer.o Debug/obj/utils_net.o Debug/obj/printnetinfo.o Debug/obj/jsmn.o Debug/obj/our_lfs.o Debug/obj/lfs_util.o Debug/obj/lfs.o Debug/obj/flash_config.o Debug/obj/ota.o Debug/obj/new_mqtt.o Debug/obj/new_http.o Debug/obj/http_tcp_server.o Debug/obj/rest_interface.o Debug/obj/logging.o Debug/obj/adapter_platform.o Debug/obj/tuya_hal_memory.o Debug/obj/tuya_hal_network.o Debug/obj/tuya_hal_thread.o Debug/obj/tuya_hal_mutex.o Debug/obj/tuya_hal_semaphore.o Debug/obj/tuya_hal_output.o Debug/obj/tuya_hal_system.o Debug/obj/tuya_hal_storge.o Debug/obj/tuya_hal_wifi.o Debug/obj/tuya_hal_rtc.o Debug/obj/tuya_hal_bt.o Debug/obj/boot_handlers.o Debug/obj/boot_vectors.o Debug/obj/croutine.o Debug/obj/event_groups.o Debug/obj/list.o Debug/obj/port.o Debug/obj/heap_4.o Debug/obj/queue.o Debug/obj/tasks.o Debug/obj/timers.o Debug/obj/rtos_pub.o  -L./beken378/lib/ -lrwnx -L./beken378/lib/ -lble -T./beken378/build/bk7231_ota.ld
    ../toolchain/gcc-arm-none-eabi-4_9-2015q1/bin/arm-none-eabi-nm ../../../apps/OpenBK7231T_App/output/32ebba46/OpenBK7231T_App_32ebba46.axf | sort > ../../../apps/OpenBK7231T_App/output/32ebba46/OpenBK7231T_App_32ebba46.map
    ../toolchain/gcc-arm-none-eabi-4_9-2015q1/bin/arm-none-eabi-objdump -d ../../../apps/OpenBK7231T_App/output/32ebba46/OpenBK7231T_App_32ebba46.axf > ../../../apps/OpenBK7231T_App/output/32ebba46/OpenBK7231T_App_32ebba46.asm
    ../toolchain/gcc-arm-none-eabi-4_9-2015q1/bin/arm-none-eabi-objcopy -O binary ../../../apps/OpenBK7231T_App/output/32ebba46/OpenBK7231T_App_32ebba46.axf ../../../apps/OpenBK7231T_App/output/32ebba46/OpenBK7231T_App_32ebba46.bin
    make[1]: Leaving directory '/home/me/tuya/OpenBK7231T/platforms/bk7231t/bk7231t_os'
    make: Leaving directory '/home/me/tuya/OpenBK7231T/platforms/bk7231t/bk7231t_os'
    Start Combined
    /**< @author <jiewu@bekencorp.com> */
    /**< @version v0.3.1 */
     encrypt without crc successfully!
     -file size: 0x81650
    {
        "count": 4, 
        "magic": "RT-Thread", 
        "section": [
            {
                "firmware": "bootloader_enc.bin", 
                "partition": "bootloader", 
                "size": "68K", 
                "start_addr": "0x00000000", 
                "version": "1.00"
            }, 
            {
                "firmware": "OpenBK7231T_App_32ebba46_enc.bin", 
                "partition": "app", 
                "size": "978944", 
                "start_addr": "0x00011000", 
                "version": "1.00"
            }
        ], 
        "version": "0.1"
    }
    beken packager V2.1.0
    Shanghai Real-Thread Electronic Technology Co.,Ltd
    Linux-4.19.0-18-amd64-x86_64-with-debian-10.11
    
    load_config: config.json
    
    partition    flash_name       phy addr   size       logic addr size       file
    ------------ ---------------- ---------- ---------- ---------- ---------- ----------------
    bootloader   beken_onchip_crc 0x00000000 68K        0x00000000 64K        bootloader_enc.bin
    app          beken_onchip_crc 0x00011000 956K       0x00010000 921359     OpenBK7231T_App_32ebba46_enc.bin
    
    image size: 1024 KB
    image name: all_1.00.bin
    
    export app partition image: OpenBK7231T_App_32ebba46_enc_uart_1.00.bin
    
    time: 0.88s
    Good bye!
    End Combined
    generate ota file
    sw_version:32ebba46
    OpenBK7231T_App_32ebba46.rbl file_size:0x54080
    OpenBK7231T_App_32ebba46.rbl sum:0x29dbf63
    header_sum:0x6dd
    rm OpenBK7231T_App_32ebba46.rbl
    ug_file size:
    344224
    /home/me/tuya/OpenBK7231T/platforms/bk7231t/bk7231t_os/tools/generate
    *************************************************************************
    *************************************************************************
    *************************************************************************
    *********************OpenBK7231T_App_32ebba46.bin********************
    *************************************************************************
    **********************COMPILE SUCCESS************************************
    *************************************************************************
    not is ci build
    $


    Added 2 hours later

    as I'm not so sure on my C skills, I just tried something.
    I was able to successfully build the sources with this change, just no time to test it in hardware yet. Tomorrow I will be able to. But for now, to prevent double work on the same issue, here is my suggestion on the inverting Button_n value:

    Code: Diff
    Log in, to see the code
  • #288 19903799
    ferbulous
    Level 18  
    @p.kaczmarek2
    It’s likely A & C
    How do i get the logs if I can’t use use bkwriter?
    Connect TX2, RX2. Use putty, set to serial and baudrate 921600?
  • #289 19903897
    boozeman
    Level 11  
    ExploWare wrote:
    Wonderful!
    As soon as my building will work, I will get on these pin definitions. And when I get it working I'll make a pull request for it.


    Remember to add PR for the Setup_Device_BK7231T_WB2S_QiachipSmartSwitch on src/httpserver/new_http.c around line 335 too ;-)
  • #290 19904000
    p.kaczmarek2
    Moderator Smart Home
    ferbulous wrote:

    It’s likely A & C
    How do i get the logs if I can’t use use bkwriter?
    Connect TX2, RX2. Use putty, set to serial and baudrate 921600?

    I think it was 115200, also maybe the better tool would be Realterm but it's up to your preference

    boozeman wrote:

    Remember to add PR for the Setup_Device_BK7231T_WB2S_QiachipSmartSwitch on src/httpserver/new_http.c around line 335 too ;-)

    @ExploWare so you are saying that WB2S Qiachip is using different relay IO pin than N version one?

    Also, please resolve your line ending issue. I can't accept pull requests that seemingly change whole file content (due to line endings issue). I tought git automatically sortes it out. There was an option for that....
    EDIT: it seems there is an option to collapse line endings changes on github side. So no problem there. Still, it's strange, it happens only for your commits, somehow (I think?)


    ExploWare wrote:

    Code: Diff
    Log in, to see the code

    it would work but why so much code?
    But wait wait wait a minute....
    You should do this change inside button_generic_get_gpio_value, because it is also used to check the initial state of the button (to avoid generating fake press on init):
    Code: C / C++
    Log in, to see the code

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    or at least it's supposed to... anyway, I fixed it and commited invert buttons fix:
    https://github.com/openshwprojects/OpenBK7231...mmit/eecd7372d5af8251e88486d7048c29c62aac3a8f[/quote]
    Helpful post? Buy me a coffee.
  • #292 19905355
    ferbulous
    Level 18  
    @p.kaczmarek2 ok, i will try that tool as well
    As for the logs from tx2, rx2.
    Do you get output only after ground the CEN pin?

    @MustangMatt
    I have a bunch of these after did a transplant on ewelink bulbs. The one i got is similar to esp-01d

    Spoiler:

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
  • ADVERTISEMENT
  • #294 19905555
    p.kaczmarek2
    Moderator Smart Home
    ferbulous wrote:

    As for the logs from tx2, rx2.
    Do you get output only after ground the CEN pin?

    The chip should remain silent as long as CEN pin connected to ground (it's in RESET state, disabled),. When you disconnect RESET from ground, it should start booting. If you broke the firmware, it will stay in boot loop (with boot log only), otherwise firmware starts to run.



    Good news! I am working on another detailed teardown and flashing guide. This time device was donated to me by @strigona from Canada.
    Here is a short sneak-peek:
    Spoiler:

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    I will publish the full article today or tomorrow. First polish version, then english. If you like detailed per-device flashing guides, remember - you can also send me your device or do a paypal donation.
    Helpful post? Buy me a coffee.
  • #295 19906275
    MustangMatt
    Level 8  
    If there a relatively affordable way to send devices? I checked postage with U.S. mail, ups, and fedex and the cheapest was about $70 USD. Probably cheaper to donate and request a device for you to purchase I suspect.
  • #296 19906676
    p.kaczmarek2
    Moderator Smart Home
    Here is the CCWFIO232PK flashing guide with detailed teardown I've been working for last few days, so far only in Polish:
    https://www.elektroda.pl/rtvforum/topic3875654.html#19906670
    Again, thanks to @strigona for donation. I will translate this article soon, same goes for previous BK7231N device teardown/flashing guide.

    Also note that this device used to be ESP-based: https://templates.blakadder.com/prime_CCWFIO232PK.html
    So we're taking the initiative now. OpenBK7231T to the rescue!

    MustangMatt wrote:
    If there a relatively affordable way to send devices? I checked postage with U.S. mail, ups, and fedex and the cheapest was about $70 USD. Probably cheaper to donate and request a device for you to purchase I suspect.

    I have no idea.
    Futhermore, I am still baffled that Polish Post Office has forced me to pay whole 8.5 złotys (about 2-3$) while receiving the package from Strigona, despite it being labelled as "gift".
    As for buying devices - I buy my devices for testing on Banggood and ebay.


    PS: I also added a "button toggle all" functionality / pin role to OpenBK. Soon I will also add support for single click and double click for each button, so users can link single button to two channels (aka two relays) - that will be useful on CCWFIO232PK, because this device has TWO relays and ONE button.
    PS2: Previous BK7231N teardown/flashing guide: https://www.elektroda.pl/rtvforum/topic3874289.html
    By the way, I also noticed that so far I have 100% success rate when it comes to flashing BK7231N/BK7231T. No problematic devices so far!
    Helpful post? Buy me a coffee.
  • #297 19906692
    ExploWare
    Level 10  
    p.kaczmarek2 wrote:

    @ExploWare so you are saying that WB2S Qiachip is using different relay IO pin than N version one?

    Yes, this is the config I need for all four of my Qiachip Smart Switches
    P.kaczmarek2 wrote:

    Also, please resolve your line ending issue. I can't accept pull requests that seemingly change whole file content (due to line endings issue). I tought git automatically sortes it out. There was an option for that....
    EDIT: it seems there is an option to collapse line endings changes on github side. So no problem there. Still, it's strange, it happens only for your commits, somehow (I think?)


    I just cloned your latest version and find there is a combination of line endings in the code. Windows and Unix variants combined.
    For example in the new_pins.c this block is mixing the Windows (DOS) line endings, shown as ^M and the Unix variants are just a new line:
    
    ^M
    typedef enum {^M
            BTN_PRESS_DOWN = 0,^M
            BTN_PRESS_UP,^M
            BTN_PRESS_REPEAT,^M
            BTN_SINGLE_CLICK,^M
            BTN_DOUBLE_CLICK,^M
            BTN_LONG_RRESS_START,^M
            BTN_LONG_PRESS_HOLD,^M
            BTN_number_of_event,^M
            BTN_NONE_PRESS^M
    }BTN_PRESS_EVT;
    
    ^M
    typedef void (*new_btn_callback)(void*);^M
    ^M
    typedef struct pinButton_ {^M
            uint16_t ticks;^M
            uint8_t  repeat : 4;^M
            uint8_t  event : 4;^M
            uint8_t  state : 3;^M
            uint8_t  debounce_cnt : 3; ^M
            uint8_t  active_level : 1;^M
            uint8_t  button_level : 1;^M
            ^M
            uint8_t  (*hal_button_Level)(void *self);^M
            new_btn_callback  cb[BTN_number_of_event];^M
    }pinButton_s;^M
    
    
    #if WINDOWS
    
    #elif PLATFORM_XR809
    ^M
    // XR809 sysinfo is used to save configuration to flash^M
    #include "common/framework/sysinfo.h"
    #include "driver/chip/hal_gpio.h"
    
    #define os_memcpy memcpy
    
    #else
    #include "flash_config/flash_config.h"
    #include <gpio_pub.h>
    
    #include "../../beken378/func/include/net_param_pub.h"
    #include "../../beken378/func/user_driver/BkDriverPwm.h"
    #undef PR_DEBUG
    

    What platform are you developing on?
    Linux would be able to run this command:
    find -type f|xargs unix2dos -s -q
    or to use linux line-endings only:
    find -type f|xargs dos2unix -s -q


    I have started to use an IDE instead of my trusty VIM environment (Visual Studio Code, since yesterday), and did not notice any line-ending-issues from there, so I think that part should be fine from my side. Just start with one clean choice on all files, I guess?
  • #298 19906694
    p.kaczmarek2
    Moderator Smart Home
    Hmm, the button code was ported from Tuya, and only adjusted to our needs (and it works now on XR809 platform as well). It could explain the line endings.
    Still, considering that I recently realized that Github has an option to collapse all "fake differences" caused by line endings in the diff view, I'd say that there is no problem. Feel free to commit more anytime you want, any help is welcome.

    EDIT: In Notepad++ I sometimes use, the option is under Edit->EOL Conversion->Convert to...
    I am using Windows with Cygwin, and I write code in MSVC 2008 (yes, that old IDE, I'm just used to it and I am using simultaneously of course newer MSVC version for other, non-iot projects, so it's handy for me).
    Helpful post? Buy me a coffee.
  • #299 19908425
    talltechdude
    Level 1  
    @ExploWare, I'm also using VSCode (in a Dev Container actually to emulate the linux build environments on MacOS). I added a note to your recent PR but Git can also handle the line endings automatically moving forward if we can get them cleaned up.

    On Windows git will automatically convert to CRLF for all files on disk, then auto-magically convert back to LF only on commits.
  • #300 19908494
    boozeman
    Level 11  
    Hi,

    Seems like User_CMD clean do not work anymore with BK7231T after the git build changes. Can someone check this.

    how to preproduce

    - Clone fresh OpenBK7231_App to your bk7231t apps directory
    - ./build_app.sh apps/OpenBK7231T_App/ OpenBK7231T_App git -> you get latest git version f6c3c8f6
    - ./build_app.sh apps/OpenBK7231T_App/ OpenBK7231T_App f6c3c8f6 clean

    It just compiled it really fast without removing object files first.

    When you look at the build process the user command is empty
    APP_BIN_NAME=OpenBK7231T_App
    APP_VERSION=f6c3c8f6
    TARGET_PLATFORM=bk7231t
    USER_CMD=

    For N version
    ./build_app.sh apps/OpenBK7231N_App/ OpenBK7231N_App 1.0.0
    ./build_app.sh apps/OpenBK7231N_App/ OpenBK7231N_App 1.0.0 clean (Object files and output will be deleted)

    Build process:
    APP_BIN_NAME=OpenBK7231N_App
    APP_VERSION=1.0.0
    TARGET_PLATFORM=bk7231n
    USER_CMD=clean

Topic summary

The discussion revolves around the development and implementation of custom firmware for devices using the BK7231T and BK7231N chips, particularly focusing on creating a mini HTTP server, MQTT support, and integration with Home Assistant. Users share their experiences flashing various smart devices, troubleshooting issues related to UART connections, and configuring GPIO pins for different functionalities. The conversation also touches on the challenges of maintaining WiFi connectivity, the importance of proper pin configuration, and the potential for using I2C for additional device control. Several users report successful firmware updates and the addition of new features, including support for various sensors and devices.
Summary generated by the language model.
ADVERTISEMENT