j-link & PIC32 using gdb on windows

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

  • j-link & PIC32 using gdb on windows

    Hi,

    I was excited to find that the j-link tool is now compatible with PIC32 JTAG and I am able to debug using MPLABX 2.15 with the j-link plugin installed and connected to my j-link v9.0 device attached a PIC32MX795F512L.

    However, I would really like to avoid using MPLABX altogether (I prefer eclipse). In order to do this, I need a version of gdb that understands the PIC32 architecture (compiled with --target=mipsel-elf32 I believe) that runs on my host machine (windows 7). Microchip's xc32 toolchain of course does not include gdb as they have no need for it in MPLABX.

    Has this sort of setup been tested yet by anyone (or by SEGGER)? I have been having a fair bit of trouble compiling gdb myself using MingGW and was wondering if a binary already existed somewhere? Is there anything else I need to get it to work?

    Thanks,
    Wyatt
  • Hi Wyatt,

    emide.org/

    Supports the Sourcery CodeBench Lite for MIPS (GNU GCC).
    It also supports J-Link
    and it has been verified with J-Link.

    Supports the Sourcery CodeBench Lite for MIPS (GNU GCC) + Eclipse should also work from the J-Link side because there is no difference for J-Link, what graphical frontend is used that controls GDB.


    - 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.
  • Alex,

    Thanks for the information, I am now able to load and debug my PIC32 application using eclipse on Windows!

    Just for reference, here is how I got it to work:

    1. I installed the latest version of the SEGGER J-Link software package (V4.90)

    2. I installed the GNU ARM j-link plugin for eclipse to manage my debug configuration - gnuarmeclipse.livius.net/blog/plugins-install/. It was intended for use with ARM, but there doesn't appear to be anything ARM-specific and it works well for me.

    3. I installed the latest Sourcery CodeBench Lite for MIPS ELF from mentor graphics (version 2014.05-24) exclusively in order to use the GNU debugger (GDB) that comes in the toolchain.

    4. In eclipse I created a new "GDB SEGGER J-Link Debugging" debug configuration and pointed the configured the GDB Client Setup to point to the MIPS ELF GDB (mips-sde-elf-gdb.exe). One gotcha I ran into here was that I needed to command GDB to use little endian by adding "set endian little" to the Commands window.

    5. I had to modify my linker script such that it used the proper physical memory addressing in the ELF file. If you don't do this, GDB tries to load your program at the virtual address space (0x9D000000) rather than the physical space (0x1D000000) which doesn't work. This requires the use of the AT keyword in the linker script so the memory is linked with the proper VMA but loaded with the proper LMA. Apparently MPLAB does this work automatically when loading ELF files because it never was a problem in that IDE.

    6. I created a new build configuration in my makefile that compiles for debug but doesn't include all of the microchip debugger stuff (ROM executive, reserved memory space, etc...)

    Hope this helps anyone else who wants to wean themselves off of MPLAB.

    Wyatt
  • Hi,

    5. I had to modify my linker script such that it used the proper physical memory addressing in the ELF file. If you don't do this, GDB tries to load your program at the virtual address space (0x9D000000) rather than the physical space (0x1D000000) which doesn't work.

    Not really...
    We have projects working with the vritual address specified (which is the preferred solution, since you then download and debug at where the CPU "sees" memory)
    You just have to make sure that you specify the boot flash in the linker file for the "uncached" region (0xBFC00000), since this is where the CPU starts after reset.
    If you defined the "cached" address (0x9FC00000), GDB will be confused after reset and tell that it does not have any code for this area.
    We have tested this with multiple projects and GDB and there is no problem.
    J-Link handles both: Downloads to physical and virtual addresses, so no matter what address GDB writes to, J-Link will recognize the flash download.


    - 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 Wyatt,

    No problem. Good to hear that GDB works well for you.
    Unfortunately, for PIC32, GDB does not seem to be that popular...


    - 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.