Giter VIP home page Giter VIP logo

pystlink's Issues

Support for STM32G0B1RET6

Hi, I have added the following lines in the DEVICES array in stm32devices.py under 'part_no': 0xc60 for the STM32G0B1RET6 support and it seems that it is working for me. I am not quite sure about the settings I choose for this part number, could you please double-check and let me know if I missed anything? Specifically, I cannot find information about the flash size register address (0x1fff75e0), the flash driver STM32L4 and the erase sizes:

'part_no': 0xc60,
'core': 'CortexM0+',
'idcode_reg': 0x40015800,
'devices': [ { 'dev_id': 0x467, 'flash_size_reg': 0x1fff75e0, 'flash_driver': 'STM32L4', 'erase_sizes': (2 * 1024, ), 'devices': [
{'type': 'STM32G0B1', 'flash_size': 512, 'sram_size': 144, 'eeprom_size': 0, 'freq': 64}, ], }, ],

Timeout error

i got *** Operation timeout *** error after execute this command my MCU is STM32L073RZ ?
PS D:\Projects\vantage-robotics\PC_App\utils\pystlink> python pystlink.py flash:verify:bin.bin
DEVICE: ST-Link/V2-1 V2J37M27
SUPPLY: 2.07V
CORE: CortexM0+
MCU: STM32L071xZ/STM32L072xZ/STM32L073xZ/STM32L081xZ/STM32L082xZ/STM32L083xZ
FLASH: 192KB
SRAM: 20KB
EEPROM: 6KB
Loaded 17332 Bytes from bin.bin file
Writing FLASH: [==== ] 12%
*** Operation timeout ***
PS D:\Projects\vantage-robotics\PC_App\utils\pystlink>

Wont run

Traceback (most recent call last):
File "pystlink.py", line 4, in
import lib.stlinkusb
File "/home/zaidshakil/TU Berlin/Robotics/pystlink/lib/stlinkusb.py", line 1, in
import usb.core
ImportError: No module named 'usb'

i keep getting this error, please suggest. I have updated the firmware

getting I/O error(13): Permission denied while flashing the new credentials into mcu through python

Hi

I am facing issue with flashing the mcu with new credentials using sigfox flasher and st link 32 utility with python(py charm) but i am able to do it manually with the command prompt but getting the error while executing with py-charm.
Below is the error mentioned:

I/O error(13): Permission denied

FYI:
I am running this command using command promt as administrator and also running py charm with administrator rights.

below is the command i am using :

SIGFOX_FLASHER"FEDCBA98;0102030405060708;0123456789ABCDEF0123456789ABCDEF;1;-1740;0;0" -e fixed -k 995511775533664400AABBCCDDEEFF00 -f D:\nishant\ID_PACK_Key.bin -w

output on command promt.

Encryption succeeded.
STM32L0 found. Programming...
Programming completed.

flashing_credentials

Please help me as i am struggling with this since very long time and not getting any solution.

Issue running flash

I am getting this error:

*** Parameter error: 'NoneType' object has no attribute 'bInterfaceNumber' ***

I am just running:

python3 pystlink.py flash:erase flash:verify:0x08000000:/home/automation/Downloads/ss2_firmware.bin

Note: I tried running via sudo and still same issue. I am running on Ubuntu 18.04.

pystlink as a library

Hi, great work on this implementation.

I'm in need to use this as a library in a python program I'm working on. I was able to take the lib folder, rename it to pystlink and change some imports from lib. to pystlink. and make it work as a library.

I see that pip install support is in the planed features. I think it would be a good idea to split the project up into two parts pystlink (library) and pystlink-cli (this application). That way pystlink-cli could just have a dependency on the library. I belive the library will need some improvemnets to make it easier to use and so on but I think this would be a good first start.

I want to avoid forking the project and doing it myself as I belive it's is better to focus on improving the original project. Thoughts?

Detecting disconnect between ST-Link and target

I'm looking for a way to determine if the link between the ST-Link and the target is broken. So far, the only way I've found is to update the target_voltage reading. I expected coreid to update if the link was unplugged but instead it seems to report a cached value. I want to do this to automate firmware downloads in a test fixture so that if a new target board was plugged in, a firmware download would automatically begin, similar to the auto-download capability of the ST-Link utility. I'm using Windows.

*** ST-Link/V2 is not connected ***

I think I am missing something obvious. My ST-Link/V2-1 can be detected by the ST-Link Utility. What are the possible reasons I am having this issue?

*** USB Error: [Errno 32] Pipe error ***

Freshly updated STLink2

