Posted on: 2010-02-05 14:41
Attached files:Hi, I have made a project using an LPC2148 evaluation board from sparkfun (logomatic V2). I think that I have a memory overflow problem because some global data are overwrited during my program execution without any write. Example: Bebug output in the beginning of my program execution
weekday N0 alarm: morning_en:0 afternoon_en:0
weekday N1 alarm: morning_en:1 afternoon_en:1
08h:30m
12h:00m
14h:00m
17h:30m
weekday N2 alarm: morning_en:1 afternoon_en:1
08h:30m
12h:00m
14h:00m
17h:30m
weekday N3 alarm: morning_en:1 afternoon_en:1
08h:30m
12h:00m
14h:00m
17h:30m
weekday N4 alarm: morning_en:1 afternoon_en:1
08h:30m
12h:00m
14h:00m
17h:30m
weekday N5 alarm: morning_en:1 afternoon_en:1
08h:30m
12h:00m
14h:00m
17h:30m
weekday N6 alarm: morning_en:1 afternoon_en:0
09h:00m
12h:00m
|
and when I read the same data later I could see that some data are overwrited by some strange values:
weekday N0 alarm: morning_en:0 afternoon_en:0
weekday N1 alarm: morning_en:1 afternoon_en:1
08h:30m
12h:00m
14h:00m
17h:30m
weekday N2 alarm: morning_en:1 afternoon_en:1
08h:30m
12h:00m
14h:00m
17h:30m
weekday N3 alarm: morning_en:1 afternoon_en:1
08h:30m
12h:00m
14h:00m
17h:30m
weekday N4 alarm: morning_en:53 afternoon_en:208
00h:02m
00h:17m
00h:04m
00h:17m
weekday N5 alarm: morning_en:54 afternoon_en:44
00h:100m
00h:128m
53h:11m
157h:60m
weekday N6 alarm: morning_en:28 afternoon_en:50
53h:248m
00h:04m
54h:220m
00h:100m
|
I think that the .bss section (my global data) is overwrited by the .stack Here is some detail: Section Size Address .text 75100 0001 0000 .data 2576 4000 0000 .bss 9564 4000 0A10 .stack 3072 4000 3000 in startup.s file
.set UND_Stack_Size, 0x00000080 .set SVC_Stack_Size, 0x00000080 .set ABT_Stack_Size, 0x00000080 .set FIQ_Stack_Size, 0x00000080 .set IRQ_Stack_Size, 0x00000200 .set USR_Stack_Size, 0x00000800 |
So the size of the stack (3000) is correct but I don't understand why it start so close to the .bss section. Shouldn't be at the address 4000 8000 ? The .bss section end at 4000 0A10 + 255C = 4000 2F6C If the .stack data start at 4000 3000 it may collide with the .bss section (4000 3000 - 0C00 = 4000 2400) !! Could you help me to solve this problem?
Posted on: 2010-02-05 15:24
I have increased the stack size from 0x800 to 0x1000 and my error seems to be solved. I hope the problem is totally solved. Here is the modification: main_memory_block.ld
ENTRY(_boot) STACK_SIZE = 0x1000; -> see startup-file and .stack-section |
startup.S
.set USR_Stack_Size, 0x00001000 |
Do you agree with me?
Posted on: 2010-02-05 18:12
Noel Le moult wrote: > I have increased the stack size from 0x800 to 0x1000 and my error seems > to be solved. > > I hope the problem is totally solved. > > Here is the modification: > > main_memory_block.ld >
> ENTRY(_boot) > STACK_SIZE = 0x1000; -> see startup-file and .stack-section > |
The mentioned lines are commented out in the file attached to the first post (seem a unmodified version from one of may examples). While the STACK_SIZE definition is not used since the stacks are defined in the startup-code it is a good idea to place an ENTRY line into the linker-script (outside a comment). Here ENTRY(Reset_Handler) should do. > startup.S >
> .set USR_Stack_Size, 0x00001000 > |
> > Do you agree with me? Yes. This defines the size of the user-mode stack which is later used to define a memory-area for this stack (using .space) and during the startup-code to initialise the core's stack-pointer for the user-mode