vdudouyt / stm8flash

program your stm8 devices with SWIM/stlinkv(1,2)
GNU General Public License v2.0
403 stars 183 forks source link

Writing is slow #72

Closed lujji closed 3 years ago

lujji commented 7 years ago

Older commit:

$ time stm8flash -c stlinkv2 -p stm8s003f3 -w empty.bin 
Determine FLASH area
Writing binary file 6144 bytes at 0x8000... OK
Bytes written: 6144

real    0m2.735s
user    0m0.020s
sys     0m0.000s

Master:

$ time stm8flash -c stlinkv2 -p stm8s003f3 -w empty.bin 
Determine FLASH area
Writing binary file 6144 bytes at 0x8000... OK
Bytes written: 6144

real    0m4.124s
user    0m0.000s
sys     0m0.020s

The issue seems to be introduced in b8dcaa1. Also, what is the purpose of usleep(2000) in stlink2_write_ functions? Code uses blocking libusb transfers so I'm not exactly sure why this delay is needed.

spth commented 3 years ago

There is work-in-progress on an stlinkv2 driver rewrite (https://github.com/vdudouyt/stm8flash/pull/144) that enables SWIM high-speed mode. For me, it results in an about 8x speedup.