cancel
Showing results for 
Search instead for 
Did you mean: 

Virgin STM32L4 always shows "Mass erase operation failed. Pleaes verify flash protection" error

JDoe.10
Associate II

Virgin STM32L4 always shows "Mass erase operation failed. Pleaes verify flash protection" error in STM32CubeProg. It is a virgin device, I guess as factory setting there should be no write protection. How could I flash it at all?

Thank you very much!

1 ACCEPTED SOLUTION

Accepted Solutions
JDoe.10
Associate II

Problem is solved by using another vendor's ST-LINK V2 USB dongle.

View solution in original post

7 REPLIES 7

There was a complaint about this the other week as I recall, but might suggest posting against current release notification.

Identify which "L4" model specifically you're having problems with.

https://community.st.com/s/question/0D53W00001Pp56zSAB/stm32cubeprogrammer-2100-released

Could perhaps relate to PERROR or OPTVERR

Code examples explicitly clear a related flag

 /* Clear OPTVERR bit set on virgin samples */

 __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_OPTVERR);

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

0693W00000LyEzqQAF.pngThank you very much! I should have provided more information.

I'm using ST Link V2 4-wire debugger to flash my board (self designed). I noticed that, if I lower down the "Frequency", then it can sometimes successfully flash (in this screenshot the frequnecy is only 15kHz).

When I select higher frequency, i got error like "Error: ST-LINK error (DEV_TARGET_CMD_ERR)".

When I select even higher frequency like 4000kHz then it can not connect at all and shows "Error: No STM32 target found!"

Therefore I would assume that the "write protection" error is a fake error, which is caused by disturbed signals between my board and the debugger.

Do you have any extra comments please? E.g. do we have any guides or application note about the 4 wire SWD debug port design?

JDoe.10
Associate II

Problem is solved by using another vendor's ST-LINK V2 USB dongle.

Had a similar problem with a particular STLink-V2 clone:

https://www.mikrocontroller.net/topic/515218

The problem was a 1k2 pull-down connected to SWCLK (rather insane, I'd say) or more likely bad PCB design.

Piranha
Chief II

> Do you have any extra comments please?

What's the point of torturing yourself with the Chinese clones instead of buying any official NUCLEO-64/144 board with an authentic onboard ST-LINK, which can also program other external boards?

Also the original standalone ST-LINK and SEGGER J-Link EDU Mini tools are pretty cheap.

You're right - to some extent. But if you've got a whole bunch of different chips (not all of them available on Nucleo boards) in use simultaneously, it's getting quite annoying to change cabling every now and then. Getting several dozens STLink clones and attaching them permanently to the various targets makes life much easier ...

The price isn't the main point here: The STLink clones are quite small, have an insulated case (vs. STLink-V3mini) and 1/10 inch headers - simply convenient. If ST would offer something like that ...

Yes, I agree that it is a good idea to have at least 1 original/authentic ST Link USB doggle to verify user board is working. And it is also common that during development there are different versions of PCB boards, multiple debug/flash connectors on PCB etc, therefore it is normal to have ST Link USB doggles from different vendors.

One more comment: it seems the cable length between PCB and doggle is critical too. The shorter, the better.