If you want to use grabserial with minicom on the same serial port without conflict, for example to temporarily set a boot parameter or specify a different kernel image without changing the parameters in flash, you could follow this procedure:

+

* Prepare the grabserial command in one window but don't hit enter.

+

* Open minicom and set the bootloader environment, bootargs, etc. and tftp the kernel.

+

* Use one bootloader command to delay a few seconds and boot. For u-boot this is done with something like: "sleep 5; bootm 0x80000000".

Introduction

grabserial is a small program which reads a serial port and writes the
data to standard output. The main purpose of this tool is to collect
messages written to the serial console from a target board running
Linux, and save the messages on a host machine.

Older versions

pyserial (required python library)

grabserial requires the python "serial" module. This module is not shipped with
most distributions of python by default. On some recent distributions of Linux
pyserial is available as a package. For example, to install it on Fedora 12,
do this (as root): 'yum -y install pyserial'. The BeagleBoard with Angstrom needs a 'opkg install python-pyserial'.

Here's a copy you can install if you don't have it.
(You can check if you already have it by typing:
'python', then "import serial" in the interactive python interpreter.

To install this, download the archive, unzip it, and following the installation
instructions in pyserial-2.2/README.txt.

The latest Pyserial can be obtained from: [1]
The current version as of November 2011 is 2.6, which is newer than what I've
got here.

Usage

The grabserial program is very simple, but it provides some useful
extra features that make it more than a mere 'cat' program.

Use 'grabserial -h' to see online usage for the program.

You can specify the serial configuration options, including the Linux
device node to use, and the port speed settings on the grabserial
command line. If no options are specified, grabserial uses serial port
/dev/ttyS0, at 115200 baud with "8, None and 1" (8N1)
settings.

Normally, the program runs in an infinite loop,
reading from the serial port and writing to standard out until it is
interrupted by the user (usually by typing control-C). However, you
can tell the program to stop after a certain amount of time. This is
useful for including the script in automated test scenarios.

Also, you can tell the program to provide timing information for each
line received. This is useful to measure the time it takes for events
to happen on the target. A common thing to measure on
a target running embedded Linux is bootup time.
With grabserial, you can specify a pattern
to match against the lines read from the serial port. When this
pattern is seen, it sets a "base time", and all subsequent time values
printed out will be relative to this base. Thus, you can customize
the start time for the time measurements, to make it easier to see the
duration of events in the system.

Usage Examples

Here are some examples of use:

grabserial

This will echo data seen on device /dev/ttyS0, until the user presses ctrl-C.

This opens /dev/ttyUSB0, at baud rate 115200, and 8-bit chars, No parity and 1 stop bit.
This will capture and display data for 30 seconds, putting a timestamp on each line
received, and restarting the timestamp at 0 when a line containing "Kernel start" is seen.
The '-v' makes grabserial verbose (printing some extra messages before starting.

If you want to use grabserial with minicom on the same serial port without conflict, for example to temporarily set a boot parameter or specify a different kernel image without changing the parameters in flash, you could follow this procedure:

Prepare the grabserial command in one window but don't hit enter.

Open minicom and set the bootloader environment, bootargs, etc. and tftp the kernel.

Use one bootloader command to delay a few seconds and boot. For u-boot this is done with something like: "sleep 5; bootm 0x80000000".

Sample Output

Here is sample output from grabserial. This shows the reboot of an ARM-based system (OMAP Starter Kit).
Note that the U-Boot prompt appears at time 0.313168. The grabserial command specifies to restart the
timestamps when "Starting kernel.*" is seen. This happens at time 8.376117 after grabserial save the
first character on the serial port. (Use the -l option to time from the start of grabserial.)

Note that the first kernel message appears 1.517790 seconds later. Actually, the kernel starts well before this,
but it takes this long before the kernel to initialize the serial port and start emitting messages. You will
notice that a bunch of messages come out in rapid succession. These are messages that were queued up during
the boot, before the serial console was initialized.

Usage Notes

Timing of kernel printk messages

Note that the kernel printk messages are normally sent to the console at the time that the printk()
function is called in the kernel. So the timings for printk messages are pretty good at indicating the
time where a particular activity occured. However, during early boot (and specifically, before the serial
console is initialized) the kernel message are stored in the log buffer. By default, all of the
messages between kernel start and console initialization are dumped to the serial port at the time of console
initialization, which gives these events an incorrect time.

You can help correct this somewhat using the early printk option with the kernel. On ARM, you need to
configure the kernel for low-level debugging to enable this feature. To do this, set the following in your kernel configuration:

CONFIG_DEBUG_LL=Y

CONFIG_EARLY_PRINTK=Y

Compile and install your kernel.

Now, kernel printk messages should be emitted to the serial port, during early boot, much sooner and closer to their actual creation, than without these options.

Finding the time to decompress the kernel

On the ARM architecture, during kernel decompression the decompressor code writes information to
the same line of output for the start and end of the operation. Since grabserial uses line terminations
as part of time measurements, grabserial without any special options would not be able to measure this
operation.

The line starts with "Uncompressing Linux...". When the decompression is complete, the code
writes on the same line: "done, booting the kernel".

You can use the grabserial "-i" option to measure the time a particular string appears on the port,
whether or not the string is at the beginning of the line. By using both the base time pattern matching,
and the "instant time" (-i) pattern matching, you can determine the time for the decompression operation.