Flash Magic Forum

In-System Programming Support => LPC9xx/LPC9xxx => Topic started by: itibira on December 06, 2006, 12:57:42 PM

Title: ISP? ICP? IAP?
Post by: itibira on December 06, 2006, 12:57:42 PM
Hi,

i am planning on using an 89LPC935 as a "subprocessor" in my project, ie: there's another main processor on the board that talks to USB and  then it talks to the LPC935 via I2C. What i'd like to be able to do is to somehow use the main processor to program the LPC935 with new code so that the end user doesn't need cables or special programming hardware to update any LPC935 firmware. Ideally it should be done through the USB connection and main processor with the programming routines residing in the PC or the main processor. i've been trying to understand all the nuances of the different programming schemes for the LPC935 (LPC9xx), ISP, IAP and ICP but it is all very confusing and seems very prone to error, different chip revisions, etc. and, worst of all, with the prospect of an incorrect programming attempt requiring the replacement of the LPC935 chip on the PCB which would be unacceptable.

Before i commit to using the LPC935, i'd like to get a solid enough understanding of and feeling for a robust method of LPC935 programming / updating of firmware with minimal added hardware resources and a method that best suits the scenario i described above. Can anyone please explain how this might be achieved or even if it's possible?

For example, in the ICP method, if i understand it correctly, the programmer must control the Vdd to the 935 for programming, which complicates the hardware and adds expense. Do ALL the various programming methods need to control Vdd or do ISP and IAP not need this?

Thanks in advance.


Title: Re: ISP? ICP? IAP?
Post by: Andy Ayre on December 06, 2006, 01:26:19 PM
ICP is probably the most robust because it is implemented in hardware. It shouldn't be too hard to implement.

ISP requires that you also control the power so you can send the three reset pulses to the device within a specific time after power up.

IAP is used only if you want to develop your own custom bootloader. For example your device may wait for a command on I2C which will then place it in "programming mode". When programming instructions are received (maybe via I2C?) then you can use IAP to program the flash.

Andy
Title: Re: ISP? ICP? IAP?
Post by: itibira on December 06, 2006, 06:08:10 PM
Thanks, Andy, for the information. i have more questions though...sorry for the trouble:

* Does ICP also require that the Vdd on the 935 be controlled?

