Monday, October 23rd 2017, 10:32pm UTC+2

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

wdrake-buhr

Beginner

Date of registration: Aug 12th 2014

Posts: 5

1

Wednesday, August 13th 2014, 4:36pm

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

SEGGER - Alex

Super Moderator

Date of registration: Dec 18th 2007

Posts: 1,514

2

Wednesday, August 13th 2014, 8:42pm

Hi Wyatt,

http://www.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

wdrake-buhr

Beginner

Date of registration: Aug 12th 2014

Posts: 5

3

Wednesday, August 13th 2014, 10:55pm

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 - http://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

SEGGER - Alex

Super Moderator

Date of registration: Dec 18th 2007

Posts: 1,514

4

Thursday, August 14th 2014, 11:32am

Hi,

Quoted

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

wdrake-buhr

Beginner

Date of registration: Aug 12th 2014

Posts: 5

5

Thursday, August 14th 2014, 6:17pm

You are right. I reverted my linker script to only use the virtual addressing and it still worked. I must have been fighting a different problem when I when down that path.

Thanks,
Wyatt

SEGGER - Alex

Super Moderator

Date of registration: Dec 18th 2007

Posts: 1,514

6

Wednesday, August 20th 2014, 9:57pm

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

Similar threads