[En-Nut-Discussion] Two problems with the new printf / putf

Ole Reinhardt ole.reinhardt at embedded-it.de
Fri Sep 27 01:07:29 CEST 2013

Hi all,

it looks like the latest changes to putf raise some some strange bugs.

I tried to debug this, but did not yet succeed, but I assume there are
still problem with the va_arg handling.

The bug is triggered with this code:

printf("Test int: %d, hex: %08x, char: %c, str: %s   %d\n",
        100, 0xabcd, 'A', "Hello world", 123456);

The output, which finally ended in a busfault (see also the wrong hex
and char value, as well as the missing final int):

Test int: 100, hex: 00000064, char: d, str:
[Bus Fault handler - all numbers in hex]

R0        = 0x0007542f
R1        = 0x00080000
R2        = 0x00000000
R3        = 0xffffffff
R12       = 0x01010101
LR [R14]  = 0x00004ecf
PC [R15]  = 0x000085ce
PSR       = 0x41000400
BFAR      = 0x00080000
CFSR      = 0x00008200
HFSR      = 0x00000000
DFSR      = 0x00000008
AFSR      = 0x00000000
SCB_SHCSR = 0x00070002

Same in a larger context:

printf("\n\nNut/OS %s\n", NutVersionString());
printf("Multicast DNS server sample\n");
printf("%d bytes free, debug dev: %s\n", NutHeapAvailable(),
printf("name: %s\n", DEV_UART0.dev_name);

The output:

Multicast DNS server sample
27868 bytes free, debug dev: p�(F!F��p@��;� F载�p@���膺h
name: usart0
Configure eth0...

I tried to read the putf code a few times now, but I can not point out
the real problem. I suppose some problems with the va_arg handling.

I have tested this code on a lpc1768 (CM3) with the current trunk. Your
patches related to the stack alignment are just included.

Any ideas on this? When rewinding the putf code to rev. r4934 everything
works fine.

Best regards,


kernel concepts GmbH            Tel: +49-271-771091-14
Sieghuetter Hauptweg 48         Mob: +49-177-7420433
D-57072 Siegen

More information about the En-Nut-Discussion mailing list