想做一个自己的hid下载工具,有通信协议的说明文档吗?
现在可以在PDF中找到串口下载程序的通信协议但找不到通过hid下载程序的协议
HID下载协议有说明文档吗?
!(data/attachment/forum/202412/03/232813av3rhuoorohior0u.png "HID 下载")
网上找到一个,还没测试
来自 github @robinkrens
```python
# Example on how to use hid to write STC chip series: STC8H8K64U,STC32G12K128,STC32F12K54
# Opens USB HID device and programs flash. No error check. Use at own risk
# Only tested on STC32F12K54
import hid
import time
import struct
from intelhex import IntelHex
from tqdm import tqdm
PACKET_START = bytes()
PACKET_END = bytes()
PACKET_MCU = bytes()
PACKET_HOST = bytes()
h = hid.device()
h.open(0x34bf, 0x1001)
print(f'Found device: {h.get_product_string()}')
# h.set_nonblocking(1)
def send_packet(packet_data):
packet = bytes()
packet += PACKET_START
packet += PACKET_HOST
# packet length and payload
packet += struct.pack(">H", len(packet_data) + 6)
packet += packet_data
# checksum and end code
packet += struct.pack(">H", sum(packet) & 0xffff)
packet += PACKET_END
h.write(packet)
if packet_data != 0xFF: # do not read if reset package
d = h.read(64) # every HID packet is 64 bytes: currently not read and discarded
## init and erase
send_packet(bytes()) # start
send_packet(bytes()) # info
send_packet(bytes()) # unlock
send_packet(bytes()) # erase
ih = IntelHex()
ih.loadhex('led.hex')
for i in tqdm(range(ih.minaddr(), ih.maxaddr(), 0x80)):
chunk = ih.tobinarray()
packet = bytes()
if i == ih.minaddr():
packet += bytes() # first package, diff number apperently
else:
packet += bytes()
packet += bytes()
packet += bytes()
packet += bytes(chunk)
send_packet(packet)
send_packet(bytes()) # reset
```
这个的协议?
这个没开源
官方有提供HID方式的用户ISP吗
DebugLab 发表于 2024-12-3 23:51
这个的协议?
这个没开源
就是这个,没开源算了,我看网上有人逆向出来了一份 :smile:
别家都是藏着掖着的,好像是什么先进技术怕被人家盗版一样,没想到STC连这通讯协议都公开了。
顺便问一下,这帖子怎么只能使用markdown编辑器编辑?表情大拇指跑哪里了?
!(data/attachment/forum/202412/04/081538w401la6k0skk1bbv.jpg "001.jpg")
xxkj2010 发表于 2024-12-4 08:16
别家都是藏着掖着的,好像是什么先进技术怕被人家盗版一样,没想到STC连这通讯协议都公开了。
顺便问 ...
我咋没看见喃,在哪里哦 DebugLab 发表于 2024-12-3 23:51
这个的协议?
这个没开源
那串口下载的协议有没有开放?
补充:哦,找到了
页:
[1]