cancel
Showing results for 
Search instead for 
Did you mean: 

I cannot program my NUCLEO-L452RE-P. Has my board been bricked?

AMacd.1
Associate III

Here is what happens when I attempt to program the board:

15:20:57 : STM32CubeProgrammer API v2.18.0 | Linux-64Bits 
15:21:09:628 : UR connection mode is defined with the HWrst reset mode
15:21:09:705 : ST-LINK SN  : 066BFF485251667187085222
15:21:09:706 : ST-LINK FW  : V2J45M31
15:21:09:706 : Board       : NUCLEO-L452RE-P
15:21:09:707 : Voltage     : 3.24V
15:21:09:707 : SWD freq    : 4000 KHz
15:21:09:707 : Connect mode: Normal
15:21:09:708 : Reset mode  : Hardware reset
15:21:09:708 : Device ID   : 0x462
15:21:09:708 : Revision ID : Rev Y
15:21:09:709 : flash loader /media/allanmacdonald/Data/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin/FlashLoader/0x is loaded
15:21:09:709 : Debug in Low Power mode enabled.
15:21:09:710 : r ap 0 @0xE0042004 0x00000004 bytes Data 0x00000000
15:21:09:710 : w ap 0 @0xE0042004 0x00000004 bytes Data 0x00000007
15:21:09:710 : r ap 0 @0xE0042008 0x00000004 bytes Data 0x00000000
15:21:09:711 : w ap 0 @0xE0042008 0x00000004 bytes Data 0x00001800
15:21:09:711 : Reading data...
15:21:09:711 : r ap 0 @0x1FFF75E0 0x00000004 bytes Data 0xFFFF0200
15:21:09:712 : r ap 0 @0x1FFF6FFE 0x00000001 bytes Data 0xFFFFFF92
15:21:10:272 : r ap 0 @0x1FFF6FFE 0x00000001 bytes Data 0xFFFFFF92
15:21:10:272 : UPLOADING OPTION BYTES DATA ...
15:21:10:273 :   Bank          : 0x00
15:21:10:273 :   Address       : 0x40022020
15:21:10:273 :   Size          : 20 Bytes
15:21:10:273 : Reading data...
15:21:10:274 : r ap 0 @0x40022020 0x00000014 bytes Data 0xFFFFF8AA
15:21:10:275 : UPLOADING OPTION BYTES DATA ...
15:21:10:275 :   Bank          : 0x00
15:21:10:275 :   Address       : 0x40022020
15:21:10:275 :   Size          : 20 Bytes
15:21:10:276 : Reading data...
15:21:10:276 : r ap 0 @0x40022020 0x00000014 bytes Data 0xFFFFF8AA
15:21:10:277 : r ap 0 @0x1FFF6FFE 0x00000001 bytes Data 0xFFFFFF92
15:21:10:277 : UPLOADING ...
15:21:10:277 :   Size          : 1024 Bytes
15:21:10:277 :   Address       : 0x8000000
15:21:10:278 : Read progress:
15:21:10:278 : Reading data...
15:21:10:279 : r ap 0 @0x08000000 0x00000400 bytes Data 0x20020000
15:21:10:279 : Data read successfully
15:21:10:279 : Time elapsed during the read operation is: 00:00:00.008
15:21:10:284 : r ap 0 @0x1FFF6FFE 0x00000001 bytes Data 0xFFFFFF92
15:21:11:122 : r ap 0 @0x1FFF6FFE 0x00000001 bytes Data 0xFFFFFF92
15:21:12:124 : r ap 0 @0x1FFF6FFE 0x00000001 bytes Data 0xFFFFFF92
15:21:13:127 : r ap 0 @0x1FFF6FFE 0x00000001 bytes Data 0xFFFFFF92
15:21:14:130 : r ap 0 @0x1FFF6FFE 0x00000001 bytes Data 0xFFFFFF92
15:21:15:133 : r ap 0 @0x1FFF6FFE 0x00000001 bytes Data 0xFFFFFF92
15:21:16:135 : r ap 0 @0x1FFF6FFE 0x00000001 bytes Data 0xFFFFFF92
15:21:17:138 : r ap 0 @0x1FFF6FFE 0x00000001 bytes Data 0xFFFFFF92
15:21:18:140 : r ap 0 @0x1FFF6FFE 0x00000001 bytes Data 0xFFFFFF92
15:21:18:794 : Read File: /media/allanmacdonald/Data/work/1178-tangotouch/008-displayboard/wip/source/mxmakefileprojects/blinky-l452/build/blinky-l452.bin
15:21:18:795 : Number of segments: 1
15:21:18:795 : segment[0]: address= 0x0, size= 0x12E8
15:21:19:314 : r ap 0 @0x1FFF6FFE 0x00000001 bytes Data 0xFFFFFF92
15:21:20:296 : r ap 0 @0x1FFF6FFE 0x00000001 bytes Data 0xFFFFFF92
15:21:21:299 : r ap 0 @0x1FFF6FFE 0x00000001 bytes Data 0xFFFFFF92
15:21:21:952 : Opening and parsing file: blinky-l452.bin
15:21:21:952 : Memory Programming ...
15:21:21:952 :   File          : blinky-l452.bin
15:21:21:953 :   Size          : 4.73 KB 
15:21:21:953 :   Address       : 0x08000000 
15:21:21:957 : Erasing Segment <0> Address <0x08000000> Size <4840>Bytes
15:21:21:957 : Erasing memory corresponding to segment 0:
15:21:21:965 : r ap 0 @0x40022040 0x00000004 bytes Data 0x00000000
15:21:21:966 : Memory Erase via FlashLoader!
15:21:21:969 : Memory erase...
15:21:21:969 : halt ap 0 
15:21:21:969 : w ap 0 reg 15 PC   (0x20000000)  
15:21:21:970 : w ap 0 reg 17 MSP  (0x20000500)  
15:21:21:970 : w ap 0 reg 16 xPSR (0x01000000)  
15:21:22:004 : w ap 0 @0x200008C0 : 0x00000200 bytes, Data 0x00000000...
15:21:22:005 : w ap 0 @0x20000000 : 0x00000004 bytes, Data 0x0000BE00...
15:21:22:012 : w ap 0 @0x20000004 : 0x0000048C bytes, Data 0xF000B580...
15:21:22:013 : Erasing internal memory sectors [0 2]
15:21:22:013 : Init flashloader...
15:21:22:013 : halt ap 0 
15:21:22:013 : w ap 0 reg 0 R0   0x00000001
15:21:22:018 : w ap 0 reg 1 R1   0x00000000
15:21:22:021 : w ap 0 reg 2 R2   0x00000000
15:21:22:023 : w ap 0 reg 3 R3   0x00000000
15:21:22:025 : w ap 0 reg 4 R4   0x00000000
15:21:22:026 : w ap 0 reg 5 R5   0x00000000
15:21:22:026 : w ap 0 reg 6 R6   0x00000000
15:21:22:026 : w ap 0 reg 7 R7   0x00000000
15:21:22:027 : w ap 0 reg 8 R8   0x00000000
15:21:22:027 : w ap 0 reg 9 R9   0x00000000
15:21:22:027 : w ap 0 reg 10 R10  0x00000000
15:21:22:027 : w ap 0 reg 11 R11  0x00000000
15:21:22:027 : w ap 0 reg 12 R12  0x00000000
15:21:22:028 : w ap 0 reg 13 SP   0x00000000
15:21:22:028 : w ap 0 reg 14 LR   0x20000001
15:21:22:028 : w ap 0 reg 15 PC   0x20000005
15:21:22:029 : w ap 0 reg 16 xPSR 0x01000000
15:21:22:029 : w ap 0 reg 17 MSP  0x2000088C
15:21:22:029 : w ap 0 reg 18 PSP  0x00000000
15:21:22:030 : run ap 0 
15:21:26:002 : halt ap 0 
15:21:26:003 : Init function fail with timeout
15:21:26:003 : r ap 0 reg 16 xPSR 0x01000003
15:21:26:004 : Loader sector erase...
15:21:26:004 : Error: failed to erase memory
15:21:26:097 : Error: failed to erase memory
15:21:26:113 : r ap 0 @0x1FFF6FFE 0x00000001 bytes Data 0xFFFFFF92
15:21:27:007 : r ap 0 @0x1FFF6FFE 0x00000001 bytes Data 0xFFFFFF92
15:21:28:010 : r ap 0 @0x1FFF6FFE 0x00000001 bytes Data 0xFFFFFF92
15:21:29:013 : r ap 0 @0x1FFF6FFE 0x00000001 bytes Data 0xFFFFFF92
15:21:30:016 : r ap 0 @0x1FFF6FFE 0x00000001 bytes Data 0xFFFFFF92
15:21:31:018 : r ap 0 @0x1FFF6FFE 0x00000001 bytes Data 0xFFFFFF92
15:21:31:652 : Disconnected
15:21:31:652 : Disconnected from device.

