pyswd
pyswd copied to clipboard
ST-Link not detected
Hi Pavel,
I just installed swd and wrote a small program to start with. But it does not find my ST-Link V3 nor a STM32-Nucleo board. I found issue #15 which looked for all devices and copied that to my program, so I hav this now:
#!/usr/bin/env python3
# coding: utf-8
import sys
import swd
import usb
def main ():
devices = []
# dev = usb.core.find(idVendor = 0x0483, idProduct = 0x374B, iProduct = 0x5, find_all = True)
dev = usb.core.find(find_all = True)
for device in dev:
devices.append (device)
print (hex(device.idVendor), hex(device.idProduct), device.serial_number)
STLink = swd.Swd (swd_frequency=4000000, serial_no='')
print (STLink)
if __name__ == '__main__':
sys.exit(main())
it produces this output:
0x4f2 0xb613 None
0x4f2 0xb604 0001
Traceback (most recent call last):
File "E:\Projects\Software\Python\PySWD_Test\source\PySWD_Test.py", line 22, in <module>
sys.exit(main())
File "E:\Projects\Software\Python\PySWD_Test\source\PySWD_Test.py", line 17, in main
STLink = swd.Swd (swd_frequency=4000000, serial_no='')
File "C:\Users\Martin\AppData\Roaming\Python\Python310\site-packages\swd\swd.py", line 15, in __init__
driver = _Stlink(
File "C:\Users\Martin\AppData\Roaming\Python\Python310\site-packages\swd\stlink\__init__.py", line 114, in __init__
usb = _usb.StlinkUsb(serial_no, debug=debug)
File "C:\Users\Martin\AppData\Roaming\Python\Python310\site-packages\swd\stlink\usb.py", line 222, in __init__
raise NoDeviceFoundException()
swd.stlink.usb.NoDeviceFoundException
With the upper dev = ... line nothing is found I changed idProduct to 0x374B (instead of 0x374F as in issue #15), because I found this value in Windows device manager. I'm running Python 3.10 under Win 10 (also swd.Swd () does not accept a keyword argument 'logger': error message is :TypeError: Swd.init() got an unexpected keyword argument 'logger')
Thanks for any help Martin