cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L476 Error: failed to download Segment[0]

HLi.1047
Associate

Hi

I'm using Atollic TrueSTUDIO® for STM32, Built on Eclipse Neon.1a. Version: 9.3.0 Build id: 20190212-0734

I get the following error when I try to debug:

 
STMicroelectronics ST-LINK GDB server. Version 5.1.0
Copyright (c) 2018, 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
 
Waiting for debugger connection...
Debugger connected
      -------------------------------------------------------------------
                       STM32CubeProgrammer v1.3.0                  
      -------------------------------------------------------------------
 
 
 
Log output file:   C:\Users\HLi\AppData\Local\Temp\STM32CubeProgrammer_a17660.log
ST-LINK SN  : 55FF6D067880565349412067
ST-LINK FW  : V2J31S7
Voltage     : 3.23V
SWD freq    : 4000 KHz
Connect mode: Under Reset
Reset mode  : Hardware reset
Device ID   : 0x415
Device name : STM32L4x1/STM32L475xx/STM32L476xx/STM32L486xx
Device type : MCU
Device CPU  : Cortex-M4
 
 
 
Memory Programming ...
Opening and parsing file: C:\Users\HLi\AppData\Local\Temp\ST-LINK_GDB_server_a17660.srec
  File          : C:\Users\HLi\AppData\Local\Temp\ST-LINK_GDB_server_a17660.srec
  Size          : 262184 Bytes
  Address       : 0x08000000 
 
 
Erasing memory corresponding to segment 0:
Erasing internal memory sectors [0 128]
Download in Progress:
 
 
Error: failed to download Segment[0]
Error: failed to download the File
Time elapsed during download operation: 00:00:08.714
 
 
 
Verifying ...
 
 
 
 
Download verified successfully 
 
 
Encountered Error when opening C:\Program Files (x86)\Atollic\TrueSTUDIO for STM32 9.3.0\Servers\STM32CubeProgrammer\bin\STM32_Programmer_CLI.exe
Error in STM32CubeProgrammer
Debugger connection lost.
Shutting down...

everything was fine before I wrote a few extra functions that pushed from 127 sectors into 128 sectors.

Here is the 127 sector message shows that it was fine before:

 
STMicroelectronics ST-LINK GDB server. Version 5.1.0
Copyright (c) 2018, 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
 
Waiting for debugger connection...
Debugger connected
      -------------------------------------------------------------------
                       STM32CubeProgrammer v1.3.0                  
      -------------------------------------------------------------------
 
 
 
Log output file:   C:\Users\HLi\AppData\Local\Temp\STM32CubeProgrammer_a16996.log
ST-LINK SN  : 55FF6D067880565349412067
ST-LINK FW  : V2J31S7
Voltage     : 3.23V
SWD freq    : 4000 KHz
Connect mode: Under Reset
Reset mode  : Hardware reset
Device ID   : 0x415
Device name : STM32L4x1/STM32L475xx/STM32L476xx/STM32L486xx
Device type : MCU
Device CPU  : Cortex-M4
 
 
 
Memory Programming ...
Opening and parsing file: C:\Users\HLi\AppData\Local\Temp\ST-LINK_GDB_server_a16996.srec
  File          : C:\Users\HLi\AppData\Local\Temp\ST-LINK_GDB_server_a16996.srec
  Size          : 260424 Bytes
  Address       : 0x08000000 
 
 
Erasing memory corresponding to segment 0:
Erasing internal memory sectors [0 127]
Download in Progress:
 
 
File download complete
Time elapsed during download operation: 00:00:08.317
 
 
 
Verifying ...
 
 
 
 
Download verified successfully 
 
 
Debugger connection lost.
Shutting down...

STM32 ST-LINK Utility loaded the same bin file without error.

0693W00000NqtXBQAZ.pngThe STM32L476 should have 1MB flash, and I've used just over1/4 of it.

I was using no optimization (-O0) when the error occurs. And I have confirmed that with the same code, if I optimize for size (-Os) then the error goes away.

Eventually, my code size will grow and hit this error again.

Please help me get over this limit.

Cheers

Harry

1 ACCEPTED SOLUTION

Accepted Solutions
Imen.D
ST Employee

Hello @HLi.1047​ ,

Try to upgrade firmware version using STM32 ST-LINK Utility: go to ST-LINK>firmware update,

 Then disconnect and connect your board.

I also advise you to update the STM32Cubeprogrammer and use the latest release.

Keep us informed about your update.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

View solution in original post

2 REPLIES 2
Imen.D
ST Employee

Hello @HLi.1047​ ,

Try to upgrade firmware version using STM32 ST-LINK Utility: go to ST-LINK>firmware update,

 Then disconnect and connect your board.

I also advise you to update the STM32Cubeprogrammer and use the latest release.

Keep us informed about your update.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
HLi.1047
Associate

Hi​ Imen

Thank you so much. Your instructions fixed it.

STM32 ST-LINK Utility showed that I had:

STM32+STM8 Debugger

V2.J37.S7

I reflashed my st-link V2 even though it was the newest firmware.

Then download the newest STM32CubeProgrammer 2.10, installed it, and followed the following instructions to integrate it into TrueStudio:

https://www.st.com/resource/en/application_note/an1801_stm32cubeprogrammer_in_truestudio-installing-stm32cubeprogrammer-in-truestudio-stmicroelectronics.pdf

I had:

STM32CubeProgrammer v1.3.0  

Which is very old, I assume it came with TrueStudio, because I never integrated into TrueStudio.

Then everything just worked without optimization.

Cheers

Harry