⭐ Star me on GitHub — it helps!
Python API to automate STMicroelectonics flash using ST-Link CLI Utility.
- pywin32
- pypiwin32
ST-Link V2 that comes with STMicroelectronics Nucleo development boards. These ST-Links also provide USB-to-Serial ports.
Download ST-Link Utility and install. Make sure to add the "ST-LINK_CLI.exe" 's directory in the PATH.
Check ST-Link Utility guide.
There aren't any installations. Clone the repository and use the methods. There are only two public methods:
- findall()
This method returns all the ST-Link Probe number and corresponding COM port number. - flash(hex_path, probe_no)
This method takes the hex file path and the probe number (default = 0). It returns status ('successful' / 'failed') and the checksum of the hex/binary file.
import stlink
if __name__ == '__main__':
print(stlink.findall())
status, checksum = stlink.flash('G:\\test.hex')
print(status)
Output:
[{'probe': '0', 'com': 'COM4'}]
successful