[45228.161514] usb 1-2.4: new full-speed USB device number 15 using xhci_hcd
[45228.266791] usb 1-2.4: New USB device found, idVendor=0483, idProduct=3748
[45228.266793] usb 1-2.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[45228.266794] usb 1-2.4: Product: STM32 STLink
[45228.266795] usb 1-2.4: Manufacturer: STMicroelectronics
[45228.266797] usb 1-2.4: SerialNumber: Uÿl�I\xffffffc2\xffffff80IU7��\xffffffc2\xffffff87
> python3 pystlink.py  -d
Successfully connected to ST-Link/V2
  USB > f1 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 (read_version)
  USB > f1 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 (read_version)
  USB < 27 07 83 04 48 37
  USB > f5 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 (leave_state)
  USB < 01 00
  USB > f7 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 (read_target_voltage)
  USB < ed 05 00 00 ca 08 00 00
  USB > f2 43 01 00 00 00 00 00 00 00 00 00 00 00 00 00 (set_swd_freq)
  USB < 80 00
  USB > f2 30 a3 00 00 00 00 00 00 00 00 00 00 00 00 00 (enter_debug_swd)
  USB < 09 00
  USB > f2 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 (read_coreid)
*** USB Error: [Errno 32] Pipe error ***

** added method names to debugging output

It can't work with error '*** Error unlocking FLASH ***'

Hi, I trying flash stm32 device but no using Keil.
I Try it successfully on Ubuntu.

For Windows, I run into some error:

c:\Users\chen>py Documents\pystlink\pystlink.py flash:erase flash:xpfw.bin
DEVICE: ST-Link/V2 V2J21S4
SUPPLY: 3.26V
CORE:   CortexM0
MCU:    STM32F042x6/STM32F048x6/STM32F070x6
FLASH:  32KB
SRAM:   6KB
*** Error unlocking FLASH ***

but when I try it again with -d param:

pystlink.py flash:erase flash:xpfw.bin  -d > stdout.txt 2> stderr.txt

nothing in stdout.txt, and here is the content of stderr.txt :

Successfully connected to ST-Link/V2
  USB > f1 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  USB < 25 44 83 04 48 37
  USB > f5 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  USB < 02 00
  USB > f2 21 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  USB > f7 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  USB < ef 05 00 00 12 08 00 00
  USB > f2 30 a3 00 00 00 00 00 00 00 00 00 00 00 00 00
  USB < 80 00
  USB > f2 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  USB < 77 14 b1 0b
DEVICE: ST-Link/V2 V2J21S4
SUPPLY: 3.26V
COREID: 0bb11477
  USB > f2 36 00 ed 00 e0 00 00 00 00 00 00 00 00 00 00
  USB < 80 00 00 00 00 c2 0c 41
CPUID:  410cc200
CORE:   CortexM0
  USB > f2 36 00 58 01 40 00 00 00 00 00 00 00 00 00 00
  USB < 80 00 00 00 45 64 00 10
IDCODE: 10006445
  USB > f2 36 cc f7 ff 1f 00 00 00 00 00 00 00 00 00 00
  USB < 80 00 00 00 20 00 ff ff
MCU:    STM32F042x6/STM32F048x6/STM32F070x6
FLASH:  32KB
SRAM:   6KB
CMD: flash:erase
Stm32FP.flash_erase_all()
  USB > f7 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  USB < ef 05 00 00 15 08 00 00
Stm32.core_reset_halt()
  USB > f2 35 f0 ed 00 e0 03 00 5f a0 00 00 00 00 00 00
  USB < 80 00
  USB > f2 35 fc ed 00 e0 01 00 00 00 00 00 00 00 00 00
  USB < 80 00
  USB > f2 35 0c ed 00 e0 04 00 fa 05 00 00 00 00 00 00
  USB < 80 00
  USB > f2 36 0c ed 00 e0 00 00 00 00 00 00 00 00 00 00
  USB < 80 00 00 00 00 00 00 00
  USB > f2 36 10 20 02 40 00 00 00 00 00 00 00 00 00 00
  USB < 80 00 00 00 00 00 00 00
  USB > f2 36 10 20 02 40 00 00 00 00 00 00 00 00 00 00
  USB < 80 00 00 00 80 00 00 00
*** Error unlocking FLASH ***
Stm32.core_nodebug()
  USB > f2 35 f0 ed 00 e0 00 00 5f a0 00 00 00 00 00 00
  USB < 80 00
  USB > f5 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  USB < 02 00
  USB > f2 21 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  USB > f5 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  USB < 02 00
DONE in 0.17s
<... ...>
  USB < 80 00 00 00 20 00 00 00
  USB > f2 35 0c 20 02 40 20 00 00 00 00 00 00 00 00 00
  USB < 80 00
  USB > f2 35 10 20 02 40 80 00 00 00 00 00 00 00 00 00
  USB < 80 00
