Flash-Download using GDB-Server

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

  • Flash-Download using GDB-Server

    Hi,

    I want to flash an LPC2368 (rev. B) with GDB-Server (v3.79w). The response from the server looks good but
    nothing is written. I guess that I have to enter some informations about the flash.

    Is there some kind of documentation for this Flash-Download feature?

    This is what I have tried:

    Source Code

    1. target remote localhost:2331
    2. Remote debugging using localhost:2331
    3. 0x00000010 in ?? ()
    4. (gdb) monitor speed auto
    5. Select auto JTAG speed (65535 kHz)
    6. (gdb) monitor endian little
    7. Target endianess set to "little endian
    8. (gdb) monitor reset
    9. Resetting target
    10. (gdb) load RTOSDemo.elf
    11. Loading section startup, size 0x48 lma 0x0
    12. Loading section prog, size 0xb060 lma 0x48
    13. Loading section .data, size 0x83c lma 0xb0a8
    14. Start address 0x2b4c, load size 47332
    15. Transfer rate: 32 KB/sec, 3380 bytes/write.
    16. (gdb)
    Display All
  • Hello let,

    we have built a new beta version (v3.79x) which is available for download from our website:
    segger.com/download_jlink_beta.html

    To enable flash download for the LPC2368 you have to add the two lines below
    to the .gdbinit file of your project:

    Source Code

    1. # Select flash device
    2. monitor flash device = LPC2368
    3. # Enable flash download
    4. monitor flash download = 1


    The flash download feature requires an additional license.
    The flash device command selects the target device by its device ID.
    For a list of all supported devices and their device IDs please refer to the J-Link / J-Trace User Guide, chapter 5.3 "Supported microcontrollers".
    For more information about how to enable flash download (and flash breakpoints) please refer to the J-Link GDB Server User Guide,
    chapter 3.2 "Enableing flash download and flash breakpoints".


    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.
  • Thank you! I did not notice the device specific informations in the manual. I will try the settings this evening.
    I have a GDB-Server and a Flash-Download license.

    How about adding some .gdbinit examples for the popular AT91, LPC and STR7 controller? Well, perhaps they exist and I don't find them ;)

    - Michael
  • Hello let,

    the J-Link GDB Server comes with sample projects which use the flash download and flash breakpoint feature.
    The samples can be found at Samples\GDB\Projects of the J-Link software installation directory.
    Currently the J-Link GDB Server comes with one sample for an AT91SAM7 and one for the STR912 (we will add more samples in the future).
    Flash download and flash breakpoints are enabled in this sample projects, by default.
    To disable flash breakpoints simply delete the following line in the .gdbinit file:

    Source Code

    1. monitor flash breakpoints = 1


    For more information about how to use the samples delivered with the J-Link GDB Server,
    please refer to the J-Link GDB Server User Guide, chapter 3.2 "How to use the sample projects".

    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.

    The post was edited 1 time, last by SEGGER - Alex ().

  • Hello Alex,

    I can use the load command now. But mostly the program will not run. Sometimes I get very high download speeds (> 3000kb/S). When I issue a step or next command afterwards, the download
    popup appears and the (regular) download begins. If that happens, the program starts.
    Fortunately the LPCs have a bootloader :)

    Then apparently I found a bug in GDB-Server. If a program contains a large global array (say 2000 bytes) and you issue a print command for this array, gdb-server will crash.
  • Hello let,

    we have built a new beta version (3.79z) which now contains
    some samples for NXP devices.
    The new beta version contains one J-Link GDB Server sample
    for the LPC2106, one for the LPC2148 and one for the LPC2378.

    The new beta version is available for download at:
    segger.com/download_jlink_beta.html

    The very high download speeds are reached because all data
    to be programmed, is cached. The target will be programmed as
    soon as an operation is performed which requires that the
    target has been programmed. Such operations are single step or go.
    This is why the download popup appears after a single step or a next command.

    We have tested the GDB Server regarding the "array-problem" you reported,
    but there seem to be no problems. The print command is performed
    and the content of the array is shown without any problems.

    Can you please try out the J-Link GDB Server sample for the LPC2378
    and check if the "array-problem" still exists?
    The LPC2378 sample project should also work with the LPC2368.

    If the problem still remains please contact support@segger.com and
    send a project file to reproduce the problem + GDB Server logfile.

    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,

    it's working now with the 'monitor long 0xE0...' command. But the flash-download feature still cannot
    replace Flash-Magic because once I cycle the power on my board or disconnect the J-Link the
    program will not run as if it's executed from RAM.
    The download script for gdb:

    Source Code

    1. file armkeyer_v3.elf
    2. target remote localhost:2331
    3. monitor flash device = LPC2368
    4. monitor flash download = 1
    5. monitor speed adaptive
    6. monitor endian little
    7. monitor reset 0
    8. monitor long 0xE01FC040 = 1
    9. load
    10. monitor go


    I can't reproduce the server crash. Yesterday it kept crashing after the print command.
    There is a display buffer (static, 1920 bytes) and for a test I added another array
    (static uint8_t dummy[2000]) to another module. In both cases gdb-server crashed
    after the array contents have been printed. I have no idea what is different now.

    - Michael
  • Hello let,

    the reason why the program does not start is, that there is no valid
    checksum written to address 0x14, when programming the flash.
    The bootloader of the LPC2368 checks address 0x14 and if no valid
    checksum is found the program counter is not set to address 0x0 so the program cannot start.
    For more information please refer to the UM10211 User Manual
    Chapter 27 "Flash memory programming firmware",
    section 4.1.1 "Criterion for Valid User Code", which says:

    Criterion for valid user code: The reserved ARM interrupt vector location (0x0000 0014)
    should contain the 2’s complement of the check-sum of the remaining interrupt vectors.
    This causes the checksum of all of the vectors together to be 0. The boot loader code
    disables the overlaying of the interrupt vectors from the boot block, then checksums the
    interrupt vectors in sector 0 of the flash. If the signatures match then the execution control
    is transferred to the user code by loading the program counter with 0x0000 0000. Hence
    the user flash reset vector should contain a jump instruction to the entry point of the user
    application code.
    If the signature is not valid, the auto-baud routine synchronizes with the host via serial port
    0. The host should send a ’?’ (0x3F) as a synchronization character and wait for a
    response.

    We will built a new beta version tomorrow. The new beta version will add a valid checksum automatically.

    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.
  • Hello let,

    sorry for the little delay.
    The new beta version is available for download from our website:
    segger.com/download_jlink_beta.html

    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.