[SOLVED] Using JLink Commander for SAM4E user signature

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

  • [SOLVED] Using JLink Commander for SAM4E user signature

    I need to program the User Signature Area on SAM4E (store production data, serial number, calibration, etc.)

    I found this thread with a person requesting writing the user signature area on a different SAM4 MCU, but there is no reply and the thread is 3 years old:
    forum.segger.com/index.php/Thr…e-programming-via-J-Link/

    I have written a Flash Loader (ramcode/applet) and included it in JLinkDevices.xml. I can erase the User Signature area using J-Link commander:

    Source Code

    1. J-Link>exec EnableEraseAllFlashBanks
    2. J-Link>erase 0x00C00000 0x00C001FF
    3. Erasing selected range...
    4. J-Link: Flash download: Total time needed: 0.129s (Prepare: 0.018s, Compare: 0.000s, Erase: 0.065s, Program: 0.000s, Ver
    5. ify: 0.000s, Restore: 0.046s)
    6. J-Link: Flash download:
    7. Flash sectors within Range [0x00C00000 - 0x00C001FF] deleted.
    8. Erasing done.


    I can write to the User Signature Area (which includes read/verify):

    Source Code

    1. J-Link>loadfile c:\test\usig_src.bin 0x00C00000
    2. Downloading file [c:\test\usig_src.bin]...
    3. J-Link: Flash download: Bank 1 @ 0x00C00000: 1 range affected (512 bytes)
    4. J-Link: Flash download: Total: 0.211s (Prepare: 0.030s, Compare: 0.052s, Erase: 0.027s, Program: 0.030s, Verify: 0.024s,
    5. Restore: 0.046s)
    6. J-Link: Flash download: Program speed: 17 KB/s
    7. O.K.
    And if I try to program again, the section gets skipped, because it already matches:

    Source Code

    1. J-Link>loadfile c:\test\usig_src.bin 0x00C00000
    2. Downloading file [c:\test\usig_src.bin]...
    3. J-Link: Flash download: Bank 1 @ 0x00C00000: Skipped. Contents already match
    4. O.K.
    And immediately after programming I can read back the user signature area:

    Source Code

    1. J-Link>savebin c:\test\usig.bin 0x00C00000 0x200
    2. Opening binary file for writing... [c:\test\usig.bin]
    3. Reading 512 bytes from addr 0x00C00000 into file...O.K.
    Unfortunately, if i exit the JLink commander session and start a new one, I cannot read out the user signature area:

    Source Code

    1. J-Link>savebin c:\test\fail.bin 0x00C00000 0x200
    2. Opening binary file for writing... [c:\test\fail.bin]
    3. Reading 512 bytes from addr 0x00C00000 into file...Could not read memory.
    Because the User Signature Area is not memory mapped, I have implemented a native read function. But it seems the ramcode/applet is not loaded or used when calling savebin. :(
    Reading works fine in J-Flash (manual > read-back > range...):

    Source Code

    1. Reading target memory (0x00C00000 - 0x00C001FF) ...
    2. - Start of determining flash info (Bank 1 @ 0x00C00000)
    3. - End of determining flash info
    4. - Flash bank info:
    5. - 1 * 512 bytes @ 0x00C00000
    6. - Start of preparing flash programming
    7. - End of preparing flash programming
    8. - Start of restoring
    9. - End of restoring
    10. - Target memory read successfully. (512 bytes, 1 range) - Completed after 0.165 sec
    Unfortunately, I really need to call this from a script, so using Jlink Commander would be ideal.
    Can anyone suggest a method to read out the user signature using Jlink Commander?

    Best regards,
    Mikkel Holm Olsen
  • Hi Mikkel,
    Thank you for your inquiry.

    Yes, this is correct, "savebin" does not use the Openflashloader, and therefore only works, when it is already initialized.
    I added this to our feature request list.

    What you can do, is use J-Flash for this.
    J-Flash is fully usable via command line:
    wiki.segger.com/UM08003_JFlash#Command_Line_Interface

    For now:
    You could call J-Flash with the -readrange command and save the data into a file.
    Then your script could simply open the file and read the data from it.
    Would this work for you?

    Best regards,
    Fabian
    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.
  • Dear Fabian,

    Thank you for the quick reply. I have just done a little testing, and it appears I can make it work with the following command line:

    Source Code

    1. start /min /wait "J-Flash" jflash.exe -openprjtest.jflash -readrange0x00C00000,0x00C001FF -saveasusig.bin,0x00C00000,0x00C001FF -exit

    Thank you for also adding it to the JLink Commander feature request list.

    Best regards,
    Mikkel Holm Olsen
  • Hi Mikkel,
    Good to hear that you are up and running.

    We will close this thread now.

    Best regards,
    Fabian
    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.