How to Disable Debugging in Platformio for STM32L152RE to Avoid Voltage Target Error?

I have a custom board with an STM32L152RE, and I’m trying to program it using the ST-Link that I detached from a Nucleo board. Using the Arduino IDE, I can program it without any issues, but I can’t do it with Platformio because I get an error: “Error: target voltage may be too low for reliable debugging.” I know this error is because the programmer is not receiving the voltage from the microcontroller on the “voltage target” pin. I’m not interested in using the debug feature for this board. Is there a way to disable the debug in the platformio.ini file so it doesn’t attempt to debug and thus avoids this error?

What is the exact output of a verbose upload? CLIpio run -t upload -v

Hi Max, thanks for your early reply, here the output.

Processing nucleo_l152re (platform: ststm32; board: nucleo_l152re; framework: arduino)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/nucleo_l152re.html
PLATFORM: ST STM32 (17.4.0) > ST Nucleo L152RE
HARDWARE: STM32L152RET6 32MHz, 80KB RAM, 512KB Flash
DEBUG: Current (stlink) On-board (stlink) External (blackmagic, cmsis-dap, jlink)
PACKAGES:
 - framework-arduinoststm32 @ 4.20701.0 (2.7.1)
 - framework-cmsis @ 2.50900.0 (5.9.0)
 - tool-dfuutil @ 1.11.0
 - tool-dfuutil-arduino @ 1.11.0
 - tool-openocd @ 3.1200.0 (12.0)
 - tool-stm32duino @ 1.0.2
 - toolchain-gccarmnoneeabi @ 1.120301.0 (12.3.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 12 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
MethodWrapper(["checkprogsize"], [".pio\build\nucleo_l152re\firmware.elf"])
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   1.3% (used 1104 bytes from 81920 bytes)
Flash: [          ]   1.6% (used 8484 bytes from 524288 bytes)
.pio\build\nucleo_l152re\firmware.elf  :

section              size        addr

.isr_vector           316   134217728

.text                7828   134218044

.rodata               556   134225872

.ARM.extab              0   134226428

.ARM                    8   134226428

.preinit_array          0   134226436

.init_array            16   134226436

.fini_array             8   134226452

.data                 100   536870912

.bss                 1004   536871012

.noinit                 0   536872016

._user_heap_stack    1536   536872016

.ARM.attributes        41           0

.comment               57           0

.debug_line          1620           0

.debug_line_str       282           0

.debug_info          1885           0

.debug_abbrev         420           0

.debug_aranges         96           0

.debug_str           2002           0

.debug_frame           96           0

.debug_loclists      2424           0

.debug_rnglists       172           0

Total               20467
<lambda>(["upload"], [".pio\build\nucleo_l152re\firmware.elf"])
AVAILABLE: blackmagic, cmsis-dap, jlink, mbed, stlink
CURRENT: upload_protocol = stlink
openocd -d2 -s C:\Users\FernandoVelasquez\.platformio\packages\tool-openocd/openocd/scripts -f board/st_nucleo_l1.cfg -c "program {.pio\build\nucleo_l152re\firmware.elf}  verify reset; shutdown;"
xPack Open On-Chip Debugger 0.12.0-01004-g9ea7f3d64-dirty (2023-01-30-15:04)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
debug_level: 2

Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
srst_only separate srst_nogate srst_open_drain connect_deassert_srst

Info : clock speed 300 kHz
Info : STLINK V2J33M25 (API v2) VID:PID 0483:374B
Info : Target voltage: 0.004728
Error: target voltage may be too low for reliable debugging
Info : [stm32l1.cpu] Cortex-M3 r2p0 processor detected
Info : [stm32l1.cpu] target has 6 breakpoints, 4 watchpoints
Info : starting gdb server for stm32l1.cpu on 3333
Info : Listening on port 3333 for gdb connections
Info : Unable to match requested speed 300 kHz, using 240 kHz
Info : Unable to match requested speed 300 kHz, using 240 kHz
[stm32l1.cpu] halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x0800175c msp: 0x20014000
STM32L: Enabling HSI
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
** Programming Started **
Info : Device: STM32L1xx (Cat.5/Cat.6)
Info : STM32L flash has dual banks. Bank (0) size is 256kb, base address is 0x8000000
** Programming Finished **
** Verify Started **
** Verified OK **
** Resetting Target **
Info : Unable to match requested speed 300 kHz, using 240 kHz
Info : Unable to match requested speed 300 kHz, using 240 kHz
shutdown command invoked

It has uploaded the code perfectly fine. The verify has gone through. It’s just complaining about the target voltage but it doesn’t matter.

1 Like

Also, the error message cannot be disabled in OpenOCD. When it has a ST-Link that’s not in Device Firmware Update (DFU) mode, it will measure the voltage, and will log and error.

The only way you can avoid this is if you don’t use OpenOCD + ST-link as your uploader combination, but instead use a different debug tool (CMSIS-DAP?) or a program that doesn’t give a frick about it. I guess the Arduino IDE was using stm32cubeprog? You can define a custom upload command as needed in upload_protocol — PlatformIO latest documentation

Thanks Max, if is programming ok, I’ll leave that way.