pystlink

2025-12-11 0 169

PYSTLINK

Python tool for manipulating with STM32 MCUs using ST-Link in-system programmer and debugger.

Goal

Goal of this project is to bring more flexible support for different MCUs, very simple command line interface, easier integration into Makefile for direct flashing or uploading program into SRAM and many more, simplest way to add support for new MCUs. Also any suggestions are welcome.

Features

  • running on Linux, Mac OS/X and Windows
  • simple command line interface
  • detect MCU
  • dump registers and memory
  • write registers
  • download memory to binary file
  • upload binary or SREC file into memory
  • FLASH binary or SREC file to all STM32
  • basic runtime control: reset, halt, step, run
  • support ST-Link/V2, ST-Link/V2-1 and ST-Link/V3

Planed features

  • FLASH support for other MCU types (STM32L)
  • FLASH information block (system memory, option bytes and OTP area)
  • connecting under RESET
  • stop Watchdog in debug mode to prevent device restart
  • allow to control breakpoints or watchpoints
  • support for more ST-Link devices connected at once
  • other file formats (SREC, HEX, ELF, …)
  • pip installer
  • proxy to GDB
  • and maybe GUI
  • support for ST-Link/V1 is NOT planed, use ST-Link/V2 or V2-1 instead

Install

Requirements

  • Python v3.7+ (tested with 3.8)
  • pyusb
  • libusb or any other libusb driver

    • for Windows download latest windows binaries and copy libusb-1.0.dll into Windows/System32 directory

pystlink

  • Download and unpack or git clone https://g**ithub.c*om/pavelrevak/pystlink.git
  • Connect ST-LINK
  • Run ./pystlink.py --help (or python3 pystlink.py ... – depend on python installation and architecture)

Help

usage: pystlink [-h] [-q | -i | -v | -d] [-V] [-c CPU] [-r] [-u]
                [action [action ...]]

pystlink v0.0.0 (ST-LinkV2)
(c)2015 by pavel.revak@gmail.com
https://git*hub.**com/pavelrevak/pystlink

optional arguments:
  -h, --help         show this help message and exit
  -V, --version      show program\'s version number and exit
  -c CPU, --cpu CPU  set expected CPU type [eg: STM32F051, STM32L4]
  -r, --no-run       do not run core when program end (if core was halted)
  -u, --no-unmount   do not unmount DISCOVERY from ST-Link/V2-1 on OS/X platform

set verbosity level:
  -q, --quiet
  -i, --info         default
  -v, --verbose
  -d, --debug

actions:
  action             actions will be processed sequentially

list of available actions:
  dump:core              print all core registers (halt core)
  dump:{reg}             print core register (halt core)
  dump:{addr}:{size}     print content of memory
  dump:sram[:{size}]     print content of SRAM memory
  dump:flash[:{size}]    print content of FLASH memory
  dump:{addr}            print content of 32 bit memory register
  dump16:{addr}          print content of 16 bit memory register
  dump8:{addr}           print content of 8 bit memory register

  set:{reg}:{data}     set register (halt core)
  set:{addr}:{data}    set 32 bit memory register

  read:{addr}:{size}:{file}      read memory with size into file
  read:sram[:{size}]:{file}      read SRAM into file
  read:flash[:{size}]:{file}     read FLASH into file

  fill:{addr}:{size}:{pattern}   fill memory with a pattern
  fill:sram[:{size}]:{pattern}   fill SRAM memory with a pattern

  write:{file.srec}     write SREC file into memory
  write:{addr}:{file}   write binary file into memory
  write:sram:{file}     write binary file into SRAM memory

  flash:erase            complete erase FLASH memory aka mass erase
  flash[:erase][:verify]:{file.srec}     erase + flash SREC file + verify
  flash[:erase][:verify][:{addr}]:{file} erase + flash binary file + verify

  reset                  reset core
  reset:halt             reset and halt core
  halt                   halt core
  step                   step core
  run                    run core

  sleep:{seconds}        sleep (float) - insert delay between commands

  (numerical values can be in different formats, like: 42, 0x2a, 0o52, 0b101010)

