Ai-Thinker TB-04-KIT: TlsrComProg825x doesn't work ("Error get version floader!")
Hi,
I've acquired a Ai-Thinker TB-04-KIT and plan to flash it with uart2swire to use it as a Swire programmer with TLSRPGM.
I'm using a MacBook Pro with macOS Sonoma 14.7.6, in case it could matter.
It is for the moment in its original state with Ai-Thinker main program+bootloader and working fine:
#####################################################
arch:CHIP_TLSR8258,0x00000001
company:Ai-Thinker|B&T
ble_mac:94C9603DAA81
sdk_version:release/v3.4.0
firmware_version:release/V0.7.5_20201116
compile_time:Nov 16 2020 13:50:10
ready
#####################################################
I'm also able to use Telink_Tools.py from Telink_825x_SDK and for example read Flash content:
python3.11 ./Telink_Tools.py --port /dev/tty.usbserial-1410 read_flash 0 255
-- EN: Please download the Ai-Thinker Bootload Firware to the board first .
-- CH: 烧录前务必确定烧录安信可科技制作的bootload固件(官方正品出厂前已烧录)。
Telink_Tools.py v0.4 dev
Open /dev/tty.usbserial-1410 ... ... Success!
Connect Board ... ...Success!
Read Flash from 0 255 Bytes ... ... OK!
26 80 00 00 00 00 00 00 4b 4e 4c 54 00 08 88 00
ce 80 00 00 00 00 00 00 a8 28 00 00 00 00 00 00
0c 64 81 a2 09 0b 1a 40 c0 06 c0 06 c0 06 c0 06
c0 06 c0 06 c0 06 c0 06 c0 06 c0 06 c0 06 c0 06
c0 06 c0 06 c0 06 c0 06 0c 6c 70 07 6f 00 80 00
34 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0f 09 10 0a 10 0b 9a 02 04 ca 08 58 10 50 04 b1
04 b2 f8 87 0d 09 0e 0a 0e 0b 0f 0c 09 90 b0 9f
9a 02 04 ca 08 58 10 50 04 b1 04 b2 f8 87 88 a1
21 40 c0 46 c0 46 c0 46 c0 46 c0 46 c0 46 c0 46
80 00 00 00 e0 9f 84 00 00 a0 84 00 00 c0 02 00
00 00 84 00 00 40 84 00 02 06 80 00 04 a2 11 48
a5 a0 88 02 03 c1 05 a2 11 48 36 08 01 40 36 08
00 a1 41 40 ab a1 01 40 00 a2 06 a3 01 b2 9a 02
fc cd 01 a1 41 40 26 08 26 09 27 0a 91 02 02 ca
08 50 04 b1 fa 87 15 08 c0 6b 16 08 85 06 14
So module seems to work fine.
I've then added a Dupont removable jumper in order to connect CH340 pin 2 to SWS signal on header pins (6th pin on TB-04, unlike TB-03 where it is 3rd pin) and revert back easily as needed.
I've downloaded the version of TlsrComProg825x from link "command" on the instruction page.
Before going any further and flash anything to it (and possibly "kill" existing Ai-Thinker bootloader), i'm trying first to check if everything is working OK by just reading flash:
python3.11 TlsrComProg.py -p /dev/tty.usbserial-1410 -t5000 rf 0 255 dump.bin
================================================
TLSR825x Floader version 22.12.24
------------------------------------------------
Open /dev/tty.usbserial-1410, 230400 baud...
Reset module (RTS low)...
Activate (5000 ms)...
Warning: Wrong RX-TX connection?
Connection...
Load <floader.bin> to 0x40000...
Bin bytes writen: 1960
CPU go Start...
------------------------------------------------
Error get version floader!
The big onboard LED turns from red (normal state with Ai-Thinker original firmware) to off when reset occurs, but then i always get "Error get version floader!", so it seems something is going wrong.
I've also tried to trigger Ai-Thinker programming mode by pressing PROG + RST buttons during the 5s TACT delay, but doesn't work neither.
I'm kind of lost here, since i don't think i've made anything wrong, and i don't want to blindy try to flash uart2swire.bin since i would like to be sure to be able to revert back or flash anything else latter, and not just brick my module...
As a side note, i've dumped the whole original Ai-Thinker flash content. It seems there are 2 programs in there:
- One at 0x0: the main Ai-Thinker serial AT command program
- One at 0x2C000: i believe it is the bootloader/programming mode program launch when PROG button is pressed at reset
I can see that TlsrComProg is trying to load (to Flash supposedly?) floader.bin to 0x40000. So maybe i could use Telink_Tools.py to flash it there (it's currently empty space filled with FF), but i don't see any command in it to then launch program at 0x40000, so i believe it will keep launching existing bootloader at 0x2C000 and main Ai-Thinker program at 0x0. I'm not sure if flashing uart2swire at 0x2C000 would work (maybe is there some absolute adressing in there?) and it would erase the existing Ai-Thinker program here, and i would loose ability to use Telink_Tools and basically brick my module.
So i'm stuck here too, and anyway, i would prefer to have TlsrComProg working.
Help would be greatly appreciated!
I can see that TlsrComProg is trying to load (to Flash supposedly?) floader.bin to 0x40000.
floader.bin is loaded into RAM and runs until the next reset or power outage.
Alternatively, the module can be flashed using USBCOMFlashTx.html. https://github.com/pvvx/ATC_MiThermometer?tab=readme-ov-file#the-usb-com-adapter-writes-the-firmware-in-explorer-web-version
Ai-Thinker has a copied utility TBXX_Flash_Tool from https://github.com/pvvx/TlsrComProg825x
https://github.com/Ai-Thinker-Open/TBXX_Flash_Tool/blob/master/UartBoot.py
I'm using a MacBook Pro with macOS Sonoma 14.7.6, in case it could matter.
It might matter. The COM port requires different delays settings.
Thanks for your help! 🙏
It might matter. The COM port requires different delays settings.
Ok. So TACT and RST parameters might need to be altered? Is there a procedure that could help to find good ones? Does the fact that original Telink_Tools + bootloader (PROG mode) works with my Mac can help in any way to find right delays or has nothing to do?
Ai-Thinker has a copied utility TBXX_Flash_Tool
I tried the command line version, but it fails:
python3.11 Telink_Tools.py --port /dev/tty.usbserial-1420 read_flash 0 255
Telink_Tools.py v0.5 dev
Open /dev/tty.usbserial-1420 ... ... Success!
Connect Board ... ...Fail!
**********************************
***Please check the connection!***
USB-TTL <--------> TB Moudle
/ ------470------SWS
Tx ----------+
\ ------470------Rx
Rx ----------------------------Tx
RTS----------------------------RST
I guess the schematic is for a bare-bone TB-04 module, but since i have a TB-04-KIT, where the TB-04 is already mounted on a board with a CH340 and other components, does it means that i need to modified it to work with this version?
Alternatively, the module can be flashed using USBCOMFlashTx.html.
My understanding is that it would allow only to write to flash, and does it completely blindly since there's only TX wired. It could probably work (i did it with an ESL and atc1441 equivalent, on this Mac but using a Windows virtual machine since the serial interface doesn't work with Firefox or Safari under macOS), but my goal here would be to have a way to fully read/write, like with an EVK. So understanding why TlsrComProg, with RX capacity refuse to work would be my prefered solution, if possible 😊
I just had a look at TB-04-KIT schematic, and it seems that the only difference with the ASCII ART schematic displayed by Telink_Tools version of TBXX_Flash_Tool is that there is a 470 Ohms resistor added between TX (CH340 pin 2) and SWS, when your own instructions say to connect them directly without resistor. The 470 Ohms resistor between Tx and Rx is already existing on the module.
So i tried to add a resistor between TX and SWS, but no change unfortunately. 😔
Without changing anything (so keeping the link with resistor between TX and SWS), the original Telink_Tools from SDK works at the condition that i keep the PROG button pressed while launching the command, since the added link between TX and SWS triggers a reset, so by keeping the PROG button pressed, the Ai-Thinker bootloader is relaunched after reset.
I can see that in TBXX_Flash_Tool, the main difference in Telink_Tools is the added UartBoot.py that basically is trying to do the same that TlsrComProg825x: loading a program in RAM at 0x40000. I tried to adjust some minor differences, like inverting the order of DTR and RTS, and delays between them, or modifying tact value between 5s and 0.01s (it is set to 0.08s in code), but no luck.
Are the delays really depends on the OS used? Should i try Windows or Linux? Could it be a different default serial port configuration between macOS and others?
- To emulate the Telink Swire protocol, a continuous transmission stream is required from UART. Apparently, macOS cannot cope with the transmission and transmits blocks with gaps.
- Delays in reading bytes in UART are handled differently in different OS. This depends on the COM port driver.
The 470 Ohms resistor between Tx and Rx is already existing on the module.
The output current of the TLSR825x chip pins is up to 4 mA. 470 ohms is 7 mA. As a result, the pin cannot lower the voltage value to the “0” level. The recommended resistor value is in the range of 1..1.8 kOhm.
https://github.com/pvvx/TlsrComSwireWriter
For these reasons the program displays “Warning”…
Everything in Apple does not comply with generally accepted standards and specifications. Apple always comes up with and applies its own standards and specifications that do not comply with the typical ones. That's why I'm not going to adapt programs for macOS. It's often useless, since Apple uses the cheapest and most outdated controllers, and each device has different implementations of programs. And macOS is still very far from implementing a system for handling events and other system reactions in real time. This is not a real-time system. Solving technical problems on macOS is always difficult. This system is for other purposes.
Hello Victor,
Sorry for the delay, but had no free time until today.
Thanks for your explanations.
Since macOS is apparently the problem, i've tried with Windows in VMWare Fusion running on the same Mac.
Good news: it works! 🥳
A little surprising, since it is the very same Mac, but running Windows in a virtual machine... But it works.
I do however still get : "Warning: Wrong RX-TX connection?" and a final "(1) Warning". 🧐
I have these warning with both:
- TB-04-KIT with direct link between CH340 pin 2 and SWS pin
- another configuration with a CH340 standalone USB UART adapter (with RX resistor removed) connected to another TLSR8359 based device.
You say that the warning is because of a bad resistor value, so for the USB UART+device combo i tried with 1, 1.5 and 1.8 kOhms resistor, but no change.
But at the same time, if it try to dump several times a whole 0x80000 Flash and compare the results, there's no difference, so it seems it works reliably despite the warnings.
So i went to the next step and flashed the TB-04-KIT with TLSRPGM firmware, and then tested direct SWire communication with another TLSR based device, and it seems to work too! 🤩
I've made some first tests with it, and the only problem i have is that it doesn't work if i set baud rate to 460800, despite i've read here (in another issue) that TB-04 should support this rate. But may be is it because of the virtual machine configuration, and 230400 is already not so slow even for 512kB.
I'm really impressed by your knowledge, your great work, and your friendly help! СПАСИБО!