[SOLVED] JLinkSTM32 - clear/erase device data

  • [SOLVED] JLinkSTM32 - clear/erase device data

    Hi,



    i am using the JLinkSTM32.exe to clear the device, this works fine, but i need a way to activate the sequence from within my code using c#, I tried using the JLinkARMFlash.dll but with out success, can anyone advice ?



    thanks.,

    Guy.
  • Hi Guy,

    what are you looking for?
    Sample code how to perform a chip erase or a way to call the JLinkSTM32.exe from command line?
    Or would either of the two options work for you?


    Best regards
    Alex
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hi Guy,

    since the source code of the STM32 unlock tool is not open source,
    I can not post it here.

    But triggering a mass/chip erase on the STM32 is not that complicated.
    Have a look at the Flash programming documentation of ST.


    Best regards
    Alex
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Alex,



    I am not sure what you mean by the " Flash programming documentation of ST", do documentation i am using is UM08002_JLinkArmDLL.pdf.



    i tried using the "JLINKARM_FLASH_EraseChip()" but it fails every time (returns false), so i guess i need to do something diffrently. is there a guid line or a code example to erase the device, as i said currently the jlinkstm32 works fine but it needs user interaction that doesn't suit my application (the application has a full flashing cycle include user interface for hex file selection, convertion, flashing and etc and the only thing missing is the "erase" of the device at the start of the flashing process).



    Thanks,

    Guy.
  • Hi Guy,

    usually the EraseChip() function of the J-Link FlashDLL should work as long as the device readout protection is NOT enabled.
    If the readout protection IS enabled, the flash has to be erased in a different way,
    since the usual chip erase command does NOT erase the option bytes and thus has no impact on the readout protection, so it can not be used.

    If NO device security is active on your STM32 device the EraseChip() function should work.
    In this case we will have a look into this.


    Best regards
    Alex
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hi Alex,



    I must assume that the device might be protected / locked, and the procedure i am doing should erase a locked device as well (knowing that all the data will be erased).



    So what is the different way to do that ? how do i disable the readout protection / the option bytes ?



    Guy.
  • Hi,

    So what is the different way to do that ? how do i disable the readout protection / the option bytes ?
    As Alex already described, the unlock sequence is described in the ST "Programming Manual" for your used device / series. The documentation can be found on the ST website. Example for the STM32F2 series: st.com/content/st_com/en/suppo…ceType=programming_manual


    Best regards
    Erik
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.