This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RM48HDK board use uCosII demo meet VFP config problem

Hi,

Using the Micrium ucosII  demo  at  RM48HDK ,  i find there maybe have some incorrect configuration  on VFP. exception will happened at  move data to FPU register.

Part of  float compute In  C  example is : Ts = 33;   fTs = (float)Ts / 10.0f;

The ASM  Cod is : 

MOVS R6,R5

SXTH R6,R6
VMOV S2,R6                         
VCVT.F32.S32 S2,S2
......

When running VMOV S2,R6 instruction , it occur  exception. i don't know  if there is something incorrect  at init? How can I init it in correct ?

the part of  FPU init ASM code is : 

........

MRC P15, 0, R0, C1, C0, 2                ; Read Coprocessor Access Register Bit Functions.
MOV R3, #C1_ACCESS_FP_EN     ; Enable Coprocessors cp10 & cp11
ORR R0, R0, R3
MCR P15, 0, R0, C1, C0, 2
                                                                ;Set the EN bit of FPEXC[30] to enable Neon/VFP
MOV R0, #FPEXC_EN
VMSR FPEXC, R0

FMDRR D0, R1, R1
FMDRR D1, R1, R1
FMDRR D2, R1, R1
FMDRR D3, R1, R1
FMDRR D4, R1, R1
FMDRR D5, R1, R1
FMDRR D6, R1, R1
FMDRR D7, R1, R1
FMDRR D8, R1, R1
FMDRR D0, R1, R1
FMDRR D10, R1, R1
FMDRR D11, R1, R1
FMDRR D12, R1, R1
FMDRR D13, R1, R1
FMDRR D14, R1, R1
FMDRR D15, R1, R1

..........

Thanks

