I need IAP help...

Started by albin_martinsson October 25, 2004

Hi

I really need some IAP help for the LPC2129.

I need to reprogramm the code area in my application and this is
done in my own bootloader.

My routines follows the IAP commands that philips has in theire
applicatione notes.

like this...

#define IAP_LOCATION 0x7FFFFFF1;

typdef void (*IAP)(unsigned int[], unsigned int[]);

unsigned int command[5];
unsigned int result[2];
IAP iap_entry; .... in a test function i do like this to read the part ID
iap_entry = (IAP)IAP_LOCATION;
command[0] = 54;
result[0] = 0;

iap_entry(command,result);
print_hex(result[0]);

The problem is that my code will hang when iap_entry is called...
Why does it do this???

Im using GCC.

Anyone now about this problem and how to solve it?

Thanks.... /Albin Martinsson



An Engineer's Guide to the LPC2100 Series


--- In , "albin_martinsson" <fredrik_m@t...>
wrote:
> The problem is that my code will hang when iap_entry is called...
> Why does it do this???
>
> Im using GCC.
>
> Anyone now about this problem and how to solve it?

Could it be because you are not calling the IAP routines from Thumb
mode? Please see also this post for a good example on how to do it:

http://groups.yahoo.com/group/lpc2000/message/3479

Chris
Tutor at ESAcademy
www.esacademy.com
www.canopenbook.com




--- In , "Tutors of ESAcademy"
<esacademy@g...> wrote:
>
> --- In , "albin_martinsson"
<fredrik_m@t...>
> wrote:
> > The problem is that my code will hang when iap_entry is called...
> > Why does it do this???
> >
> > Im using GCC.
> >
> > Anyone now about this problem and how to solve it?
>
> Could it be because you are not calling the IAP routines from
Thumb
> mode? Please see also this post for a good example on how to do it:
>
> http://groups.yahoo.com/group/lpc2000/message/3479
>
> Chris
> Tutor at ESAcademy
> www.esacademy.com
> www.canopenbook.com

Im not calling the IAP routines from Thumb mode. Do you have to do
that. There is a command in the gcc compiler "-mthumb-interwork"
that should support calls between ARM and THUMB mode..
Then... im not so good at writing code in assembler, I can just read
it so.. any more help is very welcome.

/Fredrik





> Im not calling the IAP routines from Thumb mode. Do you have to do
> that. There is a command in the gcc compiler "-mthumb-interwork"
> that should support calls between ARM and THUMB mode..
> Then... im not so good at writing code in assembler, I can just
read
> it so.. any more help is very welcome.

Yes. If you're running ARM code and u need to use the IAP u need 2do
a thumb instruction.

Though I'm not familiar with your compiler, does GCC have thumb/arm
directives that u can add-on to fuction definitions? Something
like...

typdef _thumb void (*IAP)(unsigned int[], unsigned int[])
{
.....
}

If yes, then modifying your IAP call to a thumb function should do
it.




--- In , "Leighton Rowe" <leightonsrowe@y...>
wrote:
>
> > Im not calling the IAP routines from Thumb mode. Do you have to
do
> > that. There is a command in the gcc compiler "-mthumb-interwork"
> > that should support calls between ARM and THUMB mode..
> > Then... im not so good at writing code in assembler, I can just
> read
> > it so.. any more help is very welcome.
>
> Yes. If you're running ARM code and u need to use the IAP u need
2do
> a thumb instruction.
>
> Though I'm not familiar with your compiler, does GCC have
thumb/arm
> directives that u can add-on to fuction definitions? Something
> like...
>
> typdef _thumb void (*IAP)(unsigned int[], unsigned int[])
> {
> .....
> }
>
> If yes, then modifying your IAP call to a thumb function should do
> it.

Hi
Thanks for your help.. but i did get it to work.. but I still dont
know what i was doing wrong.. but this is how i solved it...

for all C-files im using i added "-mthumb-interwork" command to the
gcc-compiler. Then the code that is generated can handel calls
between ARM och THUMB code.

Now i can go home from work today and feel happy =)...

Until next time... bye
/ Fredrik Martinsson, embedded developer, Sweden



--- In , "albin_martinsson" <fredrik_m@t...> wrote:
>
> Hi
>
> I really need some IAP help for the LPC2129.
>
> I need to reprogramm the code area in my application and this is
> done in my own bootloader.
>
> My routines follows the IAP commands that philips has in theire
> applicatione notes.
>
> like this...
>
> #define IAP_LOCATION 0x7FFFFFF1;
>
> typdef void (*IAP)(unsigned int[], unsigned int[]);
>
> unsigned int command[5];
> unsigned int result[2];
> IAP iap_entry; > .... in a test function i do like this to read the part ID
> iap_entry = (IAP)IAP_LOCATION;
> command[0] = 54;
> result[0] = 0;
>
> iap_entry(command,result);
> print_hex(result[0]);
>
> The problem is that my code will hang when iap_entry is called...
> Why does it do this???
>
> Im using GCC.
>
> Anyone now about this problem and how to solve it?
>
> Thanks.... /Albin Martinsson

hello

i have had the same problem. When i want to call the iap_entry
function the processor hang up.

I have said the gcc that it is thumb code but it still don't work.

The solution was that i update the onchip philips bootloader to the
actual version 1.63. And now it still works perfect.

i hope i can help you with this solution.

best regards Tobi





Upgrading the bootloader is a good idea. Also, make sure you disable interrupts before the call to IAP and restore them afterwards.

--- In , "burner_itfi" <burner_itfi@h...> wrote:
>
> --- In , "albin_martinsson" <fredrik_m@t...> wrote:
> >
> > Hi
> >
> > I really need some IAP help for the LPC2129.
> >
> > I need to reprogramm the code area in my application and this is
> > done in my own bootloader.
> >
> > My routines follows the IAP commands that philips has in theire
> > applicatione notes.
> >
> > like this...
> >
> > #define IAP_LOCATION 0x7FFFFFF1;
> >
> > typdef void (*IAP)(unsigned int[], unsigned int[]);
> >
> > unsigned int command[5];
> > unsigned int result[2];
> > IAP iap_entry;
> >
> >
> > .... in a test function i do like this to read the part ID
> > iap_entry = (IAP)IAP_LOCATION;
> > command[0] = 54;
> > result[0] = 0;
> >
> > iap_entry(command,result);
> > print_hex(result[0]);
> >
> > The problem is that my code will hang when iap_entry is called...
> > Why does it do this???
> >
> > Im using GCC.
> >
> > Anyone now about this problem and how to solve it?
> >
> > Thanks.... /Albin Martinsson
>
> hello
>
> i have had the same problem. When i want to call the iap_entry
> function the processor hang up.
>
> I have said the gcc that it is thumb code but it still don't work.
>
> The solution was that i update the onchip philips bootloader to the
> actual version 1.63. And now it still works perfect.
>
> i hope i can help you with this solution.
>
> best regards Tobi