This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Undefined symbol __SWI_0

I am new on ARM and I am using Keil micro vision v3 . I had build an example for RTX kernel on NXP LPC2368. I flowed step by step the description (Getting started for arm ) but

While I compiled this build I get this Error

RTX_Test.axf: Error: L6218E: Undefined symbol __SWI_0 (referred from swi_table.o).

Can anyone help me to solve this error.

  • you are trying to use a software interrupt. you should have a jump table, like this (SWI.s):

    T_Bit           EQU     0x20
    
                    PRESERVE8                      ; 8-Byte aligned Stack
                    AREA    SWI_Area, CODE, READONLY
                    ARM
    
                    EXPORT  SWI_Handler
    SWI_Handler
    
                    STMFD   SP!, {R12, LR}         ; Store R12, LR
                    MRS     R12, SPSR              ; Get SPSR
                    STMFD   SP!, {R8, R12}         ; Store R8, SPSR
                    TST     R12, #T_Bit            ; Check Thumb Bit
                    LDRNEH  R12, [LR,#-2]          ; Thumb: Load Halfword
                    BICNE   R12, R12, #0xFF00      ;        Extract SWI Number
                    LDREQ   R12, [LR,#-4]          ; ARM:   Load Word
                    BICEQ   R12, R12, #0xFF000000  ;        Extract SWI Number
    
                    LDR     R8, SWI_Count
                    CMP     R12, R8
                    BHS     SWI_Dead               ; Overflow
                    ADR     R8, SWI_Table
                    LDR     R12, [R8,R12,LSL #2]   ; Load SWI Function Address
                    MOV     LR, PC                 ; Return Address
                    BX      R12                    ; Call SWI Function
    
                    LDMFD   SP!, {R8, R12}         ; Load R8, SPSR
                    MSR     SPSR_cxsf, R12         ; Set SPSR
                    LDMFD   SP!, {R12, PC}^        ; Restore R12 and Return
    
    SWI_Dead        B       SWI_Dead               ; None Existing SWI
    
    SWI_Cnt         EQU    (SWI_End-SWI_Table)/4
    SWI_Count       DCD     SWI_Cnt
    
                    IMPORT  __SWI_0
                    IMPORT  __SWI_1
                    IMPORT  __SWI_2
                    IMPORT  __SWI_3
    SWI_Table
                    DCD     __SWI_0                ; SWI 0 Function Entry
                    DCD     __SWI_1                ; SWI 1 Function Entry
                    DCD     __SWI_2                ; SWI 2 Function Entry
                    DCD     __SWI_3                ; SWI 3 Function Entry
    ;               ...
    SWI_End
    
    
                    END
    

    insert this file into your project, and make sure your startup file does handler software interrupts (SWI_Hanlder and alike...).
    in your application you can now invoke 4 software interrupts.
    definition:

    int __swi(0) disable_fiq(void) ;
    int __SWI_0 ()
    {
       return __disable_fiq() ;
    }
    

    now you can call 'disable_fiq' from you application.

    Greetings,

    Tamir

  • Note that SWI 0 to 7 are reserved by the OS, so an application must make use of SWI fron 8 and onwards.

    Look at the help document rlarm.chm under chapter Using RTX Kernel/Writing Programs/SWI Functions.

    The directory /Keil/ARM/RL/RTX/SRC also contains a file SWI_Table.s.

  • Hi Tamir
    I have the same SWI.s file as you described.
    I added this to my application.

    int __swi(0) disable_fiq(void) ;
    int __SWI_0 ()
    { return __disable_fiq() ;
    }

    When I do that, the compilation go’s *** without any error but when I run debugging
    I receive this message.

    Data Abort: ARM Instruction at 00000128H, Memory Access at FFE08000H

  • does it go wrong after you call the SWI function?
    also, you can try the following: place a breakpoint inside your startup file where SWIs are handled. follow it up from there. is your function invoked at all? is machine code generated for your swi.s file ?

  • the address you mentioned (0x128) is typically in your startup file. check it out by looking at the disassembly view.

  • did you remember to change the SWI number from 0 to 8? I don't think so...RTX uses 0-7 !

    nt __swi(8) disable_fiq(void) ;
    int __SWI_8 ()
    { return __disable_fiq() ;
    }
    

    you have to update the swi.s file as well, of course.

  • If I change SWI number from 0 to 8 I get the same error as before

    RTX_Test.axf: Error: L6218E: Undefined symbol __SWI_0 (referred from swi_table.o).

  • well, I never worked with RTX, but why you just add the references that cause trouble and see what it gives? you might need to do an extra configuration step of RTX, leaving the entries for 0-7 in place. I would suggest that you consult your documentation.

  • Tom,
    I didn't ask you to change the range from 0 to 8. 0 to 7 must remain for RTX. 8 and above are yours! leave the handlers for 0-7 in place. solve any compile/link error. add your own stuff. tell us what happens.

  • I can only note that the SWI file you are using is not the file that I mentioned and taht is available in the RTX directory tree.

    Have you tried to use:
    /Keil/ARM/RL/RTX/SRC/SWI_Table.s
    in your application?

    It does define the entries 0..7 that RTX needs. It then shows where you may continue by adding own SWI entries.

  • Yes I had tried SWI_Table.s the result is the same

  • Hi all

    Now its running.

    Tank you all for your help.
    TOM