mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-19 11:24:42 +00:00
doc: move README.trace to HTML documentation
Convert README.trace to reStructured text and move it to develop/trace.rst. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
d0253f7e5c
commit
dce26c7d56
2 changed files with 120 additions and 110 deletions
|
@ -12,3 +12,4 @@ Develop U-Boot
|
||||||
crash_dumps
|
crash_dumps
|
||||||
global_data
|
global_data
|
||||||
logging
|
logging
|
||||||
|
trace
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
# SPDX-License-Identifier: GPL-2.0+
|
.. SPDX-License-Identifier: GPL-2.0+
|
||||||
#
|
.. Copyright (c) 2013 The Chromium OS Authors.
|
||||||
# Copyright (c) 2013 The Chromium OS Authors.
|
|
||||||
|
|
||||||
Tracing in U-Boot
|
Tracing in U-Boot
|
||||||
=================
|
=================
|
||||||
|
@ -33,73 +32,82 @@ this, follow these steps:
|
||||||
|
|
||||||
Add the following to include/configs/sandbox.h (if not already there)
|
Add the following to include/configs/sandbox.h (if not already there)
|
||||||
|
|
||||||
#define CONFIG_TRACE
|
.. code-block:: c
|
||||||
#define CONFIG_CMD_TRACE
|
|
||||||
#define CONFIG_TRACE_BUFFER_SIZE (16 << 20)
|
#define CONFIG_TRACE
|
||||||
#define CONFIG_TRACE_EARLY_SIZE (8 << 20)
|
#define CONFIG_CMD_TRACE
|
||||||
#define CONFIG_TRACE_EARLY
|
#define CONFIG_TRACE_BUFFER_SIZE (16 << 20)
|
||||||
#define CONFIG_TRACE_EARLY_ADDR 0x00100000
|
#define CONFIG_TRACE_EARLY_SIZE (8 << 20)
|
||||||
|
#define CONFIG_TRACE_EARLY
|
||||||
|
#define CONFIG_TRACE_EARLY_ADDR 0x00100000
|
||||||
|
|
||||||
Build sandbox U-Boot with tracing enabled:
|
Build sandbox U-Boot with tracing enabled:
|
||||||
|
|
||||||
$ make FTRACE=1 O=sandbox sandbox_config
|
.. code-block:: console
|
||||||
$ make FTRACE=1 O=sandbox
|
|
||||||
|
$ make FTRACE=1 O=sandbox sandbox_config
|
||||||
|
$ make FTRACE=1 O=sandbox
|
||||||
|
|
||||||
Run sandbox, wait for a bit of trace information to appear, and then capture
|
Run sandbox, wait for a bit of trace information to appear, and then capture
|
||||||
a trace:
|
a trace:
|
||||||
|
|
||||||
$ ./sandbox/u-boot
|
.. code-block:: console
|
||||||
|
|
||||||
|
$ ./sandbox/u-boot
|
||||||
|
|
||||||
U-Boot 2013.04-rc2-00100-ga72fcef (Apr 17 2013 - 19:25:24)
|
U-Boot 2013.04-rc2-00100-ga72fcef (Apr 17 2013 - 19:25:24)
|
||||||
|
|
||||||
DRAM: 128 MiB
|
DRAM: 128 MiB
|
||||||
trace: enabled
|
trace: enabled
|
||||||
Using default environment
|
Using default environment
|
||||||
|
|
||||||
In: serial
|
In: serial
|
||||||
Out: serial
|
Out: serial
|
||||||
Err: serial
|
Err: serial
|
||||||
=>trace stats
|
=>trace stats
|
||||||
671,406 function sites
|
671,406 function sites
|
||||||
69,712 function calls
|
69,712 function calls
|
||||||
0 untracked function calls
|
0 untracked function calls
|
||||||
73,373 traced function calls
|
73,373 traced function calls
|
||||||
16 maximum observed call depth
|
16 maximum observed call depth
|
||||||
15 call depth limit
|
15 call depth limit
|
||||||
66,491 calls not traced due to depth
|
66,491 calls not traced due to depth
|
||||||
=>trace stats
|
=>trace stats
|
||||||
671,406 function sites
|
671,406 function sites
|
||||||
1,279,450 function calls
|
1,279,450 function calls
|
||||||
0 untracked function calls
|
0 untracked function calls
|
||||||
950,490 traced function calls (333217 dropped due to overflow)
|
950,490 traced function calls (333217 dropped due to overflow)
|
||||||
16 maximum observed call depth
|
16 maximum observed call depth
|
||||||
15 call depth limit
|
15 call depth limit
|
||||||
1,275,767 calls not traced due to depth
|
1,275,767 calls not traced due to depth
|
||||||
=>trace calls 0 e00000
|
=>trace calls 0 e00000
|
||||||
Call list dumped to 00000000, size 0xae0a40
|
Call list dumped to 00000000, size 0xae0a40
|
||||||
=>print
|
=>print
|
||||||
baudrate=115200
|
baudrate=115200
|
||||||
profbase=0
|
profbase=0
|
||||||
profoffset=ae0a40
|
profoffset=ae0a40
|
||||||
profsize=e00000
|
profsize=e00000
|
||||||
stderr=serial
|
stderr=serial
|
||||||
stdin=serial
|
stdin=serial
|
||||||
stdout=serial
|
stdout=serial
|
||||||
|
|
||||||
Environment size: 117/8188 bytes
|
Environment size: 117/8188 bytes
|
||||||
=>host save host 0 trace 0 ${profoffset}
|
=>host save host 0 trace 0 ${profoffset}
|
||||||
11405888 bytes written in 10 ms (1.1 GiB/s)
|
11405888 bytes written in 10 ms (1.1 GiB/s)
|
||||||
=>reset
|
=>reset
|
||||||
|
|
||||||
|
|
||||||
Then run proftool to convert the trace information to ftrace format.
|
Then run proftool to convert the trace information to ftrace format
|
||||||
|
|
||||||
$ ./sandbox/tools/proftool -m sandbox/System.map -p trace dump-ftrace >trace.txt
|
.. code-block:: console
|
||||||
|
|
||||||
Finally run pytimechart to display it:
|
$ ./sandbox/tools/proftool -m sandbox/System.map -p trace dump-ftrace >trace.txt
|
||||||
|
|
||||||
$ pytimechart trace.txt
|
Finally run pytimechart to display it
|
||||||
|
|
||||||
|
.. code-block:: console
|
||||||
|
|
||||||
|
$ pytimechart trace.txt
|
||||||
|
|
||||||
Using this tool you can zoom and pan across the trace, with the function
|
Using this tool you can zoom and pan across the trace, with the function
|
||||||
calls on the left and little marks representing the start and end of each
|
calls on the left and little marks representing the start and end of each
|
||||||
|
@ -109,31 +117,31 @@ function.
|
||||||
CONFIG Options
|
CONFIG Options
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
- CONFIG_TRACE
|
CONFIG_TRACE
|
||||||
Enables the trace feature in U-Boot.
|
Enables the trace feature in U-Boot.
|
||||||
|
|
||||||
- CONFIG_CMD_TRACE
|
CONFIG_CMD_TRACE
|
||||||
Enables the trace command.
|
Enables the trace command.
|
||||||
|
|
||||||
- CONFIG_TRACE_BUFFER_SIZE
|
CONFIG_TRACE_BUFFER_SIZE
|
||||||
Size of trace buffer to allocate for U-Boot. This buffer is
|
Size of trace buffer to allocate for U-Boot. This buffer is
|
||||||
used after relocation, as a place to put function tracing
|
used after relocation, as a place to put function tracing
|
||||||
information. The address of the buffer is determined by
|
information. The address of the buffer is determined by
|
||||||
the relocation code.
|
the relocation code.
|
||||||
|
|
||||||
- CONFIG_TRACE_EARLY
|
CONFIG_TRACE_EARLY
|
||||||
Define this to start tracing early, before relocation.
|
Define this to start tracing early, before relocation.
|
||||||
|
|
||||||
- CONFIG_TRACE_EARLY_SIZE
|
CONFIG_TRACE_EARLY_SIZE
|
||||||
Size of 'early' trace buffer. Before U-Boot has relocated
|
Size of 'early' trace buffer. Before U-Boot has relocated
|
||||||
it doesn't have a proper trace buffer. On many boards
|
it doesn't have a proper trace buffer. On many boards
|
||||||
you can define an area of memory to use for the trace
|
you can define an area of memory to use for the trace
|
||||||
buffer until the 'real' trace buffer is available after
|
buffer until the 'real' trace buffer is available after
|
||||||
relocation. The contents of this buffer are then copied to
|
relocation. The contents of this buffer are then copied to
|
||||||
the real buffer.
|
the real buffer.
|
||||||
|
|
||||||
- CONFIG_TRACE_EARLY_ADDR
|
CONFIG_TRACE_EARLY_ADDR
|
||||||
Address of early trace buffer
|
Address of early trace buffer
|
||||||
|
|
||||||
|
|
||||||
Building U-Boot with Tracing Enabled
|
Building U-Boot with Tracing Enabled
|
||||||
|
@ -191,20 +199,20 @@ Commands
|
||||||
|
|
||||||
The trace command has variable sub-commands:
|
The trace command has variable sub-commands:
|
||||||
|
|
||||||
- stats
|
stats
|
||||||
Display tracing statistics
|
Display tracing statistics
|
||||||
|
|
||||||
- pause
|
pause
|
||||||
Pause tracing
|
Pause tracing
|
||||||
|
|
||||||
- resume
|
resume
|
||||||
Resume tracing
|
Resume tracing
|
||||||
|
|
||||||
- funclist [<addr> <size>]
|
funclist [<addr> <size>]
|
||||||
Dump a list of functions into the buffer
|
Dump a list of functions into the buffer
|
||||||
|
|
||||||
- calls [<addr> <size>]
|
calls [<addr> <size>]
|
||||||
Dump function call trace into buffer
|
Dump function call trace into buffer
|
||||||
|
|
||||||
If the address and size are not given, these are obtained from environment
|
If the address and size are not given, these are obtained from environment
|
||||||
variables (see below). In any case the environment variables are updated
|
variables (see below). In any case the environment variables are updated
|
||||||
|
@ -216,14 +224,14 @@ Environment Variables
|
||||||
|
|
||||||
The following are used:
|
The following are used:
|
||||||
|
|
||||||
- profbase
|
profbase
|
||||||
Base address of trace output buffer
|
Base address of trace output buffer
|
||||||
|
|
||||||
- profoffset
|
profoffset
|
||||||
Offset of first unwritten byte in trace output buffer
|
Offset of first unwritten byte in trace output buffer
|
||||||
|
|
||||||
- profsize
|
profsize
|
||||||
Size of trace output buffer
|
Size of trace output buffer
|
||||||
|
|
||||||
All of these are set by the 'trace calls' command.
|
All of these are set by the 'trace calls' command.
|
||||||
|
|
||||||
|
@ -231,18 +239,18 @@ These variables keep track of the amount of data written to the trace
|
||||||
output buffer by the 'trace' command. The trace commands which write data
|
output buffer by the 'trace' command. The trace commands which write data
|
||||||
to the output buffer can use these to specify the buffer to write to, and
|
to the output buffer can use these to specify the buffer to write to, and
|
||||||
update profoffset each time. This allows successive commands to append data
|
update profoffset each time. This allows successive commands to append data
|
||||||
to the same buffer, for example:
|
to the same buffer, for example::
|
||||||
|
|
||||||
trace funclist 10000 e00000
|
=> trace funclist 10000 e00000
|
||||||
trace calls
|
=> trace calls
|
||||||
|
|
||||||
(the latter command appends more data to the buffer).
|
(the latter command appends more data to the buffer).
|
||||||
|
|
||||||
|
|
||||||
- fakegocmd
|
fakegocmd
|
||||||
Specifies commands to run just before booting the OS. This
|
Specifies commands to run just before booting the OS. This
|
||||||
is a useful time to write the trace data to the host for
|
is a useful time to write the trace data to the host for
|
||||||
processing.
|
processing.
|
||||||
|
|
||||||
|
|
||||||
Writing Out Trace Data
|
Writing Out Trace Data
|
||||||
|
@ -250,11 +258,11 @@ Writing Out Trace Data
|
||||||
|
|
||||||
Once the trace data is in an output buffer in memory there are various ways
|
Once the trace data is in an output buffer in memory there are various ways
|
||||||
to transmit it to the host. Notably you can use tftput to send the data
|
to transmit it to the host. Notably you can use tftput to send the data
|
||||||
over a network link:
|
over a network link::
|
||||||
|
|
||||||
fakegocmd=trace pause; usb start; set autoload n; bootp;
|
fakegocmd=trace pause; usb start; set autoload n; bootp;
|
||||||
trace calls 10000000 1000000;
|
trace calls 10000000 1000000;
|
||||||
tftpput ${profbase} ${profoffset} 192.168.1.4:/tftpboot/calls
|
tftpput ${profbase} ${profoffset} 192.168.1.4:/tftpboot/calls
|
||||||
|
|
||||||
This starts up USB (to talk to an attached USB Ethernet dongle), writes
|
This starts up USB (to talk to an attached USB Ethernet dongle), writes
|
||||||
a trace log to address 10000000 and sends it to a host machine using
|
a trace log to address 10000000 and sends it to a host machine using
|
||||||
|
@ -272,16 +280,17 @@ This tool must be given the U-Boot map file and the trace data received
|
||||||
from running that U-Boot. It produces a text output file.
|
from running that U-Boot. It produces a text output file.
|
||||||
|
|
||||||
Options
|
Options
|
||||||
-m <map_file>
|
|
||||||
Specify U-Boot map file
|
|
||||||
|
|
||||||
-p <trace_file>
|
-m <map_file>
|
||||||
Specifiy profile/trace file
|
Specify U-Boot map file
|
||||||
|
|
||||||
|
-p <trace_file>
|
||||||
|
Specifiy profile/trace file
|
||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
|
|
||||||
- dump-ftrace
|
dump-ftrace
|
||||||
Write a text dump of the file in Linux ftrace format to stdout
|
Write a text dump of the file in Linux ftrace format to stdout
|
||||||
|
|
||||||
|
|
||||||
Viewing the Trace Data
|
Viewing the Trace Data
|
||||||
|
@ -301,17 +310,17 @@ The following suggestions may be helpful if you are trying to reduce boot
|
||||||
time:
|
time:
|
||||||
|
|
||||||
1. Enable CONFIG_BOOTSTAGE and CONFIG_BOOTSTAGE_REPORT. This should get
|
1. Enable CONFIG_BOOTSTAGE and CONFIG_BOOTSTAGE_REPORT. This should get
|
||||||
you are helpful overall snapshot of the boot time.
|
you are helpful overall snapshot of the boot time.
|
||||||
|
|
||||||
2. Build U-Boot with tracing and run it. Note the difference in boot time
|
2. Build U-Boot with tracing and run it. Note the difference in boot time
|
||||||
(it is common for tracing to add 10% to the time)
|
(it is common for tracing to add 10% to the time)
|
||||||
|
|
||||||
3. Collect the trace information as descibed above. Use this to find where
|
3. Collect the trace information as descibed above. Use this to find where
|
||||||
all the time is being spent.
|
all the time is being spent.
|
||||||
|
|
||||||
4. Take a look at that code and see if you can optimise it. Perhaps it is
|
4. Take a look at that code and see if you can optimise it. Perhaps it is
|
||||||
possible to speed up the initialisation of a device, or remove an unused
|
possible to speed up the initialisation of a device, or remove an unused
|
||||||
feature.
|
feature.
|
||||||
|
|
||||||
5. Rebuild, run and collect again. Compare your results.
|
5. Rebuild, run and collect again. Compare your results.
|
||||||
|
|
Loading…
Add table
Reference in a new issue