请问可以直接USB烧录吗?
552可以啊
]]>以前用CH552G做过烧录器,5V 3.3V芯片都可以用,支持页读写,
CH552很不错的,
http://www.wch.cn/bbs/thread-66188-1.html
这是我自己做的软件截图
好强大!
]]>以下 @晕哥 搬运 添加:
--------------------------------
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <libusb-1.0/libusb.h>
#define USB_VID 0x1fc8
#define USB_PID 0x300b
#define INTERFACE_NUM 0
#define ENDPOINT_A 0x02
#define ENDPOINT_B 0x82
/* For USB communication */
#define TMOUT 500
#define LENGTH 64
libusb_device_handle *burner_hand;
void dumpit(int x, unsigned char msg[], int len)
{
int i;
if (len == 0)
return;
printf("%3d: ", x);
for (i = 0; i < len; i++)
printf("%02x ", msg[i]);
printf("\n");
}
int start_burner()
{
int i;
int j;
int ret;
int received;
int ok;
unsigned char msg[LENGTH];
if (burner_hand == NULL)
{
/* Initialize libusb */
if ((ret = libusb_init(NULL)))
return ret;
/* Get a handle for the device */
if ((burner_hand = libusb_open_device_with_vid_pid(NULL, USB_VID, USB_PID)) == NULL)
{
libusb_exit(NULL);
return -100;
}
/* Detach any kernel driver */
if ((ret = libusb_kernel_driver_active(burner_hand, 0)))
{
if ((ret = libusb_detach_kernel_driver(burner_hand, 0)))
{
stop_burner();
return ret;
}
}
/* Claim the device */
/* Interface 0 is audio. Interface 1 is control */
if ((ret = libusb_claim_interface(burner_hand, INTERFACE_NUM)))
{
printf(" 33333333333333 \n");
stop_burner();
return ret;
}
}
memset(msg, 0, sizeof(msg));
//0x00, 0x09, 0x00, 0x00, 0x01, 0x00, 0x03, 0xE8, 0x02, 0x00, 0x00, 0x00, 0x00, 0xEF, 0x40, 0x19
msg[0] = 0x00;
msg[1] = 0x09;
msg[2] = 0x00;
msg[3] = 0x00;
msg[4] = 0x01;
msg[5] = 0x00;
msg[6] = 0x03;
msg[7] = 0xE8;
msg[8] = 0x02;
msg[9] = 0x00;
msg[10] = 0x00;
msg[11] = 0x00;
msg[12] = 0x00;
msg[13] = 0xEF;
msg[14] = 0x40;
msg[15] = 0x19;
if ((ok = libusb_bulk_transfer(burner_hand, ENDPOINT_A, msg, 64, &received, TMOUT)))
exit(2);
printf("Sent %d %d\n", ok, received);
if ((ok = libusb_bulk_transfer(burner_hand, ENDPOINT_B, msg, LENGTH, &received, 5*TMOUT)))
; //exit(2);
printf("Received %d %d\n", ok, received);
dumpit(0, msg, received);
return 0;
}
int stop_burner(void)
{
int ret;
if (burner_hand)
{
/* Release claimed interface */
ret = libusb_release_interface(burner_hand, INTERFACE_NUM);
if (ret && (ret != LIBUSB_ERROR_NO_DEVICE))
{
/* Close opened interface */
libusb_close(burner_hand);
burner_hand = NULL;
return ret;
}
#if 0
if (ret != LIBUSB_ERROR_NO_DEVICE)
{
/* Re-attach kernel driver */
if ((ret = libusb_attach_kernel_driver(burner_hand, 0)))
return ret;
}
#endif
/* Close opened interface */
libusb_close(burner_hand);
burner_hand = NULL;
/* Stop using libusb */
libusb_exit(NULL);
}
return 0;
}
int main(int argc, char *argv[])
{
if (start_burner())
{
printf("Failed to connect to burner\n");
exit(2);
}
if (stop_burner())
{
printf("Failed to disconnect from burner\n");
exit(2);
}
else
{
printf("Disconnect from burner sucessful!\n");
}
return 0;
}
Ubuntu编译方法:
gcc -o test usbtest.c -lusb-1.0
]]>
抓了一下点击检测按钮时候的通讯协议。
软件发送:
[0x00, 0x09, 0x00, 0x00, 0x01, 0x00, 0x03, 0xE8, 0x02, 0x00, 0x00, 0x00, 0x00, 0xEF, 0x40, 0x19]
晕哥 说:https://whycan.cn/files/members/3/QQ20190202142325.png
这就尴尬了, 这个烧录器没有这玩意,想改装成开发板还得补个电阻和按键。
CH552的串口下载支持无需手动进boot,上电即可下载。
试了一下手上这块 CH559L 开发板果然可以串口下载,
只是上面这个 CH552G 烧录器貌似烧录串口也没有引出。
https://whycan.cn/files/members/3/QQ20190202142325.png
这就尴尬了, 这个烧录器没有这玩意,想改装成开发板还得补个电阻和按键。
CH552的串口下载支持无需手动进boot,上电即可下载。
]]>用官方例程自带的 VendorDefinedDev.c,
zadig-2.3.exe 安装 libusb-win32 驱动,
然后配合以前写的 libusb 上位机,
轻轻松松实现通讯.
]]>D+ 接一个电阻上拉到 VCC, 中间串一个按钮,按下按钮,插入USB, 电脑会出现一个USB设备, 可以用官方的烧录软件烧录了.
]]>