cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G0 bought with level 2 protection

FranzCreva
Senior

Hi all, I'm new to this STM32 community.

I have a small problem: I bought some STM32G0P0.. for my project, also making the PCB and the rest. But after soldering the various components, I try to program one and see that the level 2 protection is active, I try to program another and there is the same thing.

What I see from the STM32 St-LINK program is that only some memory pages have protection, while others don't, but then going to view the memory areas I see that they have all been set to FFFFFFFF.

Below I can see that the memory on the address 0x08001400 is free, but..

0693W00000WIxGqQAL.png 

..here I see that is protected! How can I program it?

0693W00000WIxHFQA1.png 

My question now is: what the hell do I do? Do I ask for a return? Is this a normal thing of STM32G0...? Trying to write a bootloader that makes me jump from one address to another when the memory to read is full?

Thank you for your availability and attention

63 REPLIES 63
AScha.3
Chief III

Ooo,

0693W00000WKO9jQAH.pngset:

  • automated
  • 4 MHz
  • software system reset
  • keep pin boot0 lo , at gnd.

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

I don't work for ST, you'll need to raise those responsible for CubeIDE and the integration of assorted components.

The 0x1FFFxxxx addresses are indicative of being in the boot-loader.

Perhaps support for STM32G0 is not where it needs to be, I'll flag this upward.

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

Hi @Community member​ ,

This is highlighted to our STM32CubeIDE Experts, they will look to it and come back here.

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

mattias norlander
ST Employee

Hi @FranzCreva,

It seems as if you are using CubeIDE version 1.10.1.

In CubeIDE 1.11.0 released last week CubeIDE is slightly better able to detect when CubeProg CLI fails to flash and can abort the debug session a little bit earlier. That said, error handling is still an issue where one root-cause is missing granularity on return codes from CubeProg CLI. And it is unlikely to solve your issues, so no need to update for you.

Question1: Is the application you are developing putting MCU in low-power modes?

If so, you must use:

  • Reset strategy = Connect under reset
  • Enable debug in low-power modes

Not using these options should give you the error shown in the first dialogs: "No device found on target".

Reading this thread it seems as if you are able to use CubeProg stand-alone version in GUI mode to program the device.

Meanwhile inside CubeIDE when IDE is calling CubeProg to do the programming you end up with :

Error: No STM32 target found!
Encountered Error when opening C:\ST\STM32CubeIDE_1.10.1\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.win32_2.0.301.202207041506\tools\bin\STM32_Programmer_CLI.exe
Error in STM32CubeProgrammer
Shutting down...
Exit.

This makes me curious... I don't have access to a STM32G0... board even less to your custom PCB.

Here is my train of thoughts:

  • CubeProg GUI version flashes the board OK
  • Can CubeProg CLI version flash the board OK?
    • CubeIDE uses CLI version, not GUI version. They rely on same flash loader, but let's make "Test1"

Test1: Try to flash your application relying on CubeProg CLI by using this command:

C:\ST\STM32CubeIDE_1.10.1\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.win32_2.0.301.202207041506\tools\bin\STM32_Programmer_CLI.exe -c port=SWD -d C:\Users\norlandm\STM32CubeIDE\workspace_IPCEI\STM32F4_RTOS\Debug\STM32F4_RTOS.elf

Obviously you need to modify the two paths in the above example. Does Test1 work well or not?

If not, then we know that the root-cause is isolated to CubeProg CLI ( or potentially the flash loader).

I think this test will be successful. But we have to execute it anyway to narrow down the scope!

Next thought is related to this screenshot of yours:

Here I am thinking that there could be an issue inside the flash loader. If the flash loader does not de-initialize the resources it uses (specifically interrupts) it will leave the MCU in a dirty state.

The effect can be that CubeProg stand-alone can flash the MCU correctly. What you may or may not notice is that the CPU is crashed afterwards depending on how CubeProg applies resets afterwards...

This leads us to Test2:

  1. Use CubeProg stand-alone GUI version to flash your application
  2. Disconnect CubeProg. De-tach and re-attach the board to your PC
  3. In CubeIDE setup a debug configuration which does NOT load the elf-file to target. Use default settings in the debug configuration (use ST-LINK GDB server) and then make these specific settings:
    1. Reset strategy : Connect under reset
    2. Enable low power debug modes (just to be safe)
    3. In the Startup tab > Load Image and Symbols > Debug/myproject.elf > Edit
      1. Disable the Download check-box