Jianwei 

  • PS.

    The demo is Micrium official code for RM48HDK ;  code web link is  : http://micrium.com/page/downloads/ports/ti/rm48

    and use  IAR6.3 IDE  for test.

     

  • Jianwe,

    I did try the uCOS-II for RM48. Apparently the IAR project does not use by default the VFP.
    Here is a capture of the project option as it is by default:

    The FPU is disable.

    To enable it, I check CORE instead of Device, than I selected under FPU "VFPv3" and than reselected Device as "TexasInstruments RM48L950ZWT".

    After re-building the project, I can see that the following code in cstartup.s is executed. It was not the case before.

    #ifdef __ARMVFP__
        MRC   P15, 0, R0, C1, C0, 2                 ; Read Coprocessor Access Register Bit Functions.       
        MOV   R3, #C1_ACCESS_FP_EN                  ; Enable Coprocessors cp10 & cp11
        ORR   R0, R0, R3
        MCR   P15, 0, R0, C1, C0, 2
                                                    ;Set the EN bit of FPEXC[30] to enable Neon/VFP
        MOV   R0, #FPEXC_EN
        VMSR  FPEXC, R0
        
        FMDRR D0,  R1, R1
        FMDRR D1,  R1, R1
        FMDRR D2,  R1, R1
        FMDRR D3,  R1, R1
        FMDRR D4,  R1, R1
        FMDRR D5,  R1, R1
        FMDRR D6,  R1, R1
        FMDRR D7,  R1, R1
        FMDRR D8,  R1, R1
        FMDRR D0,  R1, R1
        FMDRR D10, R1, R1
        FMDRR D11, R1, R1
        FMDRR D12, R1, R1
        FMDRR D13, R1, R1
        FMDRR D14, R1, R1
        FMDRR D15, R1, R1
    #endif

    This code has VFP instruction, so if for some reason the VFP is not enable this code will fail to execute.

    Please let me know if this is helpful.

    Regards,

    Jean-Marc

  • Jean-Marc,

    The VFP function must be used in my projects if we use this chip. we don't want use softvfp.

    I use iar6.3 and the ucosII demo project default option is VFPv3, __ARMVFP__ is defined by IDE:


    I find the init is correct .

    The problem is :  the FPEXC register of FPU enable flag is cleared by  execute the OS_CPU_ARM_FP_REG_POP  code  in  function OSStartHighRdy();

    If i manual write FPU enable flag of FPEXC register  after cleared by  OS_CPU_ARM_FP_REG_POP , then program will excute with out undefined exception.

    But an other qusetion is  when OS_CPU_ARM_FP_REG_PUSH code excute , it also clear the FPU enable flag and os can't excute task schedule。

    so  i think there is something error with OS_CPU_ARM_FP_REG_PUSH  and OS_CPU_ARM_FP_REG_PUSH ;

    Can you help me a quick solution this problem, this project is very urgent ?

    The  part  of vfp push and pop asm code is :

    #ifdef __ARMVFP__
    ?OS_CPU_ARM_FP_REG_POP MACRO rx
    LOCAL OS_CPU_ARM_FP_RegPopSkip
    LOCAL OS_CPU_ARM_FP_RegPopExit
    POP {rx} ; Pop new task's FPEXC
    VMSR FPEXC, rx ; Check if FPU is enabled ...
    TEQ rx, #OS_CPU_ARM_FPEXC_EN
    BNE OS_CPU_ARM_FP_RegPopSkip
    FLDMIAS SP!, {S0-S31} ; ... Pop new task's General-Purpose floating point registers.
    POP {rx}
    VMSR FPSCR, rx ; ... Pop new task's FPSCR.
    B OS_CPU_ARM_FP_RegPopExit
    OS_CPU_ARM_FP_RegPopSkip
    POP {rx} ; Pop new task's FPEXC
    OS_CPU_ARM_FP_RegPopExit
    ENDM

    ?OS_CPU_ARM_FP_REG_PUSH MACRO rx
    LOCAL OS_CPU_ARM_FP_RegPushSkip
    LOCAL OS_CPU_ARM_FP_RegPushExit
    VMRS rx, FPEXC
    TEQ rx, #OS_CPU_ARM_FPEXC_EN ; Check if FPU is enabled ...
    BNE OS_CPU_ARM_FP_RegPushSkip
    VMRS rx, FPSCR ; ... Save current FPSCR
    PUSH {rx} ; ... Save general-purpose floating-point registers.
    FSTMDBS SP!, {S0-S31}
    VMRS rx, FPEXC ; ... Save Floating point exception register.
    PUSH {rx}
    B OS_CPU_ARM_FP_RegPushExit

    OS_CPU_ARM_FP_RegPushSkip
    PUSH {rx}
    PUSH {rx}
    OS_CPU_ARM_FP_RegPushExit
    ENDM
    #else
    ?OS_CPU_ARM_FP_REG_POP MACRO
    ENDM

    ?OS_CPU_ARM_FP_REG_PUSH MACRO
    ENDM
    #endif

    thanks a lot 

  • I have find mistake , the default demo don't save fp reg in task .

  • jianwei,

    Will it be possible to share your exact solution?

    I will contact Micrium on Monday to explain the problem and ask for a fix.
    We want the demo code able to work in both configuration, with and without VFP.

    Thanks and Regards,

    Jean-Marc

  • Jean-Marc,

    Yes, I like to share the problems I have met.

    I find  that the demo don't select OS_TASK_OPT_SAVE_FP option at creating one task , so the OS will not Init FP  Registers in OSTaskStkInit. it mean that  FPEXC is disabled in task, although the  OS_CPU_ARM_FP_EN  flag is set ,  although FP is enabled access at startup .

    So , when the OS run such as context switch or start high ready task , the os will find the initialized task don't use FPU .

    The rusult is : when access FPU register , Undfined exception will happen .

    You can contact MICRIUM to confirm , is or not the demo example   existence of such problem?

    But I think this is just a matter of the users, instead of Micrium's

    Regards,

    Jianwei