In the previous post I said that I was brewing Linux for my Raspberry Pi. And here it is, a freshly made Linux running on my Raspberry 🙂
Obviously there are available tons of resources out there showing how to build Linux using Buildroot. I would like to pointed out specifically two references that I consult to: this and that. I am using Buildroot version 2017.02 downloaded from the git repository.
Buildroot builds Linux systems according to a config file supplied to it. There are over a thousand of configurations can be made in the config file. You are free to customized all those configurations in the config menu. But the easier path is also available — start with the basic predefined configurations and make some tweaks from there. Go into the buildroot directory, and issue make list-defconfigs. There are tens of platform configurations ready to use. Basically the command lists the contents of configs directory. Have a look on those text files. Since my board is Raspberry Pi B, then I choose raspberrypi_defconfig. To use the configuration, type make raspberrypi_defconfig. After that, issue make menuconfig to bring up the configuration menu. To select a package in the menu press ‘y‘, while to unselect press ‘n’.
In my case, the kernel CUSTOM_REPO_VERSION is set by the defconfig to 1ebe8d4a4c96cd6a90805c74233a468854960f67. For unknown reasons, this does not work — it does the full git clone and gets stuck. Then I change it to a specific version rpi-4.4.y, and it works.
Since I don’t have a USB keyboard, I think it would be nice to do ssh login to the Raspberry Pi. These are what I do:
- Add ssh server (dropbear) from Target packages —> Networking applications —> dropbear
- System configuration —> Enable root login with password. I find out that by default it is not allowed to do ssh-login without password
- System configuration —> Network interface to configure through DHCP. Type in eth0
Now we are ready to build the Linux by issuing make 2>&1 | tee build.log. The 2>&1 redirects stderr to be logged and printed as well. Be patient since it takes hours to complete!
When it is finished, the image in ./output/images/sdcard.img is generated. It contains two partitions, one is boot partition and the other is root file system partition. Previously, I have installed Raspbian Jessie on my 16 GB SD card using NOOBS installation. And a few days ago I just added piCore 9.0 side by side with the Raspbian. Now I will use the same trick with that of piCore OS, to keep those three OS on my SD Card. To accomodate the newly created root file system, I create another partition on my SD Card (/dev/mmcblk0p9). The picture below shows the partition layout.
The contents of /boot partition in sdcard.img is copied into /boot (/dev/mmcblk0p6). While the contents of /rootfs is copied into /custom_root (/dev/mmcblk0p9). The last step is to modify the file /boot/cmdine.txt. By default, the rootfs location is in root=/dev/mmcblk0p2. I change it to root=/dev/mmcblk0p9 to indicate the actual location. Put the card on the Rasperry Pi, power-on the board, and voila…Welcome to Linux!
I also install isc-dhcp-server on my Ubuntu laptop, which is connected to the Raspberry via ethernet cable. When the Raspberry boots up, it is given an IP address by the Ubuntu laptop. So I can do ssh-login to the Raspberry, like shown below. Nice!