[U-Boot] [PATCH 3/7] Add timing information to printf's for use with bootgraph.pl

Andrew Murray amurray at theiet.org
Thu Sep 1 01:42:28 CEST 2011


On 1 September 2011 00:38, Graeme Russ <graeme.russ at gmail.com> wrote:
> Hi Mike, Andrew,
>
> On Thu, Sep 1, 2011 at 8:47 AM, Mike Frysinger <vapier at gentoo.org> wrote:
>> On Wednesday, August 31, 2011 18:20:57 Andrew Murray wrote:
>>>       va_list args;
>>>       uint i;
>>>       char printbuffer[CONFIG_SYS_PBSIZE];
>>> +     char *buf = printbuffer;
>>>
>>>       va_start(args, fmt);
>>>
>>> +#if defined(CONFIG_BOOT_TRACE)
>>> +     unsigned long long ticks = get_ticks();
>>> +     int secs = ticks / get_tbclk();
>>> +     int msec = ((ticks * 1000000) / get_tbclk()) - (secs * 1000000);
>>> +
>>> +     i += sprintf(buf, "[%5lu.%06lu] ", secs, msec);
>>> +     buf += i;
>>> +#endif
>>> +
>>>       /* For this to work, printbuffer must be larger than
>>>        * anything we ever want to print.
>>>        */
>>> -     i = vsprintf(printbuffer, fmt, args);
>>> +     i += vsprintf(buf, fmt, args);
>>>       va_end(args);
>>
>> NAK for a few reasons:
>>  - i dont see how this could possibly compile warning free
>>  - you never initialize "i", only added to it
>>  - you call va_start() inbetween variable decls
>
> And correct me if I'm wrong, but EVERY printf() will get the timing info
> tacked on - Even the ones without \n which are intermediate prints in
> larger messages which is going to lead to very ugly outputs
>
> I think instead we should look at another 'printf() with timestamp'
> function which can be used on an as-needed basis

Yes that's exactly the case ... e.g.

[    3.122000] initcall 0x9ff864cc returned
[    3.126000] calling  0x9ff78174
[    3.129000] ## Booting kernel from Legacy Image at 82000000 ...
[    3.135000]    Image Name:   Angstrom/2.6.32/beagleboard
[    3.141000]    Image Type:   [    3.143000] ARM Linux Kernel Image
(uncompressed)
[    3.148000]    Data Size:    [    3.151000] 3194192 Bytes = [
3.154000] 3[    3.155000]
MiB

It's certainty ugly. A dedicated printf seems very sensible.

Andrew Murray


More information about the U-Boot mailing list