[SOLVED] Flashing multiple elfs to a single target using GDB and GDB Server

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

  • [SOLVED] Flashing multiple elfs to a single target using GDB and GDB Server

    I am attempting to migrate a project currently running with makefiles in Atmel Studio to CLion, with an Atmel SAM-ICE branded J-Link device.

    With the "Embedded GDB Server" configuration in CLion I can start the server and connect to the device and debug a device programmed through Atmel Studio. However I have limited success programming the device from CLion, since I need to flash two elf files: A bootloader (Debug information not required) and the main application (Debug information required), where CLion only wants to program the main application. I expect I can circumvent this through the use of a gdbinit/script file, but I run into issues.

    I attempt to pass a init script to the GDB server through the -xc command:

    Source Code

    1. monitor reset
    2. monitor flash erase
    3. load path/to/bootloader
    4. load path/to/application
    This results in errors, as if "monitor" is prepended to all commands. Attempting with a reduced example:

    Source Code

    1. reset
    2. flash erase
    results in

    Source Code

    1. SEGGER J-Link GDB Server V6.86a Command Line Version
    2. JLinkARM.dll V6.86a (DLL compiled Sep 28 2020 15:02:50)
    3. Command line: -select USB -device ATSAMV70N20 -endian little -if SWD -speed 4000 -ir -halt -LocalhostOnly -xc REDACTED
    4. -----GDB Server start settings-----
    5. GDBInit file: REDACTED
    6. GDB Server Listening port: 2331
    7. SWO raw output listening port: 2332
    8. Terminal I/O port: 2333
    9. Accept remote connection: localhost only
    10. Generate logfile: off
    11. Verify download: off
    12. Init regs on start: on
    13. Silent mode: off
    14. Single run mode: off
    15. Target connection timeout: 0 ms
    16. ------J-Link related settings------
    17. J-Link Host interface: USB
    18. J-Link script: none
    19. J-Link settings file: none
    20. ------Target related settings------
    21. Target device: ATSAMV70N20
    22. Target interface: SWD
    23. Target interface speed: 4000kHz
    24. Target endian: little
    25. Connecting to J-Link...
    26. J-Link is connected.
    27. Firmware: J-Link V10 compiled Sep 21 2020 16:57:59
    28. Hardware: V10.10
    29. SAM-ICE found !
    30. S/N: REDACTED
    31. OEM: SAM-ICE
    32. Feature(s): RDI, GDB
    33. Checking target voltage...
    34. Target voltage: 3.35 V
    35. Listening on TCP/IP port 2331
    36. Connecting to target...
    37. Connected to target
    38. Waiting for GDB connection...Error during pretty printers setup: Undefined info command: "pretty-printer". Try "help info".
    39. Some features and performance optimizations will not be available.
    40. Connected to 127.0.0.1
    41. Executing script file [REDACTED] .
    42. ..
    43. Received monitor command: reset
    44. Resetting target
    45. Received monitor command: flash erase
    46. Erasing flash (may take a while)...
    47. ERROR: Failed to prepare RAMCode using RAM
    48. Error while determining flash info (Bank @ 0x80000000)
    49. Flash erase: Failed
    50. Flash erase: Failed
    Display All

    Any insight into:
    • The flash erase error
    • How to program multiple binaries (Only require debug information in one elf) or selectively erase and program part of the embedded flash
    is much appreciated.
  • The xc command is probably not the correct way. GDB Server is basically a translator from GDB to J-Link and takes care of the flash programming on certain memory writes.

    ELF file loading etc. are all more GDB things.

    Maybe this is of any help:
    dzone.com/articles/multiple-binaries-with-gdbeclipse

    Unfortunately, I cannot provide any CLiom example but most steps should apply to any GDB based IDE, so you may be able to adapt the steps for CLion.