examples:
  pystlink.py --help
  pystlink.py -v --cpu STM32F051R8
  pystlink.py -q --cpu STM32F03 dump:flash dump:sram
  pystlink.py dump:0x08000000:256
  pystlink.py set:0x48000018:0x00000100 dump:0x48000014
  pystlink.py read:sram:256:aaa.bin read:flash:bbb.bin
  pystlink.py -r reset:halt set:pc:0x20000010 dump:pc core:step dump:all
  pystlink.py flash:erase:verify:app.bin
  pystlink.py flash:erase flash:verify:0x08010000:boot.bin

Supported programmers

From ST exists actually three different SWD programmers:

Full support:

  • ST-Link/V2
  • ST-Link/V2-1
  • ST-Link/V3

Not supported:

  • ST-Link/V1

Minimum recommended firmware version of ST-Link is V2J32xx or newer. Otherwise is recommended upgrade using ST-LINK firmware upgrade tool.

Supported MCUs

Currently almost all ST32 MCUs. There is script list_new_stm32.py which compare supported MCUs with all listed on st.com.

Not all MCUs are tested. Please report any problems to Issues tracker.

In WiKi is some basic info about STM32 naming: STM32 coding matrix

Legal

Code is under MIT license.

In general, this program is allowed to copy, share, change, use in commercial and without any limitations, but if you make some changes or updates then will be nice to share it.

Support is only by Issues tracker

PYSTLINK is inspired by OpenOCD, STLINK and lot of info is from sniffed USB communication with original ST-LINK program.

TAGS

ST-Link/V2, ST-Link/V3, stlink, SWD, Python, ARM, CortexM, STM32, debug, FLASH, USB

下载源码

通过命令行克隆项目:

git clone https://github.com/pavelrevak/pystlink.git

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

申明:本文由第三方发布,内容仅代表作者观点,与本网站无关。对本文以及其中全部或者部分内容的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。本网发布或转载文章出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,也不代表本网对其真实性负责。

左子网 建站资源 pystlink https://www.zuozi.net/34822.html

OmegleMiddleMan
上一篇: OmegleMiddleMan
modern font stacks
下一篇: modern font stacks
常见问题
  • 1、自动:拍下后,点击(下载)链接即可下载;2、手动:拍下后,联系卖家发放即可或者联系官方找开发者发货。
查看详情
  • 1、源码默认交易周期:手动发货商品为1-3天,并且用户付款金额将会进入平台担保直到交易完成或者3-7天即可发放,如遇纠纷无限期延长收款金额直至纠纷解决或者退款!;
查看详情
  • 1、描述:源码描述(含标题)与实际源码不一致的(例:货不对板); 2、演示:有演示站时,与实际源码小于95%一致的(但描述中有”不保证完全一样、有变化的可能性”类似显著声明的除外); 3、发货:不发货可无理由退款; 4、安装:免费提供安装服务的源码但卖家不履行的; 5、收费:价格虚标,额外收取其他费用的(但描述中有显著声明或双方交易前有商定的除外); 6、其他:如质量方面的硬性常规问题BUG等。 注:经核实符合上述任一,均支持退款,但卖家予以积极解决问题则除外。
查看详情
  • 1、左子会对双方交易的过程及交易商品的快照进行永久存档,以确保交易的真实、有效、安全! 2、左子无法对如“永久包更新”、“永久技术支持”等类似交易之后的商家承诺做担保,请买家自行鉴别; 3、在源码同时有网站演示与图片演示,且站演与图演不一致时,默认按图演作为纠纷评判依据(特别声明或有商定除外); 4、在没有”无任何正当退款依据”的前提下,商品写有”一旦售出,概不支持退款”等类似的声明,视为无效声明; 5、在未拍下前,双方在QQ上所商定的交易内容,亦可成为纠纷评判依据(商定与描述冲突时,商定为准); 6、因聊天记录可作为纠纷评判依据,故双方联系时,只与对方在左子上所留的QQ、手机号沟通,以防对方不承认自我承诺。 7、虽然交易产生纠纷的几率很小,但一定要保留如聊天记录、手机短信等这样的重要信息,以防产生纠纷时便于左子介入快速处理。
查看详情

相关文章

猜你喜欢
发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务