CW10.2
Windows 7
Kinetis MK10DN512CVLQ10
I'm creating a bootloader and have copied a number of files from my "App" folder to my new "Boot" folder. I then pre-fixed all the copied filenames with "BOOT__".
The compiler now bombards me with "Multiply-Defined" errors!
Here's an example of an instance that generates this error:
The UART__inititalize function is in both my "Boot" folder and my normal "App" folder. It has the same name in both folders.
I don't understand why this is a problem. The only file in my "Boot" folder which accesses UART__inititalize has #include <BOOT__UART.h>, not #include <UART.h>.
Am I breaking a C coding standard? Or, is the compiler not letting me do something which should be valid?
You are getting multiply-defined errors because you have two functions with the same name defined, and the linker is balking. If the functions used by the bootloader project are code-identical to the functions in the app project, you should be able to declare the files as extern in your boot loader header file. If they are different, then you need to rename the functions in your bootloader project to avoid the name collision.
---Tom
Tom,
Thanks for the reply. Could you please explain the comment below some more?
My fear is that the Application code functions will have changed locations in flash (but still located in Application code) and then the Bootloader will be jumping to invalid locations. Perhaps I simply don't have a full understanding of the usage of "extern".
tom_thompson wrote:
you should be able to declare the files as extern in your boot loader header file.
add extern in the .h file to make the functions globally avaiulable
/*
Globally available functions.
*/
extern void InitializeMyStuff(void);
extern void EnableMyStuff( value);
extern void MyStuff(output);
James,
I still have the same concerns from my prior post. The address of these functions will be part of the Application code. Since that could change from Release 1.00 to 2.00, this strategy will eventually lead to a non-functional Bootloader. Am I mistaken?
You are going to have to nail down the location with the define of a structure and some magic in your linker command file.
in one of your c modules....
/* Note, this structure is not referenced by the main code but rather is
used by the code in the FlashProgrammer and BootLoader project to locate
entities within the main image. Changes here will require changes
to of the other two projects. Changes will, void backwards
compatibility */
__declspec(rodata) const unsigned long myROData[SIZEOF_CONST_MY_DATA/sizeof(unsigned long)]=
{
0, /* version */ //0x1004
0, /* starting address for execution */ //0x1008
0, /* addr of text section0 */ //0x100C
0, /* size of text section0 */ //0x1010
0, /* addr of text section1 */ //0x1014
0, /* size of text section1 */ //0x1018
,,,,,,,
0, /* addr of application data */ //0x102C
0, /* size of application data */ //0x1030
0, /* addr of romp */ //0x1034
0, /* size of romp */ //0x1038
0, /* end of text section marker */ //0x103C
0 /* filler */ //0x1040
};
in your linker command file,,,
KEEP_SECTION{.My_ROData} # Force into image so WRTITEWs below will have a target
___SOFTWARE_REVISION = 2;
#
# The following structure is reference by _main in this application and by the
# update manager (aka BootLoader). Check out both before changing it in any way.
#
.My_ROData : AT (0x1004)
{
WRITEW(0x01000000+___SOFTWARE_REVISION);# MyAddr + version data 0x1004
WRITEW(__QSIstart); # Starting address for main 0x1008
WRITEW(ADDR(.application_text0)); # Start of section 0x100C
WRITEW(SIZEOF(.application_text0)+4); # size of secttion 0x1010
WRITEW(ADDR(.application_text1)); # Start of section 0x1014
WRITEW(SIZEOF(.application_text1)+4); # size of section 0x1018
WRITEW(ADDR(.application_text2)); # Start of section 0x101C
WRITEW(SIZEOF(.application_text2)+4); # size of section 0x1020
WRITEW(ADDR(.application_text3)); # Start of section 0x1024
WRITEW(SIZEOF(.application_text3)+4); # size of section 0x1028
WRITEW(application_data_ROM); # Start of section 0x102C
WRITEW(SIZEOF(.application_data)); # size of section 0x1030
WRITEW(__S_romp); # Start of section 0x1034
WRITEW(SIZEOF(.romp)); # size of section 0x1038
WRITEW(0); # end of RO sections 0x103C
WRITEW(0); # filler, maintains pairings 0x1040
}
RODATA_SIZE = SIZEOF(.My_ROData);
Hope this gets you on the right track.
This is an example, of a how to set up a boot loader,,,, but you can't "cross call" fucntions with it.
Creating a Bootloader Environment (Freescale ColdFire Example) - from Wolin Labs