[Openocd-development] PIC32 openocd status

2009-05-17 Thread Xiaofan Chen
2009/5/5 Michel Catudal :
> A project I am working on is to make a programmer for the PIC32 on SuSE
> Linux. I am looking into implementing the use of the Programming
> Excecutive in OpenOCD.
> I have read the documentation from Microchip and it seems straight
> forward, the OpenOCD implementation is not that clear though. Many
> important commands are not implemented.
>

Nice project. What is the Jtag tool you are using? And
what is the exact status of OpenOCD with PIC32 in terms
of debugging and programming?

For programming, you can probably use the US$35
PICkit 2 and pk2cmd. But there is no debugging
support with PICkit 2 for PIC32. pk2cmd's source
codes are also available.
http://www.microchip.com/pickit2

It would be great that openocd can work with
PIC32 using JTAG. I think Real ICE, ICD 2 and
ICD 3 do not use JTAG for debugging PIC32.

Last time Spen posted some news on the  Microchip
Forum.
http://www.microchip.com/forums/tm.aspx?m=346142

Since then, it is now quite easy to build gcc toolchain
for PIC32 (newlib not ported), pk2cmd also supports
PIC32 programming now. So openocd will help a lot.

And according to the mailing list, John McCarthy has
got flashing partially working.

-- 
Xiaofan http://mcuee.blogspot.com
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] PIC32 openocd status

2009-05-17 Thread Michel Catudal
Xiaofan Chen a écrit :
> 2009/5/5 Michel Catudal :
>   
>> A project I am working on is to make a programmer for the PIC32 on SuSE
>> Linux. I am looking into implementing the use of the Programming
>> Excecutive in OpenOCD.
>> I have read the documentation from Microchip and it seems straight
>> forward, the OpenOCD implementation is not that clear though. Many
>> important commands are not implemented.
>>
>> 
>
> Nice project. What is the Jtag tool you are using? And
> what is the exact status of OpenOCD with PIC32 in terms
> of debugging and programming?
>
>   

None yet but I will use olimex tiny jtag device. I will need to make a
little adapter
for it since the connector doesn't have the same pinout.
At this point I am just studying the subject.

According to the Microchip flash programming documentation, the best
approach would be
to use the Programming Executive. The programming executive is available
as part of the programmer
that Microchip has released the source. Obviously I can't tag that with
the source of OpenOCD but
will compile it in to make the binary. The key is not to violate either
the GPL or Microchip's licence.

> For programming, you can probably use the US$35
> PICkit 2 and pk2cmd. But there is no debugging
> support with PICkit 2 for PIC32. pk2cmd's source
> codes are also available.
> http://www.microchip.com/pickit2
>
>   

I saw that and may purchase it if there is support for Linux as I don't
have any windows to work with at home.
I use windows at work but I don't want to see that crap on my own computer.

> It would be great that openocd can work with
> PIC32 using JTAG. I think Real ICE, ICD 2 and
> ICD 3 do not use JTAG for debugging PIC32.
>
>   
I am aware of that, that is why I think that it would be easier for
debugging when we get PIC32 supported.

> Last time Spen posted some news on the  Microchip
> Forum.
> http://www.microchip.com/forums/tm.aspx?m=346142
>
> Since then, it is now quite easy to build gcc toolchain
> for PIC32 (newlib not ported), pk2cmd also supports
> PIC32 programming now. So openocd will help a lot.
>
> And according to the mailing list, John McCarthy has
> got flashing partially working.
>
>   
Partially is the key. He can't erase the whole thing so that makes it
useless for now.
As I look at the code I see that most of the code is commented out so I
assumed that it is not working code.
That was the reason I asked on this newsletter to see if there is more
work done that appears to be.

Michel

-- 
Tired of Microsoft's rebootive multitasking?
then it's time to upgrade to Linux.
http://home.comcast.net/~mcatudal

___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] PIC32 openocd status

2009-05-17 Thread Xiaofan Chen
2009/5/18 Michel Catudal :
>> For programming, you can probably use the US$35
>> PICkit 2 and pk2cmd. But there is no debugging
>> support with PICkit 2 for PIC32. pk2cmd's source
>> codes are also available.
>> http://www.microchip.com/pickit2
>>
> I saw that and may purchase it if there is support for Linux as I don't
> have any windows to work with at home.
> I use windows at work but I don't want to see that crap on my own computer.
>

Yes pk2cmd works under Linux and Mac OS X along with
Windows. Last time I was also able to make it work
under FreeBSD with the beta USB stack from HPS.
You can download pk2cmd source from the above link.
We also have a mailing list to support it.
http://groups.google.com/group/pickit-devel

