logo elektroda
logo elektroda
X
logo elektroda

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

p.kaczmarek2 177933 1242
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #481 19992149
    p.kaczmarek2
    Moderator Smart Home
    As far as we know, the internal flash of Beken identifies as 00 15 70 1C so as EN25QH16B.

    And, according to the docs, it can sustain a minimum of 100K program/erase cycles on each sector or block
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #482 19992378
    kuba2k2
    Level 13  
    That's actually pretty interesting. So it seems that after entering SPI programming mode, the BK kind of turns itself off, and provides direct access to the flash memory. The commands in SPIFlash.md correspond to 25QH16 commands. That means you could probably simply use flashrom on a Raspberry Pi to access the raw flash, and basically do whatever you want. Nice!
  • #483 19992801
    p.kaczmarek2
    Moderator Smart Home
    Step by step BL602 flashing guide (and also some compiling information for developers) released, but only Polish version so far
    https://www.elektroda.pl/rtvforum/topic3889041.html#19992780
    Translation pending.
    BL602 port seems fully useable now, I am testing its stability just as we speak.

    I am still waiting for Realtek chips shipment/donation, but when I get them, I will also port my app there. @kuba2k2 if you check (because I think I saw there was a ready one) OTA bootloader before I get RTLs, it will certainly by easier for me to integrate it into OpenBeken
    Helpful post? Buy me a coffee.
  • #484 19993283
    kuba2k2
    Level 13  
    What would you say about some form of collaboration? For example integrating OpenBeken in platformio? After adding the other four hardware platforms, all of us could have a complete environment with a standardized build system. Building OBK wouldn't require cygwin, msys2, etc.

    Meanwhile, I have created a public Discord server for anyone to join. I'll probably post links to flashing guides or other info there, or setup some webhooks about my development progress.
    If anyone's interested, you're welcome to join; maybe it'll build a community at some point.
    https://discord.gg/SyGCB9Xwtf
  • #485 19993404
    sebastian48
    Level 9  
    Running the very first release firmware on two devices I've had some interesting findings:

    - Running one device seems to be issue free. I've had it running for a week without a single issue in response.
    - On the same day I power cycle the other device (which then hooks up to the system, both devices working) the first one crashes and stops responding. Physical button still working.

    This feels more low level than I initially thought. Or it might work out after a reconfigure in HomeAssistant. I find it weird that HA shows both as switches but with different icons: one is a lighting bolt and one is a typical switch button.
  • #486 19993614
    opfer15
    Level 2  
    Hi,
    bought YITOM Smart Power Strip on aliexpress. Turns out the power strip uses a WBR3 to control the sockets. WBR3 is using an RTL 8720cf which is hopefully similar to the RTL8710 so we could maybe have an easy port of OpenBeken to integrate these devices into HA :)
    It doesnt use the connectors on the bottom of the WBR3 PCB so it also could be easily replaced with an esp 12f
    PCB serials for google indexer:
    Main PCB Serials: 3AA-0500240-WF4 REV:B 2019.07.30
    PCB WBR Daughter Board 3AA-WF4AC-WF Rev B 2019.07.30

    hope this is the right thread for this post. Sry for the links. but the system insistet to trick it :')

    Power Strip: aliexpress com/item/1005002454805802.html
    GCC SDK: amebaiot. com/en/amebad-bw16-arduino-getting-started
    Arduino Lib: github. com/ambiot/ambd_arduino
    SDK: github com/ambiot/ambz2_sdk
    WBR3 Modul: developer. tuya. com/en/docs/iot/device-development/module/wifibt-dual-mode-module/wbr-series-module/wbr3-module-datasheet?id=K9dujs2k5nriy

    [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 [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 [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
  • #487 19993622
    p.kaczmarek2
    Moderator Smart Home
    @kuba2k2 most likely I will not be wasting time to recreate the thing we already have, but if someone is willing to contribute it himself for OpenBeken, then it would be great. It's just that I don't have time to reinvent the wheel. Especially with Github build system working for us.... the github build system also would have to be changed for that IO to work, right?

    sebastian48 wrote:

    - Running one device seems to be issue free. I've had it running for a week without a single issue in response.
    - On the same day I power cycle the other device (which then hooks up to the system, both devices working) the first one crashes and stops responding. Physical button still working.

    This feels more low level than I initially thought. Or it might work out after a reconfigure in HomeAssistant. I find it weird that HA shows both as switches but with different icons: one is a lighting bolt and one is a typical switch button.

    Anything more? How did you recover?
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    I am testing actively multiple devices but found no such issue so far.


    @opfer15 that's a useful information, I would like to support this platform, but the whole strip costs a lot. Did you do a transplant for ESP12F? Do you still have WB3R left? I don't have any Realtek chips at hand so my Realtek development has come to halt.
    Helpful post? Buy me a coffee.
  • #488 19993925
    kuba2k2
    Level 13  
    @opfer15
    This chip is AmebaZ2. Other SDKs like ambd_sdk are not compatible and will not work. I'm preparing to better support these chips in my project.

    p.kaczmarek2 wrote:
    most likely I will not be wasting time to recreate the thing we already have, but if someone is willing to contribute it himself for OpenBeken, then it would be great

    Sure, I think I can do this. Yes, GitHub workflows would need to be recreated, but I bet there are many PIO workflows readily available. Also, we would need only one workflow for all platforms.
  • ADVERTISEMENT
  • #489 19994002
    bole5
    Level 2  
    p.kaczmarek2 wrote:
    I will not be wasting time to recreate the thing we already have

    It is pity to see this effort as "wasting time". Having a solid build system with a popular IDE plugin such as PlatformIO would make it more attractive to potential contributors.

    You are doing great job on sorting out everything from scratch (OTA, UI, expanding chipset support, etc) but a lot of your coding effort goes into trying to replicate what tasmota already does. Wouldn't it be nicer if we could copy/paste most of the existing logic, UI, etc from that project and focus on improving this functionality? So far I did not see many pull requests for OpenBK7231T project which is pity given the interest. I believe that adopting project structure, build system, table overview, etc that @kuba2k2 created could be a great way forward.
  • ADVERTISEMENT
  • #490 19994040
    p.kaczmarek2
    Moderator Smart Home
    I'm sorry but programming doesn't work by copying file named "tasmota.ui" and getting the same interface as Tasmota. It's not that simple. Futhermore, I am actively designing project to meet the current needs of devices that are popular and adding features according to the requests of the users. I have two donation boxes of smart devices on way to me in order to support them. Copying stuff directly from Tasmota would just break things, as I have much better ideas how to handle certain things.

    For example:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Do you really think that "SetOption12" is an intuitive name for console command and end users are able to easily remember what they have to type in order to, let's say, get their buttons working?

    Or their TuyaMCU implementation... it's a mess.

    I have a very clear path for OpenBeken in mind, along with multiple useful and flexible scripting features that will cover most of the use cases.

    @bole5 have you ever heard that one of the most common mistakes in software projects is to maintain a design that is obsolete, convoluted and spending lots of time to debug "spaghetti code" instead of doing a clear rewrite? It's not that I have to reverse enginer things from scratch, I can still use other projects as reference.

    It's better to understand the functionality and implement it clearly, instead of copying it blindly like some high school student.
    Helpful post? Buy me a coffee.
  • #491 19994064
    opfer15
    Level 2  
    p.kaczmarek2 wrote:
    @opfer15 that's a useful information, I would like to support this platform, but the whole strip costs a lot. Did you do a transplant for ESP12F? Do you still have WB3R left? I don't have any Realtek chips at hand so my Realtek development has come to halt.


    Still have the WBR3 Modules. As they're most likley not useable to any of us without a HA compatible FW i have to swap them at a given time and probably loose some of the feature set. There is also the possibility to swap it with an esp32-C3, which i just ordered 2 modules of. But as you statet (on github i think) it's a waste of a good mcu and i don't like the idea to waste them too :)

    If you wanna work on it, i'll send you a parcel with one or two WB3 modules. GER to PL is just 5€. Or if you want to support the strip in total, i'll send you 10 bucks so it ain't that expensive anymore.

    I also have an ATCOMM LED bulb with a BL-200 Chip. Which has the formfactor of an ESP but definitly isn't (only 2 Pins connected) as i already ripped it out of its bulb case to check the chip and there is no google information out there for this chip, you could also take a look at it if you want to.

    ATCOMM CWWW (RGB) bulb: aliexpress .com /item/4000162934304.html

    ATCOMM led daughter board serial : LT-6335 - RGBCW XLD-W60-2.2
    Main PCB XLD-QFLWP-BP-3.2.1
  • ADVERTISEMENT
  • #492 19994073
    kuba2k2
    Level 13  
    Did you know that Tuya has official MCU protocol documentation? With everything explained in English in a .PDF file...
    Also, there is "Tuya module debugging assistant" which can connect to the MCU or the WiFi module over TuyaMCU protocol. This can really ease out debugging (for example) OpenBeken's TuyaMCU implementation.
    Additionally, you can download SDKs from Tuya's servers, for each module/chipset. Often these firmwares are newer/more updated/more complete than these on Github. The modules on their page have clearly named chipsets, for example "RTL8720CM" instead of "W701-something" which is in the "module datasheet".
    Also, BK7231T is most likely the exact same thing as BK7231S.

    I know that you probably know this all already. But I haven't seen this info in this thread, so it might be worth mentioning :D
  • #493 19994084
    p.kaczmarek2
    Moderator Smart Home
    kuba2k2 wrote:
    Did you know that Tuya has official MCU protocol documentation? With everything explained in English in a .PDF file...

    Haha I am not sure if you are referring to me or to the guy who wanted to copy Tasmota. Anyway, I am well aware about their documentation, there is even more - there is an Arduino Library for that purpose on Github. It's just as I said, I tend to write my stuff with the core assumption that I have to understand the protocol first in order to use it the best I can and I am sorry if you think that's a wrong approach and would rather just copy & paste code.
    Futhermore, I have strongly modified the TuyaMCU approach, because in my case, there is a concept called "channel" and it maps to TuyaMCU variables seamlessly and allows future scripting.
    Did I mention that TuyaMCU Dimmers are already working?
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Someone helped me support them with a pull request
    Here is how you setup such device in OpenBeken (those are script commands, you type them without recompiling software):
    
    startDriver TuyaMCU
    setChannelType 1 toggle
    setChannelType 2 dimmer
    tuyaMcu_setDimmerRange 0 1000
    linkTuyaMCUOutputToChannel 1 1 1
    linkTuyaMCUOutputToChannel 2 2 2
    

    Function names and the general inner workings are designed to be flexible and intuitive and I am doing my best to avoid hardcoding per-device hacks in C code like people sometimes do.
    Also, did you know that I already support scripted events (in Tasmota, they have Rules, they are both similiar):
    
    setPinRole 10 Btn
    setPinChannel 10 0
    setPinRole 11 Btn
    setPinChannel 11 0
    setPinRole 26 PWM
    setPinChannel 26 1
    setEventHandler OnClick 10 setChannel 1 100
    setEventHandler OnHold 10 addChannel 1 10 
    setEventHandler OnClick 11 setChannel 1 0
    setEventHandler OnHold 11 addChannel 1 -10 
    

    With the script above, I can seamlessly control TuyaMCU dimmer with two extra buttons with multiple functions for click and holds. Everything without recompiling.

    kuba2k2 wrote:

    Sure, I think I can do this. Yes, GitHub workflows would need to be recreated, but I bet there are many PIO workflows readily available. Also, we would need only one workflow for all platforms.

    As I said, I will be happy to accept that if you make sure that's working with github build system. I have nothing against PlatformIO and I think it's a good idea, it's just as I said, at the current point of development I think I won't gain much from doing it myself. A have a queue of devices to support.

    opfer15 wrote:

    Still have the WBR3 Modules. As they're most likley not useable to any of us without a HA compatible FW i have to swap them at a given time and probably loose some of the feature set. There is also the possibility to swap it with an esp32-C3, which i just ordered 2 modules of. But as you statet (on github i think) it's a waste of a good mcu and i don't like the idea to waste them too :)

    If you wanna work on it, i'll send you a parcel with one or two WB3 modules. GER to PL is just 5€. Or if you want to support the strip in total, i'll send you 10 bucks so it ain't that expensive anymore.

    It would be better to get modules, as you don't have a use of them anyway. I also don't trust aliexpress much because in last year it started having more common tax issues. I am not sure if "over 20$ has no customs" rule still applies, I am not up to speed with the import tax duties. I buy my stuff on Bg with shipping from Czech.
    Btw - take a look what I got today:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    So if you want to donate modules, thanks, send me a private message here.
    They are ESP12F form, right? So maybe I can solder them on ESP12F breakout board...
    Helpful post? Buy me a coffee.
  • #494 19994095
    kuba2k2
    Level 13  
    p.kaczmarek2 wrote:
    Haha I am not sure if you are referring to me or to the guy who wanted to copy Tasmota

    I was referring to you and the community in general. Personally, I don't even like Tasmota, nor want to use it. Mainly because their weird, complicated "commands" etc.

    p.kaczmarek2 wrote:
    I have to understand the protocol first in order to use it the best I can and I am sorry if you think that's a wrong approach and would rather just copy & paste code.

    You're totally right. It's just good that we have docs for this protocol, and that we don't have to reverse engineer it.
  • #495 19994106
    p.kaczmarek2
    Moderator Smart Home
    So we agree and will certainly team up in the future, @kuba2k2 . Personally I would like you to help with OTA stuff for Realtek and maybe BL602, but if you are not up to this yet (because you are building from scratch) then I will just solve it myself when I get some free time. I am not even sure if there a ready-made OTA example in Realtek SDK, because if there is, then it's just a matter of calling few functions from existing code.

    We already have a system to receive a drag-and-dropped file on Chrome in OpenBeken.
    Helpful post? Buy me a coffee.
  • #496 19994302
    bole5
    Level 2  
    p.kaczmarek2 wrote:
    It's better to understand the functionality and implement it clearly, instead of copying it blindly like some high school student.

    Fully agree with this statement! Reference to Tasmota is simply because I would expect that most users will come to your project with prior knowledge and experience with Tasmota, Espurna or ESP Home.

    The intention with my comment was to say that it is sometimes more productive to not "reinvent the wheel" if there is a project which already took care of some elements that are generic. One example I gave was UI. Admitedly, Tasmota is not the best example of a meaninful UI or reusable code for that matter, but the point was that code reuse (not blind copying) is not a bad thing that only high school students would do :)
  • #497 19994401
    opfer15
    Level 2  
    p.kaczmarek2 wrote:
    It would be better to get modules, as you don't have a use of them anyway. I also don't trust aliexpress much because in last year it started having more common tax issues. I am not sure if "over 20$ has no customs" rule still applies, I am not up to speed with the import tax duties. I buy my stuff on Bg with shipping from Czech.


    Banggood and Aliexpress take care of tax and customs since 1.6.2021 (eu e-commerce policy) it's calculated in the price you pay on ali. atleast its for germany but that should count for every other EU country.
    send you a PM. Yeah ESP-12F/ESP32-3C-12F are Pin compatible to WBR3

    kuba2k2 wrote:
    @opfer15
    This chip is AmebaZ2. Other SDKs like ambd_sdk are not compatible and will not work. I'm preparing to better support these chips in my project.

    too bad this didn't work out :(
  • #498 19994452
    kuba2k2
    Level 13  
    opfer15 wrote:
    too bad this didn't work out

    No, no, I'm not saying this won't work out :D
    There is an SDK for this, but it's called ambz2_sdk, and not ambd_sdk. If we have more of these modules (more people to test it), I'm sure OBK will support it someday (the APIs are not too different from RTL8710BN).

    EDIT:
    ... and then I ended up rewriting the entire WiFi driver library. But you know it's worth it, when literally copy-pasting a WifiScan Arduino example from ESP32 makes it compile and work perfectly fine on my LibreTuya.

    EDIT2:
    About OTA: ESP32 Arduino core has a simple update mechanism; you just use Update.write() to write chunks of firmware data. The underlying HAL handles everything. It seems like a pretty cool idea as an alternative to vendor OTA mechanisms. IMO, reinventing the wheel here is a way to make something better, which I'm probably going to do for Realtek.
    I also checked Realtek OTA code, it's a single function called download_new_fw_from_server, which reads data from the given socket and writes to flash. Nothing special.
    There also is a function to set OTA2 address for bootloader to run - this one may be useful; again nothing extraordinary, as the storage offset of the address is documented anyway.
  • #499 19995470
    p.kaczmarek2
    Moderator Smart Home
    sebastian48 wrote:

    - On the same day I power cycle the other device (which then hooks up to the system, both devices working) the first one crashes and stops responding. Physical button still working.

    The devices are listening to network events and automatically reconnects to WiFi when disconnected. I have tested it many times by turning off the power of my router and/or by restarting it and it worked every time reliably.

    Still, I am unable to test all possible scenarios and I suspect that the "crash" (or should you rather say, the disconnection from WiFI, because button is still working) is related to some WiFi bugs, maybe caused by overlapped WiFI channels, so I have decided to add extra failsafe just for you.

    This is always DISABLED by default, you have to enable it per device.

    It's called "ping watchdog", it pings a certain IP (preferrably your router IP) and if it fails to ping it for a given number of seconds, it forces a reconnect.
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    Also, did I mention that English BL602 guide has been released?
    https://www.elektroda.com/rtvforum/topic3889041.html

    Btw, my test devices are reaching 5 days uptime:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    it would be even longer if I wasnt updating their firmware (OTA forces a restart)
    Helpful post? Buy me a coffee.
  • #500 19995851
    gamerayers
    Level 5  
    Here's some images of the Treatlife SL10 I have (I actually have 8 of these). They can be torn down non-destructively. I'm a little concerned about the TXD/RXD and the power pins due to the location of the capacitor if I need to reach the TXD/RXD2, the TXD/RXD1 is weirdly shaped.
    Chip is a WB8P.
    Guessing because this has the extra MCU on the top board, it isn't supported yet.

    [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 [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
  • #501 19995900
    p.kaczmarek2
    Moderator Smart Home
    What is written on those "extra MCUs", are they by any chance I2C controlled?

    I just need to get my hands on one of such bulbs, and I will add support for that. I am trying to find where can I buy single piece of such bulb with good cheap shipping to Poland, but no luck so far...
    Helpful post? Buy me a coffee.
  • #502 19995911
    kuba2k2
    Level 13  
    p.kaczmarek2 wrote:
    What is written on those "extra MCUs", are they by any chance I2C controlled?

    I would say these are probably PWM controllers, or rather PWM-controlled high power drivers. I have two bulbs with chips like these, they are connected to PWM outputs of the CPU. As these bulbs drive LEDs in series, with a high voltage like 120V, that controller is needed.

    As for obtaining them, you can get one for example here:
    mediamarkt pl /sport-i-rekreacja/zarowka-led-hama-wifi-e27-rgb - this one is probably based on BK7231T with WB2L
    correct me if posting links here is not allowed
  • #503 19995954
    p.kaczmarek2
    Moderator Smart Home
    @gamerayers if that's PWM only, then it's supported. And if you read flash memory from one and send it to tuya-cloudcutter guys, you will get OTA hack for remaining ones.

    Today I tested water sensor with XR809/XR3 port. I had to add a new pin role (input digital with no pull ups) but now it works!
    [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
    Helpful post? Buy me a coffee.
  • #504 19996043
    gamerayers
    Level 5  
    Wonderful. It will be a little before I can get to pulling the data off of it, but will send it along when I get it.
    Thanks for the info.

    Added after 1 [hours] 51 [minutes]:

    So I've tried to connect directly to the USB, and after reading more, it seems that may not work due to the size of the capacitor, so I will work a little at finding a good method to power it.
    2 questions:
    1. You said you use a 5V power supply, but I'm not entirely sure I should do that since the chip is 3.3v for this. Is there a different area you attach that? Or just use a high current 3.3V power supply separate of the USB?
    2. I am not sure which is send and receive. It is a bullseye style pattern and I might assume RX1 is the center, but there isn't much which identifies which is RX and which is TX. Since it appears this is common, which did you find is RX and which is TX on other chips?
  • #505 19996365
    p.kaczmarek2
    Moderator Smart Home
    First of all, you haven't replied what is written on the SOIC-8 chips that are alongside the LEDs. It would be good to know, because @kuba2k2 could be wrong and if that's a I2C driver, then it still needs to be implemented. I would do I2C driver for those chips quickly, but I don't have such bulb at hand.

    For programming, you should follow one of the guides from the Teardowns sections.

    Never connect 5V directly to WB modules. I used to connect 5V to AMS1117-3.3V input (this LDO is often present alongside WB/Beken chips on boards), but in case of your bulb, I can't see where is the source of 3.3V so maybe it makes sense to use external 3.3V LDO to get external 3.3V. As for external LDO, I use TC1264-3.3V, but there many many low dropout regulators with 3.3V output. You could even take 3.3V from Arduino and it would work.
    If you are worried about big capacitor resetting USB, you can either get 3.3V from other port or source than the one used for programming, or use CEN method for resetting instead of repowering the chip.


    As per bullseye pattern... I haven't tested this module yet so I don't know. Still, there are only two possible options. None of the other chips had such a strange pad pattern for RX and TX. WB8P is unique in that manner.
    Helpful post? Buy me a coffee.
  • #506 19996413
    kuba2k2
    Level 13  
    p.kaczmarek2 wrote:
    it can sustain a minimum of 100K program/erase cycles on each sector or block

    That's actually amazing because I feel like I'm trying to make that program work for the 10000th time

    Do you have any experience in debugging these chips? I mean, BK, RTL, any of these. Did you ever try to attach some kind of debugger? JTAG/SWD?
    Running DiagPrintf() everywhere is sooo bad...
  • #507 19996425
    p.kaczmarek2
    Moderator Smart Home
    No, and to be honest, during the years of programming experience I worked out a method of programming without debugger. Of course, I debug when I am able to.

    What's your issue now? I can help with Realtek when I get any of Realtek chips. I am still waiting for the donation from the "96 bulbs" guy.

    Are you experiencing some kind of crash? I remember that during my short period of Realtek work, I got it to printf "Hello world" but it crashed when I tried to run some of the examples...

    By the way, do you know anything about this little guy? I have to go for a supper, but when I come back, I will do some research:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Helpful post? Buy me a coffee.
  • #508 19996455
    kuba2k2
    Level 13  
    No idea what that is. I don't really have much experience in electronics, I'm more of a programmer.
    But we all know well, that debugging with a proper debugger in an IDE like CLion or VSCode is just pure pleasure.

    My printf powers are running out, as my code seems to enter a weird loop (idk, probably caused by some memory corruption). The printfs just print over and over... and what to do next?
    Nearly the same code (but in vendor ugly libraries) was working fine, few days ago. To fix this, I would need to see the method pointers etc, in real time.
    Also, the AP starts and then goes invisible. Then it shows again, and disappears, randomly. I must admit, I thought this would be easier. I'll be trying to attach a proper debugger.

    EDIT:
    okay it gets worse and worse. Turns out the console is... built-in the chip???
    My code was running fine, I could use Serial.read(), and suddenly after connecting to WiFi the console is back... or a part of it, because it doesn't support any command. Although it exists and blocks any serial reading for my code.
  • #509 19996548
    p.kaczmarek2
    Moderator Smart Home
    My main concern during testing with Realtek was that I am not flashing the correct partition. I am still not sure about that, at least I know that my "Hello world" got printfed correctly. I was not sure about the meaning of multiple partitions in the flasher.

    I will continue porting OpenBK to Realtek when I get more chips.
    Helpful post? Buy me a coffee.
  • #510 19996589
    kuba2k2
    Level 13  
    The partitions in the flasher mean nothing; the only important things are offset and which file you flash.
    The "image2_all_ota1.bin" file goes to offset 0x0800B000, and the ..._ota2.bin file goes to 0x080D0000 for 2MB chips (Tuya). Stock Realtek boards with 1MB chips go to 0x08080000 instead. I attached a complete flash layout map here:
    https://github.com/kuba2k2/platformio-libretuya/tree/master/boards/wr3#flash-memory-map

    Meanwhile, look at this:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    EDIT:
    After some fiddling with PIO debugger config and GDB breakpoints not working, I got a fully functional debugger in my VSCode. And 2 minutes later I was able to resolve the most likely cause of these infinite loops and crashes. This wouldn't be possible with printfs :D

    EDIT2:
    @p.kaczmarek2 Apparently the UART downloader on RTL is in the chip's ROM. The bootloader in the flash is a second-stage bootloader. You said earlier that your RTL is bricked... are you sure it is? Pulling TX to GND doesn't run the UART flasher? You can check if anything shows on UART console. The entire ROM binary seems to be available in the SDK... which is kinda ridiculous. It is not even stripped.

    EDIT3:
    My project now has a built-in flash loader, meaning clicking "Upload and Monitor" in PlatformIO does everything for me - no need to use vendor image flashing tools!

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