Showing posts with label kernel. Show all posts
Showing posts with label kernel. Show all posts

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 ...



Friday, April 19, 2013

LINUX commands related to kernel

dmesg

The dmesg command can be used to examine or control the kernel ring buffer. 
Ring buffer
A ring buffer is a cyclic data structure similar to a normal buffer having a fixed size but it is managed in such a way that the newest entries are recorded, and if required, only the oldest entries are removed to keep the size of the buffer constant. Just think about a ring as if it reaches the end point it will start from the beginning.
The kernel Ring buffer
Also called the Kernel Log Buffer, it is a kind of Ring Buffer which contains messages related to the kernel and its different modules. For example it prints messages when any new kernel module is loaded or when a new file-system is registered in the kernel etc. The Linux kernel outputs these messages which are of great help in debugging and troubleshooting although it contains a great amount of noise. These messages are further classified into log levels depending upon the severity of the message.
The Log Level of Kernel Messages.
LOG_EMERG system is unusable
LOG_ALERT action must be taken immediately
LOG_CRIT critical conditions
LOG_ERR error conditions
LOG_WARNING warning conditions
LOG_NOTICE normal, but significant, condition
LOG_INFO informational message
LOG_DEBUG debug-level message

 ---------------------------------------------------------------------------------------------------------------------------------

uname -r

print the kernel release.

 ---------------------------------------------------------------------------------------------------------------------------------

rpm -q kernel (RedHat/CentOS)

dpkg --list | grep linux-image (Ubuntu, debian)

list all installed kernel and its version.

 ---------------------------------------------------------------------------------------------------------------------------------

lsmod

show the status of modules in the Linux Kernel.

---------------------------------------------------------------------------------------------------------------------------------

ldd

print shared library dependencies of a binary

---------------------------------------------------------------------------------------------------------------------------------

 
biz.