* Is there a schematic that is known good to use for ICP hardware for the 935 and where can i look at it, please? (i already have a few app notes and schematics but i'm not sure which one is the latest / most accurate)

* In my proposed system architecture (using a second USB microcontroller and I2C), are you saying that by using IAP and my own bootloader that it would be a better solution than ICP (or can i also use ICP via I2c?)?

* Are there any examples of IAP-based and ICP-based bootloader source code to look at or download?

* i would prefer to do the firmware programming / updates via my own Windows-based code. Is there any place i can download a code example or demo project for Windows to do this?

* Finally, what are the worst-case potential problems with using either IAP or ICP? eg: the LPC935 getting into a state that would require unsoldering the device and using a parallel programmer to recover it. Or does using IAP or ICP prevent this?

Again, sorry for all these questions. i'm very new at using the Philips parts and in the way they do the in-system programming. i've been downloading all the data sheets and application notes i can find, plus looking at a few forums but i'm getting more confused the deeper i look. It would be nice to get enough reliable information that says "you are >HERE<".

Any help or insight is most deeply appreciated. Thank you.





Title: Re: ISP? ICP? IAP?
Post by: rbtamd on December 07, 2006, 05:48:26 AM
search for "no touch" I think this is a solution for you

Roberto

Title: Re: ISP? ICP? IAP?
Post by: erikm on December 07, 2006, 05:51:42 AM
search for "no touch" I think this is a solution for you

A note from the author:
Read all the NoTouch documents, the NoTouch for LPC does not have "the words"

Erik


Title: Re: ISP? ICP? IAP?
Post by: itibira on December 07, 2006, 11:31:27 AM
Hi,

What do you mean when you say that NoTouch does not have "the words"? Which words are you referring to, please?

Thanks.



Title: Re: ISP? ICP? IAP?
Post by: Andy Ayre on December 07, 2006, 12:42:28 PM
I think he means no description.

The best documentation for the ICP connections is the NXP application note, that you can get from the third party section of the Flash Magic web page.

I'm not saying that one option is better than the other, only that they each have pros and cons. You have to decide what is best for your application.

You can get the LPC9xx bootloader source code from the third party section of the Flash Magic web page. This will show you how to use IAP, however it is all in assembler. You could even take the source code and change the source of the ISP commands from the UART to I2C, I suppose.

With ICP I don't think it is possible to get the device in a state where it can't be reprogrammed. I think this is the biggest advantage of that approach. With IAP you are relying on correct programming of your firmware last time. If you program it incorrectly and accidentally reset then you are stuck.

Andy
Title: Re: ISP? ICP? IAP?
Post by: Je Gold on December 09, 2006, 10:33:38 AM
With programming any flash micro-controller it is essential that Vdd is stable and within specification (any programming mode, ICP, ISP and IAP included).

ISP requires an oscillator to drive the serial UART (weather internal Osc or external Osc or Xtal Osc).  Hence it is Asynchronous and dependent on timing.

ICP is Synchronously clocked serial data(a bit like SPI or microwire) And there is less dependence on an Osc source.

I believe that ICP has more control over the micro.

Because ICP is Synchronously clocked serial data it is difficult to directly program by the serial port of a PC  (which is Asynchronous)..... Hence a micro in between the PC serial port and the "target  micro" is used do the conversion from Asych to  Synch.

The in-between micro is part of the "Bridge circuit"

Getting in to programme mode
----------------------------------------------
After POR (Power On Reset).......

3 quick pluses on the Reset pin  -  puts the LPC935 in to ISP mode.

7 quick pulse on the Reset pin - puts the LPC935 in to ICP mode.


All current promote LPC900 devices can use ICP   and only 20pin parts can do both ISP and ICP.

FINALLY
-------------
If you want less problems  - I highly recommend purchasing the  Keil  MCB900  which can ISP program quite easily.... And be used as part of the Bridge Circuit to do ICP.

Quite a few people take a bit of time to get their "home brew" ISP or ICP circuit going, hence the MCB900 is a good starter.

I think the MCB900 is $59 USD + Freight.. (which includes limited complier).

Just my 2 cents worth

Joe

;)
Title: Re: ISP? ICP? IAP?
Post by: Je Gold on December 09, 2006, 10:35:54 AM
Sorry that is only 20pin and "greater" can be programmed by ISP OR ICP.
Title: Re: ISP? ICP? IAP?
Post by: itibira on December 10, 2006, 03:09:21 AM
Hi Andy and Je,

Thanks to both of you for your input and also appreciated is your time spent for the reply.  :)

Your descriptions of the ICP and ISP are appreciated. Since i will already have a main microcontroller (with USB I/F) on the board which can be used as the ICP bridge micro, it seems at this point that ICP might be the best way to go.

Regarding the Vdd: i understand that the Vdd will need to be at the required voltage and stable for any operation, including programming, to occur properly but i have seen in a few app notes that the Vdd to the LPC935 (or LPC9xx) seems to need some kind of switching of Vdd for programming to proceed in ICP mode. Is this an absolute requirement? Must the Vdd be toggled On / Off in order to successfully program the 935 or is there a "trick" that can be used that allows the Vdd to be on and stable throughout the ICP programming?

Also, regarding using the MCB900: since i am architecting this board as well as designing the hardware and writing the firmware, my concern is to have the 935 programmed via the main USB micro through the USB port. i do not want the end-user to have to buy or have any special programming hardware in order to program the LPC935, so i don't want to use the MCB900, except maybe in initial debug of the first prototype, where it may be helpful.

Finally, thanks for the info on where to find the IAP bootloader source code. Is there similarly any bootloader source code for ICP?

Thank you.  :)





Title: Re: ISP? ICP? IAP?
Post by: Andy Ayre on December 11, 2006, 06:39:28 AM
I believe controlling VDD is necessary.

You can get the LPC9xx bootloader sources from: http://www.flashmagictool.com/resources.html (http://www.flashmagictool.com/resources.html)

Andy
Title: Re: ISP? ICP? IAP?
Post by: Je Gold on December 19, 2006, 04:13:47 AM
Yes controlling  Vdd of the "target"  LPC935 (or any of the LPC900 series in general) for ISP or ICP is nessecary  BECAUSE the "quick" programming pluses must applied immediately after POR (power on reset)....   you can only get POR by powering on/off/on the target LPC900 micro.......  hence Vdd must be controlled.