-- 
Xiaofan http://mcuee.blogspot.com
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] PIC32 openocd status

2009-05-17 Thread Strontium

>   
>> It would be great that openocd can work with
>> PIC32 using JTAG. I think Real ICE, ICD 2 and
>> ICD 3 do not use JTAG for debugging PIC32.
>>
>>   
>> 
> I am aware of that, that is why I think that it would be easier for
> debugging when we get PIC32 supported.
>
>   
Pic32 has 2 debug interfaces.  4 Wire JTAG.  And a pin count compressed 
version of Jtag which is serialised over 2 wires (ICSP).  The protocol 
is the same as JTAG, the electrical interface is the only thing that 
differs. 2 wire mode should be able to be driven using a FT2232 type 
device, in a similar fashion to I2C (Tie TDI and TDO together).


___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] PIC32 openocd status

2009-05-17 Thread David Brownell
On Sunday 17 May 2009, Strontium wrote:
> 
> Pic32 has 2 debug interfaces.  4 Wire JTAG.  And a pin count compressed 
> version of Jtag which is serialised over 2 wires (ICSP).  The protocol 
> is the same as JTAG, the electrical interface is the only thing that 
> differs. 2 wire mode should be able to be driven using a FT2232 type 
> device, in a similar fashion to I2C (Tie TDI and TDO together).

Is that 2-wire mode the same one that the JTAG folk have
been working with, or is it specific to Microchip?  Do
you know?

Nexus, for example, has both 2-wire and 4-wire/JTAG flavors.

Eventually one might expect OpenOCD to support that standard
2-wire interface.  ISTR that one configuration can drive it
directly from standard JTAG connectors.

___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] PIC32 openocd status

2009-05-17 Thread Xiaofan Chen
On Mon, May 18, 2009 at 8:58 AM, David Brownell  wrote:
> On Sunday 17 May 2009, Strontium wrote:
>>
>> Pic32 has 2 debug interfaces.  4 Wire JTAG.  And a pin count compressed
>> version of Jtag which is serialised over 2 wires (ICSP).  The protocol
>> is the same as JTAG, the electrical interface is the only thing that
>> differs. 2 wire mode should be able to be driven using a FT2232 type
>> device, in a similar fashion to I2C (Tie TDI and TDO together).

This is wrong. ICSP is Microchip's proprietory protocol for
programming and debugging. The ICSP module is independent
from the EJTAG module in PIC32. You can read Chapter
33 of the PIC32MX Family Manual for more information.
The ICSP debugging protocol is kept secret by Microchip
and Microchip does not want to released to public. NDA
access might be possible for certain 3rd party. The ICSP
programming protocol is open to the public through the
programming specification.

"To use ICD, an external system that supports ICD must load
a debugger executive program into the microcontroller. This is
automatically handled by many debugger tools, such as the
MPLAB IDE. For PIC32MX devices, the program is loaded into
the last page of the Boot Flash memory space. When not
debugging, the application is free to use the last page of Boot
Flash Memory. PIC32MX ICSP supports standard debugging
functions including memory and register viewing and modification.
Breakpoints can be set and the program execution may be
stopped or started. In addition to these functions registers or
memory contents can be viewed and modified while the
CPU is running."

The debug executive hex files are available from MPLAB installation.

Microchip's tools like Real ICE, ICD 3, ICD 2 do not use
EJTAG. But JTAG support is available from 3rd party.
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2602

> Is that 2-wire mode the same one that the JTAG folk have
> been working with, or is it specific to Microchip?  Do
> you know?

As answered before, the 2-wire ICSP is not JTAG
and the only way to know it is through reverse engineering.
The only project I know of is the Piklab project which tries
to support ICSP debugging with ICD 2.

Anyway, to openocd, it is possible to support JTAG
debugging/programming.


-- 
Xiaofan http://mcuee.blogspot.com
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] PIC32 openocd status

2009-05-17 Thread Xiaofan Chen
On Mon, May 18, 2009 at 10:06 AM, Strontium  wrote:
>>
>> This is wrong. ICSP is Microchip's proprietory protocol for
>> programming and debugging. The ICSP module is independent
>> from the EJTAG module in PIC32. You can read Chapter
>> 33 of the PIC32MX Family Manual for more information.
>
> I didn't make it up.
>
> I read it.
>
> PIC32MX Flash Programming Specification 61145D.pdf :

