Skip to main content
EAgui
Visitor II
June 12, 2019
Question

STM32CubeProgrammer: Error: Flash loader cannot be loaded

  • June 12, 2019
  • 9 replies
  • 13000 views

Recently, I bought a clone of ST-Link V2.

I am trying to program a RAK5205 board with an STM32L151CB MCU on it, with a basic program for blinking LEDs.

If I use the STM32 ST-Link Utility v 4.5.0.0, open the file RAK5205_Blink.hex and program the MCU, it ends correctly and the program runs without problems on the board. If I want to completely erase the Flash memory, it does it correctly with this indication:

Device ID: 0x429

Device flash Size: 128KBytes

Device family: STM32L100x8xxA / L15xx8xxA

Flash memory erased.

Now, if I open the STM32CubeProgrammer v2.1.0, open the same file RAK5205_Blink.hex, the ST-Link v2 is recognized and connected correctly, read the memory of the MCU without problems, but when I want to program it in the same way than before, it shows the error, "Flash loader can not be loaded".

What is the difference between the ST-Link Utility and the STM32CubeProgrammer regarding device detection and programming? 

What exactly does the error"Flash loader can not be loaded" means?

One difference I noted is that the STM32CubeProgramer, detected the Device as STM32L100x6xxA / STM32L100x8x ... with a Flash Size of 27520 KB instead of 128KB that has the MCU, different from what it is detected with ST-Link Utility.

Sorry if it is an stupid question, I'm a newby trying to lern. I'll appreciate any opinion or suggestion.

My OS is Windows 7 Ultimate.

Thank you

9 replies

AHofm
Visitor II
July 18, 2019

… I got the same issue with RAK811

Explorer II
April 9, 2025

me too,my OS is ubuntu 22.04,who can help me

Visitor II
April 2, 2026

FYI, got same issue on ubuntu 25.10. Just updated CubeProgrammer to 2.22.0 and STLINK v3 to V3J16M8 and the problem is gone

RScho.14
Visitor II
January 18, 2020

You must disable the read protection. The easiest way to do this is with the ST tool "Flash Loader Demonstrator". After a few next clicks you will find the option "Disable Read Protection" there. After that, you can check the "Option Bytes" with the STM32 ST-Link Utility. After that debugging ist running like a charm.

LKamm.2
Associate II
September 28, 2020

We have got the same issue:

  1. We use the STM32L151CBT6-A on a custom PCB. The hardware is properly installed. All supply pins are connected with their respective signals. The programming connections are fine.
  2. The software STM32CubeProgrammer is capable of reading the Flash and Option Bytes, but programming or erasing the flash results in the error message: "Error: Flash loader cannot be loaded". The same error occurs using the internal Debugger / Programmer in STM32CubeIDE.
  3. In contrast, flash programming is possible using the STM32 ST-LINK Utility by loading the .bin file. The programm is executed correctly.

I have no idea, what the source of this error might be. Since flashing and executing the program are both working fine after using the older ST-LINK Utility, the issue should be located inside the Toolchain / STM32CubeProgrammer.

Please respond to this entry if you are facing the same problem or have any ideas to solve the issue.

LKamm.2
Associate II
October 2, 2020

If anybody else is experiencing the same issue as mentioned in my previous post:

For me it works not to use the STM32 Cube Programmer (GUI / CLI or integrated in Cube IDE).

I have switched to openocd (Windows x64 binaries), either by opening a Debugging server manually or integrating the server start in Cube IDE. This works perfectly fine. My platform:

Windows 10 64 bit

Cube MX / IDE / Programmer

STLINKV2/1

The problem occured with STM32L151CB-A and STM32L152CB-A.

pieter
Visitor II
October 22, 2020

Same problem, it is not working to write with the STM32 Cube Programmer.

Target:

0693W00000590RZQAY.pngIt does work with ST Visual Programmer and STM32 ST-Link Utility.

Windows 8 64 bit

Original ST-LINK/V2

LucHardware
Associate II
May 21, 2021

I have also the same problem

0693W000007CKH9QAO.png

Tesla DeLorean
Guru
May 21, 2021

All the people on the thread have STM32L1 parts, running Windows, so I suspect you actually have a different problem