With this configuration STM32_Programmer_CLI.exe will not be involved at all. No flashing will be done from the IDE. It assume that the flashing is manually done in step1. All IDE is doing is to reset and connect to the device to just take control of the debug session.

Let us know - what works - what does not work?!

Sorry for the struggle!

Kind regards, Mattias

No no, this is not my configuration, I don't know how I managed to take this screenshot.

However my configuration is the same except for the Speed, which I set at 950khz, since with STM32Programmer I can connect to the device with that frequency and not with 4MHz.

If I try to set the speed to 4MHz I get this error:

0693W00000WKb7bQAD.png 

and this message:

Open On-Chip Debugger 0.11.0+dev-00449-g53fa0f7 (2022-06-09-09:42) [https://github.com/STMicroelectronics/OpenOCD]
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : STLINK V2J40S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.229377
Info : clock speed 4000 kHz
Info : stlink_dap_op_connect(connect)

Instead when I try to program it I get the same error as before, but with this message:

Open On-Chip Debugger 0.11.0+dev-00449-g53fa0f7 (2022-06-09-09:42) [https://github.com/STMicroelectronics/OpenOCD]
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : STLINK V2J40S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.254557
Error: init mode failed (unable to connect to the target)

Hi @mattias norlander​. Yes I use version 1.10.1.

Answer 1:

No, I don't put my microcontroller in rest mode, but I still put the flag, in the debug configuration, on the "Enable Debug in low power mode" item and also "Stop watcdog counter when halt".

I tried to set "connect under reset" as "reset mode", but I got these error messages:

0693W00000WKb8jQAD.png 

Open On-Chip Debugger 0.11.0+dev-00449-g53fa0f7 (2022-06-09-09:42) [https://github.com/STMicroelectronics/OpenOCD]
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : STLINK V2J40S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.245115
Info : clock speed 950 kHz
Info : stlink_dap_op_connect(connect)
Info : SWD DPIDR 0x0bc11477
Info : STM32G050F6Px.cpu: Cortex-M0+ r0p1 processor detected
Info : STM32G050F6Px.cpu: target has 4 breakpoints, 2 watchpoints
Info : starting gdb server for STM32G050F6Px.cpu on 3333
Info : Listening on port 3333 for gdb connections
Info : accepting 'gdb' connection on tcp/3333
Error: timed out while waiting for target halted
Error executing event gdb-attach on target STM32G050F6Px.cpu:
C:/ST/STM32CubeIDE_1.10.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.debug.openocd_2.0.300.202206090745/resources/openocd/st_scripts/gdb_helper.tcl:18: Error: TARGET: STM32G050F6Px.cpu - Not halted
in procedure 'gdb_attach_hook' called at file "C:/ST/STM32CubeIDE_1.10.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.debug.openocd_2.0.300.202206090745/resources/openocd/st_scripts/target/stm32g0x.cfg", line 128
in procedure 'first_gdb_attach_hook' called at file "C:/ST/STM32CubeIDE_1.10.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.debug.openocd_2.0.300.202206090745/resources/openocd/st_scripts/gdb_helper.tcl", line 18
Info : device idcode = 0x10006456 (STM32G05/G06xx - Rev A : 0x1000)
Info : RDP level 0 (0xAA)
Info : flash size = 32kbytes
Info : flash mode : single-bank
Warn : GDB connection 1 on target STM32G050F6Px.cpu not halted
Info : accepting 'gdb' connection on tcp/3333
Warn : GDB connection 2 on target STM32G050F6Px.cpu not halted
Error: timed out while waiting for target halted
Error executing event gdb-flash-erase-start on target STM32G050F6Px.cpu:
TARGET: STM32G050F6Px.cpu - Not halted
Error: Target not halted
Error: failed erasing sectors 0 to 3
Error: flash_erase returned -304
Info : dropped 'gdb' connection
shutdown command invoked
Info : dropped 'gdb' connection

0693W00000WKb93QAD.png 

I tried to do test 1, setting only the port in the first time, then, after seeing that it didn't detect an STM32 device, I also tried to set the frequency, but nothing:

0693W00000WKbALQA1.png 

For test 2, following all your directions, it still doesn't go debugging.

The error messages are these:

0693W00000WKbB9QAL.pngand

STMicroelectronics ST-LINK GDB server. Version 7.0.0
Copyright (c) 2022, 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
        InitWhile                  : Enabled
 
Waiting for debugger connection...
Debugger connected
Waiting for debugger connection...
Debugger connected
Waiting for debugger connection...

Thank you for all the help you are giving me and for your availability.

Have a good day everyone!

Hi Franz,

Hmm... Let me tie back to Test2! Are you saying that CubeProg GUI version could connect to the device and flash the binary successfully??

0693W00000WKdSRQA1.pngPlease confirm. Even please put the CubeProg log information with verbosity level 3?!

It would be very weird if CubeProg GUI work and CubeProg CLI does not work... We need to clarify this first.

You could also drop me a PM if we should setup a remote session.

But let's await your feedback on Test2...

Hi @mattias norlander​.

Yes I can flash the .elf of my project, I didn't try the binary:

0693W00000WKgroQAD.png 

and the entire message is this:

  00:29:26:335 : Memory Programming ...
  00:29:26:337 : Opening and parsing file: provaprovaprova.elf
  00:29:26:352 :   File          : provaprovaprova.elf
  00:29:26:353 :   Size          : 6.16 KB 
  00:29:26:353 :   Address       : 0x08000000 
  00:29:26:353 : Erasing Segment <0> Address <0x08000000> Size <6304>Bytes
  00:29:26:353 : Erasing memory corresponding to segment 0:
  00:29:26:354 : Memory erase...
  00:29:26:359 : halt ap 0 
  00:29:26:360 : w ap 0 reg 15 PC   (0x20000000)  
  00:29:26:362 : w ap 0 reg 17 MSP  (0x20000500)  
  00:29:26:366 : w ap 0 reg 16 xPSR (0x01000000)  
  00:29:26:373 : w ap 0 @0x20000B80 0x00000200 bytes Data 0x00000000
  00:29:26:374 : w ap 0 @0x20000000 0x00000004 bytes Data 0x0000BE00
  00:29:26:398 : w ap 0 @0x20000004 0x00000754 bytes Data 0x483EB580
  00:29:26:398 : Erasing internal memory sectors [0 3]
  00:29:26:399 : Init flashloader...
  00:29:26:403 : halt ap 0 
  00:29:26:407 : w ap 0 reg 0 R0   0x00000001
  00:29:26:408 : w ap 0 reg 1 R1   0x00000000
  00:29:26:409 : w ap 0 reg 2 R2   0x00000000
  00:29:26:411 : w ap 0 reg 3 R3   0x00000000
  00:29:26:411 : w ap 0 reg 4 R4   0x00000000
  00:29:26:411 : w ap 0 reg 5 R5   0x00000000
  00:29:26:412 : w ap 0 reg 6 R6   0x00000000
  00:29:26:413 : w ap 0 reg 7 R7   0x00000000
  00:29:26:414 : w ap 0 reg 8 R8   0x00000000
  00:29:26:416 : w ap 0 reg 9 R9   0x00000000
  00:29:26:425 : w ap 0 reg 10 R10  0x00000000
  00:29:26:430 : w ap 0 reg 11 R11  0x00000000
  00:29:26:430 : w ap 0 reg 12 R12  0x00000000
  00:29:26:431 : w ap 0 reg 13 SP   0x00000000
  00:29:26:432 : w ap 0 reg 14 LR   0x20000001
  00:29:26:433 : w ap 0 reg 15 PC   0x20000005
  00:29:26:435 : w ap 0 reg 16 xPSR 0x01000000
  00:29:26:435 : w ap 0 reg 17 MSP  0x20000B54
  00:29:26:436 : w ap 0 reg 18 PSP  0x00000000
  00:29:26:436 : run ap 0 
  00:29:26:436 : halt ap 0 
  00:29:26:438 : r ap 0 reg 0 R0   0x00000001
  00:29:26:438 : Loader sector erase...
  00:29:26:439 : w ap 0 reg 0 R0   0x08000000
  00:29:26:445 : w ap 0 reg 1 R1   0x08001800
  00:29:26:446 : w ap 0 reg 2 R2   0x00000002
  00:29:26:448 : w ap 0 reg 3 R3   0x00000000
  00:29:26:452 : w ap 0 reg 4 R4   0x00000000
  00:29:26:453 : w ap 0 reg 5 R5   0x00000000
  00:29:26:455 : w ap 0 reg 6 R6   0x00000000
  00:29:26:457 : w ap 0 reg 7 R7   0x00000000
  00:29:26:457 : w ap 0 reg 8 R8   0x00000000
  00:29:26:458 : w ap 0 reg 9 R9   0x00000000
  00:29:26:460 : w ap 0 reg 10 R10  0x00000000
  00:29:26:460 : w ap 0 reg 11 R11  0x00000000
  00:29:26:465 : w ap 0 reg 12 R12  0x00000000
  00:29:26:466 : w ap 0 reg 13 SP   0x00000000
  00:29:26:467 : w ap 0 reg 14 LR   0x20000001
  00:29:26:469 : w ap 0 reg 15 PC   0x20000387
  00:29:26:470 : w ap 0 reg 16 xPSR 0x01000000
  00:29:26:471 : w ap 0 reg 17 MSP  0x20000B54
  00:29:26:472 : w ap 0 reg 18 PSP  0x00000000
  00:29:26:472 : run ap 0 
  00:29:26:545 : halt ap 0 
  00:29:26:547 : r ap 0 reg 0 R0   0x00000001
  00:29:26:548 : erase: 0198ms
  00:29:26:548 : Download in Progress:
  00:29:26:549 :   Size          : 6304 Bytes
  00:29:26:549 :   Address       : 0x08000000 
  00:29:26:549 : Buffer program...
  00:29:26:560 : halt ap 0 
  00:29:26:560 : w ap 0 reg 15 PC   (0x20000000)  
  00:29:26:560 : w ap 0 reg 17 MSP  (0x20000500)  
  00:29:26:560 : w ap 0 reg 16 xPSR (0x01000000)  
  00:29:26:566 : w ap 0 @0x20000B80 0x00000200 bytes Data 0x00000000
  00:29:26:571 : w ap 0 @0x20000000 0x00000004 bytes Data 0x0000BE00
  00:29:26:594 : w ap 0 @0x20000004 0x00000754 bytes Data 0x483EB580
  00:29:26:595 : Loader write range...
  00:29:26:646 : w ap 0 @0x20000B80 0x00000C50 bytes Data 0x20004800
  00:29:26:646 : W B1 in RAM @0x20000B80 size 0x00000C50 : 0052ms
  00:29:26:646 : Init flashloader...
  00:29:26:650 : halt ap 0 
  00:29:26:651 : w ap 0 reg 0 R0   0x00000001
  00:29:26:652 : w ap 0 reg 1 R1   0x00000000
  00:29:26:653 : w ap 0 reg 2 R2   0x00000000
  00:29:26:654 : w ap 0 reg 3 R3   0x00000000
  00:29:26:655 : w ap 0 reg 4 R4   0x00000000
  00:29:26:656 : w ap 0 reg 5 R5   0x00000000
  00:29:26:658 : w ap 0 reg 6 R6   0x00000000
  00:29:26:659 : w ap 0 reg 7 R7   0x00000000
  00:29:26:661 : w ap 0 reg 8 R8   0x00000000
  00:29:26:662 : w ap 0 reg 9 R9   0x00000000
  00:29:26:663 : w ap 0 reg 10 R10  0x00000000
  00:29:26:669 : w ap 0 reg 11 R11  0x00000000
  00:29:26:672 : w ap 0 reg 12 R12  0x00000000
  00:29:26:675 : w ap 0 reg 13 SP   0x00000000
  00:29:26:676 : w ap 0 reg 14 LR   0x20000001
  00:29:26:677 : w ap 0 reg 15 PC   0x20000005
  00:29:26:677 : w ap 0 reg 16 xPSR 0x01000000
  00:29:26:677 : w ap 0 reg 17 MSP  0x20000B54
  00:29:26:678 : w ap 0 reg 18 PSP  0x00000000
  00:29:26:678 : run ap 0 
  00:29:26:678 : halt ap 0 
  00:29:26:680 : r ap 0 reg 0 R0   0x00000001
  00:29:26:687 : w ap 0 reg 0 R0   0x08000000
  00:29:26:687 : w ap 0 reg 1 R1   0x00000C50
  00:29:26:689 : w ap 0 reg 2 R2   0x20000B80
  00:29:26:691 : w ap 0 reg 3 R3   0x00000002
  00:29:26:694 : w ap 0 reg 4 R4   0x00000000
  00:29:26:696 : w ap 0 reg 5 R5   0x00000000
  00:29:26:697 : w ap 0 reg 6 R6   0x00000000
  00:29:26:698 : w ap 0 reg 7 R7   0x00000000
  00:29:26:698 : w ap 0 reg 8 R8   0x00000000
  00:29:26:699 : w ap 0 reg 9 R9   0x00000000
  00:29:26:699 : w ap 0 reg 10 R10  0x00000000
  00:29:26:700 : w ap 0 reg 11 R11  0x00000000
  00:29:26:701 : w ap 0 reg 12 R12  0x00000000
  00:29:26:703 : w ap 0 reg 13 SP   0x00000000
  00:29:26:710 : w ap 0 reg 14 LR   0x20000001
  00:29:26:710 : w ap 0 reg 15 PC   0x2000003B
  00:29:26:712 : w ap 0 reg 16 xPSR 0x01000000
  00:29:26:713 : w ap 0 reg 17 MSP  0x20000B54
  00:29:26:714 : w ap 0 reg 18 PSP  0x00000000
  00:29:26:714 : run ap 0 
  00:29:26:750 : w ap 0 @0x200017D0 0x00000C50 bytes Data 0x2201681B
  00:29:26:750 : W B2 in RAM @0x20002480 size 0x00000C50: 0101ms
  00:29:26:751 : r ap 0 reg 0 R0   0x00000001
  00:29:26:751 : Wait W B1 in Flash @0x08000000 size 0x00000C50: 0002ms
  00:29:26:754 : w ap 0 reg 0 R0   0x08000C50
  00:29:26:757 : w ap 0 reg 1 R1   0x00000C50
  00:29:26:761 : w ap 0 reg 2 R2   0x200017D0
  00:29:26:763 : w ap 0 reg 3 R3   0x00000002
  00:29:26:764 : w ap 0 reg 4 R4   0x00000000
  00:29:26:764 : w ap 0 reg 5 R5   0x00000000
  00:29:26:766 : w ap 0 reg 6 R6   0x00000000
  00:29:26:766 : w ap 0 reg 7 R7   0x00000000
  00:29:26:766 : w ap 0 reg 8 R8   0x00000000
  00:29:26:766 : w ap 0 reg 9 R9   0x00000000
  00:29:26:768 : w ap 0 reg 10 R10  0x00000000
  00:29:26:769 : w ap 0 reg 11 R11  0x00000000
  00:29:26:770 : w ap 0 reg 12 R12  0x00000000
  00:29:26:771 : w ap 0 reg 13 SP   0x00000000
  00:29:26:780 : w ap 0 reg 14 LR   0x20000001
  00:29:26:782 : w ap 0 reg 15 PC   0x2000003B
  00:29:26:784 : w ap 0 reg 16 xPSR 0x01000000
  00:29:26:786 : w ap 0 reg 17 MSP  0x20000B54
  00:29:26:787 : w ap 0 reg 18 PSP  0x00000000
  00:29:26:787 : run ap 0 
  00:29:26:817 : r ap 0 reg 0 R0   0x00000001
  00:29:26:817 : Write elapsed time: 0217ms
  00:29:26:817 : Segment[0] downloaded successfully
  00:29:26:817 : File download complete
  00:29:26:839 : Time elapsed during download operation: 00:00:00.463
  00:29:26:841 : Verifying ...
  00:29:26:841 : Read progress:
  00:29:26:841 : Reading data...
  00:29:26:906 : r ap 0 @0x08000000 0x000018A0 bytes Data 0x20004800
  00:29:26:906 : Download verified successfully 

I don't know where are you from and what is your time zone.

I'm form Italy, so my time zone is UTC +1.

Anyway thanks for all the support