Docker環(huán)境下WCHLink環(huán)境如何搭建?

在虛擬機(jī)可以正常運(yùn)行官網(wǎng)提供的 openocd 工具,但是將其移動(dòng)到docker環(huán)境后,和主機(jī)共享設(shè)備。Docker 內(nèi) lsusb 可以識(shí)別出來usb設(shè)備


qomolink@c6b6d755ebf5:/tools/MRS_Toolchain_Linux_x64_V1.92.1/beforeinstall$?lsusb
Bus?002?Device?001:?ID?1d6b:0003?Linux?Foundation?3.0?root?hub
Bus?001?Device?003:?ID?1a86:8010?QinHeng?Electronics?
Bus?001?Device?001:?ID?1d6b:0002?Linux?Foundation?2.0?root?hub


但是詳細(xì)展示出來的話就感覺缺少了一些東西


qomolink@c6b6d755ebf5:/tools/MRS_Toolchain_Linux_x64_V1.92.1/beforeinstall$?lsusb?-s?001:003?-v

Bus?001?Device?003:?ID?1a86:8010?QinHeng?Electronics?
Couldn't?open?device,?some?information?will?be?missing
Device?Descriptor:
??bLength????????????????18
??bDescriptorType?????????1
??bcdUSB???????????????1.10
??bDeviceClass??????????239?Miscellaneous?Device
??bDeviceSubClass?????????2??
??bDeviceProtocol?????????1?Interface?Association
??bMaxPacketSize0????????64
??idVendor???????????0x1a86?QinHeng?Electronics
??idProduct??????????0x8010?
??bcdDevice????????????2.12
??iManufacturer???????????1?
??iProduct????????????????2?
??iSerial?????????????????3?
??bNumConfigurations??????1
??Configuration?Descriptor:
????bLength?????????????????9
????bDescriptorType?????????2
????wTotalLength??????????120
????bNumInterfaces??????????3
????bConfigurationValue?????1
????iConfiguration??????????0?
????bmAttributes?????????0x80
??????(Bus?Powered)
????MaxPower??????????????100mA
????Interface?Association:
??????bLength?????????????????8
??????bDescriptorType????????11
??????bFirstInterface?????????0
??????bInterfaceCount?????????1
??????bFunctionClass????????255?Vendor?Specific?Class
??????bFunctionSubClass???????0?
??????bFunctionProtocol???????0?
??????iFunction???????????????2?
????Interface?Descriptor:
??????bLength?????????????????9
??????bDescriptorType?????????4
??????bInterfaceNumber????????0
??????bAlternateSetting???????0
??????bNumEndpoints???????????4
??????bInterfaceClass???????255?Vendor?Specific?Class
??????bInterfaceSubClass????128?
??????bInterfaceProtocol?????85?
??????iInterface??????????????0?
??????Endpoint?Descriptor:
????????bLength?????????????????7
????????bDescriptorType?????????5
????????bEndpointAddress?????0x82??EP?2?IN
????????bmAttributes????????????2
??????????Transfer?Type????????????Bulk
??????????Synch?Type???????????????None
??????????Usage?Type???????????????Data
????????wMaxPacketSize?????0x0040??1x?64?bytes
????????bInterval???????????????0
??????Endpoint?Descriptor:
????????bLength?????????????????7
????????bDescriptorType?????????5
????????bEndpointAddress?????0x02??EP?2?OUT
????????bmAttributes????????????2
??????????Transfer?Type????????????Bulk
??????????Synch?Type???????????????None
??????????Usage?Type???????????????Data
????????wMaxPacketSize?????0x0040??1x?64?bytes
????????bInterval???????????????0
??????Endpoint?Descriptor:
????????bLength?????????????????7
????????bDescriptorType?????????5
????????bEndpointAddress?????0x81??EP?1?IN
????????bmAttributes????????????2
??????????Transfer?Type????????????Bulk
??????????Synch?Type???????????????None
??????????Usage?Type???????????????Data
????????wMaxPacketSize?????0x0040??1x?64?bytes
????????bInterval???????????????0
??????Endpoint?Descriptor:
????????bLength?????????????????7
????????bDescriptorType?????????5
????????bEndpointAddress?????0x01??EP?1?OUT
????????bmAttributes????????????2
??????????Transfer?Type????????????Bulk
??????????Synch?Type???????????????None
??????????Usage?Type???????????????Data
????????wMaxPacketSize?????0x0040??1x?64?bytes
????????bInterval???????????????0
????Interface?Association:
??????bLength?????????????????8
??????bDescriptorType????????11
??????bFirstInterface?????????1
??????bInterfaceCount?????????2
??????bFunctionClass??????????2?Communications
??????bFunctionSubClass???????2?Abstract?(modem)
??????bFunctionProtocol???????1?AT-commands?(v.25ter)
??????iFunction???????????????4?
????Interface?Descriptor:
??????bLength?????????????????9
??????bDescriptorType?????????4
??????bInterfaceNumber????????1
??????bAlternateSetting???????0
??????bNumEndpoints???????????1
??????bInterfaceClass?????????2?Communications
??????bInterfaceSubClass??????2?Abstract?(modem)
??????bInterfaceProtocol??????1?AT-commands?(v.25ter)
??????iInterface??????????????0?
??????CDC?Header:
????????bcdCDC???????????????1.10
??????CDC?Call?Management:
????????bmCapabilities???????0x00
????????bDataInterface??????????1
??????CDC?ACM:
????????bmCapabilities???????0x02
??????????line?coding?and?serial?state
??????CDC?Union:
????????bMasterInterface????????1
????????bSlaveInterface?????????2?
??????Endpoint?Descriptor:
????????bLength?????????????????7
????????bDescriptorType?????????5
????????bEndpointAddress?????0x84??EP?4?IN
????????bmAttributes????????????3
??????????Transfer?Type????????????Interrupt
??????????Synch?Type???????????????None
??????????Usage?Type???????????????Data
????????wMaxPacketSize?????0x0040??1x?64?bytes
????????bInterval???????????????1
????Interface?Descriptor:
??????bLength?????????????????9
??????bDescriptorType?????????4
??????bInterfaceNumber????????2
??????bAlternateSetting???????0
??????bNumEndpoints???????????2
??????bInterfaceClass????????10?CDC?Data
??????bInterfaceSubClass??????0?Unused
??????bInterfaceProtocol??????0?
??????iInterface??????????????0?
??????Endpoint?Descriptor:
????????bLength?????????????????7
????????bDescriptorType?????????5
????????bEndpointAddress?????0x83??EP?3?IN
????????bmAttributes????????????2
??????????Transfer?Type????????????Bulk
??????????Synch?Type???????????????None
??????????Usage?Type???????????????Data
????????wMaxPacketSize?????0x0040??1x?64?bytes
????????bInterval???????????????0
??????Endpoint?Descriptor:
????????bLength?????????????????7
????????bDescriptorType?????????5
????????bEndpointAddress?????0x03??EP?3?OUT
????????bmAttributes????????????2
??????????Transfer?Type????????????Bulk
??????????Synch?Type???????????????None
??????????Usage?Type???????????????Data
????????wMaxPacketSize?????0x0040??1x?64?bytes
????????bInterval???????????????0

