The demo_create_softap call is for W800/W600, when porting to new platform, you just replace it with the AP call for the new platform, so it creates AP.
I could maybe try to help more, but I don't have any LN882HK devices, and from what I read here, it's possible that I would also need extra programming tool..
I expect that there is a way to flash it via UART as well. But as long as I don't have an openbk image, I don't want to spend too much time on finding out how to do that.
@p.kaczmarek2 I could prepare a virtual machine with KEIL IDE setup and an example project that compiles on a mouse click. Would you assist in adding openbk source files so that it compiles?
I ended up finding this repository with recent information and several SDKs. https://github.com/Ai-Thinker-Open/aithinker_dev_open_sdk I had to use Google Translator. Browsing the os/ln882h_sdk_lts/sdk/ln882h/tools, I found some tools and info. I have downloaded all; it is 2.45GB!!
Just to keep the participants informed: I use this Segger J-Link V9 for flashing my LN882H. Bought the device some years ago for about 20 US$. It can handle lots of different chips and software support is great. In the meantime there might be even cheaper clones available.
Hinzugefügt nach 2 [Stunden] 19 [Minuten]:
voodoopt wrote:
I ended up finding this repository with recent information and several SDKs.https://github.com/Ai-Thinker-Open/aithinker_dev_open_sdk
Nice find.
Were you able to compile one of the examples for ln882h chip?
I have the SDK setup with GCC and can build examples. I would like to try flashing this with my Segger J-Link Plus. I'm a little confused with your wiring diagram. VTRef from docs is supposed to be supplied with the target voltage, where you have it connected to the 3.3V input for the board. Are you setting something specifically to override standard VTRef behavior?
I can just try and solder this up, but clarification would be helpful. I do have quite a bit of C experience and following this thread, I think I can probably get the OpenBeken firmware compiling for this board.
I'll solder up the chip in the meantime. Thanks -(e)
@sweetlilmre Great news! Well, to be honest, I did not read a lot of the documentation from the Segger. I searched for a pinout and all I found was a schematic with pins VTRef and 5V. So I just measured the voltage of VTRef and found out that it's 3.3V on it (even though it's supposed to be an input). This is the reason I connected it to my WL2S module 3.3V. Gave it a shot and it worked right away.
@sweetlilmre Great news! Well, to be honest, I did not read a lot of the documentation from the Segger. I searched for a pinout and all I found was a schematic with pins VTRef and 5V. So I just measured the voltage of VTRef and found out that it's 3.3V on it (even though it's supposed to be an input). This is the reason I connected it to my WL2S module 3.3V. Gave it a shot and it worked right away.
I've just wired mine up and the device is not detected. Seems like VTRef is not going to work for me on this J-Link Plus. Let me do some searching and see what I can find out.
@sithyoda
I've wired up TX1, 3.3V, and ground, but am getting junk on the serial line. What baud rate, etc., did you use? I assumed 115200.
Answering my own question, the baud rate is 921600.
That was unexpected.
I can connect via JTAG now. I'm powering the device via a USB->Serial board and bridging VCC to VTRef (and GND between the board and the J-Link).
I've been experimenting further and attempting to dump the flash off the chip, first as a fallback mechanism and then for potential R.E. purposes.
I have a 128KB dump, haven't looked too much further, but this seems promising.
Happy New Year everyone
-(e)
Added after 6 [hours] 39 [minutes]:
protectivedad wrote:
I can put it into burning mode and get responses from it.
I've been trying to get burning mode working by grounding GPIOA9. This results in no output from either TX1 or TX0. Do you have any pointers for me? Should I see something on boot / after grounding EN? (I haven't connected any RX lines yet, so can't enter anything, was expecting at least some output first)
I've been trying to get burning mode working by grounding GPIOA9. This results in no output from either TX1 or TX0. Do you have any pointers for me? Should I see something on boot / after grounding EN? (I haven't connected any RX lines yet, so can't enter anything, was expecting at least some output first)
I had posted about the AI-Thinker GitHub on the first page https://www.elektroda.com/rtvforum/topic4008545.html#20840280 but no one seemed too interested, so I never bothered to post about the other things. The UART programming tools can be found on gitee.com. Search for ln882h; the company has a dozen repos there. You can use git to clone them. I used Google Translate to translate the names and some spreadsheets (they like spreadsheets as a document source). One of the repos has a Windows command line program `LN882H_CMD_Tool.exe` that can be used to flash using UART. I used the tool, the AI-Thinker examples on GitHub with an updated SDK (version 2.0) from a gitee repo to compile firmware. I merged the MQTT/OTA samples to create firmware that would connect to my MQTT using TLS, allows me to control it using the MQTT and OTA new firmware onto the device. It's not Tasmota or OpenBeken, but it does what I need. I updated all my mini-switches, but I haven't used them yet. Good luck.
Oh, it's been a while since I did this, so I forgot you will need to switch between UART0 and UART1 unless you have two TTY devices. The UART0 is for programming and AT commands, the UART1 is for log information during normal boot. Since AI-Thinker and the LN882H SDK use different logging, I was never able to consolidate them nicely, so I could use only one UART. If I go back to my firmware, I might clean it up and upload it, but I have other projects right now.
Also, I had the problem where my "ENTER" only sent the '/n' and to get proper responses from the AT commands, you need both '/n/r' which caused me some headaches.
@protectivedad Of course I noticed your post and also gave it a try on a fresh installed Debian 12 machine. Unfortunately, it does not compile here, maybe due to a lack of experience on my side with such big projects.
I was not yet able to find the LN882H_CMD_Tool.exe in the files. Would you please share it with us? I will then try to upload a compiled example from ln882's SDK via UART. If this works, the use of a J-Link wouldn't be necessary anymore.
@protectivedad Of course I noticed your post and also gave it a try on a fresh installed Debian 12 machine.
I use Ubuntu 22.04, can't remember if I needed to do anything special. I found the AI-Thinker easier to compile and they had a lot more detailed examples.
sithyoda wrote:
I was not yet able to find the LN882H_CMD_Tool.exe in the files. Would you please share it with us? I will then try to upload a compiled example from ln882's SDK via UART.
@protectivedad Of course I noticed your post and also gave it a try on a fresh installed Debian 12 machine. Unfortunately, it does not compile here, maybe due to lack of experience from my side with such big projects.
I was not yet able to find the LN882H_CMD_Tool.exe in the files. Would you please share it with us? I will then try to upload a compiled example from ln882's SDK via UART. If this works, the use of a J-Link wouldn't be necessary anymore.
There is a bulk burning tool: ln_download_tool_V2.0.1.zip with a manual (use Google Translate on the PDF). LN882H_CMD_Tool is in LN882H命令行工具_V1.0.16.zip. This allows all sorts of interesting communication with the chip.
Thanks -(e)
Added after 2 [minutes]:
Damn @protectivedad beat me to it!
Thanks for the translated Excel doc, I was busy doing that as I was replying! :)
Added after 10 [minutes]:
That repo also has the full English datasheet.
Added after 3 [hours] 15 [minutes]:
I dumped well over a megabyte of flash via the LN882H_CMD_Tool using a python script, at about 256 bytes a second LOL.
The tool will only let you dump 256 byte blocks. I have no idea if this is a legitimate flash dump, but will be interesting to have a look at.
It seems flash is not protected, which is good, but this dump differs significantly from the one I did via J-Link.
At this point I think I'm ready to start flashing some new firmware and getting back to look at the openbeken build.
-(e)
Further progress, I can flash via burn mode or J-Flash successfully off of binaries built under GCC. The "combo_mcu_basic_example" from the ln882 SDK works and connects to my AP. I've started looking into the SDK build system and putting together a CMakeLists.txt to try and include the OpenBeken app source. Once I can get something completely stubbed building, then I'll look into wrapping the HAL functions.
@p.kaczmarek2 I also had this module, and have replaced it with an ESP-02S and Tasmota. I don't need it, if you want to have the module, let me know, I can send it.
That would be great, of course, under assumption that we can get UART flashing working. I could help much more if I will be able test on physical device. Are you from Germany? I'm from Poland, so sending module in a letter shouldn't be that expensive.
So by shorting GPIOA9 and using the tool mentioned above, you can flash over TX0/RX0.
The module requires specific code loaded into RAM in order to flash it (either via UART or SWD). This is why the tool is required. A bootloader could be developed to enable flashing without the tool, but that is another story.
I am away on leave at the moment but would like to discuss the porting process. Defining another platform seems to require many changes to add e.g. PLATFORM_LN822H to various .h and .c files, and not just sorting out the HAL layer. I've spent about 8h on this so far and made some progress, but there are many oddities, probably related to my lack of familiarity with the platform.
Are you saying that I still need SWD to flash it for the first time? So there is not bootloader left by Tuya?
How can I help you with flashing process? The basic approach is to stub everything with #ifdef and then gradually fill the missing pieces of code, first with main call, then with every second timer, then log output and check if it prints, then with WiFi calls, etc. Feel free to ask any specific questions, I will do my best to help. I think you could also push your existing code to Github so I can give some feedback.
The discussion revolves around flashing OpenBeken firmware on the ELIVCO LSPA9 module, which utilizes the WL2S microcontroller and the LIGHTNING LN882HK chip. Users share their experiences with UART and JTAG flashing methods, debugging issues, and the challenges of obtaining and compiling the necessary firmware. Several users successfully managed to flash the firmware, enabling functionalities such as WiFi connectivity and relay control. The conversation also touches on power consumption, temperature management, and the implementation of power-saving features. Additionally, users discuss the integration of the BL0937 power metering chip and the development of a comprehensive template for the device. Summary generated by the language model.