I tried performing a full chip (i.e. mass) erase but I get the following error:

16:06:58 : UR connection mode is defined with the HWrst reset mode
16:06:58 : ST-LINK SN  : 066BFF485251667187085222
16:06:58 : ST-LINK FW  : V2J45M31
16:06:58 : Board       : NUCLEO-L452RE-P
16:06:58 : Voltage     : 3.24V
16:06:58 : SWD freq    : 4000 KHz
16:06:58 : Connect mode: Normal
16:06:58 : Reset mode  : Hardware reset
16:06:58 : Device ID   : 0x462
16:06:58 : Revision ID : Rev Y
16:06:58 : Debug in Low Power mode enabled.
16:06:59 : UPLOADING OPTION BYTES DATA ...
16:06:59 :   Bank          : 0x00
16:06:59 :   Address       : 0x40022020
16:06:59 :   Size          : 20 Bytes
16:06:59 : UPLOADING ...
16:06:59 :   Size          : 1024 Bytes
16:06:59 :   Address       : 0x8000000
16:06:59 : Read progress:
16:06:59 : Data read successfully
16:06:59 : Time elapsed during the read operation is: 00:00:00.008
16:07:03 : MASS ERASE ... 
16:07:08 : Error: Mass erase operation failed.Please verify flash protection
16:07:12 : Disconnected from device.

 I am unsure how to proceed.   Please help.

 

