Handling interrupts on RAM (debug) version
2006-05-26 by stefano_m_a
Yahoo Groups archive
Index last updated: 2026-04-28 23:31 UTC
Thread
2006-05-26 by stefano_m_a
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
2006-05-27 by 3gpabko
Ensure that you have copied a correct exeption vectors table into RAM(0x40000000) at startup. Regards Zdravko --- stefano_m_a <stefano_mora@...> 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 > > > > \u0417\u043d\u0430\u043d\u0438\u0435\u0442\u043e \u0435 \u043b\u0438\u0447\u043d\u043e \u043f\u0440\u0435\u0436\u0438\u0432\u044f\u043d\u0430 \u0438\u0441\u0442\u0438\u043d\u0430. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
2006-05-29 by stefano_m_a
MEMMAP=2 is not enought ?? Thanks ! --- In lpc2000@yahoogroups.com, 3gpabko <zdravko_k_d@...> wrote: > > Ensure that you have copied a correct exeption vectors > table into RAM(0x40000000) at startup. > > Regards > Zdravko > > --- stefano_m_a <stefano_mora@...> 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 > > > > > > > > > > > \u0417\u043d\u0430\u043d\u0438\u0435\u0442\u043e \u0435; \u043b\u0438\u0447\u043d\u043e \u043f\u0440\u0435\u0436\u0438\u0432\u044f\u043d\u0430 \u0438\u0441\u0442\u0438\u043d\u0430.
> > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com >
2006-05-29 by 3gpabko
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 <stefano_mora@...> wrote: > MEMMAP=2 is not enought ?? > > Thanks ! > > > --- In lpc2000@yahoogroups.com, 3gpabko > <zdravko_k_d@...> wrote: > > > > Ensure that you have copied a correct exeption > vectors > > table into RAM(0x40000000) at startup. > > > > Regards > > Zdravko > > > > --- stefano_m_a <stefano_mora@...> 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 > > > > > > > > > > > > > > > > > > > \u0417\u043d\u0430\u043d\u0438\u0435\u0442\u043e > \u0435 > \u043b\u0438\u0447\u043d\u043e > \u043f\u0440\u0435\u0436\u0438\u0432\u044f\u043d\u0430 > > \u0438\u0441\u0442\u0438\u043d\u0430. > > > > __________________________________________________ > > Do You Yahoo!? > > Tired of spam? Yahoo! Mail has the best spam > protection around > > http://mail.yahoo.com > > > > > > > > \u0417\u043d\u0430\u043d\u0438\u0435\u0442\u043e \u0435 \u043b\u0438\u0447\u043d\u043e \u043f\u0440\u0435\u0436\u0438\u0432\u044f\u043d\u0430 \u0438\u0441\u0442\u0438\u043d\u0430. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
2006-05-29 by stefano_m_a
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 <startup>: .section .startup, "ax" .code 32 .align 0 b _start 40000000: ea000083 b 40000214 <start> 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 lpc2000@yahoogroups.com, 3gpabko <zdravko_k_d@...> 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 <stefano_mora@...> wrote: > > > MEMMAP=2 is not enought ?? > > > > Thanks !
2006-05-29 by 3gpabko
--- stefano_m_a <stefano_mora@...> 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 \ufffd 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 <startup>: > .section .startup, "ax" > .code 32 > .align 0 > > b _start > 40000000: ea000083 b 40000214 <start> > 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 ...? \u0417\u043d\u0430\u043d\u0438\u0435\u0442\u043e \u0435 \u043b\u0438\u0447\u043d\u043e \u043f\u0440\u0435\u0436\u0438\u0432\u044f\u043d\u0430 \u0438\u0441\u0442\u0438\u043d\u0430. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
2006-05-29 by stefano_m_a
> > 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
2006-05-30 by 3gpabko
> > 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; \u0417\u043d\u0430\u043d\u0438\u0435\u0442\u043e \u0435 \u043b\u0438\u0447\u043d\u043e \u043f\u0440\u0435\u0436\u0438\u0432\u044f\u043d\u0430 \u0438\u0441\u0442\u0438\u043d\u0430. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
2006-05-30 by stefano_m_a
--- In lpc2000@yahoogroups.com, 3gpabko <zdravko_k_d@...> 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 !
--
SM2006-05-30 by stefano_m_a
> > > * 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
2006-05-30 by rtstofer
--- In lpc2000@yahoogroups.com, "stefano_m_a" <stefano_mora@...> wrote: > > > > > > * 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 > In James Lynch's tutorial, this topic is covered beginning around page 109. Click http://tinyurl.com/camje to download. While it may not apply to your exact setup, it does explain how to modify the linker file and the example is known to work. Richard
2006-05-30 by stefano_m_a
Good news ! If i use this code for vectors table it works ! ... #if ROM_RUN ldr pc, [pc,#-0xFF0] /* .18 IRQ - read the VIC */ #else ldr pc, _irq /* .18 IRQ - _irq */ //ldr pc, [pc,#-0xFF0] /* .18 IRQ - read the VIC */ #endif ldr pc, _fiq /* .1c FIQ - _fiq */ _undf: .word __undf /* undefined */ _swi: .word __undf /* SWI */ _pabt: .word __pabt /* program abort */ _dabt: .word __dabt /* data abort */ _fiq: .word __fiq /* FIQ */ __undf: b . /* undefined */ __pabt: b . /* program abort */ __dabt: b . /* data abort */ __fiq: b . /* FIQ */ _irq: b timer0ISR ... So the problem seems to be into: ldr pc, [pc,#-0xFF0] If i break the code when pc==0x18 and i inspect register 0xffff.f030 i found the address of my routine timer0ISR() !!! -- SM
2006-05-31 by stefano_m_a
It's incredible, i found an error on the code i wrote (and i posted) and the code should be not running, but i saw it running !! > ... > ldr pc, _irq /* .18 IRQ - _irq */ > ... > > _irq: > b timer0ISR > ... _irq label should define an address and not an instruction ... I corrected the code as following: ldr pc, _irq /* .18 IRQ - _irq */ ... _irq: .word __irq ... __irq: b timer0ISR But now the running is bad..... When the IRQ is fired the PC is pointing 0x18 or 0x4000.0018 ????? Regards ! -- SM
2006-05-31 by Karl Olsen
--- In lpc2000@yahoogroups.com, "stefano_m_a" <stefano_mora@...> wrote: > > It's incredible, i found an error on the code i wrote (and i > posted) and the code should be not running, but i saw it running !! > > > ... > > ldr pc, _irq /* .18 IRQ - _irq */ > > ... > > > > _irq: > > b timer0ISR > > ... > > _irq label should define an address and not an instruction ... > I corrected the code as following: > > ldr pc, _irq /* .18 IRQ - _irq */ > ... > > _irq: > .word __irq Or just: _irq: .word timer0ISR > ... > __irq: > b timer0ISR > > But now the running is bad..... > > When the IRQ is fired the PC is pointing 0x18 or 0x4000.0018 ????? 0x18. The ARM7 always reads the vectors at address 0x00-0x1C. The Philips MEMMAP feature makes the first 64 bytes of RAM readable at both address 0x00 and 0x4000.0000. Karl Olsen
2006-05-31 by stefano_m_a
> > Or just: > > _irq: > .word timer0ISR > > > > ... > > __irq: > > b timer0ISR I must use your solution cause: - PC is pointing low addresses - timer0ISR function is located on RAM range - b instruction is able to jump over 24 bit offsets. Is it right ? -- SM
2006-05-31 by Karl Olsen
--- In lpc2000@yahoogroups.com, "stefano_m_a" <stefano_mora@...> wrote: > > > > > Or just: > > > > _irq: > > .word timer0ISR > > > > > > > ... > > > __irq: > > > b timer0ISR > > I must use your solution cause: > - PC is pointing low addresses > - timer0ISR function is located on RAM range > - b instruction is able to jump over 24 bit offsets. > Is it right ? Yes. You could also just have a LDR pc, [pc, #-0x0FF0] at address 0x18, and have the timer0ISR address loaded into the right VICVectAddrxx register. This also works with the handler at any address. Karl Olsen
2006-05-31 by stefano_m_a
> Yes. You could also just have a LDR pc, [pc, #-0x0FF0] at address > 0x18, and have the timer0ISR address loaded into the right > VICVectAddrxx register. This also works with the handler at any > address. > > Karl Olsen > OK, thanks Karl. Yes, usually the code uses 'LDR pc, [pc, #-0x0FF0]' but now i'm investigating why my code does not work. This is driving me crazy ... I see the call on 0x18 but i can't see the code with GDB (it thinks this location is outside my program....), if i step again i fall into 0x1c (but FIQs are disabled ..), my irq_isr code is not called, into .. I'm loosing a lot af time on interrupts and i'm not able to solve... :( -- SM