Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

DAVE™ Forum Discussions

Not applicable
Hi,

Whenever I include a call to vsnprintf(..) in my code I end up in the BusFault_Handler handler in Startup_XMC4500.s and never reach main().

Stepping through from reset I get as far as line 303 in Startup_XMC4500.s and then stepping over BLX R0 I end up at BusFault_Handler

/* C++ : Call global constructors */
LDR R0,=__libc_init_array
BLX R0



My code looks like this:

static void appendResponse(const char * fmt, ...)
{
va_list ap;

va_start (ap, fmt);
vsnprintf (szLineResponse,100, fmt, ap);
strcat(statusResponse, szLineResponse);
va_end (ap);
}


I have also tried:

static void appendResponse(const char * fmt, ...)
{
__builtin_va_list ap;

__builtin_va_start (ap, fmt);
vsnprintf (szLineResponse,100, fmt, ap);
strcat(statusResponse, szLineResponse);
__builtin_ va_end (ap);
}


Note there is no call to appendResponse() in my code, it appears to be just the presence of vsnprintf() that causes the problem.

Any thoughts?

Kind regards

Andy
0 Likes
1 Reply
Not applicable
Hi

I think this may be memory related. If I add any sizeable amount of code to my application then, things start to go wrong. Even if the code is not called. For example if I add a large constant array of bytes static const unsigned char neverused[30000] = { }; then I also end up in BusFault_Handler:

As far as I can see when I am using 0x3FC10 (261136) bytes of flash and everything is OK. When I add the dummy array this increased to 0x47140 (291136) and things start to go wrong. (I bet 0x3FFFF is the boundary).


My target is the HiLight board which is XMC4500F144x1024 so I though I should be OK up to 0x100000 bytes of flash. Am missing something obvious like a linker option?


Below are the first few lines of the generated list file

Working:
[HTML]

Sections:
Idx Name Size VMA LMA File off Algn
0 .text 0003bbf0 08000000 0c000000 00008000 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .ARM.exidx 00000010 0803bbf0 0c03bbf0 00043bf0 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
2 .rodata 00004010 0803bc00 0c03bc00 00043c00 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 Stack 00000800 20000000 20000000 00050000 2**0
ALLOC
4 Communication_Buffers 00004920 30000000 30000000 00050000 2**2
ALLOC
5 .bss 000078fc 20000800 20000800 00050000 2**3
ALLOC
6 .data 00000754 20008100 0c03fc10 00048100 2**3
CONTENTS, ALLOC, LOAD, DATA
7 .debug_aranges 00003520 00000000 00000000 00048858 2**3
CONTENTS, READONLY, DEBUGGING
8 .debug_info 0005f23e 00000000 00000000 0004bd78 2**0
CONTENTS, READONLY, DEBUGGING
9 .debug_abbrev 00009833 00000000 00000000 000aafb6 2**0
CONTENTS, READONLY, DEBUGGING
10 .debug_line 0007fa47 00000000 00000000 000b47e9 2**0
CONTENTS, READONLY, DEBUGGING
11 .debug_frame 0000b92c 00000000 00000000 00134230 2**2
CONTENTS, READONLY, DEBUGGING
12 .debug_str 00015d34 00000000 00000000 0013fb5c 2**0
CONTENTS, READONLY, DEBUGGING
13 .debug_loc 00013706 00000000 00000000 00155890 2**0
CONTENTS, READONLY, DEBUGGING
14 .debug_macinfo 02565a2a 00000000 00000000 00168f96 2**0
CONTENTS, READONLY, DEBUGGING
15 .debug_ranges 000030c0 00000000 00000000 026ce9c0 2**3
CONTENTS, READONLY, DEBUGGING
16 .svc_table 00000004 00000000 00000000 026d1a80 2**0
CONTENTS, READONLY
17 .build_attributes 00001eb1 00000000 00000000 026d1a84 2**0
CONTENTS, READONLY
[/HTML]
Faulty:

[HTML]
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 0003bbf0 08000000 0c000000 00008000 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .ARM.exidx 00000010 0803bbf0 0c03bbf0 00043bf0 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
2 .rodata 0000b540 0803bc00 0c03bc00 00043c00 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 Stack 00000800 20000000 20000000 00058000 2**0
ALLOC
4 Communication_Buffers 00004920 30000000 30000000 00058000 2**2
ALLOC
5 .bss 000078fc 20000800 20000800 00058000 2**3
ALLOC
6 .data 00000754 20008100 0c047140 00050100 2**3
CONTENTS, ALLOC, LOAD, DATA
7 .debug_aranges 00003520 00000000 00000000 00050858 2**3
CONTENTS, READONLY, DEBUGGING
8 .debug_info 0005f265 00000000 00000000 00053d78 2**0
CONTENTS, READONLY, DEBUGGING
9 .debug_abbrev 00009833 00000000 00000000 000b2fdd 2**0
CONTENTS, READONLY, DEBUGGING
10 .debug_line 0007fa47 00000000 00000000 000bc810 2**0
CONTENTS, READONLY, DEBUGGING
11 .debug_frame 0000b92c 00000000 00000000 0013c258 2**2
CONTENTS, READONLY, DEBUGGING
12 .debug_str 00015d3e 00000000 00000000 00147b84 2**0
CONTENTS, READONLY, DEBUGGING
13 .debug_loc 00013706 00000000 00000000 0015d8c2 2**0
CONTENTS, READONLY, DEBUGGING
14 .debug_macinfo 02565a2a 00000000 00000000 00170fc8 2**0
CONTENTS, READONLY, DEBUGGING
15 .debug_ranges 000030c0 00000000 00000000 026d69f8 2**3
CONTENTS, READONLY, DEBUGGING
16 .svc_table 00000004 00000000 00000000 026d9ab8 2**0
CONTENTS, READONLY
17 .build_attributes 00001eb1 00000000 00000000 026d9abc 2**0
CONTENTS, READONLY

[/HTML]

King Regards,

Andy
0 Likes