cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX can't recognize the flash size correctly and the debugger won't start

高健一.1
Associate

[ The text uses a translation tool. ]

Flash size is the default and no more programs can be loaded.

environment

Windows10 + STM32CubeMX + ST-Link2

************** Console log

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

                      STM32CubeProgrammer v2.4.0                 

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

ST-LINK SN : 53FF6D064882505226101587

ST-LINK FW : V2J36S7

Voltage    : 3.23V

SWD freq   : 4000 KHz

Connect mode: Under Reset

Reset mode : Hardware reset

Device ID  : 0x436

Device name : STM32L15xxD/STM32L162xD

Flash size : 128 KBytes (default)

Device type : MCU

Device CPU : Cortex-M3

Memory Programming ...

Opening and parsing file: ST-LINK_GDB_server_a20796.srec

 File         : ST-LINK_GDB_server_a20796.srec

 Size         : 137888 Bytes

 Address      : 0x08010000

Erasing memory corresponding to segment 0:

Error: Operation exceeds memory limits

Error: failed to erase memory

Encountered Error when opening C:\ST\STM32CubeIDE_1.3.0\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.win32_1.3.0.202002181050\tools\bin\STM32_Programmer_CLI.exe

Error in STM32CubeProgrammer

Debugger connection lost.

Shutting down...

*************

I'm using an STM2L151DTx, so there's plenty of flush

Why is it [Flash size: 128 KBytes (default)]?

The STM32 ST-LINK Utility can be recognized and written normally.

Am I doing something wrong?

21 REPLIES 21
DThom.3
Associate II

I am seeing the same problem and think I've narrowed it down a bit.  

@ST Please review!!!

I have two prototype boards, both are STM32L151RCT6A

Board 1 (device id 0x427):

C:\Users\Dave>"C:\Program Files (x86)\STMicroelectronics\STM32 ST-LINK Utility\ST-LINK Utility\ST-LINK_CLI.exe" -c
STM32 ST-LINK CLI v3.5.0.0
STM32 ST-LINK Command Line Interface
 
ST-LINK SN: 49FF70064986555549352587
ST-LINK Firmware version: V2J35S7
Connected via SWD.
SWD Frequency = 4000K.
Target voltage = 2.9 V
Connection mode: Normal
Reset mode: Hardware reset
Device ID: 0x427
Device flash Size: 256 Kbytes
Device family: STM32L100xC/L15xxC/L162xC
 
C:\Users\Dave>
C:\Users\Dave>"C:\Program Files (x86)\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin\STM32_Programmer_CLI.exe" -c port=SWD
   -------------------------------------------------------------------
            STM32CubeProgrammer v2.4.0
   -------------------------------------------------------------------
 
ST-LINK SN : 49FF70064986555549352587
ST-LINK FW : V2J35S7
Voltage   : 2.90V
SWD freq  : 4000 KHz
Connect mode: Normal
Reset mode : Software reset
Device ID  : 0x427
Device name : STM32L100xC/STM32L15xxC/STM32L162xC
Flash size : 256 KBytes
Device type : MCU
Device CPU : Cortex-M3
 
C:\Users\Dave>

So far so good... Both STLink utility and STM32CubeProgrammer report device ID 0x427 and correct flash size of 256kbytes

Board 2 (device id 0x436):

C:\Users\Dave>"C:\Program Files (x86)\STMicroelectronics\STM32 ST-LINK Utility\ST-LINK Utility\ST-LINK_CLI.exe" -c
STM32 ST-LINK CLI v3.5.0.0
STM32 ST-LINK Command Line Interface
 
ST-LINK SN: 49FF70064986555549352587
ST-LINK Firmware version: V2J35S7
Connected via SWD.
SWD Frequency = 4000K.
Target voltage = 2.9 V
Connection mode: Normal
Reset mode: Hardware reset
Device ID: 0x436
Device flash Size: 256 Kbytes
Device family: STM32L15xxC-xxD/L162xC-xD
  
C:\Users\Dave>
C:\Users\Dave>"C:\Program Files (x86)\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin\STM32_Programmer_CLI.exe" -c port=SWD
   -------------------------------------------------------------------
            STM32CubeProgrammer v2.4.0
   -------------------------------------------------------------------
 
