Hi there,
I've been trying for some days to get a C++ project running.
Unfortunately, there appears to be a problem with the board startup
script and the linker script which were provided and are propably
generated. These files we initially not intended to incorporate C++ code
so now we're trying to adapt them to do just that. We are also using
freeRTOS. I attached the code of the two files
sdram(W!RX):ORIGIN=0x20000000,LENGTH=32M/* this board provided 64M, but we are just using 32M to model another device which only has 32M external SDRAM */
25
}
26
27
SECTIONS
28
{
29
.fixed:
30
{
31
.=ALIGN(4);/* tells the linker that these section ought to be word aligned */
32
_sfixed=.;
33
KEEP(*(.startup));
34
*(.text*)/* Code is placed in .text */
35
*(.rodata*)/* global variables marked as const. are placed in .rodata */
36
*(.glue_7)/* glue arm to thumb code */
37
*(.glue_7t)/* glue thumb to arm code */
38
*(.eh_frame)
39
*(.data)
40
*(.data*)/* contains all initialized global and static variables */
41
*(.CP15_*)/* required for system control coprocessor? */
42
KEEP(*(.init))
43
KEEP(*(.fini))
44
.=ALIGN(4);
45
/* preinit data */
46
PROVIDE_HIDDEN(__preinit_array_start=.);
47
KEEP(*(.preinit_array))
48
PROVIDE_HIDDEN(__preinit_array_end=.);
49
50
.=ALIGN(4);
51
/* init data, the constructors are placed in this sections */
52
PROVIDE_HIDDEN(__init_array_start=.);
53
KEEP(*(SORT(.init_array.)))
54
KEEP(*(.init_array))
55
PROVIDE_HIDDEN(__init_array_end=.);
56
57
.=ALIGN(4);
58
/* finit data, destructors are placed in this section */
59
PROVIDE_HIDDEN(__fini_array_start=.);
60
KEEP(*(SORT(.fini_array.)))
61
KEEP(*(.fini_array))
62
PROVIDE_HIDDEN(__fini_array_end=.);
63
}>sdram
64
65
.ARM.extab(NOLOAD):{
66
*(.ARM.extab*.gnu.linkonce.armextab.*)
67
}>sdram
68
69
__exidx_start=.;
70
.ARM.exidx(NOLOAD):{
71
*(.ARM.exidx*.gnu.linkonce.armexidx.*)
72
}>sdram
73
__exidx_end=.;
74
_efixed=.;
75
76
.prerelocate:AT(_efixed)/* all relocation stuff is pretty much taken from atmel */
/* Useless instruction for referencing the .vectors section */
109
ldrr0,=resetVector
110
111
/* Set pc to actual code location (i.e. not in remap zone) */
112
ldrpc,=1f
113
114
/* Initialize the prerelocate segment */
115
1:
116
ldrr0,=_efixed
117
ldrr1,=_sprerelocate
118
ldrr2,=_eprerelocate
119
1:
120
cmpr1,r2
121
ldrccr3,[r0],#4
122
strccr3,[r1],#4
123
bcc1b
124
125
/* Perform low-level initialization of the chip using LowLevelInit() */
126
ldrsp,=_sstack
127
stmfdsp!,{r0}
128
ldrr0,=LowLevelInit
129
blxr0
130
131
/* Initialize the postrelocate segment */
132
133
ldmfdsp!,{r0}
134
ldrr1,=_spostrelocate
135
ldrr2,=_epostrelocate
136
1:
137
cmpr1,r2
138
ldrccr3,[r0],#4
139
strccr3,[r1],#4
140
bcc1b
141
142
/* Clear the zero segment */
143
ldrr0,=__bss_start__
144
ldrr1,=__bss_end__
145
movr2,#0
146
1:
147
cmpr0,r1
148
strccr2,[r0],#4
149
bcc1b
150
151
/* Setup stacks
152
**************/
153
/* IRQ mode */
154
msrCPSR_c,#ARM_MODE_IRQ|I_BIT|F_BIT
155
ldrsp,=_sstack
156
subr4,sp,#IRQ_STACK_SIZE
157
158
/* Supervisor mode (interrupts enabled) */
159
msrCPSR_c,#ARM_MODE_SVC|F_BIT
160
movsp,r4
161
162
/* Call static constructors */
163
ldrr0,=__libc_init_array
164
movlr,pc/* set the return address */
165
bxr0/* the target code can be ARM or THUMB */
166
/* Branch to main()
167
******************/
168
ldrr0,=main
169
blxr0
170
171
/* Loop indefinitely when program is finished */
172
1:
173
b1b
Do you have any idea why are program is crashing randomly? Right now it
always crashes and jumps to an adress it is not intended to be. I
attached the dissassembly when this happends while debugging.
My guess is that this relates to the two files shown above. Maybe
something is missing so that C++ is working properly? The program
crashes when the freeRTOS task scheduler has already started. I hope
someone has a clue how to get this working. Especially someone who
managed to get C++ working on ARM processors. Thanks a lot in advance !
Kind Regards,
Robin
The program does not crash anymore when I comment out code related to
hardware drivers. The program does not crash when performing these
functions but crashes at the adresses I have shown in the 2 pictures.
This is really confusing.
I use the AT91SAM9G20-EK board and provided drivers. This is inside a
function which is called by performOperation() which crashed
1
//ATMEL
2
AT91S_USART*rs232;// do not initialize this register handle, causes problems !