====== USB Debugging with sigrok ======
Advanced USB packet capture with logic analyzers and sigrok.
* [[https://odysee.com/@OpenTechLab:f/otl-011-sigrok-usb-decoding:d|odysee]]
* [[https://www.youtube.com/watch?v=4FOkJLp_PUw|YouTube]]
* [[https://peertube.social/videos/watch/9b3e7d78-7b82-46c8-95b9-3203c5c423a2|peertube.social]]
===== Microcontroller =====
* [[http://www.st.com/en/microcontrollers/stm32f042k6.html|STM32F042K6]]
* [[http://www.st.com/resource/en/datasheet/stm32f042k6.pdf|Datasheet]]
* [[http://www.st.com/resource/en/reference_manual/dm00031936.pdf|Reference Manual]]
===== Test Tools =====
* [[https://www.banggood.com/3_3V-5V-XTW-ST-LINK-V2-STM8-STM32-Simulator-Programmer-Downloader-Debugger-With-20cm-Dupont-Wire-p-1177014.html?p=SD062212952342201708|ST-LINK Debugger on Banggood]] @ $3.60
* [[https://www.banggood.com/New-Upgrade-PL2303HX-USB-To-RS232-TTL-Chip-Converter-Adapter-Module-p-85993.html?p=SD062212952342201708|USB TTL RS232 adaptor]] @ $1.63
* [[http://dreamsourcelab.com/|DreamSourceLab]] DSLogic Plus Logic Analyzer
===== Software =====
* [[https://sigrok.org/|sigrok]]
* [[https://sigrok.org/wiki/PulseView|PulseView]]
* [[http://openocd.org/|OpenOCD]]
* [[http://libopencm3.org/|libopencm3]]
* [[https://walac.github.io/pyusb/|pyusb]]
* [[https://github.com/tmux/tmux/wiki|tmux]]
===== libopencm3 Bug =====
* [[https://github.com/libopencm3/libopencm3/issues/779|Issue 779]]
* [[https://github.com/libopencm3/libopencm3/pull/777|Pull 777]]
* [[https://github.com/libopencm3/libopencm3/pull/785|Pull 785]]
===== Source Code =====
==== Demo Firmware ====
* [[https://github.com/jhol/opencm3-usb-error-demo|Demo Firmware]]
==== control-test.py ====
#! /usr/bin/env python3
import usb.core
import time
dev = usb.core.find(idVendor=0x0925, idProduct=0xD100)
if dev is None:
raise ValueError('Device not found')
res = dev.ctrl_transfer(
bmRequestType=0x40, # OUT, VENDOR, DEVICE request
bRequest=1, # Request #1
wValue=0xCAFE,
wIndex=0xD00D,
data_or_wLength=[0x01, 0x23, 0x45, 0x67])