> Plus PIC32MX talks about debugging using EJTAG.
> EJTAG is designed for debugging. However that same functionality can be used
> to allow programming. PIC do not need to re-specify EJTAG, as that is
> available from MIPS. I have found no suggestion that the PIC32 does not
> implement a compliant EJTAG core, and as ICSP is just de-multiplexed into 4
> wire jtag internally, there is no reason why EJTAG operations will not
> operate as expected over ICSP.

PIC32MX supports EJTAG, no doubt about it. I am saying
the ICSP module is different from the EJTAG.
I am thinking that the ICSP programming and EJTAG
programming interface may indeed share the same protocol
internally as per the programming specification. But I am 100%
sure  that ICSP debugging is different from the EJTAG
debugging. And I am also 100% sure that existing Microchip
debuggers for PIC32 (ICD 2, ICD 3 and Real ICE) do not
speak EJTAg for debugging.

Example:
http://www.microchip.com/forums/tm.aspx?m=414877
You have to disable JTAG port if using MPLAB ICD 2/3
and Real ICE for debugging since they use ICSP debugging.
Microchip PIC32 starter kit and PIC32 USB satrter kit do use
JTAG for debugging. Real ICE also has the trace function with
an add-on.

> There are lots of MIPS chips that have an EJTAG core. An EJTAG
> implementation in OpenOCD would be awesome. PIC32 is a nice
> cheap platform to develop and test this with.

I agree with this one. As I mentioned before, it would be good for
OpenOCD to support EJTAG of PIC32MX. 3rd parties already offers
this possibility now (Ashling, Macraigor Systems, and maybe Green Hill).
And the two starter kits also offers JTAG debugging within MPLAB.
So it is definitely possible. Actually I think it is already partially
supported by Openocd according to Spen.
http://www.microchip.com/forums/tm.aspx?m=346142

Since ICSP debugging protocol is closed, it is very difficult to support
it. So the only choice for debugging is EJTAG.

-- 
Xiaofan http://mcuee.blogspot.com
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] PIC32 openocd status

2009-05-17 Thread Strontium
>
> This is wrong. ICSP is Microchip's proprietory protocol for
> programming and debugging. The ICSP module is independent
> from the EJTAG module in PIC32. You can read Chapter
> 33 of the PIC32MX Family Manual for more information.

I didn't make it up.

I read it.

PIC32MX Flash Programming Specification 61145D.pdf :

Section 5:

> 5.0 EJTAG vs. ICSP
> Programming is accomplished via the EJTAG module
> in the CPU core. EJTAG is connected to either the full
> set of JTAG pins, or a reduced 2-wire to 4-wire EJTAG
> interface. In both modes, programming of the PIC32MX
> Flash memory is accomplished through the ETAP
> controller. The TAP Controller uses the TMS pin to
> determine if instruction or data registers should be
> accessed in the shift path between TDI and TDO (see
> Figure 5-1).
...
> 2-Wire to 4-Wire:
> Converts 2-wire ICSP interface to 4-wire JTAG.
> • ETAP
> - Serially feeds instructions and data into CPU.
...
> 5.2 2-wire ICSP Details
> When in this mode the 2-wire ICSP signals are time
> multiplexed into the 2-wire to 4-wire block. The 2-wire
> to 4-wire block then converts the signals to look like a
> 4-wire JTAG port to the TAP controller.
> There are two possible modes of operation:
> • 4-Phase ICSP
> • 2-Phase ICSP
> 5.2.1 4-PHASE ICSP
> In 4-Phase ICSP, TDI, TDO, and TMS are multiplexed
> onto PGD in 4 clocks (see Figure 5-4). The Least Significant
> bit (LSb) is shifted first, and TDI and TMS are
> sampled on the falling edge of PGC while TDO is
> driven on the falling edge of PGC. 4-Phase mode is
> used for both read and write data transfers.
And there are some nice timing diagrams showing the TMS/TDI/TDO 
relationship to the clock over ICSP.

Plus PIC32MX talks about debugging using EJTAG. EJTAG is a MIPS Standard:
Which is publicly available (after you register) at:
http://www.mips.com/secure-download/index.cfm?filename=mips-architecture/MD00047%2D2B%2DEJTAG%2DSPC%2D04%5F14.pdf

EJTAG is designed for debugging. However that same functionality can be 
used to allow programming. PIC do not need to re-specify EJTAG, as that 
is available from MIPS. I have found no suggestion that the PIC32 does 
not implement a compliant EJTAG core, and as ICSP is just de-multiplexed 
into 4 wire jtag internally, there is no reason why EJTAG operations 
will not operate as expected over ICSP.

There are lots of MIPS chips that have an EJTAG core. An EJTAG 
implementation in OpenOCD would be awesome. PIC32 is a nice cheap 
platform to develop and test this with.

Strontium


