kendryte / kflash.py

kflash, A Python-based cross-platform Kendryte K210 UART ISP Utility
MIT License
94 stars 56 forks source link

make a pip package #4

Closed minux closed 5 years ago

minux commented 5 years ago

And we can split the script into two parts.

  1. a package (also usable as a script) that converts elf / raw binary programs into flash content (add flash header and optionally encrypt it)
  2. another package to actually do the serial download, use the first package to do the conversion.

Also, we should consider adding the source code and build files for the embedded ISP program to this repository. (I'd also like to support compression for unencrypted serial downloads. Use lzip for the best compression ratio and speed up; but that means adding yet another host dependency. probably we should just stick with deflate.)

MarsTechHAN commented 5 years ago

Some comments on my own ideas.

  1. I think the packaging should be done in the "make" stage. Formats like Intel Hex is preferred (but maybe in binary form).
  2. I do believe a compressed download is required since the resource file of K210 is enormous with high compression rate.
  3. YES! Adding sources code would be a wonderful idea. We can do some fancy job with that.
Yangff commented 5 years ago

What about a multi-stage bootloader? K210's bootrom only use default uart frequency -- 115200 so if the isp rom is too complex it will take a lot of time on download this rom into board. We can first have a tiny rom, maybe only few hundred bytes that: 1. config uart baudrate 2. download other parts of isp rom from accelerated uart. And, for exmaple I don't want to use encrypted rom or compression, they can be excluded from the second rom.

vowstar commented 5 years ago

@Yangff

After commit https://github.com/kendryte/kflash.py/commit/030de69064c961139952ac9a890a46eee19aeccc , it more fast than before. But very sorry that CH340 not support very well.

For fast programming,

# This will enable opoenec super-baudrate!
python3 kflash.py -b 4500000 -B goE firmware.bin
# Trainer could use 8000000 baudrate!
python3 kflash.py -b 8000000 -B trainer firmware.bin
# Dan could use 3000000 baudrate!
python3 kflash.py -b 3000000 -B dan firmware.bin

Screenshot from 2019-04-27 01-15-11 Screenshot from 2019-04-27 01-14-45 Screenshot from 2019-04-27 01-14-34

vowstar commented 5 years ago

Although there are still many things that have not been done, the PyPI package upload is complete.

https://pypi.org/project/kflash/

Usage:

    sudo usermod -a -G dialout $(whoami)
    sudo pip3 install kflash
    kflash --help
    kflash -b 115200 -B goE -s -t hello_world.bin
    kflash -b 8000000 -B trainer firmware.bin
    kflash -p /dev/ttyUSB0 firmware.bin
minux commented 5 years ago

Cool! Thanks!