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.

how to create our own startup codes in CCSv5.2.1

Other Parts Discussed in Thread: OMAPL138

Hi

I am now programming on omapl138 using CCSV5.2.1. I want to declare and initialize three stacks: SVC, FIQ and IRQ stacks for the following use. I was thinking I can declare and initialize them in my own startup codes, which would run before _c_int00. So in addition to my current project, which was created as a general C/C++ CCS project with all default .cmd and link settings, I added another file initstack.asm, which is

;**********************************************
; Global symbols defined here
.global _c_int00
.global _init_stack

;***********************************************
; define SVC stack, FIQ stack and IRQ stack
__SVC_STACK_SIZE:.set 0x1000
__IRQ_STACK_SIZE:.set 0x1000
__FIQ_STACK_SIZE:.set 0x1000
__svc_stack:.usect ".svcstack", __SVC_STACK_SIZE, 4
__irq_stack:.usect ".irqstack", __IRQ_STACK_SIZE, 4
__fiq_stack:.usect ".fiqstack", __FIQ_STACK_SIZE, 4

;***********************************************
; define function _init_stack
_init_stack:.asmfunc

; switch to SVC mode
MRS R0,CPSR
BIC R0,R0,#0x1f
ORR R0,R0,#0x13
MSR CPSR_cf,R0
; initialize svc stack
LDR SP, svc_stack
LDR R0, SVC_STACK_SIZE
ADD SP,SP,R0

; switch to IRQ mode
MRS R0,CPSR
BIC R0,R0,#0x1f
ORR R0,R0,#0x12
MSR CPSR_cf,R0
; initialize irq stack
LDR SP, irq_stack
LDR R0, IRQ_STACK_SIZE
ADD SP,SP,R0

; switch to fiq mode
MRS R0,CPSR
BIC R0,R0,#0x1f
ORR R0,R0,#0x11
MSR CPSR_cf, R0
; initialize fiq stack
LDR SP, fiq_stack
LDR R0, FIQ_STACK_SIZE
ADD SP, SP,R0

;jump to _c_int00
LDR PC,c_int00
.endasmfunc

;***********************************************
;constant used in this module
c_int00 .long _c_int00
SVC_STACK_SIZE .long __SVC_STACK_SIZE
IRQ_STACK_SIZE .long __IRQ_STACK_SIZE
FIQ_STACK_SIZE .long __FIQ_STACK_SIZE
svc_stack .long __svc_stack
irq_stack .long __irq_stack
fiq_stack .long __fiq_stack

And in .cmd file, I include these three stacks like this:

...

/* stack sections */
.svcstack > SHRAM
.irqstack > SHRAM
.fiqstack > SHRAM

...

With above change, compile and link can all be done successfully. However, after I downloaded it into omapl138 using xds100v2, it seems that _init_stack was not executed and I could not find section .svcstack, .irqstack and .fiqstack in the memory. What's more, even without downloading it, I opened the .map file, which is generated in the link process, where I could not find _init_stack module neither.

 In my project, .asm is the only asm file, and it was complied successfully because I do can find a .obj file under that folder, but it seems that this compiled module was not linked with other part in my project. 

So I was wondering how can I include my own startup codes in my project and have it run before _c_int00?

Thanks

Fu