Forum › Forums › New users › New Users and General Questions › Help CH341a mode TTL
- This topic has 24 replies, 3 voices, and was last updated Nov 15-1:30 pm by shareator.
-
AuthorPosts
-
November 1, 2021 at 1:11 pm #69915Member
shareator
Hi all, 100% newby in linux, need back up flash memo router HG532s with usb ch341a in ttl mode and run script, please need instrucctions like a child 4 years old 🙂 thx in advance
November 1, 2021 at 1:15 pm #69916Membershareator
::#!/usr/bin/python
# -*- coding: utf-8 -*-# This tool expects data from the serial terminal in a format like this
# bldr> dump b0000000 a0
# b0000000 0b f0 00 0a.00 00 00 00.00 00 00 00.00 00 00 00 |…………….|
# b0000010 00 00 00 00.00 00 00 00.00 00 00 00.00 00 00 00 |…………….|
# b0000020 00 00 00 00.00 00 00 00.40 80 90 00.40 80 98 00 |……..@…@…|
# b0000030 40 1a 60 00.24 1b ff e6.03 5b d0 24.40 9a 60 00 |@..$....[.$@..|
# b0000040 3c 1a 00 80.40 9a 68 00.0f f0 00 a2.00 00 00 00 |<…@.h………|
# b0000050 0f f0 01 60.00 00 00 00.3c 1a bf b0.8f 5b 00 64 |…`….<….[.d|
# b0000060 00 00 00 00.00 1b dc 02.23 7b ff fd.07 60 00 05 |……..#{…`..|
# b0000070 00 00 00 00.0f f0 01 e1.00 00 00 00.0b f0 00 23 |……………#|
# b0000080 00 00 00 00.0f f0 03 7e.00 00 00 00.0f f0 01 7c |…….~…….||
# b0000090 00 00 00 00.3c 02 bf bf.34 42 02 00.24 04 00 00 |….<…4B..$…|
# bldr>#Example command, backup 8MB of flash:
# python2 rt63365tool.py –read=test.bin –addr=0xB0000000 –size=0x800000 –block=0x10000#Example command, dump 32MB of RAM content:
# python2 rt63365tool.py –read=test.bin –addr=0x80000000 –size=0x2000000 –block=0x10000from __future__ import division
from optparse import OptionParserimport serial
import sys
import re
import timelineregex = re.compile(r'(?:[0-9a-f]{8} )((?:[ |\\.][0-9a-f]{2}){1,16})’)
def printf(string):
sys.stdout.write(string)
sys.stdout.flush()def skip_prompt(ser):
while ser.read(1):
passdef wait_prompt(ser):
printf(“Waiting for a prompt…”)
ser.flush()
while True:
ser.write(“\x74”) #send t (required on Tplink routers)
ser.write(“\x0D”) #send carriage return
ser.write(“\x0D”) #send 2nd carriage return for getting a clean CLI
if(ser.read(1) == ‘b’ and ser.read(1) == ‘l’ and ser.read(1) == ‘d’ and ser.read(1) == ‘r’ and ser.read(1) == ‘>’):
skip_prompt(ser)
printf(” OK\n”)
returndef memreadblock(ser, addr, size):
skip_prompt(ser)
ser.write(“dump %x %x\r” %(addr, size))
buf=”
m = False
while not m:
line = ser.readline().strip().replace(“.”, ” “, 3)
m = lineregex.match(line)
while m:
bytes = [chr(int(x, 16)) for x in m.group(1)[1:].split(‘ ‘)]
buf+=”.join(bytes)
line = ser.readline().strip().replace(“.”, ” “, 3)
m = lineregex.match(line)
return bufdef memreadblock2file(ser, fd, addr, size):
while True:
buf = memreadblock(ser, addr, size)
if len(buf) == size:
break
printf(‘ [!]\n’)
printf(‘ [.]\n’)
fd.write(buf)
returndef memread(ser, path, addr, size, block):
wait_prompt(ser)
total_size = size
fd = open(path, “wb”)
while size > 0:
cur_size = (total_size – size)
printf(‘%d%% (%d/%d)’ %((cur_size / total_size) * 100, cur_size, total_size))
if size > block:
memreadblock2file(ser, fd, addr, block)
size -= block
addr += block
else:
memreadblock2file(ser, fd, addr, size)
size = 0
fd.close()
returndef main():
optparser = OptionParser(“usage: %prog [options]”,version=”%prog 0.1″)
optparser.add_option(“–block”, dest=”block”, help=”buffer block size”, default=”10240″,metavar=”block”)
optparser.add_option(“–serial”, dest=”serial”, help=”specify serial port”, default=”/dev/ttyUSB0″, metavar=”dev”)
optparser.add_option(“–read”, dest=”read”, help=”read mem to file”, metavar=”path”)
optparser.add_option(“–addr”, dest=”addr”,help=”mem address”, metavar=”addr”)
optparser.add_option(“–size”, dest=”size”,help=”size to copy”, metavar=”bytes”)
(options, args) = optparser.parse_args()
if len(args) != 0:
optparser.error(“incorrect number of arguments”)
ser = serial.Serial(options.serial, 115200, timeout=1)
if options.read:
memread(ser, options.read, int(options.addr, 0), int(options.size, 0), int(options.block, 0))
returnif __name__ == ‘__main__’:
main()Attachments:
November 1, 2021 at 3:14 pm #69924MemberModdIt
::Unclear exactly what you intend to do.
You can find firmware for your device at https://www.huaweiflashfiles.com/
Maybe a far better place to ask regarding router is Huawei or open wrt forums.
I hard bricked my TP Link router trying to install open firmware, that is supposedly
an easy job. be carefulNovember 2, 2021 at 12:00 am #69969Membershareator
::Hi, thx in advance for you time and help and sorry for mi bad english.
I install antix in virtualbox , I already soldered the cables and the connection is ok under W7,
but newby in linux
need make a backup firmware router with a CH341a black edition in TTL mode.
need check if ok the connection under antix 1A86:5523 [0304] ??
(in VirtualBox read QinHeng Electronics CH341 in Serial mode, usb to serial port)
need install driver to CH341a ??need instructions to run script rt63365tool.py, please any help is good for me…
November 2, 2021 at 7:30 am #69980Member
Xecure
::Please, link the tutorial you are trying to follow. We have no idea what you want to do and antiX is not a router OS, so we don’t have experience with what you are trying to do. There most be a set of instructions you are trying to follow, and decided to do this on a lightweight linux distro, but people who use linux don’t know everything, and we cannot understand what you are trying to do without context. Are you following a openwrt tutorial, as Moddit points out, to backup the router’s firmware? Cannot this be done in the Windows terminal? Why do you need to do it on linux, because it says so on the tutorial you are following?
antiX Live system enthusiast.
General Live Boot Parameters for antiX.November 2, 2021 at 11:02 am #70005MemberModdIt
::Please, link the tutorial you are trying to follow.
And exact make and model of router not just the usb to serial adapter..
What you gave HG532s points to a Huawei model for which firmware is available so I assumed
no need to backup.Maybe https://github.com/matthiasbock/linux-i2c-ch341 can help you to prepare a kernel module
for your USB to serial adapterI see no reason why linux should not be usable, may not be easy though as we have no equipment
to replicate your work and it is outside of anything most of us have tried. You really need to
ask some experts.November 2, 2021 at 12:44 pm #70013Membershareator
November 2, 2021 at 2:04 pm #70024Member
Xecure
::Thanks for the link.
Requirements mentioned in the tutorial:
Requisitos:
Adaptador de puerto serie TTL para conectar al router, y saber manejarlo mĂnimamente
Cliente TFTP en nuestro ordenador. En esta guĂa usamos un ordenador con sistema operativo GNU/Linux, aunque no es obligatorio, pero es más cĂłmodo para la guĂa.There is an extra requirement (to have python2 installed). python2 has been retired on most systems, replaced with python3, but you are in luck. antiX 19.4 still brings python2 installed.
I have no idea about the first requirement (minimal knowledge of using the adapter). If you know how this adapter works, then that is good.
On the second requirement, you should be able to run the python commands and use the programs in windows, but I will try to help out in Linux.
If running on Virtualbox, you will need to connect the USB device (Adaptador de puerto serie TTL) through Virtualbox to work on the antiX Linux guest. Try first with a storage device to see how it works (and if it works) and then you can try passing through the other USB device. You need to select something similar to “Dispositivos > USB > (whatever name the “Adaptador de puerto serie TTL” has)” in the top menus inside virtualbox.
Then, starting the instructions:
1. Hacemos un backup de la flash entera para lo cual ejecutamos este script de phyton rt63365tool.py con el siguiente comando:
python2 rt63365tool.py --read=hg532sfull.bin --addr=0xB0000000 --size=0x800000 --block=0x10000
encendemos el router con el puerto serie conectado, el backup deberĂa comenzar inmediatamente. Puede tardar bastante en completarloUse Spacefm (can be launched from App Select). Navigate to the folder containing the rt63365tool.py file. Press the key F4 to launch a terminal that will already have the folder’s path ready. In terminal, run the command the same as the post mentioned, and see if it works.
Follow the steps in the guide. Note: You need to check the correct MAC address for the router (should be in the sticker on the back of the router).
antiX Live system enthusiast.
General Live Boot Parameters for antiX.November 2, 2021 at 4:55 pm #70046Membershareator
::Thx!!! 4 all
——————
Traceback (most recent call last):
File “rt63365tool.py, line 27, in <module>
import serial
ImportError: No module named serialAttachments:
November 2, 2021 at 6:03 pm #70052MemberModdIt
::No module named serial
Did you prepare a kernel module for your USB to serial adapter
https://github.com/matthiasbock/linux-i2c-ch341 may help.
As far as I am aware the module is not included in a standard kernel.November 2, 2021 at 6:19 pm #70055Member
Xecure
::File “rt63365tool.py, line 27, in <module>
import serial
ImportError: No module named serialThis is one of the reasons I dislike python. You need all kind of libraries and it is never clear which until you run the script-
In this case, you need to install python-serial
sudo apt update && sudo apt install python-serial
Probably more error messages will come asking for specific modules. We will have to go one by one until we have them all.antiX Live system enthusiast.
General Live Boot Parameters for antiX.November 2, 2021 at 11:31 pm #70093Membershareator
::mi good is a “nightmare”… no internet in Antix (wifi usb TL-WN823N ok in W7 same PC)
search “python-serial” and many result
https://packages.debian.org/stretch/python-serial
https://pkgs.org/search/?q=python-serial
many options…
which one I choose?
How do I install it without internet?
thx again for you patience…November 3, 2021 at 6:36 pm #70146Member
Xecure
::antiX should connect automatically to the internet inside the Virtual Machine, (this is usually the default configuration). I would:
1. Connect to the internet on your W7 machine.
2. Start the antiX Virtual Machine (it shoudl connect to the internet automatically)
3. Update the system (sudo apt update) and see if it properly connects to the the antiX and debian servers. If it doesn’t, check the Virtual machine connection configuration, so that it shares your internet connection in W7 with the virtual machine.
4. Install python-serial. If you cannot download it from inside the Virtual machine, download it on W7 from the Debian website (you can select the mirror you want if you cannot find an easier way to download it).
4. Try the script again.antiX Live system enthusiast.
General Live Boot Parameters for antiX.November 5, 2021 at 2:36 pm #70306Membershareator
::Finally make backup! many thx 4all especially “Xecure” for you patience.
Confirm Antix work perfect with CH341a in TTL mode, no need driver (automatic detection and function; amazing OS),
open bin and dates see like my firmware router (take 40 minutes, maybe much time, need test with putty-0.73.tar.gz 0.76 fail install ).
Fix connection internet (simple by ethernet, no wifi adapter)Attachments:
November 5, 2021 at 4:28 pm #70325Membershareator
::Hi! sorry again need your help…
How install putty (0.73 and 0.76 same error)?
How install offline python-serial_3.4-4_all.deb?
How show VM folder in SpaceFM? -
AuthorPosts
- You must be logged in to reply to this topic.




