MiniProg4
PSoC Creator不支持JLink,真是可惜!官方的MiniProg4相当mini精巧,可惜价格高昂,接口又很不友好,Infineon的Github上有KitProg3的开源代码,除了实现了DAPLink的功能,还有USB转IIC、SPI等外扩功能,于是就借助于它开始拼凑我的MiniProg4!
参考文档:
KitProg3:github.com/infineon/kitprog3
Infineon-AN84858_PSoC4_Programming xxx
Infineon-KitProg_Host_Protocol_Interface-UserManual
MCU就选择之前申请的CH32V307/CH32F207剩余的样片吧,高速USB,性能不弱接口丰富,加上个TFT和SD、SPI Flash还可以实现离线烧录功能,PCB在上次307的基础上简单修改了下就完成了。
首先实现设备的枚举:在CH32F207 HS USB CDC的例程上,按照MiniProg4的设备描述符上传所需的字符串即可。一番修改终于实现了:
HID接口的DAP我不需要,直接删掉,只保留了WINUSB的DAP、Bridge和虚拟串口,设备枚举成功后,算是迈出了第一步,接下来就开始APP的移植操作。
又一番操作后,终于可以在PSoC Programmer中下载程序了,通过IO控制对外电源的输出,实现了Power Cycle,对于未接XRES并且将SWD接口配置为GPIO的4014,使用Power Cycle模式也可以下载了,好开心~
剩下的就是USB 2 IIC、SPI的移植了,日后再搞。
补一个离线下载:(目前在线和离线都已支持)
参考AN84858,将HSSP代码添加进工程中,稍作修改即可。
目前CH32的SDIO还有bug,每次上电首次初始化sdio会卡死,复位一下即可重新运行。
TODO List:
- USB Bridge to IIC。
- USB MSC 及bootloader。
附 - 官方MiniProg4的设备描述符:(欢迎一起交流)
Device Descriptor:
bcdUSB: 0x0200
bDeviceClass: 0xEF
bDeviceSubClass: 0x02
bDeviceProtocol: 0x01
bMaxPacketSize0: 0x08 (8)
idVendor: 0x04B4 (Cypress Semiconductor)
idProduct: 0xF151
bcdDevice: 0x0101
iManufacturer: 0x01
0x0409: "Cypress Semiconductor"
iProduct: 0x09
0x0409: "Cypress MiniProg4 (CMSIS-DAP)"
0x0409: "Cypress MiniProg4 (CMSIS-DAP)"
0x0409: "Cypress MiniProg4 (CMSIS-DAP)"
iSerialNumber: 0x80
0x0409: "0E23018800121400"
bNumConfigurations: 0x01
ConnectionStatus: DeviceConnected
Current Config Value: 0x01
Device Bus Speed: Full
Device Address: 0x14
Open Pipes: 7
Endpoint Descriptor:
bEndpointAddress: 0x01 OUT
Transfer Type: Bulk
wMaxPacketSize: 0x0040 (64)
bInterval: 0x00
Endpoint Descriptor:
bEndpointAddress: 0x82 IN
Transfer Type: Bulk
wMaxPacketSize: 0x0040 (64)
bInterval: 0x00
Endpoint Descriptor:
bEndpointAddress: 0x86 IN
Transfer Type: Bulk
wMaxPacketSize: 0x0040 (64)
bInterval: 0x00
Endpoint Descriptor:
bEndpointAddress: 0x07 OUT
Transfer Type: Bulk
wMaxPacketSize: 0x0040 (64)
bInterval: 0x00
Endpoint Descriptor:
bEndpointAddress: 0x83 IN
Transfer Type: Interrupt
wMaxPacketSize: 0x0008 (8)
bInterval: 0x02
Endpoint Descriptor:
bEndpointAddress: 0x84 IN
Transfer Type: Bulk
wMaxPacketSize: 0x0040 (64)
bInterval: 0x00
Endpoint Descriptor:
bEndpointAddress: 0x05 OUT
Transfer Type: Bulk
wMaxPacketSize: 0x0040 (64)
bInterval: 0x00
Configuration Descriptor:
wTotalLength: 0x0079
bNumInterfaces: 0x04
bConfigurationValue: 0x01
iConfiguration: 0x09
0x0409: "Cypress MiniProg4 (CMSIS-DAP)"
0x0409: "Cypress MiniProg4 (CMSIS-DAP)"
0x0409: "Cypress MiniProg4 (CMSIS-DAP)"
bmAttributes: 0x80 (Bus Powered )
MaxPower: 0xC8 (400 Ma)
Interface Descriptor:
bInterfaceNumber: 0x00
bAlternateSetting: 0x00
bNumEndpoints: 0x02
bInterfaceClass: 0xFF
bInterfaceSubClass: 0x00
bInterfaceProtocol: 0x00
iInterface: 0x09
0x0409: "Cypress MiniProg4 (CMSIS-DAP)"
0x0409: "Cypress MiniProg4 (CMSIS-DAP)"
0x0409: "Cypress MiniProg4 (CMSIS-DAP)"
Endpoint Descriptor:
bEndpointAddress: 0x01 OUT
Transfer Type: Bulk
wMaxPacketSize: 0x0040 (64)
bInterval: 0x00
Endpoint Descriptor:
bEndpointAddress: 0x82 IN
Transfer Type: Bulk
wMaxPacketSize: 0x0040 (64)
bInterval: 0x00
Interface Descriptor:
bInterfaceNumber: 0x01
bAlternateSetting: 0x00
bNumEndpoints: 0x02
bInterfaceClass: 0xFF
bInterfaceSubClass: 0x00
bInterfaceProtocol: 0x00
iInterface: 0x11
0x0409: "MiniProg4 bridge"
Endpoint Descriptor:
bEndpointAddress: 0x86 IN
Transfer Type: Bulk
wMaxPacketSize: 0x0040 (64)
bInterval: 0x00
Endpoint Descriptor:
bEndpointAddress: 0x07 OUT
Transfer Type: Bulk
wMaxPacketSize: 0x0040 (64)
bInterval: 0x00
Unknown Descriptor:
bDescriptorType: 0x0B
bLength: 0x08
08 0B 02 02 02 02 00 00
Interface Descriptor:
bInterfaceNumber: 0x02
bAlternateSetting: 0x00
bNumEndpoints: 0x01
bInterfaceClass: 0x02
bInterfaceSubClass: 0x02
bInterfaceProtocol: 0x01
iInterface: 0x0F
0x0409: "KitProg3 USBUART"
Unknown Descriptor:
bDescriptorType: 0x24
bLength: 0x05
05 24 00 10 01
Unknown Descriptor:
bDescriptorType: 0x24
bLength: 0x04
04 24 02 02
Unknown Descriptor:
bDescriptorType: 0x24
bLength: 0x05
05 24 06 02 03
Unknown Descriptor:
bDescriptorType: 0x24
bLength: 0x05
05 24 01 00 03
Endpoint Descriptor:
bEndpointAddress: 0x83 IN
Transfer Type: Interrupt
wMaxPacketSize: 0x0008 (8)
bInterval: 0x02
Interface Descriptor:
bInterfaceNumber: 0x03
bAlternateSetting: 0x00
bNumEndpoints: 0x02
bInterfaceClass: 0x0A
bInterfaceSubClass: 0x00
bInterfaceProtocol: 0x00
iInterface: 0x04
0x0409: "KitProg3 USBUART"
Endpoint Descriptor:
bEndpointAddress: 0x84 IN
Transfer Type: Bulk
wMaxPacketSize: 0x0040 (64)
bInterval: 0x00
Endpoint Descriptor:
bEndpointAddress: 0x05 OUT
Transfer Type: Bulk
wMaxPacketSize: 0x0040 (64)
bInterval: 0x00