Debugging a program located in internal FLASH of the M52235 ColdFire MCU.
Claude Sylvain
csylvain at electro-technica.com
Mon Feb 19 04:38:53 UTC 2007
Hello Mark,
>>
>>Claude Sylvain wrote:
>>
>>
>> 1) Get the startup source code and try to patch those problems. The
>> startup source code is not included with Sourcery G++ Lite.
>> Is it possible to get it ?
>>
>
> Mark Mitchell wrote:
>
> All of the source code is available in the source package. The crt0
> code is also available in m68k-elf/lib/cf-crt0.S of the binary
> installation, although this file does not include __reset. (This code
> is not covered by the GPL, so there is no requirement that it be
> provided at all, but our packaging machinery will automatically include
> it, as a convenience to users.)
>
> Sourcery G++ Lite 4.1-32 does appear to have a defect in the handling of
> __reset for unhosted mode. Our Personal and Professional edition
> customers already have this fix; a future Lite edition release will
> correct it as well.
>
> However, even with 4.1-32, you may simply define your own __reset
> function (in assembly code) and link it into your program. It will take
> precedence over the version in the library.
>
I wrote my own startup module (crt0_flash.S).
In this startup module, I put the "new" code associated with __reset
and __start.
In the linker script file, I replaced all the reference to the
original startup object file (cf-unhosted-crt0.o) by the one I wrote
(crt0_flash.o).
Sadly, when I build the application, the linker seems to see multiple
definition of __reset and __start !?
This tell me that __reset and __start are not defined in
cf-unhosted-crt0.o module, but elsewhere in another library. This
also tell that linker do not handle multiple definition of __reset
and __start symbols.
Here is the makefile output:
----------
c_mcf52235>make
m68k-elf-as -mcpu=52235 --gstabs -al -o ./obj/isv_flash.o
\
./src/isv_flash.S > ./obj/isv_flash.lst
m68k-elf-as -mcpu=52235 --gstabs -al -o ./obj/crt0_flash.o
\
./src/crt0_flash.S > ./obj/crt0_flash.lst
m68k-elf-gcc -c -I./src -I./src/common -I./src/drivers -mcpu=52235
-T./src/m5223
5evb-flash.ld -g -o ./obj/main.o ./src/main.c
m68k-elf-gcc -c -I./src -I./src/common -I./src/drivers -mcpu=52235
-T./src/m5223
5evb-flash.ld -g -o ./obj/common.o \
./src/common.c
m68k-elf-gcc -c -I./src -I./src/common -I./src/drivers -mcpu=52235
-T./src/m5223
5evb-flash.ld -g -o ./obj/uart0.o \
./src/drivers/uart0.c
m68k-elf-gcc -c -I./src -I./src/common -I./src/drivers -mcpu=52235
-T./src/m5223
5evb-flash.ld -g -o ./obj/ach_con.o \
./src/common/ach_con.c
m68k-elf-gcc -I./src -I./src/common -I./src/drivers -mcpu=52235
-T./src/m52235ev
b-flash.ld -g -o ./out/basic_mcf52235.elf ./obj/isv_flash.o
./obj/crt0_flash.o .
/obj/main.o ./obj/common.o ./obj/uart0.o ./obj/ach_con.o
./obj/crt0_flash.o:./src/crt0_flash.S:50: multiple definition of `__start'
./obj/crt0_flash.o:./src/crt0_flash.S:50: first defined here
./obj/crt0_flash.o:./src/crt0_flash.S:32: multiple definition of `__reset'
./obj/crt0_flash.o:./src/crt0_flash.S:32: first defined here
collect2: ld returned 1 exit status
make: *** [out/basic_mcf52235] Error 1
C:\Documents and Settings\Claude Sylvain\My
Documents\Code\coldfire-gnu\prj\basi
c_mcf52235>
----------
So, It seems impossible to make my own startup module.
I think, it will be better for me to wait the next release of
Sourcery G++, or try to convince my boss to buy a Sourcery G++
licence (not sure I will succeed, since we only evaluate the tool for
future project(s)).
Thank you Mark for your help.
Also, thank you to Marc Vincent for its __reset code example and advices.
Claude Sylvain
Electro-Technica inc.
More information about the coldfire-gnu-discuss
mailing list