Lock a device with JLinkARM.dll

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • Lock a device with JLinkARM.dll

    Hello everybody,

    I am trying to lock my device (STM32...) J-Link ARM using the provided JLinkARM.dll library. In one example code proyect, I found a native function called "
    JLINKARM_Lock()" but it does not work. Could anybody help me to sort this problem out please?



    [DllImport("JLinkARM.dll")]
    private static extern void JLINKARM_Lock();


    internal static void jLINKARM_Lock()
    {
    JLINKARM_Lock();
    }



    Thanks in advance

    The post was edited 1 time, last by Spoon83 ().

  • Hi,

    there is no specific API function for enabling the read protection of the STM32.
    I we recommend to perform the secure-sequence out of the target application as far as possible (to not accidentally lock a incorrectly programmed device).
    On the STM32 this is possible, since the read-out protection is activated by programming the option bytes.
    J-Flash also supports activating the read-out protection of the STM32F103 devices.


    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 and thank you for answering me,

    Assuming that I would like to do it anyway, how could I programm those option bytes in order to lock my device?
    I have tried to follow the manual "J-Flash ARM (UM08003)" Section 7.6.1.2 (Option byte programming), and I am able to readMem of the real memory location (0x1FFFF800) of those bytes getting the value of 0xA5 in the first option byte. It means that it is unlocked, so I try to change it to 0xFF to lock it but it does not. Could you help me please?

    Thank you again
  • Hi,

    If you want to activate the readout protection of the STM32F103, simply use the Target -> Secure Chip option in J-Flash.
    You can also program a bin file via J-Flash (Start addr. 0x06000000 as described in UM08003) which defines the option bytes contents
    If you want to do it in your own application, you have to write the option byte handling by yourself.
    How to erase & program the option bytes is explained in the flash programming manual of the STM32F1xxx.

    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.