Sunday, November 29, 2015

Raspberry pi - prepare for Kernel Space Programming

Raspberry pi is one of the most popular SBC in market with ARM processor. It is very popular among students for playing as embedded stuff.

There are few points, need to noted down, while working or playing with Raspberry pi.

1. SDCard shows 56 MB, while I've 4 / 8 / 16 GB etc.

The reason, windows cannot read the actual size of SDCard is, its reading only the boot partition. To get rid of this problem, its advised to use SDFormatter.

2. Which image to Install ?

Default Raspberry pi gives two type of installation image.
        1. NOOB -- completely for beginner. I'd say for those who have no / less knowledge about linux.

        2. Raspbian -- A good place to start learning with Raspberry pi. Usually WHEEZY image is popular as starting. If you've smaller SDCard, and no requirement of Desktop, you may choose Jessie Lite minimum version.

3. After Install rpi, df -h shows different size than actual one.

You need to expand the file system. You can do it by using command


or, can use fdisk to delete and make new partition.

restart the rpi. While it back, you need to resize the latest partition with ext2.

   sudo resize2fs -p /dev/mmcblk0p2

4. Need to install linux-headers to program and compile kernel space programs.

This thing brings a lot of problem, trouble and solutions. Its possible to download the separate linux-headers for system Kernel version from here.

And, installing it with dpkg. But these header has dependencies of gcc-4.7 and there after CPP-4.7. These packages could be found

$ wget

$ wget wget

$ wget

In this case you need to create softlink, with installed source and in /lib/modules directory.

 ln –s /usr/src/linux-headers-3.18.11+ /lib/modules/3.18.11+/build

But if you don't want to bother all of these, You better use $ sudo rpi-source

You've some pre-requisite to use $sudo rpi-source

$ sudo wget -O /usr/bin/rpi-source && sudo chmod +x /usr/bin/rpi-source && /usr/bin/rpi-source -q --tag-update

$ sudo apt-get install -y gcc-4.8 g++-4.8  [you may need to apt-get update before]

Set gcc-4.8 linked in /etc/alternatives

$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 20

$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50

You probably need ncurse.

$ sudo apt-get install libncurses5-dev

It required minimum 900 MB free space in SDCard. If there has not enough space to install the headers, try look to uninstall unnecessary programs.

For example, if you installed raspberry pi with Desktop, and you needn't any GUI, it better to uninstall these,

$ sudo apt-get remove --auto-remove --purge 'libx11-.*'

Now you can run it ->

$sudo rpi-source

After everything downloaded and installed, go to the installed directory of linux-headers [e.g. linux-bb6b4b6b331680bed807605685572d727638bb51/ ]

- run ..

$ sudo make prepare

The rpi is ready to use to kernel_space programming.

No comments:

Post a Comment