1 ACCEPTED SOLUTION

Accepted Solutions

After thinking about it a bit, I finally figured out a way to get my board programmed.  Steps:

  1. I found a Windows 11 machine and installed STM32CubeProgrammer on that machine.
  2. I connected the NUCLEO-L452RE-P to the windows machine.
  3. At first it wouldn't connect  (Error: No STM32 target found! If your product embeds Debug Authentication, please perform a discovery using Debug Authentication*).
  4. I then changed the ST-Link Configuration Mode to "Under Reset" and I was able to connect.
  5. I then obtained the hex file that was created on the other machine using the makefile generated by CubeMX.
  6. I was able to program my board.

So, it looks like the whole problem has to do with the STM32CubeProgrammer application running on Linux.

Since I've proven that my board is not bricked, I can say this question is answered.  I will go find a way to report the bug in STM32CubeProgrammer.

*Note: I found out how to solve the connection error on this forum thread.

View solution in original post

8 REPLIES 8
AScha.3
Super User

So connect it with CubeProgrammer, then check:

- rdp level   (do nothing here !!! just look, and show screenshot)

- option bytes

-> look at all blocks, there might be some with write protection active; set them to not protected.

 

Then try program/flash again.

If you feel a post has answered your question, please click "Accept as Solution".

Hi @AScha.3 

What do you mean by "Look at all blocks, there might be some with write protection active; set them to not protected."?

Here are the contents of the FLASH Registers:

:020000044002B8
:202000000006000000000000000000000000000000000000000000C00000000000000000FA
:14202000AAF8FFFFFFFFFFFF0000FFFFFFFF00FFFFFF00FF18
:00000001FF

I'll try to look through this but how would this help?  Correct me if I'm wrong but, for me to correct these, I believe I would have to manually enter the flash key codes before editing these register values.  Shouldn't the STM32CubeProgrammer do that automatically?  I'm not "accidentally" erasing flash here.  Please elaborate.

Here my option bytes including rdp level:

