Handling interrupts on RAM (debug) version

Started by stefano_m_a May 26, 2006
Hi group,
i'm studying ARM stuff on Olimex LPC-E2294 and, in particular, i'm
testing interrupts.

My problem is the following:
if i compile for RAM_RUN configuration (MEMMAP=2), on interrupt event
the board stucks;
if i compile for ROM_RUN configuration, everything is ok.

This behavoiur is both for timer interrupt and uart interrupt.

Can anyone help me ?
Thanks !!
--
SM

An Engineer's Guide to the LPC2100 Series

Ensure that you have copied a correct exeption vectors
table into RAM(0x40000000) at startup.

Regards
Zdravko

--- stefano_m_a wrote:

> Hi group,
> i'm studying ARM stuff on Olimex LPC-E2294 and, in
> particular, i'm
> testing interrupts.
>
> My problem is the following:
> if i compile for RAM_RUN configuration (MEMMAP=2),
> on interrupt event
> the board stucks;
> if i compile for ROM_RUN configuration, everything
> is ok.
>
> This behavoiur is both for timer interrupt and uart
> interrupt.
>
> Can anyone help me ?
> Thanks !!
> --
> SM
Знанието е лично преживяна истина.

__________________________________________________

MEMMAP=2 is not enought ??

Thanks !
--- In l..., 3gpabko wrote:
>
> Ensure that you have copied a correct exeption vectors
> table into RAM(0x40000000) at startup.
>
> Regards
> Zdravko
>
> --- stefano_m_a wrote:
>
> > Hi group,
> > i'm studying ARM stuff on Olimex LPC-E2294 and, in
> > particular, i'm
> > testing interrupts.
> >
> > My problem is the following:
> > if i compile for RAM_RUN configuration (MEMMAP=2),
> > on interrupt event
> > the board stucks;
> > if i compile for ROM_RUN configuration, everything
> > is ok.
> >
> > This behavoiur is both for timer interrupt and uart
> > interrupt.
> >
> > Can anyone help me ?
> > Thanks !!
> > --
> > SM
> >
> >
> >
> >
>
>
> Знанието е
лично
преживяна
истина.
>
> __________________________________________________





When you have set MEMMAP=2 and an exception occurs the
ARM core will fetch from addresses 0x40000000 -
0x4000001C instead of 0x00000000 - 0x0000001C. That's
why you have to be sure that before this happens you
already have at address 0x40000000 a correct Exception
Vectors Table.
With my tools I am doing this with manually written
code in the startup file(reset handler) and linker
scripts.

Regards
Zdravko

--- stefano_m_a wrote:

> MEMMAP=2 is not enought ??
>
> Thanks !
> --- In l..., 3gpabko
> wrote:
> >
> > Ensure that you have copied a correct exeption
> vectors
> > table into RAM(0x40000000) at startup.
> >
> > Regards
> > Zdravko
> >
> > --- stefano_m_a wrote:
> >
> > > Hi group,
> > > i'm studying ARM stuff on Olimex LPC-E2294 and,
> in
> > > particular, i'm
> > > testing interrupts.
> > >
> > > My problem is the following:
> > > if i compile for RAM_RUN configuration
> (MEMMAP=2),
> > > on interrupt event
> > > the board stucks;
> > > if i compile for ROM_RUN configuration,
> everything
> > > is ok.
> > >
> > > This behavoiur is both for timer interrupt and
> uart
> > > interrupt.
> > >
> > > Can anyone help me ?
> > > Thanks !!
> > > --
> > > SM
> > >
> > >
> > >
> > >
> >
> >
> Знанието
> е
> лично
>
преживяна
>
> истина.
> >
> > __________________________________________________
> >
> >
Знанието е лично преживяна истина.

__________________________________________________

My code has a classic startup written in assembly code that run the C
main() function.
Into the main() function i have:

#ifdef RAM_RUN
// Per la compilazione in RAM necessario reimpostare
// anche la zona degli interrupt (se usati...)
SCB_MEMMAP = 2;
#endif
VIC_Init();
initTimer0(1000); // set up the timer0
enableIRQ();
while(1) .....

If i take a look into the main.lss i see:

40000000 :
.section .startup, "ax"
.code 32
.align 0

