Using CW for ARM developer suite V1.2.
The piece of code below works correctly if there is no split memory specified in the link command. Linked at 0x05000000 there are no problems.
If the code is linked at RO Base 0x05000000 and RW Base 0x02000000, the load is not initialized correctly. The wrong data gets copied to the RW base and a data error occurs on the 4th printf. Is this a bug, or does it need to have scatter loading specified?
I have tried a scatter load file, but I don't think it was correct. If it needs a scatter file please show an example that should work.
Thanks, Scott
/* * File: main.c * Purpose: sample program * */ #include #include
#define SIZE 4
const char *sprintffmt[SIZE] = /* sprintf format strings */ { "%s\n", /* 0 */ "%s%s\n", /* 1 */ "%s%s%s\n", /* 2 */ "%s%s\n"}; /* 3 */
#define INDEX 0 /* Output buffer filename */ char buff[]; /* output stream buffer */
int main() { // sprintffmt[INDEX] = "%s";
strcpy(buff, "This is a test\n");
printf("\nAddr of sprintffmt = %x \n", sprintffmt ); // 0x02000000 printf("\nAddr of sprintffmt = %x \n", &sprintffmt[INDEX] ); //
0x02000000 printf("\nAddr of sprintffmt = %x \n", sprintffmt[INDEX] );printf(sprintffmt[INDEX], buff);
return 0; }