There is much more electronic hardware work with ICP and ISP  but it is the hardware control of the LPC935 (LPC900 series) that put it in to programming mode.

Notouch IAP (In Application Programming)  requires "back door / front door" code that detects a micro controller event and calls ISP bootloader (to put it in to ISP programme mode) BUT this tiny bit of NoTouch code... must be loaded the 1st time and all subsequent times  NoTouch is to be used.

Where as....  Hardware ISP / ICP.... hardware forces the LPC935 in to programming mode, but hitting the RESET line on the head 3 or 7 times.

Joe
Title: Re: ISP? ICP? IAP?
Post by: erikm on December 20, 2006, 06:54:04 AM
Yes controlling  Vdd of the "target"  LPC935 (or any of the LPC900 series in general) for ISP or ICP is nessecary  Unless you use NoTouch!

if you use NoTouch and install it the very first (and, since it will be part of your code every time thereafter) you need no, none, zero, nada "control signals", just the serial

NoTouch works with ISP, NOT ICP

Erik
Title: Re: ISP? ICP? IAP?
Post by: itibira on December 21, 2006, 12:32:54 AM
OK, so what i am getting is that NoTouch is only for ISP but then there is no need for power cycling the Vdd and playing with the reset, etc., BUT there could be issues if the NoTouch is not programmed correctly the first time and something goes wrong, in which case it's time to solder a new chip in.

On the other hand, the advantages / disadvantages of ICP are that because it is hardware driven, there is no issue with the LPC9xx getting into a curare-like paralysis state BUT there is all that extra hardware to deal with.

i won't even attempt to figure out IAP...

Is this about right?

Moreover, ISP uses the TxD / RxD pins whereas ICP uses P0.4 and P0.5 (plus the power and Reset). There has been mention made of bootloaders for both ICP and ISP. Is this correct or ? Just to be clear, does the bootloader code go into the target LPC9xx as a set of routines alongside the firmware used for the embedded application (ie: the code i write)?

Finally, i still don't understand the issues with using the bootloader: is it used to provide a ISP front-end to be able to program the micro via Flash Magic? Is it also used for ICP? If i am using my own "bridge" microcontroller via USB, then can Flash Magic still be used or do i need to write my own PC-based code?

Sorry for so many questions. i think that Philips might have done a much better job if they had settled on one programming method for their microcontrollers and developed it properly, with REAL information and detailed examples on how to program the FLASH instead of having the information scattered to the four winds. As it is, there is too much confusion (especially for me) and it is taking much too much time and energy to figure all this out. It shouldn't have to be this difficult.

Perhaps a different microcontroller would be better suited and easier to program? (not necessarily Philips...)

Thanks again.
Title: Re: ISP? ICP? IAP?
Post by: Je Gold on December 21, 2006, 04:29:49 AM
It is not difficullt if you follow the Keil MCB900 board/design... It work's almost out of the box and allows you to get to 1st base very fast....  (ISP Hardware Mode)...  here is the schematic / circuit diagram.
http://www.keil.com/mcb900/mcb900-schematics.pdf  and the main page is www.keil.com/mcb900/

ISP works for 20 to 44pin parts mainly because they have a UART on-board:

Please consider using MCB900 development - which should get you 1st base quickly.

If you are having trouble obtianing the MCB900 then you might try www.lpctoos.com

Other comments
The ISP bootloader is preloaded at the factory for the 20pin and larger parts.

Notouch is software control  that allows you to jump to the ISP from some programmed event.


It's alway better using development tools for the 1st time.

Joe
Title: Re: ISP? ICP? IAP?
Post by: Andy Ayre on December 21, 2006, 08:05:37 AM
This is my understanding:

The flash programming algorithms are implemented in hardware. The ICP protocol directly accesses those algorithms. The bootloader sits in the top of flash memory and is programmed at the factory by NXP. The bootloader provides two interfaces to the programming algorithms. The first is called ISP which allows the UART to be used for communication. The second is IAP, which allows registers to be used for the communication. Therefore if you are using ICP you can erase the entire flash memory of the device, including the factory bootloader.

I think your first two paragraphs are correct.

Flash Magic only understands the ISP protocol, nothing else. So if you want to use Flash Magic, then you must make the ISP protocol available on a COM port. If you are using ICP then you don't have that protocol, so how is it solved? By taking an LPC935 and programming the ICP to ISP bridge code from NXP into it. Flash Magic talks to the bridge device, which then uses ICP to talk to the target device.