Stm32.core_reset_halt()
  USB > f2 35 f0 ed 00 e0 03 00 5f a0 00 00 00 00 00 00
  USB < 80 00
  USB > f2 35 fc ed 00 e0 01 00 00 00 00 00 00 00 00 00
  USB < 80 00
  USB > f2 35 0c ed 00 e0 04 00 fa 05 00 00 00 00 00 00
  USB < 80 00
  USB > f2 36 0c ed 00 e0 00 00 00 00 00 00 00 00 00 00
  USB < 80 00 00 00 00 00 05 fa
Writing FLASH: [========================================] done in 1.45s
Stm32.core_nodebug()
  USB > f2 35 f0 ed 00 e0 00 00 5f a0 00 00 00 00 00 00
  USB < 80 00
  USB > f5 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  USB < 02 00
  USB > f2 21 00 00 00 00 00 00 00 00 00 00 00 00 00 00
DONE in 1.75s

out

Upoload command not implemented?

I tried to upload short program to SRAM by using upload command like this:

python3 pystlink.py upload:bytesWrite.srec

but it gives me error

*** Bad param "upload:bytesWrite.srec" ***

When I look into the pystlink.py, it looks like upload command is not implemented in cmd method...?

Reset does not work with ST-LINK/V3

DEVICE: ST-Link/V3 V3J7M2B4S1
SUPPLY: 3.29V
COREID: 6ba02477
CPUID: 411fc271
CORE: CortexM7
MCU: STM32H743xI/STM32H753xI/STM32H745xI/STM32H755xI
FLASH: 2048KB
SRAM: 1024KB

Nothing happens when I reset. I have it working with a ST-LINK/V2 I have.

With the ST-LINK/V3:

Stm32.core_reset()
  USB > f2 35 fc ed 00 e0 00 00 00 00 00 00 00 00 00 00
  USB < 80 00
  USB > f2 35 0c ed 00 e0 04 00 fa 05 00 00 00 00 00 00
  USB < 80 00
  USB > f2 36 0c ed 00 e0 00 00 00 00 00 00 00 00 00 00
  USB < 80 00 00 00 00 00 05 fa

STM32FP - direct flashing is reverted

@UweBonnes make great work, but now I see that his patch don't work with STM32F0 (I don't make tests with other FP MCUs before merging)
Currently is the code reverted to flashing using microcode.
Also I don't understand why this e72aca9 ? because this stop currently running program in MCU but don't restart all the peripherals and it make many problems. reset_halt is not halt under reset but reset and halt on first address..

pystlink says it can't connect to CPU

$ python3 pystlink.py --debug
Successfully connected to ST-Link/V2
  USB > f1 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  USB < 26 04 83 04 48 37
  USB > f5 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  USB < 00 01
  USB > f3 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  USB > f7 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  USB < f2 05 00 00 fe 07 00 00
  USB > f2 43 01 00 00 00 00 00 00 00 00 00 00 00 00 00
  USB < 80 00
  USB > f2 30 a3 00 00 00 00 00 00 00 00 00 00 00 00 00
  USB < 80 00
  USB > f2 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  USB < 77 14 a0 2b
DEVICE: ST-Link/V2 V2J24S4
SUPPLY: 3.23V
COREID: 2ba01477
  USB > f2 36 00 ed 00 e0 00 00 00 00 00 00 00 00 00 00
  USB < 14 00 00 00 00 00 00 00
*** Not connected to CPU ***
  USB > f5 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  USB < 02 00
  USB > f2 21 00 00 00 00 00 00 00 00 00 00 00 00 00 00
DONE in 0.14s

But if I run OpenOCD first and then run pystlink.py, I get the following output:

$ python3 pystlink.py --debug
Successfully connected to ST-Link/V2
  USB > f1 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  USB < 26 04 83 04 48 37
  USB > f5 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  USB < 02 00
  USB > f2 21 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  USB > f7 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  USB < f2 05 00 00 fd 07 00 00
  USB > f2 43 01 00 00 00 00 00 00 00 00 00 00 00 00 00
  USB < 80 00
  USB > f2 30 a3 00 00 00 00 00 00 00 00 00 00 00 00 00
  USB < 80 00
  USB > f2 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  USB < 77 14 a0 2b
DEVICE: ST-Link/V2 V2J24S4
SUPPLY: 3.22V
COREID: 2ba01477
  USB > f2 36 00 ed 00 e0 00 00 00 00 00 00 00 00 00 00
  USB < 80 00 00 00 41 c2 0f 41
CPUID:  410fc241
CORE:   CortexM4
  USB > f2 36 00 20 04 e0 00 00 00 00 00 00 00 00 00 00
  USB < 80 00 00 00 31 64 00 10
IDCODE: 10006431
  USB > f2 36 20 7a ff 1f 00 00 00 00 00 00 00 00 00 00
  USB < 80 00 00 00 00 c0 00 02