和宿主機(jī)里面不一樣:

binwatson@LAPTOP-0GJDRKKJ:~/docker/development_environment_docker/ch32$?lsusb?-v?-s?001:003

Bus?001?Device?003:?ID?1a86:8010?QinHeng?Electronics?
Device?Descriptor:
??bLength????????????????18
??bDescriptorType?????????1
??bcdUSB???????????????1.10
??bDeviceClass??????????239?Miscellaneous?Device
??bDeviceSubClass?????????2??
??bDeviceProtocol?????????1?Interface?Association
??bMaxPacketSize0????????64
??idVendor???????????0x1a86?QinHeng?Electronics
??idProduct??????????0x8010?
??bcdDevice????????????2.12
??iManufacturer???????????1?wch.cn
??iProduct????????????????2?WCH-Link
??iSerial?????????????????3?BC66DF7E9BE4
??bNumConfigurations??????1
??Configuration?Descriptor:
????bLength?????????????????9
????bDescriptorType?????????2
????wTotalLength??????????120
????bNumInterfaces??????????3
????bConfigurationValue?????1
????iConfiguration??????????0?
????bmAttributes?????????0x80
??????(Bus?Powered)
????MaxPower??????????????100mA
????Interface?Association:
??????bLength?????????????????8
??????bDescriptorType????????11
??????bFirstInterface?????????0
??????bInterfaceCount?????????1
??????bFunctionClass????????255?Vendor?Specific?Class
??????bFunctionSubClass???????0?
??????bFunctionProtocol???????0?
??????iFunction???????????????2?WCH-Link
????Interface?Descriptor:
??????bLength?????????????????9
??????bDescriptorType?????????4
??????bInterfaceNumber????????0
??????bAlternateSetting???????0
??????bNumEndpoints???????????4
??????bInterfaceClass???????255?Vendor?Specific?Class
??????bInterfaceSubClass????128?
??????bInterfaceProtocol?????85?
??????iInterface??????????????0?
??????Endpoint?Descriptor:
????????bLength?????????????????7
????????bDescriptorType?????????5
????????bEndpointAddress?????0x82??EP?2?IN
????????bmAttributes????????????2
??????????Transfer?Type????????????Bulk
??????????Synch?Type???????????????None
??????????Usage?Type???????????????Data
????????wMaxPacketSize?????0x0040??1x?64?bytes
????????bInterval???????????????0
??????Endpoint?Descriptor:
????????bLength?????????????????7
????????bDescriptorType?????????5
????????bEndpointAddress?????0x02??EP?2?OUT
????????bmAttributes????????????2
??????????Transfer?Type????????????Bulk
??????????Synch?Type???????????????None
??????????Usage?Type???????????????Data
????????wMaxPacketSize?????0x0040??1x?64?bytes
????????bInterval???????????????0
??????Endpoint?Descriptor:
????????bLength?????????????????7
????????bDescriptorType?????????5
????????bEndpointAddress?????0x81??EP?1?IN
????????bmAttributes????????????2
??????????Transfer?Type????????????Bulk
??????????Synch?Type???????????????None
??????????Usage?Type???????????????Data
????????wMaxPacketSize?????0x0040??1x?64?bytes
????????bInterval???????????????0
??????Endpoint?Descriptor:
????????bLength?????????????????7
????????bDescriptorType?????????5
????????bEndpointAddress?????0x01??EP?1?OUT
????????bmAttributes????????????2
??????????Transfer?Type????????????Bulk
??????????Synch?Type???????????????None
??????????Usage?Type???????????????Data
????????wMaxPacketSize?????0x0040??1x?64?bytes
????????bInterval???????????????0
????Interface?Association:
??????bLength?????????????????8
??????bDescriptorType????????11
??????bFirstInterface?????????1
??????bInterfaceCount?????????2
??????bFunctionClass??????????2?Communications
??????bFunctionSubClass???????2?Abstract?(modem)
??????bFunctionProtocol???????1?AT-commands?(v.25ter)
??????iFunction???????????????4?WCH-Link
????Interface?Descriptor:
??????bLength?????????????????9
??????bDescriptorType?????????4
??????bInterfaceNumber????????1
??????bAlternateSetting???????0
??????bNumEndpoints???????????1
??????bInterfaceClass?????????2?Communications
??????bInterfaceSubClass??????2?Abstract?(modem)
??????bInterfaceProtocol??????1?AT-commands?(v.25ter)
??????iInterface??????????????0?
??????CDC?Header:
????????bcdCDC???????????????1.10
??????CDC?Call?Management:
????????bmCapabilities???????0x00
????????bDataInterface??????????1
??????CDC?ACM:
????????bmCapabilities???????0x02
??????????line?coding?and?serial?state
??????CDC?Union:
????????bMasterInterface????????1
????????bSlaveInterface?????????2?
??????Endpoint?Descriptor:
????????bLength?????????????????7
????????bDescriptorType?????????5
????????bEndpointAddress?????0x84??EP?4?IN
????????bmAttributes????????????3
??????????Transfer?Type????????????Interrupt
??????????Synch?Type???????????????None
??????????Usage?Type???????????????Data
????????wMaxPacketSize?????0x0040??1x?64?bytes
????????bInterval???????????????1
????Interface?Descriptor:
??????bLength?????????????????9
??????bDescriptorType?????????4
??????bInterfaceNumber????????2
??????bAlternateSetting???????0
??????bNumEndpoints???????????2
??????bInterfaceClass????????10?CDC?Data
??????bInterfaceSubClass??????0?Unused
??????bInterfaceProtocol??????0?
??????iInterface??????????????0?
??????Endpoint?Descriptor:
????????bLength?????????????????7
????????bDescriptorType?????????5
????????bEndpointAddress?????0x83??EP?3?IN
????????bmAttributes????????????2
??????????Transfer?Type????????????Bulk
??????????Synch?Type???????????????None
??????????Usage?Type???????????????Data
????????wMaxPacketSize?????0x0040??1x?64?bytes
????????bInterval???????????????0
??????Endpoint?Descriptor:
????????bLength?????????????????7
????????bDescriptorType?????????5
????????bEndpointAddress?????0x03??EP?3?OUT
????????bmAttributes????????????2
??????????Transfer?Type????????????Bulk
??????????Synch?Type???????????????None
??????????Usage?Type???????????????Data
????????wMaxPacketSize?????0x0040??1x?64?bytes
????????bInterval???????????????0
Device?Status:?????0x47c0
??(Bus?Powered)
??Debug?Mode


