• AVR Freaks

openocd and mips_m4k

Page: 123 > Showing page 1 of 3
Author
sjo
Starting Member
  • Total Posts : 49
  • Reward points : 0
  • Joined: 2006/02/22 07:12:07
  • Location: UK
  • Status: offline
2008/06/18 07:59:58 (permalink)
4 (1)

openocd and mips_m4k

Hi all,

For anyone that is interested we have created a mips branch to the openocd project.
This is still in very early alpha state, basic debugging is possible (step/resume/halt etc)

No flash programming  is implemented yet, but this will follow in time.

For those who have not heard of openocd - it has been around for about 3 years supporting the onchip debug hardware of arm7/9/11 and cortex_m3.
It offers a gdbserver and telnet interface for connecting to your target.

The project homepage is here:
http://developer.berlios.de/projects/openocd
and the mips branch can be found here:
svn://svn.berlios.de/openocd/branches/mips

The current development of the mips branch was tested on a pic32mx (explorer16 board).
The code at the moment is really only intended for people able to debug any issues, so be warned.

Cheers
Spen
#1

56 Replies Related Threads

    xiaofan
    Super Member
    • Total Posts : 6247
    • Reward points : 0
    • Joined: 2005/04/14 07:05:25
    • Location: Singapore
    • Status: offline
    RE: openocd and mips_m4k 2008/11/26 07:05:42 (permalink)
    0
    I still could not find any documentation specific to the PIC32 target. What is the debuggers supported? How to setup?

      USB_Links and libusb
    #2
    sjo
    Starting Member
    • Total Posts : 49
    • Reward points : 0
    • Joined: 2006/02/22 07:12:07
    • Location: UK
    • Status: offline
    RE: openocd and mips_m4k 2008/11/26 10:25:47 (permalink)
    0
    Hi,

    Documentation to openocd can be built from the source - an online version is also available here:
    http://openocd.berlios.de/web/?page_id=54

    openocd is a telnet/gdb server, so supports any debugger that uses the gdb server interface.
    most people will be using gdb as the backend debugger and possible eclipse/insight as a gui.

    As such there is no specific docs for the mips port, just a matter of configuring openocd.
    openocd contains sample config files for various targets, including pic32.

    for example to use the amontec jtag key with the pic32mx we would start openocd as follows:
    openocd -f interface/jtagkey.cfg -f target/pic32mx.cfg -c init -c "reset halt"

    this will reset the target and halt at the reset vector.

    also the mips branch has been merged into the main trunk, so that is the place to get the latest source
    svn://svn.berlios.de/openocd/trunk

    Cheers
    Spen
    post edited by sjo - 2008/11/26 10:29:20
    #3
    xiaofan
    Super Member
    • Total Posts : 6247
    • Reward points : 0
    • Joined: 2005/04/14 07:05:25
    • Location: Singapore
    • Status: offline
    RE: openocd and mips_m4k 2008/11/26 18:15:23 (permalink)
    0
    There are many good tutorials using Eclipse+GCC for ARM+openocd, however there are no documentations about how to set up a good toolchain with PIC32.

    What is the compiler you are using? Do you use plain gdb or Eclipse? How do you connect the debugger to the Explorer 16 board? Any examples?

    I highly appreciate your work. One of the main missing piece to get PIC32 to be popular is the lack of a cheap JTAG debugger. If openocd works, then that is great. The other missing piece is a truely free toolchain (mips gcc + newlib or similar).


      USB_Links and libusb
    #4
    sjo
    Starting Member
    • Total Posts : 49
    • Reward points : 0
    • Joined: 2006/02/22 07:12:07
    • Location: UK
    • Status: offline
    RE: openocd and mips_m4k 2008/11/27 02:26:36 (permalink)
    0
    Most of the docs for arm will apply to mips.

    regarding toolchains you could use one of the following:
    1. microchips own, just a matter of getting gdb from a source below.
    2. use mips SDE Lite - http://www.mips.com/products/software-tools/mips-sde-lite/
    3. use codesourcery - http://www.codesourcery.com/gnu_toolchains/mips
    4. build your own from source.

    generally i build my own tools, just the way i have always done things - i use either use eclipse or insight to debug.
    the initial work was done using the explorer16 and a pic32mx plugin.

    as openocd only supports jtag this is the interface we connect to on the explorer16.
    initially i used a parallel port wiggler with flying leads, some jtag interfaces such as amontec come with flying leads for non standard connections.
    connections used were, arm 20way connector to explorer16 jtag connector (J13).
    SRST (15) - J13.11
    TDI (5) - J13.3
    TDO (13) - J13.5
    TMS (7) - J13.7
    TCK (9) - J13.9

    microchip have used the standard ejtag pinout on the explorer16 - details about the various pinouts  can be found here:
    http://www.macraigor.com/downloads/pinouts.pdf

    Hope this helps.
    Spen
    #5
    xiaofan
    Super Member
    • Total Posts : 6247
    • Reward points : 0
    • Joined: 2005/04/14 07:05:25
    • Location: Singapore
    • Status: offline
    RE: openocd and mips_m4k 2008/11/27 05:22:39 (permalink)
    0
    Thanks. That is a good start. I actually have a Olimex parallel based wiggler but my current desktop does not have a parallel port. [:@]

    I use Jlink for ARM and openocd seems to work (tested under Linux with Olimex LPC-P2148 and IAR LPC2468 KS) even though I use IAR more often under Windows Vista. I was also trying to use openocd with LPC-Stick (modified from Comstick settings, tested under Linux and Windows) as the Hitex 5.2 GUI comes with the stick does not work under Vista.

    Maybe Jlink can be used as well for PIC32. wink

    Actually the toolchain for PIC32 is an interesting topic. How is the things going with SDE Lite and Code Sourcery MIPS compiler? How do you build from the source? Do you have a port of newlib for your own tools? How do you deal with the header files? Do you have a complete examples for Explorer 16?

    Sorry for so much questions. This is really an interesting topics for me. And I believe there are many others who are also interested.

      USB_Links and libusb
    #6
    sjo
    Starting Member
    • Total Posts : 49
    • Reward points : 0
    • Joined: 2006/02/22 07:12:07
    • Location: UK
    • Status: offline
    RE: openocd and mips_m4k 2008/11/27 07:17:46 (permalink)
    0
    you should be able to use the jlink no problems - just would have to make an adapter to the mips header.

    The microchip compiler was used for initial testing, and the sde-gdb for testing the debugging side.
    I have built a mips toolchain but have not tested it with the pic32 yet - the header files would need to be written or borrowed.
    newlib was used, it is just not as optimized as the mips c lib used in the microchip toolchain.

    codesourcery would probably be the best place to start as their arm toolchains work well.

    I have only been testing at a core level (m4k) so pic32 specifics are not as issue at the moment.
    The flash driver still needs writing but when i get some spare time will look inot it.

    Cheers
    Spen
    #7
    xiaofan
    Super Member
    • Total Posts : 6247
    • Reward points : 0
    • Joined: 2005/04/14 07:05:25
    • Location: Singapore
    • Status: offline
    RE: openocd and mips_m4k 2008/11/27 07:31:24 (permalink)
    0
    Thanks. Now I got a clearer picture of your setup and the status of openocd for PIC32.
    1. Currently it is still easier to use Microchip's C32 compiler (with MIPS C library). But in the future, maybe it is possible to use MIPS GCC+newlib. CodeSourcery may be an option as well. This is interesting. I am not a programmer myself but I could help testing if someone wants to embark on this.

    2. sde-gdb can be used. Maybe we can also build gdb from Microchip provided source. Last time I did it but I have never tried to use it.

    3. Currently flash loading is not working yet. How do you program the device then? Do you use other tools like PICkit 2 or ICD 2?

    4. Once the work is finished, this will be very nice as other cheaper JTAG debugger can be used for debugging PIC32. Currently Microchip tools like ICD 2, ICD 3, Real ICE and PICkit 3 all do not use JTAG for PIC32.

    Thanks for the nice work!
    post edited by xiaofan - 2008/11/27 07:32:54

      USB_Links and libusb
    #8
    sjo
    Starting Member
    • Total Posts : 49
    • Reward points : 0
    • Joined: 2006/02/22 07:12:07
    • Location: UK
    • Status: offline
    RE: openocd and mips_m4k 2008/11/27 07:44:18 (permalink)
    0
    1. For work then yes the microchip toolchain is the simplest option.
    2. any mips gdb can be used, not just sde.
    3. currently i use a realice

    The uptake on the openocd mips target has been slow - certainly compared to the arm side of things.
    we have a few users using other mips cores but only a couple using the pic32.

    as ever more people are needed to get involved, and perhaps write a pic32 flash driver.

    Cheers
    Spen
    #9
    xiaofan
    Super Member
    • Total Posts : 6247
    • Reward points : 0
    • Joined: 2005/04/14 07:05:25
    • Location: Singapore
    • Status: offline
    RE: openocd and mips_m4k 2009/05/21 20:12:21 (permalink)
    0
    Updated status thread from OpenOCD mailing list
    http://www.mail-archive.com/openocd-development@lists.berlios.de/msg04334.html

    Debugging:
    http://www.mail-archive.com/openocd-development@lists.berlios.de/msg04445.html

    With regards to pic32 debugging most of the work for the ejtag was based on the pic32.All basic functions within gdb should be working, including software/hardware breakpoints.


    Programming

    >From: John McCarthy
    >Date: Mon, Jan 5, 2009 at 12:39 PM
    >Subject: [Openocd-development] pic32mx flash fixups and speedups
    >To: OpenOCD Development <Openocd-development@lists.berlios.de>
    >
    >I found my problems with writing boot flash and optimized single 32bit
    >word read/writes to speed things up a bit. I also added support for
    >writing flash using the pgm_row command to greatly speed up programming.
    >
    >So now all flash can be erased and/or programmed. Still no chip_erase
    >command and data transfers to/from the target are still slow but it is
    >usable.




      USB_Links and libusb
    #10
    xiaofan
    Super Member
    • Total Posts : 6247
    • Reward points : 0
    • Joined: 2005/04/14 07:05:25
    • Location: Singapore
    • Status: offline
    RE: openocd and mips_m4k 2009/05/21 20:14:37 (permalink)
    0
    Once this support is in place, debugging/programming with many common JTAG tools (like FT2232 based, parallel port wiggler, or Segger J-Link) will be possible for PIC32, under Windows, Linux and Mac OS X.

      USB_Links and libusb
    #11
    Samoht
    New Member
    • Total Posts : 2
    • Reward points : 0
    • Joined: 2009/12/10 07:49:57
    • Location: 0
    • Status: offline
    RE: openocd and mips_m4k 2009/12/10 08:02:48 (permalink)
    0
    Hi,

    I'm  interrested in openocd project.
    Today, Is this project working well for pic32 as programming and debugging ?

    I've got an Amontec Key and a pic32mx440f256h target.
    The Jtag communication seems  to be OK. The probe recognize the target and I can connect with a telnet session.
    Then I try to program flash memory with the flash write_image command but still have the message :


    May be it's y pic32.cfg file. Is this correct :
    $_TARGETNAME configure -work-area-virt 0 -work-area-phys 0xa0000000 -work-area-size 16384 -work-area-backup 0
    I think that the pic32 has no MMU so shall we specify a working area virtual or not? and which address ans size

    flash bank pic32mx 0x1d000000 0 0 0 $_TARGETNAME
    flash bank pic32mx 0x1fc00000 0 0 0 $_TARGETNAME
    shall we specify the size of those banks and chip_width and bus width.

    A last question. The dump file (even if my µC is blank) seems to work but it's very long : 103 seconds for a 2048 bytes

    Anyone has already try to read/write or debug  sucessfully a pic32 with the openocd project ?

    Thank you for your help Smile
    #12
    xiaofan
    Super Member
    • Total Posts : 6247
    • Reward points : 0
    • Joined: 2005/04/14 07:05:25
    • Location: Singapore
    • Status: offline
    RE: openocd and mips_m4k 2009/12/20 18:27:56 (permalink)
    0
    I myself have not tried it for the PIC32. The best place to ask questions is the Openocd-development mailing list.
    https://lists.berlios.de/mailman/listinfo/openocd-development

      USB_Links and libusb
    #13
    Samoht
    New Member
    • Total Posts : 2
    • Reward points : 0
    • Joined: 2009/12/10 07:49:57
    • Location: 0
    • Status: offline
    RE: openocd and mips_m4k 2010/01/08 08:18:39 (permalink)
    0
    Thank you xiaofan.
    Already done but no answer.
    I understand that some people succeed in the flash programming and debugging operations with pic32.
    It seems that developpers are working to make a faster programming.
    #14
    isza
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2010/08/20 09:03:52
    • Location: Hungary
    • Status: offline
    Re: RE: openocd and mips_m4k 2010/08/20 09:25:27 (permalink)
    0

    Hi,

    I've successfully built the C32 compiler on OSX. When I compile my led blinking test program, I get an ELF which has references to virtual memory addresses.

    If I try to write it into the flash memory with OpenOCD, it seems to succeed, but it doesn't run. I'm using the following command: flash write_image test.elf .

    If I convert it with pic32mx-bin2hex, it has references to the physical memory, and OpenOCD is not able to write it into the flash, even if I configure the physical flash banks properly in pic32.cfg.

    What am I doing wrong? Do I have to erase the banks somehow before trying to write them?

    OpenOCD says that every sector is protected. What does it mean?

    > flash info 0              
    #0 : pic32mx at 0x9d000000, size 0x00080000, buswidth 4, chipwidth 4
    #  0: 0x00000000 (0x1000 4kB) protected
    #  1: 0x00001000 (0x1000 4kB) protected


    Thanks for your help


    #15
    isza
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2010/08/20 09:03:52
    • Location: Hungary
    • Status: offline
    Re: RE: openocd and mips_m4k 2010/08/20 13:13:32 (permalink)
    0
    They have lines like this in pic32mx.c:
    target_write_u32(target, PIC32MX_NVMADDR,    KS1Virt2Phys(address));


    So I guess I have to specify virtual addresses everywhere.


    I tried to erase the flash with the erase option of write_flash, but then openocd complained about the configuration bits, which do not start at a segment boundary. The chip erase command returns without any error, but i don't know if it really works. I don't even know how I could check if it works. :/ I'm stuck.

    #16
    isza
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2010/08/20 09:03:52
    • Location: Hungary
    • Status: offline
    Re: RE: openocd and mips_m4k 2010/08/21 02:50:32 (permalink)
    0
    I managed to erase the appropriate segments in the flash, or at least openocd did something. I also seem to be able to program the flash, but the code doesn't run. 


    I have a PIC32MX340F512H, with to bicolor leds connected like this:


    RB0 -- LED -- 220R -- RB1
    RB6 -- LED -- 220R -- RB7


    I'm new to PIC32, and I can't decide if my test code is correct.


    Should this code make them glow?

    #include <p32xxxx.h>
    #pragma config POSCMOD = OFF, FNOSC = FRC, FWDTEN = OFF

    main()
    {
        TRISB = 0b00111100;
        PORTB = 0b10000010;
        while(1);
    }

    When I halt the CPU with OpenOCD, PC=0xBFC00380, which is the exception handler. :/ The other registers have some random values instead of the ones they should be holding according to the assembly code GCC generates. :(

    #17
    isza
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2010/08/20 09:03:52
    • Location: Hungary
    • Status: offline
    Re: RE: openocd and mips_m4k 2010/08/21 12:12:19 (permalink)
    0
    I installed the GIT version of openocd, and I was happy to see that they improved the PIC32 support. :) The new version has a virtual memory driver, and the configuration file of PIC32 uses it. :)

    Sadly, it doesn't work. I figured out how to read the memory with openocd. Everything is 0xFF everywhere. I can program words with the pic32mx pgm_word command successfully, but flash write_image just doesn't work. It says "wrote 17284 bytes from file main in 1.735783s (9.724 KiB/s)", but leaves 0xFF everywhere. :/

    In the meantime I borrowed a pickit2, but it doesn't support PIC32MX340F512H.
    #18
    isza
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2010/08/20 09:03:52
    • Location: Hungary
    • Status: offline
    Re: RE: openocd and mips_m4k 2010/08/21 14:35:32 (permalink)
    0
    Writing smaller amounts of data to the flash works, but for more than 128 bytes, openocd has a separate function, which does not work:

    static int pic32mx_write_row(struct flash_bank *bank, uint32_t address, uint32_t srcaddr)

    Now I disabled it, and it seems to work. It became really slow, because it can only write one word each time. I hope it will survive the many write operations. :)



    #19
    isza
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2010/08/20 09:03:52
    • Location: Hungary
    • Status: offline
    Re: RE: openocd and mips_m4k 2010/08/22 02:00:29 (permalink)
    0
    Well, only using pic32mx_write_word is so slow, that it's literally unusable. It takes about a second to write 4 bytes.

    I figured out that pic32mx_write_row works properly, it can write the content of the RAM to the flash, but filling the RAM doesn't work. Now I "only" need to correct the function that fills the working area in the RAM. 
    #20
    Page: 123 > Showing page 1 of 3
    Jump to:
    © 2020 APG vNext Commercial Version 4.5