Andy
Title: Re: ISP? ICP? IAP?
Post by: erikm on December 21, 2006, 01:30:00 PM
OK, so what i am getting is that NoTouch is only for ISP but then there is no need for power cycling the Vdd and playing with the reset, etc., BUT there could be issues if the NoTouch is not programmed correctly the first time and something goes wrong, in which case it's time to solder a new chip in.

On the other hand, the advantages / disadvantages of ICP are that because it is hardware driven, there is no issue with the LPC9xx getting into a curare-like paralysis state BUT there is all that extra hardware to deal with.


yes and no
1) if you add "the backdoor" (IMMEDIATELY at Startup:) the only case where NoTouch will leave a chip dead is if you do not complete a program download.  I always implement NoTouch for convenience and the backdoor for safety.
2) the "fiddle the pins" can be implemented as an external circuit, then you do not need copy it on each and every board you make.

Erik
Title: Re: ISP? ICP? IAP?
Post by: itibira on December 21, 2006, 11:35:12 PM
Thank you all for the responses. i'm still going over them and looking at documentation but in general it is becoming more clear.

Quote from: erikm on December 21, 2006, 01:30:00 PM

2) the "fiddle the pins" can be implemented as an external circuit, then you do not need copy it on each and every board you make.


Thank you for the idea, and it does make sense for an engineering oriented end-user. However, the firmware upgrade method i would like to implement on my board is one in which the (non-technical) end user doesn't need to buy extra cables or equipment and doesn't need to take the final product apart in order to reprogram the LPC935 microcontroller. It should be done transparently through the USB microcontroller interface (acting as a bridge) along with the proper PC-based software. Thus i would like to find a minimal cost way (in terms of BOM cost) to make the firmware update as easy and transparent as possible, as well as robust and error-immune as possible. This means i should do all the hard work at the beginning in the design phase so that the end user will not really have to work so hard or be technically inclined in order to upgrade or update the firmware. It should be extremely simple and foolproof.

As i see it at this moment in time, although the ISP method is the easiest and the LPC935 chips come already preloaded with the ISP bootloader from the factory, and even though if i implement the NoTouch method, there is still that slightest of possibilities that if there is a power failure at the end-user's location during firmware update, the LPC935 will be dead and the end user will need to ship the product back for rework, which is not a pleasant thought and is expensive. Therefore, it seems that the most robust way of doing things is to use ICP and the extra hardware.

Since i can use the USB micro as an ISP-ICP bridge, all i need to do, theoretically, is to implement the Vdd powerdown of the LPC935, because the Reset pulsing and any other pin toggling on the target LPC935 can be done strictly via firmware in the bridge micro (plus some very minimal external components), instead of using all the external gates and other logic shown typically in something like the MCB900 schematic. Is this correct? All the literature i've seen so far regarding ICP programming always includes external circuitry attached to an RS232 level converter (eg: MAX232) to generate the proper ICP hardware timings via the host's serial port. This implies (i haven't investigated it yet) that Flash Magic creates the basic timings in the COM port signals which are massaged further by the on-board ICP programming logic. Is this also correct? Then my next question would be: would ISP-ICP bridge firmware do all of the signal conversion needed in the brdge micro's firmware only, by toggling some pins, without resorting to any RS232 level converter chip?

Finally, i haven't been able to figure out if Flash Magic can be used with USB. i assume it can, since Flash Magic has an "interface" setting and one of those is FDI USB. Am i correct or is it more complicated than that?

Does it look something like:

Flash Magic -> PC USB (FDI?) -> USB micro bridge firmware and pins -> LPC935 (with external power control component only, no other logic) ?

Is there any bridge micro firmware available for this particular architecture? Is there a Flash Magic DLL that i can get that i can incorporate into my own PC software?

Thank you for your patience. i know i've asked too many questions already...






Title: Re: ISP? ICP? IAP?
Post by: erikm on December 22, 2006, 06:04:48 AM
OK, so what i am getting is that NoTouch is only for ISP but then there is no need for power cycling the Vdd and playing with the reset, etc., BUT there could be issues if the NoTouch is not programmed correctly the first time and something goes wrong, in which case it's time to solder a new chip in.

On the other hand, the advantages / disadvantages of ICP are that because it is hardware driven, there is no issue with the LPC9xx getting into a curare-like paralysis state BUT there is all that extra hardware to deal with.

i won't even attempt to figure out IAP...

Is this about right?


1) if you add "the backdoor" at the right place the only case you may need to "solder a new chip in" is failure during programming the chip.  Not 'bad code' not any other case except failure in that exact time slot.  In some cases, even that will not make you 'lose' the chip.
2) the kick the uC into ISP circuitry can be added externally in which case you do not need to add it to every board you make.