然后在 Docker 里面執(zhí)行

qomolink@c6b6d755ebf5:/tools/MRS_Toolchain_Linux_x64_V1.92.1/OpenOCD/bin$?./openocd?-f?wch-riscv.cfg?
Open?On-Chip?Debugger?0.11.0+dev-02415-gfad123a16-dirty?(2024-11-11-16:29)
Licensed?under?GNU?GPL?v2
For?bug?reports,?read
????????http://openocd.org/doc/doxygen/bugs.html
Info?:?only?one?transport?option;?autoselect?'sdi'
Warn?:?Transport?"sdi"?was?already?selected
Ready?for?Remote?Connections
Info?:?Listening?on?port?6666?for?tcl?connections
Info?:?Listening?on?port?4444?for?telnet?connections
Error:?libusb_open()?failed?with?LIBUSB_ERROR_ACCESS
Error:?open?failed


在宿主機(jī)就是正常的

binwatson@LAPTOP-0GJDRKKJ:~/docker/development_environment_docker/ch32/MRS_Toolchain_Linux_x64_V1.92.1/OpenOCD/bin$?./openocd?-f?w
ch-riscv.cfg?
Open?On-Chip?Debugger?0.11.0+dev-02415-gfad123a16-dirty?(2024-11-11-16:29)
Licensed?under?GNU?GPL?v2
For?bug?reports,?read
????????http://openocd.org/doc/doxygen/bugs.html
Info?:?only?one?transport?option;?autoselect?'sdi'
Warn?:?Transport?"sdi"?was?already?selected
Ready?for?Remote?Connections
Info?:?Listening?on?port?6666?for?tcl?connections
Info?:?Listening?on?port?4444?for?telnet?connections
Info?:?WCH-Link-CH549??mode:RV?version?2.12?
Info?:?wlink_init?ok
Info?:?clock?speed?6000?kHz
Info?:?[wch_riscv.cpu.0]?datacount=2?progbufsize=8
Info?:?[wch_riscv.cpu.0]?Examined?RISC-V?core;?found?1?harts
Info?:?[wch_riscv.cpu.0]??XLEN=32,?misa=0x40901125
[wch_riscv.cpu.0]?Target?successfully?examined.
Info?:?starting?gdb?server?for?wch_riscv.cpu.0?on?3333
Info?:?Listening?on?port?3333?for?gdb?connections



