Skip to content

Commit 6bc0753

Browse files
committed
Removed printf call in _Error_Handler() to reduce code size
By using the printf function of the library C this inflates the size of the code. An alternative, will be to implement a tiny and limited functionality implementation of printf. Example, build modified Blink.ino with _Error_Handler() calls for Nucloe F103RB: With printf: Sketch uses 16368 bytes Without printf: Sketch uses 10220 bytes Difference is 6k of flash used which is not negligible. Nano static library is linked to use this printf call. Signed-off-by: Frederic.Pillon <[email protected]>
1 parent f9e1d01 commit 6bc0753

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Diff for: cores/arduino/stm32/stm32_def.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@ extern "C" {
1212
WEAK void _Error_Handler(const char * msg, int val)
1313
{
1414
/* User can add his own implementation to report the HAL error return state */
15-
printf("Error: %s (%i)\n", msg, val);
15+
/* By using the printf function of the library C this inflates the size of
16+
* the code, use a lot of stack. An alternative, will be to implement a tiny
17+
* and limited functionality implementation of printf.
18+
*/
19+
UNUSED(msg);
20+
UNUSED(val);
21+
/*printf("Error: %s (%i)\n", msg, val);*/
1622
while(1)
1723
{
1824
}

0 commit comments

Comments
 (0)