cancel
Showing results for 
Search instead for 
Did you mean: 

Read and write using ST-Link V2

AKh.2
Associate II

Hi everyone,

I do have 2 PCB boards based on STM32F030F4P6 MCU, the two PCBs have the same hardware and connection with other components, I read the first MCU's code using ST-LInk V2 -using SWD- and saved the .hex file to my PC then I wanted to re-program the other one with the same code, the programming proccess works well and the ST Link utility says that it success but when trying to run the code it says "unable to run"

what shall I do to correctly copy the same code? I program the flash memory and make sure that the Option Bytes are the same, what else must be copied to let the MCU work?

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions

I guess that I got my problem, so my question will be: how to correctly read the whole flash memory? as I was trying to read it following the program's default settings (address : 0x08000000 and size : 0x400), I've tried to read from 0x0 up to 0x10000000 just to try getting the whole size but the program says: Error: Data read failed.

View solution in original post

12 REPLIES 12
TDK
Guru

Copying the flash and option bytes is all you need to do. Do you have a screenshot of the "unable to run" message? You could try STM32CubeProgrammer instead.

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

Thanks for your reply, here is a screenshot

why do you prefer to use STM32CubeProgrammer? shall I also read the flash memory again with it?

I've tried STM32CubeProgrammer and when program it it says "Core is locked up"

Well the ST-LINK Utilities have been deprecated, most development efforts focus on the STM32 Cube Programmer

Are these boards you designed, or are you trying to copy someone else's? Perhaps protected, or keyed on Unique ID or OTP

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

I don't see a screenshot in your post.

STM32CubeProgrammer is newer and better supported. They do the same job, so sometimes one works and one doesn't. For older chips though, both should work. Easy enough to test.

There are a few hits online for "core is locked up" but no clear solution. Maybe decrease the clock speed.

If the flash is programmed, you shouldn't need anything to run the code. Just remove the ST-Link and power cycle the chip.

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

No they are someone else's design both, I am trying to reverse engineering it.

but I guess they aren't protected as I can read the flash memory, option bytes and CPU information.

but what do you mean by Unique ID or OTP? can I read the first one's and change them for the other?

AKh.2
Associate II

0693W0000059FTfQAM.png

AKh.2
Associate II

@TDK​ I worked for two days trying to find any way to solve my problem, I've opened another board trying to program it but the same thing happened to me :(

Please if you can help me I can tell you what I do step by step.

Thanks

TDK
Guru

I'm not sure what "Run" in that box is supposed to do. Without a debugger attached, the chip will run on its own. Within STM32CubeIDE, you can also run the code. You don't need to tell the chip to run. Once you provide it power, it will run, assuming it's not halted from the debugger or in reset.

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