找到問題了??!


Docker 內(nèi)執(zhí)行下面這條指令出現(xiàn)?

Couldn't?open?device,?some?information?will?be?missing
qomolink@c6b6d755ebf5:/tools/MRS_Toolchain_Linux_x64_V1.92.1/beforeinstall$?lsusb?-s?001:003?-v

Bus?001?Device?003:?ID?1a86:8010?QinHeng?Electronics?
Couldn't?open?device,?some?information?will?be?missing
Device?Descriptor:

是因?yàn)槲沂褂玫牟皇?root 用戶,加上 sudo lsusb -s 001:003 -v 就正常了。


因此,如果需要執(zhí)行 openocd 的話 也需要加上 sudo openocd -f wch-riscv.cfg 就正常了??

qomolink@6a2ebc8b487a:/tools/MRS_Toolchain_Linux_x64_V1.92.1/OpenOCD/bin$?sudo?openocd?-f?wch-riscv.cfg?
Open?On-Chip?Debugger?0.11.0+dev-02415-gfad123a16-dirty?(2024-11-11-16:29)
Licensed?under?GNU?GPL?v2
For?bug?reports,?read
????????http://openocd.org/doc/doxygen/bugs.html
Info?:?only?one?transport?option;?autoselect?'sdi'
Warn?:?Transport?"sdi"?was?already?selected
Ready?for?Remote?Connections
Info?:?Listening?on?port?6666?for?tcl?connections
Info?:?Listening?on?port?4444?for?telnet?connections
Info?:?WCH-Link-CH549??mode:RV?version?2.12?
Info?:?wlink_init?ok
Info?:?clock?speed?6000?kHz
Info?:?[wch_riscv.cpu.0]?datacount=2?progbufsize=8
Info?:?[wch_riscv.cpu.0]?Examined?RISC-V?core;?found?1?harts
Info?:?[wch_riscv.cpu.0]??XLEN=32,?misa=0x40901125
[wch_riscv.cpu.0]?Target?successfully?examined.
Info?:?starting?gdb?server?for?wch_riscv.cpu.0?on?3333
Info?:?Listening?on?port?3333?for?gdb?connections

希望我踩的坑,對(duì)大家有幫助。


Docker 的好處就是搭建的環(huán)境不會(huì)對(duì)宿主機(jī)有影響,畢竟 ./start.sh 會(huì)往宿主機(jī)里面塞東西....


sudo 是懶辦法吧,歸根結(jié)底是權(quán)限問題。

你所嫌棄的“往宿主機(jī)里面塞東西”其實(shí)就包含了權(quán)限配置啊,讓 Link-E 的組是 plugdev,然后你用戶也加入這個(gè)組,就可以正常訪問了。


docker的USB熱插拔支持還是挺差的。

2017年有一篇?https://pic.huodongjia.com/ganhuodocs/2017-08-18/1503028636.63.pdf?提到用mknod加載,我也是這么干的,確實(shí)能支持新插入硬件。不知道有沒有更好更簡單的辦法。



只有登錄才能回復(fù),可以選擇微信賬號(hào)登錄

国产91精品新入口,国产成人综合网在线播放,九热这里只有精品,本道在线观看,美女视频a美女视频,韩国美女激情视频,日本美女pvp视频