Thursday, May 9, 2013

Prepare your SD Card to boot a kernel

Read this post for the kernel build instructions.
Read this post if you're interested in how the pi boots once powered up.
Read this post for the partitioning instructions.

The following files are needed on your boot partition :

- bootcode.bin
- start.elf
- fixup.dat
- cmdline.txt
- kernel.img

To get (most of) them, you can either clone this repo : https://github.com/raspberrypi/firmware.git
or download the latest repository content here.

Note : The source code of bootcode.bin and start.elf is not open source.

First boot

For the first boot tryout, we will use the files provided by the raspberry pi foundation. We voluntarily omit the modules and the file system for now, we just want to see if the booting chain is OK until the startup of the init process.

Copy bootcode.bin, start.elf, fixup.dat and kernel.img to the boot partition of your SD card.
Create a text file named cmdline.txt right next to these files and add the following kernel parameters to it :
root=/dev/mmcblk0p1 rootdelay=2
Unmount the sdcard, plug it to your Pi, power up, and pray...

Here is the resulting display :



As we can see, the kernel boots perfectly until trying to start the init process :-)

Kernel image

We want to use our own-built kernel :
# Go the build output directory
 cd /arch/arm/boot 
# Backup the previous kernel image
mv /media/mysdcard/boot/kernel.img /media/mysdcard/boot/kernel.img.backup
# Copy the kernel image to your sd card and rename it
cp Image /media/mysdcard/boot/kernel.img
Here is the result with our image :



The result is identical (except for 2 or 3 different log traces). We can now step further ...



Cem SOYDING

Author & Editor

Senior software engineer with 12 years of experience in both embedded systems and C# .NET

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.

 
biz.