Xiaofan Chen wrote:
> On Mon, May 18, 2009 at 8:58 AM, David Brownell  wrote:
>   
>> On Sunday 17 May 2009, Strontium wrote:
>> 
>>> Pic32 has 2 debug interfaces.  4 Wire JTAG.  And a pin count compressed
>>> version of Jtag which is serialised over 2 wires (ICSP).  The protocol
>>> is the same as JTAG, the electrical interface is the only thing that
>>> differs. 2 wire mode should be able to be driven using a FT2232 type
>>> device, in a similar fashion to I2C (Tie TDI and TDO together).
>>>   
>
> The ICSP debugging protocol is kept secret by Microchip
> and Microchip does not want to released to public. NDA
> access might be possible for certain 3rd party. The ICSP
> programming protocol is open to the public through the
> programming specification.
>
> "To use ICD, an external system that supports ICD must load
> a debugger executive program into the microcontroller. This is
> automatically handled by many debugger tools, such as the
> MPLAB IDE. For PIC32MX devices, the program is loaded into
> the last page of the Boot Flash memory space. When not
> debugging, the application is free to use the last page of Boot
> Flash Memory. PIC32MX ICSP supports standard debugging
> functions including memory and register viewing and modification.
> Breakpoints can be set and the program execution may be
> stopped or started. In addition to these functions registers or
> memory contents can be viewed and modified while the
> CPU is running."
>
> The debug executive hex files are available from MPLAB installation.
>
> Microchip's tools like Real ICE, ICD 3, ICD 2 do not use
> EJTAG. But JTAG support is available from 3rd party.
> http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2602
>
>   
>> Is that 2-wire mode the same one that the JTAG folk have
>> been working with, or is it specific to Microchip?  Do
>> you know?
>> 
>
> As answered before, the 2-wire ICSP is not JTAG
> and the only way to know it is through reverse engineering.
> The only project I know of is the Piklab project which tries
> to support ICSP debugging with ICD 2.
>
> Anyway, to openocd, it is possible to support JTAG
> debugging/programming.
>
>
>   

___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] PIC32 openocd status

2009-05-18 Thread Nico Coesel
 
> -Oorspronkelijk bericht-
> Van: openocd-development-boun...@lists.berlios.de 
> [mailto:openocd-development-boun...@lists.berlios.de] Namens Strontium
> Verzonden: maandag 18 mei 2009 4:06
> Aan: Xiaofan Chen
> CC: openocd-development@lists.berlios.de
> Onderwerp: Re: [Openocd-development] PIC32 openocd status
> 
> >
> > This is wrong. ICSP is Microchip's proprietory protocol for 
> > programming and debugging. The ICSP module is independent from the 
> > EJTAG module in PIC32. You can read Chapter
> > 33 of the PIC32MX Family Manual for more information.
> 
> I didn't make it up.
> 
> I read it.
> 
> PIC32MX Flash Programming Specification 61145D.pdf :
> 
> Section 5:
> 
> EJTAG is designed for debugging. However that same 
> functionality can be used to allow programming. PIC do not 
> need to re-specify EJTAG, as that is available from MIPS. I 
> have found no suggestion that the PIC32 does not implement a 
> compliant EJTAG core, and as ICSP is just de-multiplexed into 
> 4 wire jtag internally, there is no reason why EJTAG 
> operations will not operate as expected over ICSP.
> 
> There are lots of MIPS chips that have an EJTAG core. An 
> EJTAG implementation in OpenOCD would be awesome. PIC32 is a 
> nice cheap platform to develop and test this with.
> 

Gentlemen,
AFAIK EJTAG is already implemented in OpenOCD (I'm using it for another
MIPS based SOC to program external flash). I just don't know how
complete it is in respect to debugging/single stepping. The flash
programming routines for PIC32 are also available in OpenOCD. So I guess
everything is available in OpenOCD to program a PIC32.

Slighty off-topic: I think the MIPS GCC compiler from Codesourcery can
be used for PIC32 straight away. It is based on GCC 4.x (not the old 3.x
GCC), has newlib support and isn't crippled! The C library from mspgcc
(GCC for TI's MSP430 series) is a usefull replacement for newlib because
it is really really small. I had little problems compiling it for ARM.

Nico Coesel

___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] PIC32 openocd status

2009-05-18 Thread Xiaofan Chen
On Mon, May 18, 2009 at 3:36 PM, Nico Coesel  wrote:

> Gentlemen,
> AFAIK EJTAG is already implemented in OpenOCD (I'm using it for another
> MIPS based SOC to program external flash). I just don't know how
> complete it is in respect to debugging/single stepping. The flash
> programming routines for PIC32 are also available in OpenOCD. So I guess
> everything is available in OpenOCD to program a PIC32.

