At this moment, I have played with my Raspberry Pi B for quite some time. Instead of using the standard Raspbian Jessie OS, I am curious about running alternative OS. I am looking for something much simpler than the full featured Raspbian Jessie. The reason I am doing this is because I want to comprehend the internal working of embedded Linux. I aim to understand the detail processes of building the Linux OS, and steps involved from power-on, running user apps, until power-off. I suppose the simpler the system, the easier to learn. Back to the alternative OS, it should be lightweight and fast to boot up. One of the options that I encounter — and looks promising — is piCore. It is the Raspberry Pi porting of TinyCore OS.
Here I describe how I install piCore 9.0 on my Raspberry Pi B. piCore-9.0.zip compressed image is downloaded from here. Extract it and you will have a 51.4 MB piCore image. According to the official installation guide the image can be extracted directly on SD Card using dd command on Linux or Win32 Disk Imager on Windows. However, my SD card already contains the Raspbian Jessie (using NOOBS image), and I still want to keep it there. So, I am trying to copy the image contents manually in a way that the Raspbian sits still on my SD Card. Later, I can revert back to the Raspbian Jessie. This workaround will just work because of the booting mechanisms of NOOBS installation. A nice explanation can be found here.
First, go to the directory containing the image and issue fdisk -l piCore-9.0.img command to list the partitions and its corresponding start sector.
Disk piCore-9.0.img: 49 MiB, 51380224 bytes, 100352 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x0009bf4f Device Boot Start End Sectors Size Id Type piCore-9.0.img1 8192 77823 69632 34M c W95 FAT32 (LBA) piCore-9.0.img2 77824 100351 22528 11M 83 Linux
It can be seen that the unit sector size is 512 bytes, and there are two images. So, create two directories for mounting those two images, let’s say: mkdir picore_1 and picore_2. Then mount the images on the created directories:
sudo mount -o loop,offset=$((512*8192)) piCore-9.0.img ./picore_1 sudo mount -o loop,offset=$((77824*8192)) piCore-9.0.img ./picore_2
picore_1 contains the Linux kernel, Device Tree Blobs, initramfs, and booting parameters. All of them will be copied in the /boot partition on my SD Card. But, before copying, I have created a directory /boot/rpi-boot and moved all the exisiting files in /boot to /boot/rpi-boot. By doing so, I can still use the Raspian OS in the future by moving them back into the parent directory, i.e. /boot.
picore_2 only contains a single tce directory. It is copied to /root partition on my SD Card. Now, the SD Card can be put on the Raspberry Pi, and power-on the board. If everything goes well, piCore will boot into command line mode. To install TC desktop packages, issue: tce-load -wi TC. It will download all necessary packages from the repository. Surely, this assumes that internet access has been provided via LAN connection. After downloading has finished, issue command filetool.sh -b to make all settings persistent. So the settings will be automatically loaded on next boots.Now, we can fire up the desktop mode by issuing startx.
Next time we reboot piCore it will automatically go into desktop mode. The video below shows the piCore booting on my Raspberry Pi B. Note that I have enabled showapps boot parameter in /boot/cmdline.txt so that the loaded modules get printed on the screen. It is surprising to me that the overall booting time is not faster than that of Raspbian OS. It is even slower, I think.
At the time of this writing, available apps ported to piCore are still very limited. The only web browser you can install is Dillo 3. Not much can be explored as an end-user. Previously I am thinking to run Firefox or Chromium to compare the performance when run in Raspbian OS, since piCore is advertised to be fast due to its operation that is fully run in RAM.
I also compare the content of /boot partition of Raspbian Jessie and piCore. I found out that there is no initramfs in the Raspbian Jessie. I suppose it is bundled into the kernel image.
It is worth to mention that for unknown reasons sometimes the extended modules do not get loaded during boot-up. And no information whatsoever is spilled out to notify this situation. It try to change the boot parameter to waitusb=5 for example, to give (indirectly) time for the SD Card to get ready. Although I have not done an exhausted test, but it seems to work. Still, I am not sure whether it is the root of cause.
In the meantime, I am still running buildroot to automate the building process of another Linux (official RPi) for my Raspberry Pi. It does take a long time since all the source codes are downloaded from the repositories and then get compiled. Can’t wait to see the result!