https://community.st.com/s/question/0D53W00000VivMBSAZ/access-the-flash-memory-from-stm32f767bi

The interaction with the device looks to be broken, so I'd assume some low-level drivers on the ST-LINK side.

Did the new version or the patch offered work?

Is the failure only in Ubuntu? Or did it follow you to Windows too?

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
LucHardware
Associate II
May 21, 2021

Hi,

In the Terminal "LSUSB" I find "ID xxxx:xxxx STMicroelectronics ST-LINK/V2". Some pages from the STM32F767BI are readable. I already install the latest linux driver for the ST-LINK/V2 version 1.0.3-1 from the packet en.stsw-linl007_V2-38-27.zip (other versions are windows only).

LucHardware
Associate II
May 25, 2021

Still no sollution. They mention on google about st-link utility but this is integrated in the STM32 IDE.

Can someone help me out, if I run the IDE it gives the result below:

STMicroelectronics ST-LINK GDB server. Version 5.7.0

Copyright (c) 2020, STMicroelectronics. All rights reserved.

Starting server with the following options:

       Persistent Mode           : Disabled

       Logging Level             : 1

       Listen Port Number        : 61234

       Status Refresh Delay      : 15s

       Verbose Mode              : Disabled

       SWD Debug                 : Enabled

       InitWhile                 : Enabled

Waiting for debugger connection...

Debugger connected

     -------------------------------------------------------------------

                       STM32CubeProgrammer v2.6.0-RC3                 

     -------------------------------------------------------------------

ST-LINK SN : 55FF6D066684564928211687

ST-LINK FW : V2J37S7

Board      : --

Voltage    : 3,26V

SWD freq   : 4000 KHz

Connect mode: Under Reset

Reset mode : Hardware reset

Device ID  : 0x451

Revision ID : Rev Z

Device name : STM32F76x/STM32F77x

Flash size : 63 KBytes (default)

Device type : MCU

Device CPU : Cortex-M7

Memory Programming ...

Opening and parsing file: ST-LINK_GDB_server_lSOXfX.srec

 File         : ST-LINK_GDB_server_lSOXfX.srec

 Size         : 6092 Bytes

 Address      : 0x08000000

Erasing memory corresponding to segment 0:

Erasing external memory sector 0

Error: failed to erase memory

Error: failed to erase memory

Encountered Error when opening /opt/st/stm32cubeide_1.5.0/plugins/com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.linux64_1.5.0.202011040924/tools/bin/STM32_Programmer_CLI

Error in STM32CubeProgrammer

Debugger connection lost.

Shutting down...

Tesla DeLorean
Guru
May 25, 2021

Well it's consistent at least.

What board is this? A Nucleo or some custom board? Does it have it's own loader code on it? Does that have any protections enabled?

Is NRST wired to the debug interface?

Strap BOOT0 High and try to get whatever is on the device currently erased.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
LucHardware
Associate II
May 26, 2021

Hi, the development board is new from Mikroe type Clicker4 for STM32F767BI (schematic is on the website). The boot0 was low, now I put it to high. Cause it is high the factory program didn't run. The optionbit RDP = FF and must be AA, only bank nWRP11 is unchecked. The NRST pin is connected to the JTAG/SWD with the ST-link. Erase the full chip flash is also impossible like before.

If I type the command "lsusb" in the terminal, the STM32 is not detected (not in the list), ST-link is recognized. When start ST-PRG, the connection with STM32 is established, but unable to change and ST-link led is green and blink 5 times red.

Tesla DeLorean
Guru
May 26, 2021

Unfortunately not a board/os/tool combo I'm using.

The flash size reporting and option byte reading looks broken, not sure I can explain that short of a connectivity failure, perhaps try a connection speed below 4 MHz

This is using a authentic external ST-LINK, right?

Have you tried with the stand-alone Windows tools (not the IDE or GDB), guessing not?

Perhaps someone at ST has some insights.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
LucHardware
Associate II
May 31, 2021

Hi,

I try to upload my test program via arduino, it fails also cause of missing packets from the STM32 programmer. I uninstall all STM32 and reinstall the new version 1.6.1

but the problem stay. Must Boot0 by high or low. The STM32F chip is never in the list of USB devices.