Open qrp73 opened 6 months ago
actually if you look in k5prog.c at the comment on line 679:
/* 0x19 0x5 0xc 0x1 0x8a 0x8d 0x9f 0x1d
i did write length_msb length_lsb :)
so i think that you've found a bug. will try to debug it next week
I wrote my own tool for read/write eeprom and upload firmware: https://github.com/qrp73/K5TOOL It has detailed protocol log, support firmware image in packed and unpacked formats, and has UV-K5 bootloader simulator which allows to use it as UV-K5 simulator to use original firmware updater and analyze protocol in the log.
I tested original firmware updater with simulator and found that your version for length field is correct and uvtool version is mistaken.
it appears that both variants are incorrect. The packet contains packet number, not offset... And it uses Little Endian... So k5prog and other tools using incorrect packet structure, but it appears that these mistakes in most cases don't affect firmware upload procedure :)
I'm analyze source code and found some strange inconsistency.
Your k5prog utility uses write flash packet with data length fields 0x00,0x01, see this line: https://github.com/sq5bpf/k5prog/blob/241ab18b61f6d8933fecf60643fe94322fbf4198/k5prog.c#L698
But uvtool flasher uses this packet with length in reversed order 0x01,0x00, see this line: https://github.com/whosmatt/uvmod/blob/72eecd083e50a7b2f12404d49ee157d3d200841b/js/tool_patcher.js#L178 https://github.com/egzumer/uvtools/blob/7148b01f11357cb28e74fff3a9591b12a656ea13/js/tool_patcher.js#L178
Could you please help to understand what is going on here? And which version is correct? Thanks