IAP trouble

Started by dpavli2 October 24, 2006
Hello,

I own a LPC2138 (ARM7TDMI) development board from iSystem and I am
developing my firmwares with the WinIDEA software.

I know there has already been some discussion about IAP, but I really
cannot get it to work for me. The C code follows:

IAP IAP_entry = (IAP) 0x7ffffff1;
int IAP_result[10];
int IAP_command[5];
IAP_command[0] = 50; //prepare sectors
IAP_command[1] = 5;
IAP_command[2] = 5;
IAP_entry(IAP_command, IAP_result);

As I call IAP_entry and watch the dissasembler, the disassembly looks
like this:

sub r3,r11,#50
sub r2,r11,#3C
ldr r12,[r11,-0014]
mov r0,r3
mov r1,r2
mov r14,pc
move pc,r12

Then it branches to the IAP address, where I can see:

ldrbt r11,[r14,r0,lsl #0B]!
stclt [r0], 018C
ldrmi r11,[r8,-r8,lsl #18]
swi FFFFFF

After that I get a prefetch exception and lose control of everything.
I noticed that the T flag in CPSR doesn't get set after branching to
the IAP code, although the IAP code is thumb code and not ARM.

What am I doing wrong? How can I find a solution or even a workaround
for my problem?

Thank you very much in advance. Best regards,
Denis Pavliha

An Engineer's Guide to the LPC2100 Series

Hi,

IAP has to be executed in Thumb. I guess it's compiler specific how you
specify that IAP_entry is to be called as Thumb.

Currently, your compiler uses a normal ARM branch instruction (mov pc, rN).

Regards,

Dominic

On Tuesday 24 October 2006 14:58, dpavli2 wrote:
> Hello,
>
> I own a LPC2138 (ARM7TDMI) development board from iSystem and I am
> developing my firmwares with the WinIDEA software.
>
> I know there has already been some discussion about IAP, but I really
> cannot get it to work for me. The C code follows:
>
> IAP IAP_entry = (IAP) 0x7ffffff1;
> int IAP_result[10];
> int IAP_command[5];
> IAP_command[0] = 50; //prepare sectors
> IAP_command[1] = 5;
> IAP_command[2] = 5;
> IAP_entry(IAP_command, IAP_result);
>
> As I call IAP_entry and watch the dissasembler, the disassembly looks
> like this:
>
> sub r3,r11,#50
> sub r2,r11,#3C
> ldr r12,[r11,-0014]
> mov r0,r3
> mov r1,r2
> mov r14,pc
> move pc,r12
>
> Then it branches to the IAP address, where I can see:
>
> ldrbt r11,[r14,r0,lsl #0B]!
> stclt [r0], 018C
> ldrmi r11,[r8,-r8,lsl #18]
> swi FFFFFF
>
> After that I get a prefetch exception and lose control of everything.
> I noticed that the T flag in CPSR doesn't get set after branching to
> the IAP code, although the IAP code is thumb code and not ARM.
>
> What am I doing wrong? How can I find a solution or even a workaround
> for my problem?
>
> Thank you very much in advance. Best regards,
> Denis Pavliha
Hi,

thanks for the reply.

The compiler in the IDE I use is

$(EXEDIR)gcc\arm\bin\arm-elf-gcc.exe

with the options

$(EDNAME) -O0 -gdwarf-2 -c

I suppose I should convince my IDE not to only use the arm-elf-gcc but
also thumb-elf-gcc? How could I do that, since I do not even have a
thumb-elf-gcc compiler? I suppose I can download it, but after that?

Thank you,
Denis
--- In l..., Dominic Rath wrote:
>
> Hi,
>
> IAP has to be executed in Thumb. I guess it's compiler specific how you
> specify that IAP_entry is to be called as Thumb.
>
> Currently, your compiler uses a normal ARM branch instruction (mov
pc, rN).
>
> Regards,
>
> Dominic
>
> On Tuesday 24 October 2006 14:58, dpavli2 wrote:
> > Hello,
> >
> > I own a LPC2138 (ARM7TDMI) development board from iSystem and I am
> > developing my firmwares with the WinIDEA software.
> >
> > I know there has already been some discussion about IAP, but I really
> > cannot get it to work for me. The C code follows:
> >
> > IAP IAP_entry = (IAP) 0x7ffffff1;
> > int IAP_result[10];
> > int IAP_command[5];
> > IAP_command[0] = 50; //prepare sectors
> > IAP_command[1] = 5;
> > IAP_command[2] = 5;
> > IAP_entry(IAP_command, IAP_result);
> >
> > As I call IAP_entry and watch the dissasembler, the disassembly looks
> > like this:
> >
> > sub r3,r11,#50
> > sub r2,r11,#3C
> > ldr r12,[r11,-0014]
> > mov r0,r3
> > mov r1,r2
> > mov r14,pc
> > move pc,r12
> >
> > Then it branches to the IAP address, where I can see:
> >
> > ldrbt r11,[r14,r0,lsl #0B]!
> > stclt [r0], 018C
> > ldrmi r11,[r8,-r8,lsl #18]
> > swi FFFFFF
> >
> > After that I get a prefetch exception and lose control of everything.
> > I noticed that the T flag in CPSR doesn't get set after branching to
> > the IAP code, although the IAP code is thumb code and not ARM.
> >
> > What am I doing wrong? How can I find a solution or even a workaround
> > for my problem?
> >
> > Thank you very much in advance. Best regards,
> > Denis Pavliha
>
dpavli2 wrote:
[...]
>The compiler in the IDE I use is
>
>$(EXEDIR)gcc\\arm\\bin\\arm-elf-gcc.exe
>
>with the options
>
>$(EDNAME) -O0 -gdwarf-2 -c
>

arm-elf-gcc -O0 -ggdb -c:

ldr r3, [pc, #188]
ldr r3, [r3]
ldr r0, [pc, #176]
ldr r1, [pc, #180]
mov lr, pc
bx r3

>I suppose I should convince my IDE not to only use the arm-elf-gcc but
>also thumb-elf-gcc? How could I do that, since I do not even have a
>thumb-elf-gcc compiler? I suppose I can download it, but after that?

Try compile from command line to check if you need to change
IDE or compiler options/installation.

Albert
----------

Hi,

thanks for the reply.

The compiler in the IDE I use is

$(EXEDIR)gcc\arm\bin\arm-elf-gcc.exe

with the options

$(EDNAME) -O0 -gdwarf-2 -c

I suppose I should convince my IDE not to only use the arm-elf-gcc but
also thumb-elf-gcc? How could I do that, since I do not even have a
thumb-elf-gcc compiler? I suppose I can download it, but after that?

Thank you,
Denis
--- In l..., Dominic Rath wrote:
>
> Hi,
>
> IAP has to be executed in Thumb. I guess it's compiler specific how you
> specify that IAP_entry is to be called as Thumb.
>
> Currently, your compiler uses a normal ARM branch instruction (mov
pc, rN).
>
> Regards,
>
> Dominic
>
> On Tuesday 24 October 2006 14:58, dpavli2 wrote:
> > Hello,
> >
> > I own a LPC2138 (ARM7TDMI) development board from iSystem and I am
> > developing my firmwares with the WinIDEA software.
> >
> > I know there has already been some discussion about IAP, but I really
> > cannot get it to work for me. The C code follows:
> >
> > IAP IAP_entry = (IAP) 0x7ffffff1;
> > int IAP_result[10];
> > int IAP_command[5];
> > IAP_command[0] = 50; //prepare sectors
> > IAP_command[1] = 5;
> > IAP_command[2] = 5;
> > IAP_entry(IAP_command, IAP_result);
> >
> > As I call IAP_entry and watch the dissasembler, the disassembly looks
> > like this:
> >
> > sub r3,r11,#50
> > sub r2,r11,#3C
> > ldr r12,[r11,-0014]
> > mov r0,r3
> > mov r1,r2
> > mov r14,pc
> > move pc,r12
> >
> > Then it branches to the IAP address, where I can see:
> >
> > ldrbt r11,[r14,r0,lsl #0B]!
> > stclt [r0], 018C
> > ldrmi r11,[r8,-r8,lsl #18]
> > swi FFFFFF
> >
> > After that I get a prefetch exception and lose control of everything.
> > I noticed that the T flag in CPSR doesn't get set after branching to
> > the IAP code, although the IAP code is thumb code and not ARM.
> >
> > What am I doing wrong? How can I find a solution or even a workaround
> > for my problem?
> >
> > Thank you very much in advance. Best regards,
> > Denis Pavliha
>
Dear Denis Pavliha

This is David Catalan from Spain.

Im working with LPC2138, the same like you.

I can see in the forum that you are working with this ARM and probabibly you
have more experience than me.

I need a source file with de Startup Code for the LPC2138. Can you help me?

Thanks in advance.



David Catal

R+D Engineer

PROMAX

_____

De: l... [mailto:l...] En nombre de
dpavli2
Enviado el: martes, 24 de octubre de 2006 14:59
Para: l...
Asunto: [lpc2000] IAP trouble



Hello,

I own a LPC2138 (ARM7TDMI) development board from iSystem and I am
developing my firmwares with the WinIDEA software.

I know there has already been some discussion about IAP, but I really
cannot get it to work for me. The C code follows:

IAP IAP_entry = (IAP) 0x7ffffff1;
int IAP_result[10];
int IAP_command[5];
IAP_command[0] = 50; //prepare sectors
IAP_command[1] = 5;
IAP_command[2] = 5;
IAP_entry(IAP_command, IAP_result);

As I call IAP_entry and watch the dissasembler, the disassembly looks
like this:

sub r3,r11,#50
sub r2,r11,#3C
ldr r12,[r11,-0014]
mov r0,r3
mov r1,r2
mov r14,pc
move pc,r12

Then it branches to the IAP address, where I can see:

ldrbt r11,[r14,r0,lsl #0B]!
stclt [r0], 018C
ldrmi r11,[r8,-r8,lsl #18]
swi FFFFFF

After that I get a prefetch exception and lose control of everything.
I noticed that the T flag in CPSR doesn't get set after branching to
the IAP code, although the IAP code is thumb code and not ARM.

What am I doing wrong? How can I find a solution or even a workaround
for my problem?

Thank you very much in advance. Best regards,
Denis Pavliha