Skip to main content
Explorer
July 7, 2025
Solved

Using ST-Link v2 and Utility to read program from STM32F103C8T

  • July 7, 2025
  • 4 replies
  • 922 views

Using ST-Link v2 and Utility I've been trying to read and save a hex file from a EVSE device that uses a STM32F1 microprocessor to control and display functions. I thought that it was just a matter of connecting via the  debug/program interface and then saving the result, but unfortunately I seem to have erased everything and now the memory is displayed as empty.
My experience on this sort of thing is limited so can anyone help and possibly comment on what I'm doing wrong?

    This topic has been closed for replies.
    Best answer by Karl Yamashita

    @ludemon wrote:

    Thank you Andrew for your reply.

    Yes it is Electric Vehicle Supply Equipment aka Portable EV Charger.

    I did get a message saying that read-out protection was enabled so I disabled it in Option Bytes. Is that likely to have caused the problem?

    I don't know if the ST-Link is genuine or not, I bought it from an Aliexpress seller. It does seem to be recognized as genuine by the utility.

    I have another similar working EVSE which I could attempt to extract the program from using a STM32CubeProgrammer, but from my previous experience and your comment about Intellectual Property I'm reluctant to take the risk.


    By disabling the Option byte, you've inevitably erased the firmware in the STM32F1xx.

    If the STM32 is code protected, then there is not much you can do to extract the code.  

    4 replies

    Super User
    July 7, 2025

    Is that "EVSE" as in Electric Vehicle Supply Equipment ?

    It's quite likely that the manufacturer will have read-protected the device - ie, their Intellectual Property (IP). 

     

    Is it a genuine ST-Link?

    Note that the ST-Link Utility has been obsolete for years - the current tool is STM32CubeProgrammer:

    https://www.st.com/en/development-tools/stm32cubeprog.html

     

     

    ludemonAuthor
    Explorer
    July 7, 2025

    Thank you Andrew for your reply.

    Yes it is Electric Vehicle Supply Equipment aka Portable EV Charger.

    I did get a message saying that read-out protection was enabled so I disabled it in Option Bytes. Is that likely to have caused the problem?

    I don't know if the ST-Link is genuine or not, I bought it from an Aliexpress seller. It does seem to be recognized as genuine by the utility.

    I have another similar working EVSE which I could attempt to extract the program from using a STM32CubeProgrammer, but from my previous experience and your comment about Intellectual Property I'm reluctant to take the risk.

    Graduate II
    July 7, 2025

    @ludemon wrote:

    Thank you Andrew for your reply.

    Yes it is Electric Vehicle Supply Equipment aka Portable EV Charger.

    I did get a message saying that read-out protection was enabled so I disabled it in Option Bytes. Is that likely to have caused the problem?

    I don't know if the ST-Link is genuine or not, I bought it from an Aliexpress seller. It does seem to be recognized as genuine by the utility.

    I have another similar working EVSE which I could attempt to extract the program from using a STM32CubeProgrammer, but from my previous experience and your comment about Intellectual Property I'm reluctant to take the risk.


    By disabling the Option byte, you've inevitably erased the firmware in the STM32F1xx.

    If the STM32 is code protected, then there is not much you can do to extract the code.  

    Technical Moderator
    July 7, 2025

    Hello;

    Are you using Blue Pill board?

    Post photos of your board and the ST-LINK: bottom and top.

    ludemonAuthor
    Explorer
    July 8, 2025

    I'm not using a Blue Pill board. I thought that was for development purposes.

    The photo shows my ST-Link connected to the existing board via GND CLK DIO VCC port.

    EVSE_STLINK.jpg

    Technical Moderator
    July 8, 2025

    That’s unfortunately not a genuine STLINK.

    Super User
    July 8, 2025

    > My experience on this sort of thing is limited so can anyone help and possibly comment on what I'm doing wrong?

    If you can connect over SWD and view the content of the flash, you can save it to disk. It is straightforward.

    Unclear what you did to erase the flash memory, but don't do that. It requires some effort--don't click things randomly.

     

    Try STM32CubeProgrammer instead of the ST-Link Utility which is no longer supported.

    ludemonAuthor
    Explorer
    July 8, 2025

    From what others have said, the fact that I disabled read out protection in Option Bytes caused the flash memory to be erased. Maybe this is more difficult to do in STM32CubeProgrammer with more warnings given, but it seems that if the code is read protected I can't do anything anyway.

    Super User
    July 8, 2025

    @ludemon wrote:

     the fact that I disabled read out protection in Option Bytes caused the flash memory to be erased. .


    Indeed - that is the documented behaviour.

    Think about it: if you could simply bypass the readout protection by just editing the option bytes that wouldn't provide any protection at all - would it?

     


    @ludemon wrote:

     it seems that if the code is read protected I can't do anything anyway.


    Indeed - that is the whole point of protecting the code!

     

    Super User
    July 9, 2025

    It seems that your original question is now answered?

    If so, please mark the solution - see:

    https://community.st.com/t5/community-guidelines/help-others-to-solve-their-issues/ta-p/575256