How to send files with serial connection?

I installed OpenWRT version 23.05.5 on my ZyXEL XGS1250-12, but doing so seems to have caused the switch to lose all Ethernet port connectivity. I'd like to try an earlier firmware version per advice I received in my earlier post.

I can interact with the switch using only the serial connection, but I can't figure out how to send a file over the serial connection. Kermit and mincom don't seem to be on OpenWrt. Could someone suggest a way to send the older firmware file to the switch using a serial connection?

There are several project like this one on GitHub, if this one fails.

1 Like

Minicom would be on the *nix-based machine you use to fix the device, not installed on the OpenWrt itself. Kermit is a serial protocol, it would be in the Minicom program.

1 Like

Kermit is also a serial term application, you could do kermit in Kermit ,)

1 Like

Minicom would be on the *nix-based machine you use to fix the device, not installed on the OpenWrt itself. Kermit is a serial protocol, it would be in the Minicom program.

I was not able to find a tutorial that did not require the OpenWrt box to do something. For example, following this tutorial, everything is fine until I get to "The file receiving side must be waiting to receive the file". I don't know how to make the openWrt switch able to receive the file.

Kermit is also a serial term application, you could do kermit in Kermit ,)

Can you explain how I would do it with Kermit (or any other serial application)? I could be missing something, but it seems to me that after I send a file from the host running kermit, I need to run a GET command on the openWrt box.

There are several project like this one on GitHub, if this one fails.
This is the closes I cam to success, but when I run the program, I get errors like:

  File "/run/media/ian/wisdom/projects/serial-transfer/./serial-transfer.py", line 327, in <module>
    main()
  File "/run/media/ian/wisdom/projects/serial-transfer/./serial-transfer.py", line 324, in main
    args.func(args)
  File "/run/media/ian/wisdom/projects/serial-transfer/./serial-transfer.py", line 285, in parse_write
    return write_files(sio, args.input, args.output, DEFAULT_CHUNK_SIZE, args.perm, args.base64, args.nodirstruct)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/run/media/ian/wisdom/projects/serial-transfer/./serial-transfer.py", line 188, in write_files
    if write_file(ser, DEFAULT_LPATH_B64D, DEFAULT_RPATH_B64D, chunk_size, '777', False):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/run/media/ian/wisdom/projects/serial-transfer/./serial-transfer.py", line 152, in write_file
    exec_cmd(ser, "mkdir -p %s" % rdir)
  File "/run/media/ian/wisdom/projects/serial-transfer/./serial-transfer.py", line 75, in exec_cmd
    write_ser(ser, cmd + '\n')
  File "/run/media/ian/wisdom/projects/serial-transfer/./serial-transfer.py", line 63, in write_ser
    ser.write(unicode(str))
              ^^^^^^^
NameError: name 'unicode' is not defined

I took that error to mean that the GitHub repo is written in python2. I applied 2to3 to the repo, but got the same error.

frollic, could you suggest another project. When I searched, the projects I encountered were towards writing python programs that involved transfer of serial data. I have not found a python3 project that has a CLI for file transfer over a serial connection.

I came across a python3 implementation of a tool called Serio, that seems to be transferring the old firmware using the serial connection.

After downloading and un -compressing the file from GitHub I ran these commands to set up the environment and run the tool:

cd serio
virtualenv .
source bin/activate
pip install pySerial

./serio.py \
    -s /path/to/openwrt-22.03.7-realtek-rtl930x-zyxel_xgs1250-12-initramfs-kernel.bin \
    -d /tmp/openwrt-22.03.7-realtek-rtl930x-zyxel_xgs1250-12-initramfs-kernel.bin \
    -p /dev/ttyUSB0
2 Likes

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.