zmodem

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
OutoftheBOTS_
Posts: 449
Joined: Mon Nov 20, 2017 10:18 am

zmodem

Post by OutoftheBOTS_ » Sun Dec 02, 2018 9:55 am

I have backed this project to have a play with it and learn new things https://www.indiegogo.com/projects/sipe ... &utm_term=#/

I have started to read the docs a little about the port of MP that runs on it. It seems it uses zmodem for upload/download files from PC to the module. I use a windows machine so have been mainly using puTTY as my serial terminal and on ESP32 I have used FTP to transfer files and on other MP platforms I used ampy to transfer files (I have never got rshell to work on windows).

I am wondering about speed performance between rshell, ampy and this zmodem? I certainly found that FTP on ESP32 was much faster than ampy over uart 115200, I have also used MP on the OpenMV cam and it uses USB for transfer and this is very fast.

Is zmodem likely to be faster than ampy??

I have found KiTTY with zmodem capabilities as an improved fork of the open source PuTTY.

loboris
Posts: 300
Joined: Fri Oct 02, 2015 6:19 pm

Re: zmodem

Post by loboris » Sun Dec 02, 2018 4:08 pm

zmodem protocol can use RLE encoding which means the transfer of the files can be faster than the UART speed.
For transfering text files (e.g. Python sources) or any files which can be RLE encoded with good enough compression ratio the speed can be at least double of the UART speed.

As far as I know, RLE encoding is supported in MaixPy, but the terminal emulator must also support it to be used.

OutoftheBOTS_
Posts: 449
Joined: Mon Nov 20, 2017 10:18 am

Re: zmodem

Post by OutoftheBOTS_ » Sun Dec 02, 2018 8:35 pm

I also read that zmodem uses sliding windows that means it sends the next block of data before the receiver completes checksum and sends back ack/nack this means speed is not lost lost in waiting for a ack back.

loboris
Posts: 300
Joined: Fri Oct 02, 2015 6:19 pm

Re: zmodem

Post by loboris » Sun Dec 02, 2018 11:38 pm

Don't forget that we don't need to use 115200 baud. Both ESP32 and K210 have UARTS capable of running at 5 Mbaud speeds :!:
Of course, the speed must be supported by USBtoUART chip.
On most ESP32 boards I have, MicroPython works with no issues with 921600 baud.

OutoftheBOTS_
Posts: 449
Joined: Mon Nov 20, 2017 10:18 am

Re: zmodem

Post by OutoftheBOTS_ » Mon Dec 03, 2018 4:18 am

Ok so most commonly used uart-USB bridge is the CP2104 and datasheet quotes "Baud rates: 300 bps to 2 Mbits"

So first why is 115200 the standard default and how do I change the firmware to run at these higher speed?

loboris
Posts: 300
Joined: Fri Oct 02, 2015 6:19 pm

Re: zmodem

Post by loboris » Mon Dec 03, 2018 9:33 am

You just have to change the UART baudrate in menuconfig:
→ Component config → ESP32-specific → UART console baud rate

In the current GitHub version there is a small bug which will prevent MicroPython REPL to operate at other than 115200 baud rates.
If you want to test, you have to make a small change in main.c:

Code: Select all

    uart_config_t uartcfg = {
        .baud_rate = CONFIG_CONSOLE_UART_BAUDRATE,
        .data_bits = UART_DATA_8_BITS,
        .parity = UART_PARITY_DISABLE,
        .stop_bits = UART_STOP_BITS_1,
        .flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
        .rx_flow_ctrl_thresh = 0,
	//.use_ref_tick = true
    };
The update (with many more changes) will be commited to GitHub later this week.

I have tested on ESP32-WROVER-KIT v3 (which uses FTDI usb2uart chip) and it works with baudrates of 1000000, 2000000, 2500000, 3000000 and 3500000.
On M5Stack, which uses CP2104 chip, the maximum baud rate is 2000000.
You have to change the baud rate of your terminal emulator to the same baudrate used by ESP32.

OutoftheBOTS_
Posts: 449
Joined: Mon Nov 20, 2017 10:18 am

Re: zmodem

Post by OutoftheBOTS_ » Mon Dec 03, 2018 11:15 am

Thanks :)

Post Reply