What I do is install NoTouch for convenience, "the backdoor" for emergency and, should I ever need to I will make the xternal "kick" circuitry, I have, for the sake of "belt, suspenders and a piece of rope" the connector for the "kick circuitry" on my boards with a 'shorting nugget' on the Vcc interrupt pins

Erik

Title: Re: ISP? ICP? IAP?
Post by: Andy Ayre on December 22, 2006, 08:11:20 AM
It's not possible for Windows applications to generate the timing needed for ICP entry and protocol. Therefore you need something inbetween your PC and your device to generate the ICP signals. This is where the ISP to ICP bridge comes in. The FDI USB-ICP is also an ISP to ICP bridge, but in a more convenient package - i.e. you don't have to build and program the bridge yourself. So it looks like:

Flash Magic <---> FDI USB-ICP <---> Target Device using ICP

The FDI USB-ICP interface uses a driver that makes it look like it is a COM port to Windows applications. This is the only way that Flash Magic can talk to a USB device.

Andy
Title: Re: ISP? ICP? IAP?
Post by: Andy Ayre on December 22, 2006, 08:13:09 AM
Yes, you can buy the DLL that powers Flash Magic and use it for your own applications. It provides an API that gives you access to every ISP feature that Flash Magic supports. For more information see: http://www.flashmagictool.com/devkit.html (http://www.flashmagictool.com/devkit.html).

Andy
Title: Re: ISP? ICP? IAP?
Post by: erikm on December 22, 2006, 10:12:45 AM
OK, so what i am getting is that NoTouch is only for ISP but then there is no need for power cycling the Vdd and playing with the reset, etc., BUT there could be issues if the NoTouch is not programmed correctly the first time and something goes wrong, in which case it's time to solder a new chip in.

On the other hand, the advantages / disadvantages of ICP are that because it is hardware driven, there is no issue with the LPC9xx getting into a curare-like paralysis state BUT there is all that extra hardware to deal with.

i won't even attempt to figure out IAP...

Is this about right?


1) if you install NoTouch for use and 'the backdoor' for safety, the only case where you will need to "solder a new chip in" is some instances where something goes wring while FlashMagic is programming the chip no other cases
2) for the sake of "belt, suspenders and a piece of rope" my boards have a connector for an external 'wiggle the bits" circuit.  Should I lose some chips I will make that board (have had no reason to so far)
3) even if you decide to go totally for "wiggle the bits" if you make the wiggle circuitry external, you do not have to repeat it for every board you make.  Yes, the connector will need to be laid out so a couple of "shorting plugs" e.g. Vcc can be inserted for normal operation.

Merry Christmas to all

Erik
Title: Re: ISP? ICP? IAP?
Post by: erikm on December 22, 2006, 10:14:19 AM
OK, so what i am getting is that NoTouch is only for ISP but then there is no need for power cycling the Vdd and playing with the reset, etc., BUT there could be issues if the NoTouch is not programmed correctly the first time and something goes wrong, in which case it's time to solder a new chip in.

On the other hand, the advantages / disadvantages of ICP are that because it is hardware driven, there is no issue with the LPC9xx getting into a curare-like paralysis state BUT there is all that extra hardware to deal with.

i won't even attempt to figure out IAP...

Is this about right?


1) if you install NoTouch for use and 'the backdoor' for safety, the only case where you will need to "solder a new chip in" is some instances where something goes wring while FlashMagic is programming the chip no other cases
2) for the sahe of "belt, suspenders and a piece of rope" my boards have a connector for an external 'wiggle the bits" circuit/  Should I lose some chips I will make that board (have had no reason to)
30 even if you decide to go totally for "wiggle the bits" if you make the wiggle circuitry external, you do not have to repeat it for every board you make.  Yes, the connector will need to be laid out so a couple of "shorting plugs" e.g. Vcc can be inserted for normal operation.

Merry Christmas to all

Erik"