{
  "deviceId" : 1122,
  "bitNameToValue" : {
    "RDP" : 170,
    "BOR_LEV" : 0,
    "nRST_STOP" : 1,
    "nRST_STDBY" : 1,
    "nRST_SHDW" : 1,
    "IWDG_SW" : 1,
    "IWDG_STOP" : 1,
    "IWDG_STDBY" : 1,
    "WWDG_SW" : 1,
    "nBOOT1" : 1,
    "SRAM2_PE" : 1,
    "SRAM2_RST" : 1,
    "nSWBOOT0" : 1,
    "nBOOT0" : 1,
    "PCROP1_STRT" : 65535,
    "PCROP1_END" : 0,
    "PCROP_RDP" : 1,
    "WRP1A_STRT" : 255,
    "WRP1A_END" : 0,
    "WRP1B_STRT" : 255,
    "WRP1B_END" : 0
  }
}

 

I dont know, what you try to do...

just connect with CubeProg , then see OB  ...option bytes:

AScha3_0-1751639454552.png

...then check for write protected blocks:

AScha3_1-1751639528136.png

What you using to make the program ? CubeIDE ? 

If you feel a post has answered your question, please click "Accept as Solution".

Hi @AScha.3 

The option bytes were already provided in my last post (I used the export utility instead of a screenshot).  However, here is the screenshot.

AMacd1_0-1751642099885.png

I can't make heads or tails of this at the moment.  I'm trying to read and understand section 3 of the Ref Manual now (RM0394 Rev 5) but that'll take me a bit to go through.

About your question, "What you to make the program ? CubeIDE ?"

For now I just want to see the erase flash operation succeed on this particular board.  If that is fixed, I can go on to the next problem.  One problem at a time.

However, just to answer your question, I am using STM32CubeMX to generate a Makefile project and I run make from the command line to build the project.  I then use STM32CubeProgrammer to load the hex file.  I have all the prerequisites installed:

$ arm-none-eabi-gcc --version
arm-none-eabi-gcc (15:10.3-2021.07-4) 10.3.1 20210621 (release)

$ arm-none-eabi-objcopy --version
GNU objcopy (2.38-3ubuntu1+15build1) 2.38

$ arm-none-eabi-size --version
GNU size (2.38-3ubuntu1+15build1) 2.38

I hope that is sufficient.

So I finally read through section 3.  From what I can tell, for each protected area, the settings are as follows:

Area A Start Page Offset 0xFF

Area A End Page Offset 0x00

Area B Start Page Offset 0xFF

Area B End Page Offset 0x00

So taking these settings literally, I see that the start page is after the end page for each area.  This is an impossible situation in my view - perhaps that means that there is no protected area defined but I'm not sure.  RM0394 doesn't seem to say how to disable all flash area write protection.  Should all the registers be zero?  Should they all be 0xFF?  Should they be as set above?  I have no idea.

 

...hmm... i dont have this L4xx cpu, so i dont know, how the protection is to be set. Seems bit different to my Fxx, Hxx cpus.

So look at the rm , how to set unprotected state.

 

btw

Was it ever working ? Did you ever flash it successfully ? (You didnt tell, so its a lot of guessing for me.)

If you feel a post has answered your question, please click "Accept as Solution".

>Was it ever working ? Did you ever flash it successfully ? (You didnt tell, so its a lot of guessing for me.)

...?

If you feel a post has answered your question, please click "Accept as Solution".

After thinking about it a bit, I finally figured out a way to get my board programmed.  Steps:

  1. I found a Windows 11 machine and installed STM32CubeProgrammer on that machine.
  2. I connected the NUCLEO-L452RE-P to the windows machine.
  3. At first it wouldn't connect  (Error: No STM32 target found! If your product embeds Debug Authentication, please perform a discovery using Debug Authentication*).
  4. I then changed the ST-Link Configuration Mode to "Under Reset" and I was able to connect.
  5. I then obtained the hex file that was created on the other machine using the makefile generated by CubeMX.
  6. I was able to program my board.

So, it looks like the whole problem has to do with the STM32CubeProgrammer application running on Linux.

Since I've proven that my board is not bricked, I can say this question is answered.  I will go find a way to report the bug in STM32CubeProgrammer.

*Note: I found out how to solve the connection error on this forum thread.