Skip to main content
Visitor II
June 8, 2019
Solved

Unable to program using ST-Link

  • June 8, 2019
  • 2 replies
  • 7407 views

We are using STM32L476ZGTx. Until recently I was able to program the chip using ST-Link. A few hours back programming failed due to power issue and since then I have been unable to program the controller.

The device connects with ST-Link Utility every time, so I am guessing the connections are not an issue. Reading the device shows garbage , repeated at every memory location, PFA

0690X000008iOHAQA2.png

Full chip erase gives the error "Some flash pages are read protected!"

Programming a file gives error "Programming error @ 0x08000000!" in the gui, this log in the log window

11:43:53 : Some flash sectors are read protected.

11:43:57 : Read protection disabled.

11:43:57 : The elf loader Sector Erase function fails.

11:43:57 : Memory-Loader error

11:43:57 : Error occured during erase operation!

11:43:58 : Programming error @ 0x08000000!

and this in the .log file generated

11:47:57 : ST-LINK SN : -----

11:47:57 : V2J33S7

11:47:57 : Connected via SWD.

11:47:57 : SWD Frequency = 4,0 MHz.

11:47:57 : Connection mode : Connect Under Reset.

11:47:57 : Debug in Low Power mode enabled.

11:47:58 : Device ID:----

11:47:58 : Device family :STM32L4x1/L4x5/L4x6

11:47:58 : [some_hex.hex] opened successfully.

11:47:58 : [some_hex.hex] checksum : 0x03A16C7F 

11:47:59 : Some flash sectors are read protected.

11:48:00 : Read protection disabled.

11:48:01 : The elf loader Sector Erase function fails.

11:48:01 : Memory-Loader error

11:48:01 : Error occured during erase operation!

11:48:01 : Programming error @ 0x08000000!

11:48:02 : Programmed memory Checksum: 0x0124CE00

Please advise ASAP

    This topic has been closed for replies.
    Best answer by HMahm

    The device was mass erased by setting the Read Out Protection to Level 1 and then to Level 0, using ST Link->Target->Option Bytes.

    Now I can flash it with the desired HEX files

    2 replies

    HMahmAuthorAnswer
    Visitor II
    June 8, 2019

    The device was mass erased by setting the Read Out Protection to Level 1 and then to Level 0, using ST Link->Target->Option Bytes.

    Now I can flash it with the desired HEX files

    Visitor II
    April 19, 2021

    Related problem,

    the device was in level 0 but ST Link report the message "The elf loader Mass Erase function fails".

    Setted the Red Out Protection from level 0 to level 1 than to level 0, checking the flag PCROP_RDP in the Option bytes page

    problem solved