b _start
40000000: ea000083 b 40000214
ldr pc, _undf
40000004: e59ff014 ldr pc, [pc, #20] ; 40000020
<_undf>
ldr pc, _swi
40000008: e59ff014 ldr pc, [pc, #20] ; 40000024
<_swi>
ldr pc, _pabt
4000000c: e59ff014 ldr pc, [pc, #20] ; 40000028
<_pabt>
ldr pc, _dabt
40000010: e59ff014 ldr pc, [pc, #20] ; 4000002c
<_dabt>
nop
40000014: e1a00000 nop (mov r0,r0)

ldr pc, [pc,#-0xFF0]

So I think this it is correcty mapped ...
My dubt is: when the interrupt is fired, the flow should go to
0x4000.0018 address to read the IRQ VIC address (0xFFFF.F030)
containing the service routine.
When the vectors are based on 0x0 (Flash) then pc,#-0xFF0 =>
0xFFFF.F030 but when the vectors are based on 0x4000.000 (RAM) the
difference is equal to 0x3FFF.F030 that's incorrect !!

Thanks again !!

--- In l..., 3gpabko wrote:
>
> When you have set MEMMAP=2 and an exception occurs the
> ARM core will fetch from addresses 0x40000000 -
> 0x4000001C instead of 0x00000000 - 0x0000001C. That's
> why you have to be sure that before this happens you
> already have at address 0x40000000 a correct Exception
> Vectors Table.
> With my tools I am doing this with manually written
> code in the startup file(reset handler) and linker
> scripts.
>
> Regards
> Zdravko
>
> --- stefano_m_a wrote:
>
> > MEMMAP=2 is not enought ??
> >
> > Thanks !





--- stefano_m_a wrote:

> My code has a classic startup written in assembly
> code that run the C
> main() function.
> Into the main() function i have:
>
> #ifdef RAM_RUN
> // Per la compilazione in RAM necessario
> reimpostare
> // anche la zona degli interrupt (se usati...)
> SCB_MEMMAP = 2;
> #endif
> VIC_Init();
> initTimer0(1000); // set up the timer0
> enableIRQ();
> while(1) .....
>
> If i take a look into the main.lss i see:
>
> 40000000 :
> .section .startup, "ax"
> .code 32
> .align 0
>
> b _start
> 40000000: ea000083 b 40000214
> ldr pc, _undf
> 40000004: e59ff014 ldr pc, [pc, #20] ; 40000020
> <_undf>
> ldr pc, _swi
> 40000008: e59ff014 ldr pc, [pc, #20] ; 40000024
> <_swi>
> ldr pc, _pabt
> 4000000c: e59ff014 ldr pc, [pc, #20] ; 40000028
> <_pabt>
> ldr pc, _dabt
> 40000010: e59ff014 ldr pc, [pc, #20] ; 4000002c
> <_dabt>
> nop
> 40000014: e1a00000 nop (mov r0,r0)
>
> ldr pc, [pc,#-0xFF0]
> So I think this it is correcty mapped ...

Yes this seems to be OK.
> My dubt is: when the interrupt is fired, the flow
> should go to
> 0x4000.0018 address to read the IRQ VIC address
> (0xFFFF.F030)
> containing the service routine.
> When the vectors are based on 0x0 (Flash) then
> pc,#-0xFF0 =>
> 0xFFFF.F030 but when the vectors are based on
> 0x4000.000 (RAM) the
> difference is equal to 0x3FFF.F030 that's incorrect
> !!
>

No. You are making a mistake. The remapping does not
affect the program counter.
In my code I have also:

ldr pc, [pc,#-0xFF0]

at IRQ vector location and it works placed in RAM or
FLASH.
So this is not the case.
You are telling that only interrupts are not working
...?

Знанието е лично преживяна истина.

__________________________________________________

> > So I think this it is correcty mapped ...
>
> Yes this seems to be OK.

OK :)
>
> No. You are making a mistake. The remapping does not
> affect the program counter.
> In my code I have also:
>
> ldr pc, [pc,#-0xFF0]
>
> at IRQ vector location and it works placed in RAM or
> FLASH.
> So this is not the case.

OK :)

> You are telling that only interrupts are not working
> ...?

Yes, both uart interrupts and timer interrupts, so i also think any
interrups will work :( (not tested)

Any other ideas ?
I try with GDB, i see a jump to location 0x18 but i can't see any
code; if i step one more time, i jump to location 0x1C (FIQ??)

Thanks again !
--
SM





>
> Any other ideas ?
> I try with GDB, i see a jump to location 0x18 but i
> can't see any
> code; if i step one more time, i jump to location
> 0x1C (FIQ??)
>

If you can verify with the debugger that MEMMAP is
correctly set to 0x02 and that you have the correct
exception vectors table at 0x40000000 pointing
correctly to some exception handlers... there are a
few more ideas:

* Be sure that you are starting your program from
0x40000000;
* Be sure that on your board BOOT[1:0] pins and pin
P0.14 are pulled up on reset;
* Try starting your code from RAM after erasing
completely the FLASH of the device;

Знанието е лично преживяна истина.

__________________________________________________

--- In l..., 3gpabko wrote:
>
> If you can verify with the debugger that MEMMAP is
> correctly set to 0x02 and that you have the correct
> exception vectors table at 0x40000000 pointing
> correctly to some exception handlers...

When the location 0x18 is called MEMMAP=2 and i see the same vector
table on 0x4000.0000 and 0x0000.0000.
But i don't understand: the correct location for irq handler is
0x0000.0018 or 0x4000.0018 ? (i'm lost in mapping modes....)

> * Be sure that you are starting your program from
> 0x40000000;

On the GDB window i see that starting point is 0x4000.0214 => first
instruction of my startup code (labelled as '_start').
On location 0x4000.0000 i found {0xea000083} value that is
b _start (from the main.lss file)
Is it possible to point 0x4000.0000 with the GDB code window to view
disassembled code ?

> * Be sure that on your board BOOT[1:0] pins and pin
> P0.14 are pulled up on reset;

All the BOOT pins are pulled to +3.3V through jumpers.
But P0.14 is jumped in a voltage partition (22k to +3.3, 1k to
ground, so the value is low) but i need it to work with RAM and ISP
commands ......
Now i'm debugging with a JTAG cable, i think that is regardless from
the P0.14 value ..

> * Try starting your code from RAM after erasing
> completely the FLASH of the device;

Now, i'm trying ....

Thanks again !
--
SM

>
> > * Try starting your code from RAM after erasing
> > completely the FLASH of the device;
>
> Now, i'm trying ....

I erased the Flash: nothing changed.

Thanks again !
--
SM