[PATCH] tiny-printf: Add support for upper case hex values

Quentin Schulz quentin.schulz at cherry.de
Thu Mar 20 15:00:18 CET 2025


Hi Marek,

On 3/20/25 12:49 PM, Marek Vasut wrote:
> On 3/20/25 11:23 AM, Christoph Niedermaier wrote:
>> If tiny printf is used with 0x%08X (upper case X) the output is
>> always 0x00000000. It could be confusing if upper case instead
>> of lower case is used intentionally or accidentally because the
>> actual value is not output. To avoid this confusion, tiny printf
>> is extended to support also the formatting with %X.
>>
>> Signed-off-by: Christoph Niedermaier <cniedermaier at dh-electronics.com>
> TINY_PRINTF is meant to be tiny, i.e. not consume a lot of space, at the 
> expense of functionality. This is meant to be used in size constrained 
> environments, like the SPL. If you need full vsprintf() formatting 
> support, disable TINY_PRINTF in your config and use the regular 
> vsprintf() implementation.

The issue is that disabling TINY_PRINTF may not be possible (size 
constraints) and some code is compiled for different stages and people 
typically don't check whether the format used in printf is valid with 
tiny_printf. I've had this issue already in the past, I vaguely recall 
"complaining" about it on IRC.

Maybe there's something we can do to verify that the code is working how 
we expect it to work, regardless of tiny_printf/full printf selection? 
checkpatch or a compile-time check for the formats maybe?

But yeah, essentially the whole thing is... if we continue like this, 
we'll just end up getting closer and closer to the full printf which is 
not something we want :)

Cheers,
Quentin


More information about the U-Boot mailing list