As far as I know,  the chip erase is not implemented/working
for flashing the PIC32 according to the mailing list archive. So
it might be barely working. I do not know the status of debugging.

>From: John McCarthy 
>Date: Mon, Jan 5, 2009 at 12:39 PM
>Subject: [Openocd-development] pic32mx flash fixups and speedups
>To: OpenOCD Development 
>
>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.
>

I will need to make a connector to test J-link with my Explorer 16 in
the future. Right now I am not really using PIC32 but more on
USB PIC24. And I will need to learn to use OpenOCD with LPC-2148 first.

> Slighty off-topic: I think the MIPS GCC compiler from Codesourcery can
> be used for PIC32 straight away. It is based on GCC 4.x (not the old 3.x
> GCC), has newlib support and isn't crippled! The C library from mspgcc
> (GCC for TI's MSP430 series) is a usefull replacement for newlib because
> it is really really small. I had little problems compiling it for ARM.
>

The Microchip C32 compiler is not really crippled but the libraries are
as far as I know.
http://www.microchip.com/forums/tm.aspx?m=292995

Since then, Microchip has moved the C32 sourcecodes and
 build scripts to Sourceforge.
http://sourceforge.net/projects/microchipopen/

-- 
Xiaofan http://mcuee.blogspot.com
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] PIC32 openocd status

2009-05-18 Thread Spencer Oliver
> > Gentlemen,
> > AFAIK EJTAG is already implemented in OpenOCD (I'm using it for 
> > another MIPS based SOC to program external flash). I just 
> don't know 
> > how complete it is in respect to debugging/single stepping. 
> The flash 
> > programming routines for PIC32 are also available in OpenOCD. So I 
> > guess everything is available in OpenOCD to program a PIC32.
> 
> As far as I know,  the chip erase is not implemented/working 
> for flashing the PIC32 according to the mailing list archive. 
> So it might be barely working. I do not know the status of debugging.
> 

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.

Having said that i have not tried svn head lately with the pic32.

I have a couple of patches to finish off, and complete the work on the
run_algorithm.
At the moment i am struggling to find any time to spend on openocd, work is
very busy.

Once the run_algorithm is added the flash programming should speed up, my
next step was to look at using the ejtag fast_data area.

Cheers
Spen
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] PIC32 openocd status

2009-05-18 Thread Michel Catudal
Xiaofan Chen a écrit :
> As far as I know,  the chip erase is not implemented/working
> for flashing the PIC32 according to the mailing list archive. So
> it might be barely working. I do not know the status of debugging.
>
>   
The mips debugger should work with it but you need some way to flash the
program.
I am busy working on the programmer. When I get something working I will
submit it as well as my debugger and eclipse support.

>
>> Slighty off-topic: I think the MIPS GCC compiler from Codesourcery can
>> be used for PIC32 straight away. It is based on GCC 4.x (not the old 3.x
>> GCC), has newlib support and isn't crippled! The C library from mspgcc
>> (GCC for TI's MSP430 series) is a usefull replacement for newlib because
>> it is really really small. I had little problems compiling it for ARM.
>>
>> 
>
> The Microchip C32 compiler is not really crippled but the libraries are
> as far as I know.
> http://www.microchip.com/forums/tm.aspx?m=292995
>
> Since then, Microchip has moved the C32 sourcecodes and
>  build scripts to Sourceforge.
> http://sourceforge.net/projects/microchipopen/
>
>   
I have created some binaries for SuSE 11.1 and Fedora 9 based on the
sourceforge. I have made a debugger for mips but haven't put it on my
web site.
I am waiting to get my openocd implementation and need to test the
debugger before I release it.

The gcc that I have is missing newlib which I don't use anyhow, I don't
like that bloated crap.

Michel

-- 
Tired of Microsoft's rebootive multitasking?
then it's time to upgrade to Linux.
http://home.comcast.net/~mcatudal

___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] PIC32 openocd status

2009-05-18 Thread Xiaofan Chen
2009/5/19 Michel Catudal :

> The mips debugger should work with it but you need some way to flash the
> program.
> I am busy working on the programmer. When I get something working I will
> submit it as well as my debugger and eclipse support.
>

That would be great. I have the PICKit 2 which works under Linux/Windows
for programming PIC32. So I can probably use that for verifying when you finish.
The first thing for me to do is to make a connector for my Explorer 16 board
since the JTAG connector is not the same as J-Link I have.

-- 
Xiaofan http://mcuee.blogspot.com
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development