ST-LINK SN : 49FF70064986555549352587
ST-LINK FW : V2J35S7
Voltage   : 2.90V
SWD freq  : 4000 KHz
Connect mode: Normal
Reset mode : Software reset
Device ID  : 0x436
Device name : STM32L15xxD/STM32L162xD
Flash size : 1 KBytes
Device type : MCU
Device CPU : Cortex-M3
 
C:\Users\Dave>

Problem: on board 2, STlink utility reports 256kb, and STM32cube reports 1kb.

I see the same 1kb in the GUI version (STM32CubeProgrammer.exe).

According to reference manual RM0038 Rev 16:

Bits 15:0 F_SIZE: Flash memory size 

For DEV_ID = 0x416 or 0x427 or 0x429 or 0x437, this field value indicates the Flash memory size of the device in Kbytes. 

Example: 0x0080 = 128 Kbytes. 

For DEV_ID = 0x436, the field value can be ‘0’ or ‘1’, with ‘0’ for 384 Kbytes and ‘1’ for 256 Kbytes. Note: For DEV_ID = 0x429, only LSB part of F_SIZE: F_SIZE[7:0] is valid. The MSB part F_SIZE[15:8] is reserved and must be ignored.

When I run from atollic 9.0.1 in debug mode and view register *0x1FF800CC, i see the value 0x0001. So I think this should be reported as 256kb, and ST-LINK_CLI.exe seems to handle this correctly, but STM32_Programmer_CLI.exe doesnt.

Could this be a bug in STM32_Programmer_CLI.exe, which is ignoring the special case of DEV_ID=0x436, and treating *0x1FF800CC=1 as meaning 1kbyte?

Effect: cannot erase or program this device using STM32CubeProgrammer.exe or STM32_Programmer_CLI.exe.

Workaround: use ST-LINK_CLI.exe or the gdb debugger built into the IDE rather than STM32CubeProgrammer.

Happy to provide more info to help if needed.

oolor.1
Associate II

Is there a solution to this problem yet?

I have a similar problem. I am using STM32L152ZCT6 with STM32CubeIDE.

@clive1​ , et. al

I'm not responsible for any of this...

Yes, there does some to be a recurrent issue with the correct identification of flash size by STM32 Cube Programmer, and it may well have to do with whether it reads the FLASH_SIZE as an 8 or 16-bit wide value.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

@Nawres GHARBI​ @Imen DAHMEN​ @Amel NASRI​ 

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
oolor.1
Associate II

Thanks. I will await response from those you mentioned.

I don't think the issue or 8 or 16bits, its that (as per the datasheet) device ID=0x436 is a special case which means "ignore all other rules" and interpret  (uint_16)*0x1FF800CC as...

0: 384k

1: 256k

2-65535: (undefined I assume)

If they forgot to put in this logic, then the 'standard' code would just multiply the value by 1k resulting in ...

0: 0k

1: 1k

Thanks. I just understood your previous response properly.

Nawres GHARBI
ST Employee

Hello All, problem is already under fix

will be delivered for the next release, sorry for the disturbance

FARSL.1
Associate

Hello,

environment

Windows 10 + STM32CubeIDE(v1.6.1) + ST-Link2

Windows 10 + STM32CubeProgrammer(v2.7.0) + ST-Link2

Windows 10 + STM32 ST-LINK Utility(4.6.0) + ST-Link2

My Microcontroller: Stm32l151RD flash size 384 Kbytes, 48 Kbytes ram, Package LQFP64.

I have same problems. I cannot send my code. I tried to use STM32CubeIDE and STM32CubeProgrammer. 2 programs seen 128kB flash size. Why is it [Flash size: 128 Kbytes (default)]? How can I change flash size 128kB default value?

Also, I can send my code when I try to send with STM32 ST-LINK Utility. Because STM32 ST-LINK Utility can recognize the 384kB flash size correctly.

*************Screenshot from STM32CubeProgrammer*************

0693W00000BZxwcQAD.png*************

I am waiting your solutions @Nawres GHARBI​ @Imen DAHMEN​ @Amel NASRI​.