Skip to main content
Visitor II
October 25, 2020
Solved

Read and write using ST-Link V2

  • October 25, 2020
  • 3 replies
  • 8699 views

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.

    This topic has been closed for replies.
    Best answer by AKh.2

    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.

    3 replies

    Super User
    October 25, 2020

    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.

    AKh.2Author
    Visitor II
    October 25, 2020

    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?

    AKh.2Author
    Visitor II
    October 25, 2020

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

    AKh.2Author
    Visitor II
    October 27, 2020

    @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

    AKh.2AuthorAnswer
    Visitor II
    October 27, 2020

    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.

    Graduate II
    October 27, 2020

    It says your part has 32KB, so size would be 0x8000

    Super User
    October 27, 2020

    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.