[SOLVED] JLinkExe with LM3S5B91 on Linux

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

  • [SOLVED] JLinkExe with LM3S5B91 on Linux

    Hi,
    I am trying to make a script to flash this micro (on Linux) without any user prompts but I am having a few issues.

    The first was that I have to reset because the JTAG pins are used by the application - I tried various rsettype settings but to no avail as well as some attempts with rx.
    In the end I did

    Source Code

    1. r0
    2. sleep 200
    3. r1
    4. connect


    and it worked but I am wondering if there is a better way.

    The other as yet unsolved problem is that I am always prompted for the jtag configuration (IRlen etc).

    My command file is..

    Source Code

    1. device LM3S5B9
    2. 1if JTAG
    3. speed 1000
    4. sleep 10
    5. r0
    6. sleep 100
    7. r1
    8. connect
    9. r
    10. halt
    11. erase
    12. loadbin bl.bin 0
    13. loadbin main.bin 0x2000
    14. g
    15. qc
    Display All


    And I run it like so

    Source Code

    1. JLinkExe -CommanderScript flashit


    The output is as follows (I have to press enter at the 'JTAGConf>' prompt)

    Source Code

    1. [ubuntu 4:56] ~/firmware >JLinkExe -CommanderScript flashit
    2. SEGGER J-Link Commander V5.12d (Compiled Apr 26 2016 19:23:38)
    3. DLL version V5.12d, compiled Apr 26 2016 19:23:34
    4. Script file read successfully.
    5. Processing script file...
    6. J-Link connection not established yet but required for command.
    7. Connecting to J-Link via USB...O.K.
    8. Firmware: J-Link Ultra Rev.1 compiled Dec 3 2013 14:27:53
    9. Hardware version: V1.00
    10. S/N: 291200193
    11. OEM: IAR
    12. VTref = 3.332V
    13. Selecting JTAG as current target interface.
    14. Selecting 1000 kHz as target interface speed
    15. Sleep(10)
    16. Sleep(100)
    17. Device position in JTAG chain (IRPre,DRPre) <Default>: -1,-1 => Auto-detect
    18. JTAGConf>
    19. Device "LM3S5B91" selected.
    20. TotalIRLen = 4, IRPrint = 0x01
    21. Found Cortex-M3 r2p0, Little endian.
    22. FPUnit: 6 code (BP) slots and 2 literal slots
    23. CoreSight components:
    24. ROMTbl 0 @ E00FF000
    25. ROMTbl 0 [0]: FFF0F000, CID: B105E00D, PID: 002BB000 SCS
    26. ROMTbl 0 [1]: FFF02000, CID: B105E00D, PID: 002BB002 DWT
    27. ROMTbl 0 [2]: FFF03000, CID: B105E00D, PID: 002BB003 FPB
    28. ROMTbl 0 [3]: FFF01000, CID: B105E00D, PID: 002BB001 ITM
    29. ROMTbl 0 [4]: FFF41000, CID: B105900D, PID: 002BB923 TPIU-Lite
    30. Found 1 JTAG device, Total IRLen = 4:
    31. #0 Id: 0x4BA00477, IRLen: 04, IRPrint: 0x1, CoreSight JTAG-DP (ARM)
    32. Cortex-M3 identified.
    33. Reset delay: 0 ms
    34. Reset type NORMAL: Resets core & peripherals via SYSRESETREQ & VECTRESET bit.
    35. PC = 01000D94, CycleCnt = 00000000
    36. R0 = 00079F96, R1 = 00000001, R2 = 078E3AD1, R3 = 00000002
    37. R4 = 400FE000, R5 = 04C00380, R6 = 078E3AD0, R7 = 07C06810
    38. R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000
    39. R12= 00000000
    40. SP(R13)= 2000C210, MSP= 2000C210, PSP= 00000000, R14(LR) = 01002BAF
    41. XPSR = 21000000: APSR = nzCvq, EPSR = 01000000, IPSR = 000 (NoException)
    42. CFBP = 00000000, CONTROL = 00, FAULTMASK = 00, BASEPRI = 00, PRIMASK = 00
    43. Erasing device (LM3S5B91)...
    44. Comparing flash [100%] Done.
    45. Erasing flash [100%] Done.
    46. Verifying flash [100%] Done.
    47. J-Link: Flash download: Total time needed: 2.273s (Prepare: 0.149s, Compare: 0.000s, Erase: 2.110s, Program: 0.000s, Verify: 0.000s, Restore: 0.013s)
    48. Erasing done.
    49. Downloading file [bl.bin]...Comparing flash [100%] Done.
    50. Erasing flash [100%] Done.
    51. Programming flash [100%] Done.
    52. Verifying flash [100%] Done.
    53. J-Link: Flash download: Flash programming performed for 1 range (7168 bytes)
    54. J-Link: Flash download: Total time needed: 0.403s (Prepare: 0.172s, Compare: 0.011s, Erase: 0.000s, Program: 0.169s, Verify: 0.002s, Restore: 0.048s)
    55. O.K.
    56. Downloading file [main.bin]...Comparing flash [100%] Done.
    57. Erasing flash [100%] Done.
    58. Programming flash [100%] Done.
    59. Verifying flash [100%] Done.
    60. J-Link: Flash download: Flash programming performed for 1 range (233472 bytes)
    61. J-Link: Flash download: Total time needed: 3.911s (Prepare: 0.202s, Compare: 0.089s, Erase: 0.000s, Program: 3.515s, Verify: 0.021s, Restore: 0.082s)
    62. O.K.
    63. Script processing completed.
    Display All


    So far I am working around it by doing

    Source Code

    1. echo | JLinkExe -CommanderScript flashit

    but that is a pretty gross hack IMO :)

    Any tips much appreciated, thanks!

    The post was edited 4 times, last by Darius ().

  • Hi,

    Call J-Link Commander like this:

    C Source Code

    1. JLinkExe -jtagconf -1,-1 -CommanderScript flashit
    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.
  • SEGGER - Alex wrote:

    Hi,

    Call J-Link Commander like this:

    C Source Code

    1. JLinkExe -jtagconf -1,-1 -CommanderScript flashit


    Greta that works, thanks!

    Is there a reason I can't use 'config' in the script to do it?

    Not that it makes a practical difference but it seems silly and inconsistent (not to mention confusing)
  • Hi,

    Is there a reason I can't use 'config' in the script to do it?
    No. We do not really the necessity for this. However, i will bring this up in our next team meeting.
    Also, any idea on the reset problem? Using r0/r1 seems like a work around.
    What are you referring to? Can you please provide further / detailed information?


    Best regards
    Niklas
    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.
  • SEGGER - Niklas wrote:

    Hi,

    Also, any idea on the reset problem? Using r0/r1 seems like a work around.
    What are you referring to? Can you please provide further / detailed information?


    It would be nice if jlink handled the reset process better so I don't have to do it manually.

    i.e. right now I have to tell it to hold down reset, release, then attach.

    It would be much nicer if the jlink could do the reset and poll the core rapidly to freeze the CPU before the application code turns the JTAG port off.
  • Hi,

    Did you gave the "RSetType <Type>" command a try (example "RSetType 2", followed by "r")
    For Cortex-M / JTAG, resettype 2 is reset via reset pin which should be similar to the manual reset pin toggling (via "r1", "r0").

    Apart from this, you can override the reset sequence used by the J-Link DLL using J-Link Script files. They also allow to perform the manual pin toggling using the "JLINK_JTAG_ResetPin = 1" or "JLINK_JTAG_ResetPin = 0" commands. For further information regarding this, please refer to the J-Link User Manual (UM08001).


    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.
  • SEGGER - Erik wrote:

    Hi,

    Did you gave the "RSetType <Type>" command a try (example "RSetType 2", followed by "r")
    For Cortex-M / JTAG, resettype 2 is reset via reset pin which should be similar to the manual reset pin toggling (via "r1", "r0").

    Apart from this, you can override the reset sequence used by the J-Link DLL using J-Link Script files. They also allow to perform the manual pin toggling using the "JLINK_JTAG_ResetPin = 1" or "JLINK_JTAG_ResetPin = 0" commands. For further information regarding this, please refer to the J-Link User Manual (UM08001).


    Thanks for the information. I am pretty sure I tried RSetType with no effect.

    Unfortunately I am off the project where I was using it so I can't test it any more :(
  • I double checked the source code and reset type 2 also performs a reset via reset pin toggling so it should work in the s ame way as when using "r1" and "r0". However, as you wrote you can not test it anymore, we consider this case closed.


    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.