pavelrevak / pystlink

Python tool for flashing and debugging STM32 devices using ST-LINK/V2
MIT License
218 stars 59 forks source link

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

Closed jguembe closed 11 months ago

jguembe commented 1 year ago

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!

severinandersen commented 1 year ago

Hi, I had the same issue but was not happy about just disabling the check. The solution is to mount the R9 resistor on the ST-LINK board with a value of 4k7 (not 100 ohms as listed in the schematics). Together with R27 it creates a voltage divider for AIN_1, which samples the voltage. But keep in mind that the measured voltage will be app. 0.3V lower than the actual voltage due to the voltage drop over D1. On other NUCLEO boards, like NUCLEO-144, the parts have different names, e.g. on NUCLEO-F767ZI the resistor is named R1. But they are located close to the external SWD connector.

jguembe commented 11 months ago

Thanks for the answer. Makes sense. Previously it did not connect pin 1 of the SWD connector (CN4). Now, I have mounted a 4k7 R9 resistor and connected pin 1 of the SWD to the power supply of the 3V3 MCU. The result was successful, I have a value of 3.09V in pystlink and the verification passed.

image