cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G491KEU6 - booting problem

Adam_Stastny
Visitor

Hello,

I need to use a nRST pin as MCO in my aplication and programm my STM with STlink v3-set. I set up a MCO to output 8MHz signal and set nRST pin to GPIO with code you can see bellow. Now I have a problem with booting - I cannot connect to STM, CubeProgrammer have a error: 10:00:55 : Error: Data read failed
Can you please help me, how to fix that? I tried to used software reset, which does not help.

btw I can connect to STM only via STlink - I made a custom PCB for my application

Thank you

 

HAL_FLASH_Unlock();

HAL_FLASH_OB_Unlock();

OBInit.OptionType = OPTIONBYTE_USER;

OBInit.USERType = OB_USER_NRST_MODE;

OBInit.USERConfig = FLASH_OPTR_NRST_MODE_1;

HAL_FLASHEx_OBProgram(&OBInit);

HAL_FLASH_OB_Launch();

HAL_FLASH_OB_Lock();

HAL_FLASH_Lock();

1 ACCEPTED SOLUTION

Accepted Solutions
gbm
Lead III

Unless you have disabled SWDIO or SWCLK, the debug connection should still work - no hardware reset is neede. Set the debug interface to reset method - sysresetrq, normal connection of live/hot connection.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice

View solution in original post

5 REPLIES 5
gbm
Lead III

Unless you have disabled SWDIO or SWCLK, the debug connection should still work - no hardware reset is neede. Set the debug interface to reset method - sysresetrq, normal connection of live/hot connection.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice
Adam_Stastny
Visitor

11:31:31 : Debug in Low Power mode is not supported for this device.
11:31:32 : UPLOADING OPTION BYTES DATA ...
11:31:32 : Bank : 0x00
11:31:32 : Address : 0x40022020
11:31:32 : Size : 84 Bytes
11:31:32 : UPLOADING ...
11:31:32 : Size : 1024 Bytes
11:31:32 : Address : 0x8000000
11:31:32 : Read progress:
11:31:32 : Error: Data read failed

gbm
Lead III

So the debug connection is basically working. Try to restore the factory settings - reset option bytes and do a full chip erase, then play again, more carefully.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice
Adam_Stastny
Visitor

Thank you,
can you please me with reseting memory? I am kinda lost...
I set NRST_MODE back to 1, as you can see bellow

Adam_Stastny_0-1732013940761.png

Then I tried to erase flash memory, but it give me a error

Adam_Stastny_1-1732014038043.png

 

I figured out, how it works, so thank you for help.

Anyway, what should I do to properly activate MCO instead of nRST on my STM, but still keep debugger functional? I read something about delay (or timer?) before changing nRST to MCO...