MCU:    STM32F411xE
FLASH:  512KB
SRAM:   128KB
Stm32.core_nodebug()
  USB > f2 35 f0 ed 00 e0 00 00 5f a0 00 00 00 00 00 00
  USB < 80 00
  USB > f5 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  USB < 02 00
  USB > f2 21 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  USB > f5 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  USB < 01 00
DONE in 0.15s

I'm running OS X 10.11 with an eBay ST-Link v2 connected with a WiFiMCU/EMW3165.

question: nu-link programmer

I am looking for a linux compatible tool to flash n76e003. If necessary, I would also invest some time to build one using Python. Any known attempts using pystlink to do the same? Would pystlink be a good starting point for that?

stm32l151zDT6 not supported. Check protection error

running on stm32l151zDT6:
sudo python3 pystlink.py -d

returns:
Connected to ST-Link/ V2, serial 38ff6a064d43323542092243
USB > f1 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00
USB < 28 80 83 04 48 37
USB > f5 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
USB < 01 00
USB > f7 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
USB < 97 06 00 00 00 08 00 00
USB > f2 43 00 00 00 00 00 00 00 00 00 00 00 00 00 00
USB < 80 00
USB > f2 30 a3 00 00 00 00 00 00 00 00 00 00 00 00 00
USB < 80 00
USB > f2 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00
USB < 77 14 a0 2b
DEVICE: ST-Link/V2 V2J34S0
SUPPLY: 2.91V
COREID: 2ba01477
Stm32.core_halt()
Halted after 0 transactions
USB > f2 36 00 ed 00 e0 00 00 00 00 00 00 00 00 00 00
USB < 80 00 00 00 30 c2 2f 41
CPUID: 412fc230
CORE: CortexM3
USB > f2 36 00 20 04 e0 00 00 00 00 00 00 00 00 00 00
USB < 80 00 00 00 36 64 38 10
IDCODE: 10386436
USB > f2 36 cc 00 f8 1f 00 00 00 00 00 00 00 00 00 00
USB < 80 00 00 00 00 00 00 00
*** Connected CPU with DEV_ID: 0x436 and FLASH size: 0KB is not supported. Check Protection ***
USB > f5 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
USB < 02 00
USB > f2 21 00 00 00 00 00 00 00 00 00 00 00 00 00 00
DONE in 0.14s

I get similar results with the stlink v3

serial port getting engaged after reading single command in python.

I am making a connection with python using pyserial with a UART port. As I send the command using serial.write my output is received but my serial port does not break connection. As I need to send a second command also to receive the output. Please guide me on this.

I have also used ser.close still I am not able to close the port.

import serial

ser = serial.Serial(
port='COM5',
baudrate=9600,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout= 10)
print("connected to: " + ser.portstr)

ser.write(b'\reeprom\r')
seq = []
count = 1

while True:
for c in ser.readline():
seq.append(chr(c)) # convert from ANSII
joined_seq = ''.join(str(v) for v in seq) # Make a string from array

        if chr(c) == '\n':
            print("Line " + str(count) + ': ' + joined_seq)
            seq = []
            count += 1
            break

ser.close()

Can you please guide what is going wrong. I am expecting that I should get my output of the fired command to UART and then code should exit rather than continue running. Also I wanted to know if this works can I again make connection and fire the second command to UART. Please help me on this.

@desprit - I have take this cutting of code from your stack overflow contribution. Can you help me guide what is wrong at my end that i am not able to release port.

*** Supply voltage is 0.01V, but minimum for FLASH program or erase is 2.0V ***

Hi! I am able to successfully load firmware in NUCLEO-F103RB if the NUCLEO is no modified, with its own STLINK connected internally via PCB and supplied by USB. However, when y cut ST-LINKV2 of NUCLEO and connect Externally via SWD connector, and supplied MCU externally I get Low supply voltage message:

 $pystlink.py -c STM32F103xB flash:erase:verify:F103_PruebaLED.bin
 
 DEVICE: ST-Link/V2-1 V2J40M27
 SUPPLY: 0.01V
 CORE:   CortexM3
 MCU:    STM32F103xB
 FLASH:  128KB
 SRAM:   20KB
 Loaded 5924 Bytes from F103_PruebaLED.bin file
 *** Supply voltage is 0.01V, but minimum for FLASH program or erase is 2.0V ***

Pin connection:
image

That connection works with STM32CubeIDE for programming MCU successfully (I think pin 6 is unnecessary).
I dont know if pin 1 is necessary.

In order to test, I tried skiping MCU voltage verification commenting this two lines:

# if self._stlink.target_voltage < 2.0:
     # raise lib.stlinkex.StlinkException('Supply voltage is %.2fV, but minimum for FLASH program or erase is 2.0V' % self._stlink.target_voltage) 

It works properly! It loads the firmware successfully.
So, I want to know if there is a way to solve this issue without skipping verification.

Thanks for all!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.