CH55x使用Arduino编程记录(二)

坑二

从闲鱼买了一管磨了标的ch552t,烧录时报错
https://github.com/DeqingSun/ch55xduino/issues/44

找到烧录时用的vnproch55x.exe手动烧录,报同样的错误

使用“导出已编译的二进制文件”功能,用官方的WCHISPTool烧录,可以正常识别并烧录运行

使用在线工具https://deqingsun.github.io/ch55xduino/bootloaderWebtool/烧录,报错 MCU family Not support

down下来ch55xbl.js的源码,发现这个报错是由

//detect MCU
    await device.transferOut(endpointOut, (new Uint8Array(bootloaderDetectCmd)).buffer)
    result = await device.transferIn(endpointIn, 64);
    resultUint8 = new Uint8Array(result.data.buffer)
    bootloaderDeviceID = resultUint8[4]
    if (resultUint8[5] != 0x11) {
        statusDiv.innerHTML = 'MCU family Not support';
        return 0;
    }
    if (![0x51, 0x52, 0x54, 0x58, 0x59].includes(bootloaderDeviceID)) {
        statusDiv.innerHTML = 'Device not supported 0x' + bootloaderDeviceID.toString(16);
        return 0;
    }

这部分引起的

修改代码加入控制台输出https://github.com/DeqingSun/ch55xduino/issues/44#issuecomment-810809585

//detect MCU
    await device.transferOut(endpointOut, (new Uint8Array(bootloaderDetectCmd)).buffer)
    //await device.transferOut(endpointOut, (new Uint8Array(bootloaderIDCmd)).buffer)
    result = await device.transferIn(endpointIn, 64);  
    resultUint8 = new Uint8Array(result.data.buffer)
    bootloaderDeviceID = resultUint8[4]
    console.log(result.data.buffer);
    console.log(resultUint8[4]);
    console.log(resultUint8[5]);
    if (resultUint8[5] != 0x11) {
        
        statusDiv.innerHTML = 'MCU family Not support';
        return 0;
    }
    if (![0x51, 0x52, 0x54, 0x58, 0x59].includes(bootloaderDeviceID)) {
        statusDiv.innerHTML = 'Device not supported 0x' + bootloaderDeviceID.toString(16);
        return 0;
    }

使用CH552T时控制台打印

ArrayBuffer(2) {}byteLength: (...)__proto__: ArrayBuffer[[Int8Array]]: Int8Array(2)[[Uint8Array]]: Uint8Array(2)[[Int16Array]]: Int16Array(1)[[ArrayBufferByteLength]]: 2[[ArrayBufferData]]: "0x314400e08060"
ch55xbl.js:85 undefined
ch55xbl.js:86 undefined

而其他设备打印

ArrayBuffer(6) {}byteLength: (...)__proto__: ArrayBuffer[[Int8Array]]: Int8Array(6)[[Uint8Array]]: Uint8Array(6)[[Int16Array]]: Int16Array(3)[[ArrayBufferByteLength]]: 6[[ArrayBufferData]]: "0x314400e08030"
ch55xbl.js:85 81
ch55xbl.js:86 17

就很奇怪,为什么552t读不出来内容

https://github.com/DeqingSun/ch55xduino/issues/44#issuecomment-811054140


才知道CH552T有好几个bootloader版本1.0, 2.3.1, 2.4.0
而vnproch55x只支持2.3和2.4版本的bootloader

https://github.com/ole00/chprog
https://github.com/rgwan/librech551
这个支持1.0版本的,测试过可以正常烧录,但是用的是bin文件而不是hex文件所以需要手动转换一下,而且需要libusb驱动

Start Hacking Arduino and Good Luck For Me!

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值