openshwprojects / OpenBK7231T_App

Open source firmware (Tasmota/Esphome replacement) for BK7231T, BK7231N, BL2028N, T34, XR809, W800/W801, W600/W601, BL602 and LN882H
https://openbekeniot.github.io/webapp/devicesList.html
1.41k stars 246 forks source link

TR6260 support #1020

Open salvomaltese opened 8 months ago

salvomaltese commented 8 months ago

I have purchase a smart switch from Aliexpress, but unlike what I expected the chip is not a BK7231N/T or similar but a TR6260. By researching the web I found the following information:

https://www.elektroda.pl/rtvforum/topic3960571.html https://github.com/Akeeta/Akeeta-SDK-TR6260/tree/master https://github.com/Akeeta/Akeeta-SDK-TR6260/blob/master/%E9%9B%85%E8%A7%82tr6260-SDK%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E.pdf http://www.skylab.com.cn/newsview-697.html https://fcc.report/FCC-ID/2AUUL-TR6260/4520594.pdf https://electric.garden/shenzhen-leadcoo-2axje/manuals/LA-WE3L-Users-Manual-Shenzhen-Leadcoo-2axje-la-we3l-ex-1-11.pdf

It seems to be based on esp8266 or similar. is it possible to create a build with openbeken for this chip?

Thanks so much in advance :)

openshwprojects commented 8 months ago

Hello, is there an UART flash tool for that?

salvomaltese commented 8 months ago

I couldn't find anything about it

salvomaltese commented 8 months ago

Finding on web I have found at https://electric.garden/shenzhen-leadcoo-2axje/wifi-module-la-we3l this TEST report https://electric.garden/shenzhen-leadcoo-2axje/test-report/LA-WE3L-Test-Report-Shenzhen-Leadcoo-2axje-la-we3l-ex-1-9.pdf Where they used this tool "UTP" image

openshwprojects commented 8 months ago

but do we have a download link?

salvomaltese commented 8 months ago

I have requested the AURT flash tool to Skylab http://www.skylab.com.cn/productview-150-TR6260_uartwifi_lcs6260.html Will follow up with updates when I hear back from them

UPDATE: in the meantime that I wait I was able to connect via UART (115000) and via the help command I was able to get this: assert - active assert buffer - uart buffer cmd_pow_test - cmd_round_test - debugset - setting debug value dhcp - dhcp command dhcps - dhcps command dump_mac - flashdump - flash_print get_mac - get_mac get_rssi - get_version - get_version help - display information about CLI commands ifconfig - ifconfig command nvd - delete nv nve - nv_erase nvg - getting nv value nvgamt - nv get amt nvs - setting nv value nvsamt - amt set otp_lock - otp_lock otp_read - sf_otp_read otp_se - otp_se otp_write - sf_otp_write phy - configure phy ping - ping command psm - psm test begin pwm - test ramread - read 32-bit value(s) from a ram memory location read - read 32-bit value(s) from a memory location reboot - reset chip to boot reset - reset configuration and setting resystem - reset chip to boot rf - rf setting rtc_test - rtc_test set - set various MAC/PHY parameters sferase - sf_erase show - displays current configuration and setting spi_init - spi_init spi_init_slave - spi_slave_init spi_master_buffer - spi_master_buffer spi_read - spi_read spi_read_slave - spi_slave_read spi_slave_buffer - rx_buufer r - spi_staus spi_test - spi_write spi_write - spi_write spi_write_slave - spi_write_slave station_rssi_connect - station_rssi_connect station_rssi_disconnect - station_rssi_disconnect telnet - run telnet test - test uartpsm - uart delya psm time werr - watch dog err test wpa - wpa_supplicant command (vif 0) wpb - wpa_supplicant command(vif 1) wprint - wreset - wresume - write - write a 32-bit value to a memory location wstop -

jekader commented 8 months ago

This output looks like a standard Tuya CLI since TR6260 is listed as supported by their platform. https://developer.tuya.com/en/docs/iot-device-dev/hardware?id=Kaiuyfgqxi1cl

Looking at the datasheet for this chip - looks like an Andes N25F RISC-V core or something similar from the same family: https://fcc.report/FCC-ID/2AUUL-TR6260/4520594.pdf CPU specs look quite similar, especially the PowerBrake part: https://www.andestech.com/en/products-solutions/andescore-processors/riscv-n25f/

There is no openly available SDK, I only found sources for the 6600U wifi dongle also from Eswin - that one looks like an MCU pretending to be a USB device, so maybe its firmware upload code can be useful to find the commands needed for flashing the other chip: https://github.com/eswincomputing/eswin_6600u/blob/master/usb/fw.c

The TR6260 was also used in the HLK-M20 module which has since been discontinued but there may be SDKs floating around on Chinese forums.

jekader commented 8 months ago

After some more digging, found a couple firmware images for TR6260 and they seem to point to this SDK from andestech:

https://github.com/andestech/Andes-Development-Kit/releases/tag/ast-v5_2_1-release-linux

Looking at the compatibility table in AndeSight_STD_v5.3_IDE_User_Manual_UM271_V1.0.pdf, nds32le-elf-[newlib|mculib]-v5 is the SDK to use with this MCU.

Source code for the toolchain to be available here: https://github.com/andestech/nds-gnu-toolchain

Should be possible to port OpenBeken to TR6260, someone with enough skills would just need to have the hardware on hand. I see HLK-M20 for sale so if there's anyone willing I can sponsor some boards just for the fun of it. Not sure if it's worth the effort though as this MCU is not very ubiquitous and superceeded by more modern hardware.

openshwprojects commented 8 months ago

What about ther flash tool? I would love to try porting. I am currently finishing LN882H support, and TR6260 could be next.

salvomaltese commented 8 months ago

reading the document AndeSight_STD_v5.3_IDE_User_Manual_UM271_V1.0.pdf, in paragraph 2.3 they write about how to use the flash tool via the program in the https://github.com/andestech/Andes-Development-Kit/releases/tag/ast-v5_2_1-release-linux

P.S. This flash tool is via SPI

jekader commented 7 months ago

Got HLK-M20 boards in the mail this week which sparked my interest again. So far could not get them to output anything. Did take a look through AndeSight docs and I don't think they will be of much help. They only cover the core, not the peripherals (WiFi, GPIO, etc) of the specific implementation.

Found some hints of what the SDK is called in the Akeeta-SDK-TR6260 repo:

SDK version: TR6260V1.1.1B01P02 Manufacturer's partition table: image

Some of the HLK-M20 images I've obtained contain a different parititon structure, including OTA and MQTT support. Since there's no known flasher tool at this point, I don't think an alternative firmware is possible until the full SDK is published.

Some strings which could be used to search for the SDK:

platform/otaHal/otaDiffHal.c wifi/hal/tr6260/hal_phy_tr6260.c wifi/mac/lmac/hal_lmac_common.c

If there is any interest in reverse-engineering the firmware images, extracting the bootloader, etc - let me know, I can share some binaries.

On a side note, some other modules using this MCU: