今天想把UC/OSIII移植到LPC4357上,现在有些问题不知道如何解
今天想把UC/OSIII移植到LPC4357上,现在有些问题不知道如何解,请大神们帮我看看错误提示如下
..\uCOS-III\Ports\os_cpu_a.asm(120): error: A1167E: Invalid line start
..\uCOS-III\Ports\os_cpu_a.asm(138): error: A1108E: Multiply defined symbol 'OSStartHighRdy'
..\uCOS-III\Ports\os_cpu_a.asm(168): error: A1108E: Multiply defined symbol 'OSCtxSw'
..\uCOS-III\Ports\os_cpu_a.asm(184): error: A1108E: Multiply defined symbol 'OSIntCtxSw'
..\uCOS-III\Ports\os_cpu_a.asm(227): error: A1108E: Multiply defined symbol 'OS_CPU_PendSVHandler'
改动os_cpu_a.asm如下
;
;********************************************************************************************************
; uC/OS-III
; The Real-Time Kernel
;
;
; (c) Copyright 2010; Micrium, Inc.; Weston, FL
; All rights reserved.Protected by international copyright laws.
;
; ARM Cortex-M4 Port
;
; File : OS_CPU_A.ASM
; Version : V3.01.2
; By : JJL
; BAN
;
; For : ARMv7 Cortex-M4
; Mode : Thumb-2 ISA
; Toolchain : IAR EWARM
;********************************************************************************************************
;
;********************************************************************************************************
; PUBLIC FUNCTIONS
;********************************************************************************************************
EXTERNOSRunning ; External references
EXTERNOSPrioCur
EXTERNOSPrioHighRdy
EXTERNOSTCBCurPtr
EXTERNOSTCBHighRdyPtr
EXTERNOSIntExit
EXTERNOSTaskSwHook
EXTERNOS_CPU_ExceptStkBase
EXTERNOSStartHighRdy ; Functions declared in this file
EXTERNOSCtxSw
EXTERNOSIntCtxSw
EXTERNOS_CPU_PendSVHandler
;IF {FPU} != "SoftVFP"
;EXPORTOS_CPU_FP_Reg_Push
;EXPORTOS_CPU_FP_Reg_Pop
;ENDIF
;#ifdef __ARMVFP__
;EXTERNOS_CPU_FP_Reg_Push
;EXTERNOS_CPU_FP_Reg_Pop
;#endif
;PAGE
;********************************************************************************************************
; EQUATES
;********************************************************************************************************
NVIC_INT_CTRL EQU 0xE000ED04 ; Interrupt control state register.
NVIC_SYSPRI14 EQU 0xE000ED22 ; System priority register (priority 14).
NVIC_PENDSV_PRI EQU 0xFF ; PendSV priority value (lowest).
NVIC_PENDSVSETEQU 0x10000000 ; Value to trigger PendSV exception.
;********************************************************************************************************
; CODE GENERATION DIRECTIVES
;********************************************************************************************************
AREA |.text|, CODE, READONLY, ALIGN=2
THUMB
REQUIRE8
PRESERVE8
;#ifdef __ARMVFP__
;PAGE
;********************************************************************************************************
; FLOATING POINT REGISTERS PUSH
; voidOS_CPU_FP_Reg_Push (CPU_STK*stkPtr)
;
; Note(s) : 1) This function saves S0-S31, and FPSCR registers of the Floating Point Unit.
;
; 2) Pseudo-code is:
; a) Get FPSCR register value;
; b) Push value on process stack;
; c) Push remaining regs S0-S31 on process stack;
; d) Update OSTCBCurPtr->StkPtr;
;********************************************************************************************************
OS_CPU_FP_Reg_Push
MRS R1, PSP ; PSP is process stack pointer
CBZ R1, OS_CPU_FP_nosave ; Skip FP register save the first time
VMRS R1, FPSCR
STR R1, !
VSTMDBR0!, {S0-S31}
LDR R1, =OSTCBCurPtr
LDR R2,
STR R0,
OS_CPU_FP_nosave
BX LR
;PAGE
;********************************************************************************************************
; FLOATING POINT REGISTERS POP
; voidOS_CPU_FP_Reg_Pop (CPU_STK*stkPtr)
;
; Note(s) : 1) This function restores S0-S31, and FPSCR registers of the Floating Point Unit.
;
; 2) Pseudo-code is:
; a) Restore regs S0-S31 of new process stack;
; b) Restore FPSCR reg value
; c) Update OSTCBHighRdyPtr->StkPtr pointer of new proces stack;
;********************************************************************************************************
OS_CPU_FP_Reg_Pop
VLDMIAR0!, {S0-S31}
LDMIA R0!, {R1}
VMSR FPSCR, R1
LDR R1, =OSTCBHighRdyPtr
LDR R2,
STR R0,
BX LR
#endif
;PAGE
;********************************************************************************************************
; START MULTITASKING
; void OSStartHighRdy(void)
;
; Note(s) : 1) This function triggers a PendSV exception (essentially, causes a context switch) to cause
; the first task to start.
;
; 2) OSStartHighRdy() MUST:
; a) Setup PendSV exception priority to lowest;
; b) Set initial PSP to 0, to tell context switcher this is first run;
; c) Set the main stack to OS_CPU_ExceptStkBase
; d) Trigger PendSV exception;
; e) Enable interrupts (tasks will run with interrupts enabled).
;********************************************************************************************************
OSStartHighRdy
LDR R0, =NVIC_SYSPRI14 ; Set the PendSV exception priority
LDR R1, =NVIC_PENDSV_PRI
STRB R1,
MOVS R0, #0 ; Set the PSP to 0 for initial context switch call
MSR PSP, R0
LDR R0, =OS_CPU_ExceptStkBase ; Initialize the MSP to the OS_CPU_ExceptStkBase
LDR R1,
MSR MSP, R1
LDR R0, =NVIC_INT_CTRL ; Trigger the PendSV exception (causes context switch)
LDR R1, =NVIC_PENDSVSET
STR R1,
CPSIE I ; Enable interrupts at processor level
OSStartHang
B OSStartHang ; Should never get here
;PAGE
;********************************************************************************************************
; PERFORM A CONTEXT SWITCH (From task level) - OSCtxSw()
;
; Note(s) : 1) OSCtxSw() is called when OS wants to perform a task context switch.This function
; triggers the PendSV exception which is where the real work is done.
;********************************************************************************************************
OSCtxSw
LDR R0, =NVIC_INT_CTRL ; Trigger the PendSV exception (causes context switch)
LDR R1, =NVIC_PENDSVSET
STR R1,
BX LR
;PAGE
;********************************************************************************************************
; PERFORM A CONTEXT SWITCH (From interrupt level) - OSIntCtxSw()
;
; Note(s) : 1) OSIntCtxSw() is called by OSIntExit() when it determines a context switch is needed as
; the result of an interrupt.This function simply triggers a PendSV exception which will
; be handled when there are no more interrupts active and interrupts are enabled.
;********************************************************************************************************
OSIntCtxSw
LDR R0, =NVIC_INT_CTRL ; Trigger the PendSV exception (causes context switch)
LDR R1, =NVIC_PENDSVSET
STR R1,
BX LR
;PAGE
;********************************************************************************************************
; HANDLE PendSV EXCEPTION
; void OS_CPU_PendSVHandler(void)
;
; Note(s) : 1) PendSV is used to cause a context switch.This is a recommended method for performing
; context switches with Cortex-M3.This is because the Cortex-M3 auto-saves half of the
; processor context on any exception, and restores same on return from exception.So only
; saving of R4-R11 is required and fixing up the stack pointers.Using the PendSV exception
; this way means that context saving and restoring is identical whether it is initiated from
; a thread or occurs due to an interrupt or exception.
;
; 2) Pseudo-code is:
; a) Get the process SP, if 0 then skip (goto d) the saving part (first context switch);
; b) Save remaining regs r4-r11 on process stack;
; c) Save the process SP in its TCB, OSTCBCurPtr->OSTCBStkPtr = SP;
; d) Call OSTaskSwHook();
; e) Get current high priority, OSPrioCur = OSPrioHighRdy;
; f) Get current ready thread TCB, OSTCBCurPtr = OSTCBHighRdyPtr;
; g) Get new process SP from TCB, SP = OSTCBHighRdyPtr->OSTCBStkPtr;
; h) Restore R4-R11 from new process stack;
; i) Perform exception return which will restore remaining context.
;
; 3) On entry into PendSV handler:
; a) The following have been saved on the process stack (by processor):
; xPSR, PC, LR, R12, R0-R3
; b) Processor mode is switched to Handler mode (from Thread mode)
; c) Stack is Main stack (switched from Process stack)
; d) OSTCBCurPtr points to the OS_TCB of the task to suspend
; OSTCBHighRdyPtrpoints to the OS_TCB of the task to resume
;
; 4) Since PendSV is set to lowest priority in the system (by OSStartHighRdy() above), we
; know that it will only be run when no other exception or interrupt is active, and
; therefore safe to assume that context being switched out was using the process stack (PSP).
;********************************************************************************************************
OS_CPU_PendSVHandler
CPSID I ; Prevent interruption during context switch
MRS R0, PSP ; PSP is process stack pointer
CBZ R0, OS_CPU_PendSVHandler_nosave ; Skip register save the first time
SUBS R0, R0, #0x20 ; Save remaining regs r4-11 on process stack
STM R0, {R4-R11}
LDR R1, =OSTCBCurPtr ; OSTCBCurPtr->OSTCBStkPtr = SP;
LDR R1,
STR R0, ; R0 is SP of process being switched out
; At this point, entire context of process has been saved
OS_CPU_PendSVHandler_nosave
PUSH {R14} ; Save LR exc_return value
LDR R0, =OSTaskSwHook ; OSTaskSwHook();
BLX R0
POP {R14}
LDR R0, =OSPrioCur ; OSPrioCur = OSPrioHighRdy;
LDR R1, =OSPrioHighRdy
LDRB R2,
STRB R2,
LDR R0, =OSTCBCurPtr ; OSTCBCurPtr = OSTCBHighRdyPtr;
LDR R1, =OSTCBHighRdyPtr
LDR R2,
STR R2,
LDR R0, ; R0 is new process SP; SP = OSTCBHighRdyPtr->StkPtr;
LDM R0, {R4-R11} ; Restore r4-11 from new process stack
ADDS R0, R0, #0x20
MSR PSP, R0 ; Load PSP with new process SP
ORR LR, LR, #0x04 ; Ensure exception return uses process stack
CPSIE I
BX LR ; Exception return will restore remaining context
END
自己对照着屈环宇的方法都修改了, 提示重定义了,你看看是不是.h文件不要随便都加,应该是加多了。
EXTERNOSStartHighRdy ; Functions declared in this file
EXTERNOSCtxSw
EXTERNOSIntCtxSw
EXTERNOS_CPU_PendSVHandler
上面这几个好像不能用external,这几个只要说明是在本文件内就可以好了,IAR是PUBLIC,Keil是EXPORT,你可以再确认下,如果说得不对,请指正 第一个多了个#endif lusson 发表于 2014-4-19 19:49
第一个多了个#endif
改正了一下,还是提示错误 不明白他说的意思
.\Obj\Project.sct(7): error: L6236E: No section matches selector - no section to be FIRST/LAST.
Not enough information to list image symbols.
Not enough information to list the image map.
Finished: 2 information, 0 warning and 1 error messages.
".\Obj\Project.axf" - 1 Error(s), 0 Warning(s).
错误指向了
LR_IROM1 0x1A000000 0x00080000{ ; load region size_region
ER_IROM1 0x1A000000 0x00080000{; load address = execution address
*.o (RESET, +First) //错误指向此处
*(InRoot$$Sections)
.ANY (+RO)
}
RW_IRAM1 0x10000000 0x00008000{; RW data
.ANY (+RW +ZI)
}
}
改正代码如下
;
;********************************************************************************************************
; uC/OS-III
; The Real-Time Kernel
;
;
; (c) Copyright 2010; Micrium, Inc.; Weston, FL
; All rights reserved.Protected by international copyright laws.
;
; ARM Cortex-M4 Port
;
; File : OS_CPU_A.ASM
; Version : V3.01.2
; By : JJL
; BAN
;
; For : ARMv7 Cortex-M4
; Mode : Thumb-2 ISA
; Toolchain : IAR EWARM
;********************************************************************************************************
;
;********************************************************************************************************
; PUBLIC FUNCTIONS
;********************************************************************************************************
EXTERNOSRunning ; External references
EXTERNOSPrioCur
EXTERNOSPrioHighRdy
EXTERNOSTCBCurPtr
EXTERNOSTCBHighRdyPtr
EXTERNOSIntExit
EXTERNOSTaskSwHook
EXTERNOS_CPU_ExceptStkBase
EXPORTOSStartHighRdy ; Functions declared in this file
EXPORTOSCtxSw
EXPORTOSIntCtxSw
EXPORTOS_CPU_PendSVHandler
;IF {FPU} != "SoftVFP"
;EXPORTOS_CPU_FP_Reg_Push
;EXPORTOS_CPU_FP_Reg_Pop
;ENDIF
;#ifdef __ARMVFP__
;EXTERNOS_CPU_FP_Reg_Push
;EXTERNOS_CPU_FP_Reg_Pop
;#endif
;PAGE
;********************************************************************************************************
; EQUATES
;********************************************************************************************************
NVIC_INT_CTRL EQU 0xE000ED04 ; Interrupt control state register.
NVIC_SYSPRI14 EQU 0xE000ED22 ; System priority register (priority 14).
NVIC_PENDSV_PRI EQU 0xFF ; PendSV priority value (lowest).
NVIC_PENDSVSETEQU 0x10000000 ; Value to trigger PendSV exception.
;********************************************************************************************************
; CODE GENERATION DIRECTIVES
;********************************************************************************************************
AREA |.text|, CODE, READONLY, ALIGN=2
THUMB
REQUIRE8
PRESERVE8
;#ifdef __ARMVFP__
;PAGE
;********************************************************************************************************
; FLOATING POINT REGISTERS PUSH
; voidOS_CPU_FP_Reg_Push (CPU_STK*stkPtr)
;
; Note(s) : 1) This function saves S0-S31, and FPSCR registers of the Floating Point Unit.
;
; 2) Pseudo-code is:
; a) Get FPSCR register value;
; b) Push value on process stack;
; c) Push remaining regs S0-S31 on process stack;
; d) Update OSTCBCurPtr->StkPtr;
;********************************************************************************************************
OS_CPU_FP_Reg_Push
MRS R1, PSP ; PSP is process stack pointer
CBZ R1, OS_CPU_FP_nosave ; Skip FP register save the first time
VMRS R1, FPSCR
STR R1, !
VSTMDBR0!, {S0-S31}
LDR R1, =OSTCBCurPtr
LDR R2,
STR R0,
OS_CPU_FP_nosave
BX LR
;PAGE
;********************************************************************************************************
; FLOATING POINT REGISTERS POP
; voidOS_CPU_FP_Reg_Pop (CPU_STK*stkPtr)
;
; Note(s) : 1) This function restores S0-S31, and FPSCR registers of the Floating Point Unit.
;
; 2) Pseudo-code is:
; a) Restore regs S0-S31 of new process stack;
; b) Restore FPSCR reg value
; c) Update OSTCBHighRdyPtr->StkPtr pointer of new proces stack;
;********************************************************************************************************
OS_CPU_FP_Reg_Pop
VLDMIAR0!, {S0-S31}
LDMIA R0!, {R1}
VMSR FPSCR, R1
LDR R1, =OSTCBHighRdyPtr
LDR R2,
STR R0,
BX LR
;#endif
;PAGE
;********************************************************************************************************
; START MULTITASKING
; void OSStartHighRdy(void)
;
; Note(s) : 1) This function triggers a PendSV exception (essentially, causes a context switch) to cause
; the first task to start.
;
; 2) OSStartHighRdy() MUST:
; a) Setup PendSV exception priority to lowest;
; b) Set initial PSP to 0, to tell context switcher this is first run;
; c) Set the main stack to OS_CPU_ExceptStkBase
; d) Trigger PendSV exception;
; e) Enable interrupts (tasks will run with interrupts enabled).
;********************************************************************************************************
OSStartHighRdy
LDR R0, =NVIC_SYSPRI14 ; Set the PendSV exception priority
LDR R1, =NVIC_PENDSV_PRI
STRB R1,
MOVS R0, #0 ; Set the PSP to 0 for initial context switch call
MSR PSP, R0
LDR R0, =OS_CPU_ExceptStkBase ; Initialize the MSP to the OS_CPU_ExceptStkBase
LDR R1,
MSR MSP, R1
LDR R0, =NVIC_INT_CTRL ; Trigger the PendSV exception (causes context switch)
LDR R1, =NVIC_PENDSVSET
STR R1,
CPSIE I ; Enable interrupts at processor level
OSStartHang
B OSStartHang ; Should never get here
;PAGE
;********************************************************************************************************
; PERFORM A CONTEXT SWITCH (From task level) - OSCtxSw()
;
; Note(s) : 1) OSCtxSw() is called when OS wants to perform a task context switch.This function
; triggers the PendSV exception which is where the real work is done.
;********************************************************************************************************
OSCtxSw
LDR R0, =NVIC_INT_CTRL ; Trigger the PendSV exception (causes context switch)
LDR R1, =NVIC_PENDSVSET
STR R1,
BX LR
;PAGE
;********************************************************************************************************
; PERFORM A CONTEXT SWITCH (From interrupt level) - OSIntCtxSw()
;
; Note(s) : 1) OSIntCtxSw() is called by OSIntExit() when it determines a context switch is needed as
; the result of an interrupt.This function simply triggers a PendSV exception which will
; be handled when there are no more interrupts active and interrupts are enabled.
;********************************************************************************************************
OSIntCtxSw
LDR R0, =NVIC_INT_CTRL ; Trigger the PendSV exception (causes context switch)
LDR R1, =NVIC_PENDSVSET
STR R1,
BX LR
;PAGE
;********************************************************************************************************
; HANDLE PendSV EXCEPTION
; void OS_CPU_PendSVHandler(void)
;
; Note(s) : 1) PendSV is used to cause a context switch.This is a recommended method for performing
; context switches with Cortex-M3.This is because the Cortex-M3 auto-saves half of the
; processor context on any exception, and restores same on return from exception.So only
; saving of R4-R11 is required and fixing up the stack pointers.Using the PendSV exception
; this way means that context saving and restoring is identical whether it is initiated from
; a thread or occurs due to an interrupt or exception.
;
; 2) Pseudo-code is:
; a) Get the process SP, if 0 then skip (goto d) the saving part (first context switch);
; b) Save remaining regs r4-r11 on process stack;
; c) Save the process SP in its TCB, OSTCBCurPtr->OSTCBStkPtr = SP;
; d) Call OSTaskSwHook();
; e) Get current high priority, OSPrioCur = OSPrioHighRdy;
; f) Get current ready thread TCB, OSTCBCurPtr = OSTCBHighRdyPtr;
; g) Get new process SP from TCB, SP = OSTCBHighRdyPtr->OSTCBStkPtr;
; h) Restore R4-R11 from new process stack;
; i) Perform exception return which will restore remaining context.
;
; 3) On entry into PendSV handler:
; a) The following have been saved on the process stack (by processor):
; xPSR, PC, LR, R12, R0-R3
; b) Processor mode is switched to Handler mode (from Thread mode)
; c) Stack is Main stack (switched from Process stack)
; d) OSTCBCurPtr points to the OS_TCB of the task to suspend
; OSTCBHighRdyPtrpoints to the OS_TCB of the task to resume
;
; 4) Since PendSV is set to lowest priority in the system (by OSStartHighRdy() above), we
; know that it will only be run when no other exception or interrupt is active, and
; therefore safe to assume that context being switched out was using the process stack (PSP).
;********************************************************************************************************
OS_CPU_PendSVHandler
CPSID I ; Prevent interruption during context switch
MRS R0, PSP ; PSP is process stack pointer
CBZ R0, OS_CPU_PendSVHandler_nosave ; Skip register save the first time
SUBS R0, R0, #0x20 ; Save remaining regs r4-11 on process stack
STM R0, {R4-R11}
LDR R1, =OSTCBCurPtr ; OSTCBCurPtr->OSTCBStkPtr = SP;
LDR R1,
STR R0, ; R0 is SP of process being switched out
; At this point, entire context of process has been saved
OS_CPU_PendSVHandler_nosave
PUSH {R14} ; Save LR exc_return value
LDR R0, =OSTaskSwHook ; OSTaskSwHook();
BLX R0
POP {R14}
LDR R0, =OSPrioCur ; OSPrioCur = OSPrioHighRdy;
LDR R1, =OSPrioHighRdy
LDRB R2,
STRB R2,
LDR R0, =OSTCBCurPtr ; OSTCBCurPtr = OSTCBHighRdyPtr;
LDR R1, =OSTCBHighRdyPtr
LDR R2,
STR R2,
LDR R0, ; R0 is new process SP; SP = OSTCBHighRdyPtr->StkPtr;
LDM R0, {R4-R11} ; Restore r4-11 from new process stack
ADDS R0, R0, #0x20
MSR PSP, R0 ; Load PSP with new process SP
ORR LR, LR, #0x04 ; Ensure exception return uses process stack
CPSIE I
BX LR ; Exception return will restore remaining context
END
zhcj66 发表于 2014-4-21 09:19
改正了一下,还是提示错误 不明白他说的意思
.\Obj\Project.sct(7): error: L6236E: No section matches...
LPC4357-UCOS III 移植成功 {:smile:}{:smile:}{:smile:}{:smile:}
页:
[1]