Monday, December 24, 2012

First Build Steps: the Bootloaders and the Kernel


Okay, now that I have the sources, it's time to try some builds from them.

First, I'll do the bootloaders and the kernel because they're self-contained and have their own special instructions. If I'm going to fail, I want to fail fast. I use TI's directions for both the bootloaders, and
the kernel.

I'll stash the script I used for these two steps here.

I'd like to know how long each step takes, so I've instrumented the script with timing info. Doing this is a good excuse to use a couple of tricks.

Trick 1
To capture the info, I use set -x, which echoes each command as it's executed, and then set $PS4, the prompt issued before those echoes, to print the time.
PS4='[ $(date +%T) ] 'set -x
This time-stamps every command in the script as it's run.

Trick 2

I'd also like to mark off bigger blocks, so I can see when major sections and subsections start.   For this, I use another trick -- the colon command.

':' is a real command -- a no-op. In really old Unixes, ':' was in /bin, but today it's a shell built-in. It has a variety of uses, but in this case, I just use it to mark off big chunks, like this:
: == Name of Chunk
Paired with trick 1, from above, when the shell sees this command, it time-stamps it, then echoes it, like this.
[ 12:04:00 ] : == Name of Chunk
I capture the output, I can find the chunks with this command:
grep '==' /tmp/build-bootloader-and-kernel.OUT
I use a pair of equals signs because they don't occur in most shell commands. Subsections get four equals signs, sub-sub-sections, six, and so on. The grep, above, finds all these.

How long dose building this pair of pieces take? Three minutes for the bootloaders, twenty minutes for the kernel. Voila!
[ 17:51:39 ] : == ./build-bootloader-and-kernel: BEGIN[ 17:51:39 ] : ==== Build u-boot[ 17:54:18 ] : ==== Build the kernel[ 18:15:35 ] : == ./build-bootloader-and-kernel: SUCCESS

No comments:

Post a Comment