give you the answer that why using "PRESERVE8" in startup code

来源:互联网 发布:可变数据喷码机 编辑:程序博客网 时间:2024/06/06 17:32

refer:   http://www.keil.com/forum/17485/

            http://www.keil.com/support/docs/3268.htm


blow is the detail:

ARMLINK: WARNING: L6306W: '~PRES8' SECTION SHOULD NOT USE 'REQ8'

QUESTION

I have written an interrupt handler in assembly language using the RealView assembler. In this interrupt handler, I am calling another routine that is written in C. When I link my program, I receive the following warning:

Warning: L6306W: '~PRES8' section arm_isr.o(asm_irq) should not                 use the address of 'REQ8' function (c_func).

What is wrong?


ANSWER

All C code generated by the RealView compiler assumes that stack allocation is aligned on 8-byte boundaries.You must ensure that the assembler interrupt handler has an 8-byte aligned stack by specifying the PRESERVE8 directive at the beginning of your assembly file. For example,

      PRESERVE8..      AREA irq_asm, CODE, READONLY



another one

New! OVERWRITE EXCEPTION HANDLER

Hello,

I use the NXP LPC 2368 and want to write a function to save the exceptions Data Abort Error, Undefined Instruction Error and Pre-fetch Abort Error in a seriel EEPROM and after reset the CPU.
How can I overwrite the dummy exception handler Undef_HandlerPAbt_Handler and DAbt_Handler with C code?
I found the technical support:
http://www.keil.com/support/docs/3027.htm
If I write the irq-functions there is no warning and no error so far so good. But if I test the irq the PC stuck always in the dummy function in startup and not in my own function!
Somebody have a idea?

New! RE: OVERWRITE EXCEPTION HANDLER

If your handler is called ProgramAbortHandler(), then
in your startup file find
PAbt_Addr DCD PAbt_Handler
and replace it with
PAbt_Addr DCD ProgramAbortHandler

New! RE: OVERWRITE EXCEPTION HANDLER

Thanks for the tip. But now the Compiler Error:
"system\LPC2300.s(615): error: A1516E: Bad symbol 'ProgramAbortHandler', not defined or external"
comes.

Here my Code:
Startup-File

; Exception Vectors;  Mapped to Address 0.;  Absolute addressing mode must be used.;  Dummy Handlers are implemented as infinite loops which can be modified.Vectors         LDR     PC, Reset_Addr                LDR     PC, Undef_Addr                LDR     PC, SWI_Addr                LDR     PC, PAbt_Addr                LDR     PC, DAbt_Addr                NOP                            ; Reserved Vector;               LDR     PC, IRQ_Addr                LDR     PC, [PC, #-0x0120]     ; Vector from VicVectAddr                LDR     PC, FIQ_AddrReset_Addr      DCD     Reset_HandlerUndef_Addr      DCD     Undef_HandlerSWI_Addr        DCD     SWI_HandlerPAbt_Addr       DCD     ProgramAbortHandlerDAbt_Addr       DCD     DAbt_Handler                DCD     0                      ; Reserved AddressIRQ_Addr        DCD     IRQ_HandlerFIQ_Addr        DCD     FIQ_Handler                                IMPORT  SWI_HandlerUndef_Handler   B       Undef_Handler;SWI_Handler     B       SWI_Handler;Don't need the dummy PAbt handler;PAbt_Handler    B       PAbt_HandlerDAbt_Handler    B       DAbt_HandlerIRQ_Handler     B       IRQ_HandlerFIQ_Handler     B       FIQ_Handler


File irq.c

void ProgramAbortHandler(void) __irq{   // For Test   while(1);}


I think I have to declare the function because it is defined in another file. How can I do this in Assembler? Thanks


New! RE: OVERWRITE EXCEPTION HANDLER

Add the following line to the startup before referencing your function:

        IMPORT ProgramAbortHandler

New! RE: OVERWRITE EXCEPTION HANDLER

Just add

    IMPORT   IntSPI_isr


at the beginning of your startup file and i think that would be it :)

New! RE: OVERWRITE EXCEPTION HANDLER

I write too slowly :)
And the answer above is better than mine, because I used the name of my own handler :D

New! RE: OVERWRITE EXCEPTION HANDLER

Thank you very much for the help. The startup assembler is very hard to understand for me. The solution above works! But now I get a warning (after the linking process):
Warning: L6306W: '~PRES8' section lpc2300.o(RESET) should not use the address of 'REQ8' function ProgramAbortHandler. In the technical Support I read this: http://www.keil.com/support/docs/3268.htm
So what I did was PRESERVE8 put in the first line of my start up code. But after i get a compiler error:
error: A1355U: A Label was found which was in no AREA
Now the Joke of the Day: The label is the PRESERVE8 comand! First I think I wrote wrong. But I copy and paste it of the technical support document!

So the solution of the technical support is not the best way. Anybody know why there is a linker-warning and how I can solve it?

New! RE: OVERWRITE EXCEPTION HANDLER

Like all directives in asm, the PRESERVE8 needs to have some whitespace before it. If it starts in column 1 then it's a label and not a directive.

New! RE: OVERWRITE EXCEPTION HANDLER

Hello,

thank you very much for the fast help. After I insert a space before the asm PRESERVE8 everything works fine! I am sorry for my lack of knowledge.
So I wrote now Exception Handlers for the PAbt, DAbt and Undef Instructions.
I use the RTX OS so I additinal check for the stack overflow and wrote my own os_stk_overflow function.
Somebody know further exceptions so I can handle? If no so I thank again very much for the good help.

原创粉丝点击