Ну, точнее говоря, libjaylink совместимый - https://repo.or.cz/libjaylink.git
OpenOCD работает с j-link через libjaylink и принимает такой дебаггер за j-link
Протокол j-link опубликован - https://archive.org/details/segger-jlin … rotocol-r7
OpenOCD и libjaylink - open source
Жаль только, что openocd для j-link не настраивается на произвольные usb vid/pid, и приходится использовать segger-овские
Протоколы j-link и swd укладываются в 100 строчек кода - https://pastebin.com/ZzeuwdF5
Поскольку единственная привязка к мк там - это тип __xdata для xram в sdcc, то всё это легко переносится на любой мк
Для ch551 вся программа, использующая этот код, выглядит так:
#include <stdint.h> #include <string.h> #include <compiler.h> #include <8051.h> #include "timer.c" #include "usb.c" #include "gpio.c" #include "jay.c" void main ( void ) { timer_init(); usb_init(); jay_init(); loop: timer_poll(); usb_poll(); jay_poll( usb_buf1.r, &usb_len1.r, usb_buf1.t, &usb_len1.t ); GPIO_LED( timer_ms999 > 500 ); goto loop; }
USB дескрипторы:
---------------------- Device Descriptor ---------------------- bLength : 0x12 (18 bytes) bDescriptorType : 0x01 (Device Descriptor) bcdUSB : 0x110 (USB Version 1.10) bDeviceClass : 0x00 (defined by the interface descriptors) bDeviceSubClass : 0x00 bDeviceProtocol : 0x00 bMaxPacketSize0 : 0x08 (8 bytes) idVendor : 0x1366 idProduct : 0x0104 bcdDevice : 0x5504 iManufacturer : 0x00 (No String Descriptor) iProduct : 0x02 (String Descriptor 2) Language 0x0409 : "Jay" iSerialNumber : 0x03 (String Descriptor 3) Language 0x0409 : "12345" bNumConfigurations : 0x01 (1 Configuration) Data (HexDump) : 12 01 10 01 00 00 00 08 66 13 04 01 04 55 00 02 03 01 ------------------ Configuration Descriptor ------------------- bLength : 0x09 (9 bytes) bDescriptorType : 0x02 (Configuration Descriptor) wTotalLength : 0x0020 (32 bytes) bNumInterfaces : 0x01 (1 Interface) bConfigurationValue : 0x01 (Configuration 1) iConfiguration : 0x00 (No String Descriptor) bmAttributes : 0x80 D7: Reserved, set 1 : 0x01 D6: Self Powered : 0x00 (no) D5: Remote Wakeup : 0x00 (no) D4..0: Reserved, set 0 : 0x00 MaxPower : 0x64 (200 mA) Data (HexDump) : 09 02 20 00 01 01 00 80 64 09 04 00 00 02 FF FF FF 00 07 05 01 02 40 00 00 07 05 81 02 40 00 00 ---------------- Interface Descriptor ----------------- bLength : 0x09 (9 bytes) bDescriptorType : 0x04 (Interface Descriptor) bInterfaceNumber : 0x00 bAlternateSetting : 0x00 bNumEndpoints : 0x02 (2 Endpoints) bInterfaceClass : 0xFF (Vendor Specific) bInterfaceSubClass : 0xFF bInterfaceProtocol : 0xFF iInterface : 0x00 (No String Descriptor) Data (HexDump) : 09 04 00 00 02 FF FF FF 00 ----------------- Endpoint Descriptor ----------------- bLength : 0x07 (7 bytes) bDescriptorType : 0x05 (Endpoint Descriptor) bEndpointAddress : 0x01 (Direction=OUT EndpointID=1) bmAttributes : 0x02 (TransferType=Bulk) wMaxPacketSize : 0x0040 (64 bytes) bInterval : 0x00 (ignored) Data (HexDump) : 07 05 01 02 40 00 00 ----------------- Endpoint Descriptor ----------------- bLength : 0x07 (7 bytes) bDescriptorType : 0x05 (Endpoint Descriptor) bEndpointAddress : 0x81 (Direction=IN EndpointID=1) bmAttributes : 0x02 (TransferType=Bulk) wMaxPacketSize : 0x0040 (64 bytes) bInterval : 0x00 (ignored) Data (HexDump) : 07 05 81 02 40 00 00 -------------------- String Descriptors ------------------- ------ String Descriptor 0 ------ bLength : 0x04 (4 bytes) bDescriptorType : 0x03 (String Descriptor) Language ID[0] : 0x0409 (English - United States) Data (HexDump) : 04 03 09 04 ------ String Descriptor 2 ------ bLength : 0x08 (8 bytes) bDescriptorType : 0x03 (String Descriptor) Language 0x0409 : "Jay" Data (HexDump) : 08 03 4A 00 61 00 79 00 ------ String Descriptor 3 ------ bLength : 0x0C (12 bytes) bDescriptorType : 0x03 (String Descriptor) Language 0x0409 : "12345" Data (HexDump) : 0C 03 31 00 32 00 33 00 34 00 35 00
Готовая прошивка для ch551 и ch552 - https://pastebin.com/j6LEiiK3
Распиновка для этой прошивки:
P1.7 - SWCLK
P1.5 - SWDIO
P1.4 - RESET
P1.6 - LED
Отредактировано vt (2021-01-02 15:37:01)