MarsTechHAN / ch552tool

An open sourced python tool for flashing WCH CH55x series USB microcontroller with bootloader v2.30, v2.31 & v2.40.
GNU General Public License v3.0
153 stars 24 forks source link

CH554 programming error ... #2

Open RandoSY opened 4 years ago

RandoSY commented 4 years ago

Howdy!

Just experiment with the ch552 this morning ...

lsusb returns

Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 002 Device 003: ID 7392:a812 Edimax Technology Co., Ltd Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 005 Device 002: ID 04f2:1825 Chicony Electronics Co., Ltd Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 001 Device 015: ID 04e8:3315 Samsung Electronics Co., Ltd ML-2540 Series Laser Printer Bus 001 Device 034: ID 4348:55e0 WinChipHead Bus 001 Device 026: ID 239a:8019
Bus 001 Device 004: ID 0bda:0181 Realtek Semiconductor Corp. Bus 001 Device 002: ID 058f:6254 Alcor Micro Corp. USB Hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

I can see WinChipHead ...

Got this error, when I attempted to flash ...

rasyoung@vic2016:~/code_test/8051/wch/ch554_sdcc/examples/blink$ sudo python ch55xtool.py --file blink.hex Found CH554. BTVER: V2.31.

Traceback (most recent call last): File "ch55xtool.py", line 337, in main() File "ch55xtool.py", line 314, in main ret = write_flash_ch55x_v23(dev, chk_sum, payload) File "ch55xtool.py", line 143, in write_flash_ch55x_v23 payload = payload + [0] ((math.ceil(len(payload) / 56) 56) - len(payload)) # Payload needs to be padded, 56 is a good number TypeError: can't multiply sequence by non-int of type 'float'

I notice in the hex file ... the first lines are "short"

:03000000020006F5 :03005F0002000399 :0300030002006296 :1000620012007C53930CAF92747F5FF5924393809E :100072009000641200A4B29780F675A15575A1AAEA :1000820074F855B94405F5B975A10022AE82AF8363

It reports the correct chip type and bootloader version. Wondered if you know what was the issue?

Thanks for posting this code!

Randy

ishiyakazuo commented 4 years ago

Are you sure this can be used to program an Intel HEX file? It mentions bin in the readme... (Actually, I'm also having a different problem with this tool, where it says it's programmed but the chip isn't happy afterwards. I've used this same code on chips with earlier bootloaders without a problem, so I'm inclined to think that it's this tool doing something, but I'm not sure what, yet... I found this while I was looking to see if it was expecting a .hex file)

ishiyakazuo commented 4 years ago

Just a quick update -- I was able to get it to work with a binary file in my case, but not hex. (It could've been my hex file, but I think the answer is that flashing a bin file is the "safe" solution for now.) I didn't have a CH554 on hand (nor CH552) with bootloader 2.3.1 -- I used CH551. It didn't work immediately with CH551, but I patched it to fix the issue I was running into. If you try a bin file and it still doesn't work, you might want to try my fork and see if that resolves it. I can't say for sure that my workaround doesn't break anything other than CH551 and CH552.

MarsTechHAN commented 4 years ago

This does not working with hex, I might gonna to add it (and check file name suffix)later

hmmm... I dont have older CH55x on my hand :( , so if @ishiyakazuo test it works, that will be nice.

ishiyakazuo commented 4 years ago

I have some CH55x with bootloader 2.3.1 still, if this is needed.