EmbeddedLinux – Kernel

This is the continuation of series of blogs about cross compiling, loading bootloader, linux kernel and filesystem into an embedded development platform. Pls check the previous blog for the target hardware and setup that is needed.

In short, the embedded development platform is Banana Pro from Lemaker with MicroSD card. We have already partitioned the card in the first blog and pls look into it for more info.

A little bit about linux kernel

Linux Kernel, this is the biggest open source project for starters. This is the most dominant O.S in the world and is the de facto platform which the embedded designers chooses nowadays even for real time purposes.

If you have not heard about it, but if you have a smartphone based on android platform, then you are actually using linux kernel. Internet literally runs on machines based on linux kernel. Let’s put it this way, information technology world depends on linux to achieve its functionality. 98% of the TOP500 supercomputers use linux as it’s core O.S. It runs on various embedded devices such as routers, wireless access points, smart TVs, NAS appliances and the list goes on and on.

Getting the kernel source code

The best place to get the kernel source code is from http://www.kernel.org website. It is always a good option to choose the stable version of the kernel, and current stable kernel version is 4.9.10 (at the time when this document is written). Below is command for getting the 4.9.10 stable kernel version.

Vostro bpro # wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.9.10.tar.xz

Pls look into the website to know more about available list of releases that is there.

The kernel source comes in compressed version and we need to unzip it to access the source code.

Vostro bpro # tar xf linux-4.9.10.tar.xz
Vostro bpro # cd linux-4.9.10/
Vostro linux-4.9.10 #

The directory structure looks very similar to that of the U-Boot bootloader which we have already seen. In fact U-boot took linux kernel as reference and migrated to this format. Since many of the directories were explained in the U-Boot blog itself let us look into the details about the missing ones.

block –> Contains support for block devices.

crypto –> Contains support for cryptography. Linux kernel supports a large set of cryptographic algorithms and its supported protocols. Many modifications are made for each and every release.If you deeply look into the cryptographic support provided by the kernel you will understand why linux kernel is one of the safest kernel’s to use.

drivers –> Contains support for humongous set of peripherals devices. This contains almost 60 percent of the kernel code.

firmware –> Contains binary or hex files that should be loaded onto the devices when they come up. This can happen either on boot or when the devices is inserted into the target. These are mostly provided by the device vendor itself.

fs –> Contains support for a large set of filesystem. This is also another major portion of the kernel code. Linux kernel has the best support when it comes to filesystem. In fact linux kernel provides the best possible filesystem support of all the O.S that exists in the world today.

init –> Contains the initialization code which is non architecture specific. Most subsystems are initialized from here like interrupts, software interrupts, memory management, timers etc.

kernel –> Contains the actual kernel related code like scheduler, timer, irqs and threads. You will be surprised to see that the kernel directory contains a small list of files only.

lib –> Contains support for libraries. These are helper library functions which includes support for algorithms used for encryption, checking the integrity of the files and etc.

mm –> Contains code related to the memory management. This is a very important feature of the linux kernel. Virtual memory is one key functionality provided by the modern O.Ses today. This is very much architecture specific and a very complex subject to discuss. ARM processors with MMU can support upto 3 levels of page tables which is pretty much complex.

net –> Contains code for networking support. This is also another major subsystem in the linux kernel. Almost all the networking protocols are supported by the kernel and internet literally runs with the support of linux.

The other directories are self explanatory.

Get the proper config and start the compilation.

As with the bootloader each boards are categorised by a specific config file which comes with the linux kernel itself. It is best advised to use the already available config file as it has been tested and is known to be working. All the configs files related to development platform are stored in their corresponding architecture specific directory.

For example in case of ARM processor, all related boards configs are kept at arch/arm/configs/. You can check this for other architectures also.

Vostro linux-4.9.10 # ls -l arch/arm/configs/

The above command gives us the list of available config files supported by this kernel. In this plethora of config files, “sunxi_defconfig” is the config file which we need to use.

Setup the toolchain

As we have already downloaded the toolchain and untarred it for compiling the bootloader we just need to setup up the path of the cross tool to compile the kernel.

Vostro linux-4.9.10 # export PATH=/Sourcefiles/crosstool/arm-2013.05/bin:$PATH
Vostro linux-4.9.10 # export CROSS_COMPILE=arm-none-linux-gnueabi-
Vostro linux-4.9.10 # export ARCH=arm
Vostro linux-4.9.10 #

After setting up the cross tool, we can now use the already available config file to create a .config file.

Vostro linux-4.9.10 # cp arch/arm/configs/sunxi_defconfig .config

The output shows that the .config file was created. Let us check a few things here. When you execute the below command it will show the list of options/selections available for this kernel.

Vostro linux-4.9.10 # make menuconfig


Few things to note from the above image, at the top left corner it should show the architecture version for which we are compiling. In our case it is showing as ARM and it is the correct one. If it shows as x86 or anything else then the cross toolchain path has not been setup correctly. We can now exit this menu and start the compilation.


Pls look into the available options as it will help you to get a better understanding.

Compiling the kernel

Vostro linux-4.9.10 # make uImage LOADADDR=0x40000000 

uImage –> Creates a kernel image which contains headers understood by U-Boot.

dtbs –> Compile the device tree blobs (see below).

LOADADDR –> It is the physical address from which the kernel should start executing.

The above command will start the compilation process. It make take from few minutes to hours to compile the kernel depending upon the build machine hardware specs and the list of options we have chosen this kernel to support. In the below case it took 12 to 15 minutes to compile the kernel.

AS arch/arm/boot/compressed/piggy.o

LD arch/arm/boot/compressed/vmlinux

OBJCOPY arch/arm/boot/zImage

Kernel: arch/arm/boot/zImage is ready

UIMAGE arch/arm/boot/uImage

“mkimage” command not found – U-Boot images will not be built

arch/arm/boot/Makefile:77: recipe for target ‘arch/arm/boot/uImage’ failed

make[1]: *** [arch/arm/boot/uImage] Error 1

arch/arm/Makefile:330: recipe for target ‘uImage’ failed

make: *** [uImage] Error 2

Vostro linux-4.9.10 # 

If you get an error like this don’t panic. Actually it needs a tool “mkimage” with which it should be able to create the uImage. It is provided by the package u-boot-tools.

Dependency Installation (if any)

Vostro linux-4.9.10 #  apt install u-boot-tools

Now rerun the above make command again so that uImage is created.

Vostro linux-4.9.10 # make uImage LOADADDR=0x40000000 

CC arch/arm/boot/compressed/fdt.o
CC arch/arm/boot/compressed/atags_to_fdt.o
SHIPPED arch/arm/boot/compressed/lib1funcs.S
AS arch/arm/boot/compressed/lib1funcs.o
SHIPPED arch/arm/boot/compressed/ashldi3.S
AS arch/arm/boot/compressed/ashldi3.o
SHIPPED arch/arm/boot/compressed/bswapsdi2.S
AS arch/arm/boot/compressed/bswapsdi2.o
LD arch/arm/boot/compressed/vmlinux
OBJCOPY arch/arm/boot/zImage
Kernel: arch/arm/boot/zImage is ready
UIMAGE arch/arm/boot/uImage
Image Name: Linux-4.9.10
Created: Thu Feb 16 21:12:30 2017
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 3550936 Bytes = 3467.71 kB = 3.39 MB
Load Address: 40000000
Entry Point: 40000000
Kernel: arch/arm/boot/uImage is ready
Vostro linux-4.9.10 #

We have compiled our own linux kernel image.The compiled image should be available in  “arch/arm/boot/”. Pls note that i have cut short the above log to show the final steps only. You may see different logs but as long as uImage is getting created there is nothing to worry.

We now need to compile the device tree with the below make command

Vostro linux-4.9.10 # make dtbs
CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
CHK include/generated/bounds.h
CHK include/generated/timeconst.h
CHK include/generated/asm-offsets.h
CALL scripts/checksyscalls.sh
DTC arch/arm/boot/dts/sun4i-a10-a1000.dtb
DTC arch/arm/boot/dts/sun4i-a10-ba10-tvbox.dtb
DTC arch/arm/boot/dts/sun4i-a10-chuwi-v7-cw0825.dtb
DTC arch/arm/boot/dts/sun4i-a10-cubieboard.dtb
DTC arch/arm/boot/dts/sun4i-a10-dserve-dsrv9703c.dtb
DTC arch/arm/boot/dts/sun4i-a10-gemei-g9.dtb
DTC arch/arm/boot/dts/sun4i-a10-hackberry.dtb
DTC arch/arm/boot/dts/sun4i-a10-hyundai-a7hd.dtb
DTC arch/arm/boot/dts/sun4i-a10-inet1.dtb
DTC arch/arm/boot/dts/sun4i-a10-inet97fv2.dtb
DTC arch/arm/boot/dts/sun4i-a10-inet9f-rev03.dtb
DTC arch/arm/boot/dts/sun4i-a10-itead-iteaduino-plus.dtb
DTC arch/arm/boot/dts/sun4i-a10-jesurun-q5.dtb
DTC arch/arm/boot/dts/sun4i-a10-marsboard.dtb
DTC arch/arm/boot/dts/sun4i-a10-mini-xplus.dtb
DTC arch/arm/boot/dts/sun4i-a10-mk802.dtb
DTC arch/arm/boot/dts/sun4i-a10-mk802ii.dtb
DTC arch/arm/boot/dts/sun4i-a10-olinuxino-lime.dtb
DTC arch/arm/boot/dts/sun4i-a10-pcduino.dtb
DTC arch/arm/boot/dts/sun4i-a10-pcduino2.dtb
DTC arch/arm/boot/dts/sun4i-a10-pov-protab2-ips9.dtb
DTC arch/arm/boot/dts/sun5i-a10s-auxtek-t003.dtb
DTC arch/arm/boot/dts/sun5i-a10s-auxtek-t004.dtb
DTC arch/arm/boot/dts/sun5i-a10s-mk802.dtb
DTC arch/arm/boot/dts/sun5i-a10s-olinuxino-micro.dtb
DTC arch/arm/boot/dts/sun5i-a10s-r7-tv-dongle.dtb
DTC arch/arm/boot/dts/sun5i-a10s-wobo-i5.dtb
DTC arch/arm/boot/dts/sun5i-a13-difrnce-dit4350.dtb
DTC arch/arm/boot/dts/sun5i-a13-empire-electronix-d709.dtb
DTC arch/arm/boot/dts/sun5i-a13-empire-electronix-m712.dtb
DTC arch/arm/boot/dts/sun5i-a13-hsg-h702.dtb
DTC arch/arm/boot/dts/sun5i-a13-inet-98v-rev2.dtb
DTC arch/arm/boot/dts/sun5i-a13-olinuxino.dtb
DTC arch/arm/boot/dts/sun5i-a13-olinuxino-micro.dtb
DTC arch/arm/boot/dts/sun5i-a13-q8-tablet.dtb
DTC arch/arm/boot/dts/sun5i-a13-utoo-p66.dtb
DTC arch/arm/boot/dts/sun5i-gr8-evb.dtb
DTC arch/arm/boot/dts/sun5i-r8-chip.dtb
DTC arch/arm/boot/dts/sun6i-a31-app4-evb1.dtb
DTC arch/arm/boot/dts/sun6i-a31-colombus.dtb
DTC arch/arm/boot/dts/sun6i-a31-hummingbird.dtb
DTC arch/arm/boot/dts/sun6i-a31-i7.dtb
DTC arch/arm/boot/dts/sun6i-a31-m9.dtb
DTC arch/arm/boot/dts/sun6i-a31-mele-a1000g-quad.dtb
DTC arch/arm/boot/dts/sun6i-a31s-colorfly-e708-q1.dtb
DTC arch/arm/boot/dts/sun6i-a31s-cs908.dtb
DTC arch/arm/boot/dts/sun6i-a31s-inet-q972.dtb
DTC arch/arm/boot/dts/sun6i-a31s-primo81.dtb
DTC arch/arm/boot/dts/sun6i-a31s-sina31s.dtb
DTC arch/arm/boot/dts/sun6i-a31s-sinovoip-bpi-m2.dtb
DTC arch/arm/boot/dts/sun6i-a31s-yones-toptech-bs1078-v2.dtb
DTC arch/arm/boot/dts/sun7i-a20-bananapi.dtb
DTC arch/arm/boot/dts/sun7i-a20-bananapi-m1-plus.dtb
DTC arch/arm/boot/dts/sun7i-a20-bananapro.dtb
DTC arch/arm/boot/dts/sun7i-a20-cubieboard2.dtb
DTC arch/arm/boot/dts/sun7i-a20-cubietruck.dtb
DTC arch/arm/boot/dts/sun7i-a20-hummingbird.dtb
DTC arch/arm/boot/dts/sun7i-a20-itead-ibox.dtb
DTC arch/arm/boot/dts/sun7i-a20-i12-tvbox.dtb
DTC arch/arm/boot/dts/sun7i-a20-icnova-swac.dtb
DTC arch/arm/boot/dts/sun7i-a20-lamobo-r1.dtb
DTC arch/arm/boot/dts/sun7i-a20-m3.dtb
DTC arch/arm/boot/dts/sun7i-a20-mk808c.dtb
DTC arch/arm/boot/dts/sun7i-a20-olimex-som-evb.dtb
DTC arch/arm/boot/dts/sun7i-a20-olinuxino-lime.dtb
DTC arch/arm/boot/dts/sun7i-a20-olinuxino-lime2.dtb
DTC arch/arm/boot/dts/sun7i-a20-olinuxino-lime2-emmc.dtb
DTC arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dtb
DTC arch/arm/boot/dts/sun7i-a20-orangepi.dtb
DTC arch/arm/boot/dts/sun7i-a20-orangepi-mini.dtb
DTC arch/arm/boot/dts/sun7i-a20-pcduino3.dtb
DTC arch/arm/boot/dts/sun7i-a20-pcduino3-nano.dtb
DTC arch/arm/boot/dts/sun7i-a20-wexler-tab7200.dtb
DTC arch/arm/boot/dts/sun7i-a20-wits-pro-a20-dkt.dtb
DTC arch/arm/boot/dts/sun8i-a23-evb.dtb
DTC arch/arm/boot/dts/sun8i-a23-gt90h-v4.dtb
DTC arch/arm/boot/dts/sun8i-a23-inet86dz.dtb
DTC arch/arm/boot/dts/sun8i-a23-ippo-q8h-v5.dtb
DTC arch/arm/boot/dts/sun8i-a23-ippo-q8h-v1.2.dtb
DTC arch/arm/boot/dts/sun8i-a23-polaroid-mid2407pxe03.dtb
DTC arch/arm/boot/dts/sun8i-a23-polaroid-mid2809pxe04.dtb
DTC arch/arm/boot/dts/sun8i-a23-q8-tablet.dtb
DTC arch/arm/boot/dts/sun8i-a33-et-q8-v1.6.dtb
DTC arch/arm/boot/dts/sun8i-a33-ga10h-v1.1.dtb
DTC arch/arm/boot/dts/sun8i-a33-inet-d978-rev2.dtb
DTC arch/arm/boot/dts/sun8i-a33-ippo-q8h-v1.2.dtb
DTC arch/arm/boot/dts/sun8i-a33-olinuxino.dtb
DTC arch/arm/boot/dts/sun8i-a33-q8-tablet.dtb
DTC arch/arm/boot/dts/sun8i-a33-sinlinx-sina33.dtb
DTC arch/arm/boot/dts/sun8i-a83t-allwinner-h8homlet-v2.dtb
DTC arch/arm/boot/dts/sun8i-a83t-cubietruck-plus.dtb
DTC arch/arm/boot/dts/sun8i-h3-bananapi-m2-plus.dtb
DTC arch/arm/boot/dts/sun8i-h3-nanopi-neo.dtb
DTC arch/arm/boot/dts/sun8i-h3-orangepi-2.dtb
DTC arch/arm/boot/dts/sun8i-h3-orangepi-lite.dtb
DTC arch/arm/boot/dts/sun8i-h3-orangepi-one.dtb
DTC arch/arm/boot/dts/sun8i-h3-orangepi-pc.dtb
DTC arch/arm/boot/dts/sun8i-h3-orangepi-pc-plus.dtb
DTC arch/arm/boot/dts/sun8i-h3-orangepi-plus.dtb
DTC arch/arm/boot/dts/sun8i-h3-orangepi-plus2e.dtb
DTC arch/arm/boot/dts/sun8i-r16-parrot.dtb
DTC arch/arm/boot/dts/sun9i-a80-optimus.dtb
DTC arch/arm/boot/dts/sun9i-a80-cubieboard4.dtb
Vostro linux-4.9.10 #

The device tree blobs should be available in “arch/arm/boot/dts/“. The device tree blob which belongs to  our target (banana pro) is “sun7i-a20-bananapro.dtb“.

Prepare the formatted Micro SD Card

Since we have the linux kernel image and its corresponding dtb file, now we need to copy the same into the formatted Micro SD Card’s boot partition. When the Micro SD Card was inserted into the build machine it was mounted at the below location.

Vostro linux-4.9.10 # mount
/dev/mmcblk0p2 on /media/kasi/root type ext4 (rw,nosuid,nodev,relatime,block_validity,delalloc,barrier,user_xattr,acl,uhelper=udisks2)
/dev/mmcblk0p1 on /media/kasi/BCCA-7937 type vfat (rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks2)

Pls note this will vary mostly from machine to machine so double check on where the Micro SD Card is mounted. From the above output, we can see that the Micro SD Card’s boot partition (Filesystem type is vfat) is mounted at /media/kasi/BCCA-7937. Now copy the uImage and device tree blob to that location.

Vostro linux-4.9.10 # cp arch/arm/boot/uImage /media/kasi/BCCA-7937/uImage-next
Vostro linux-4.9.10# cp arch/arm/boot/dts/sun7i-a20-bananapro.dtb /media/kasi/BCCA-7937/
Vostro linux-4.9.10 # sync

The reason i have renamed uImage to uImage-next is to show that it doesn’t really matter what is the name of the kernel image as long as it was compiled for the proper target.

Setup the bootloader

As we have copied the kernel image and the dtb to the MicroSD card’s boot partition we need to add one more file by the name boot.cmd to the boot partition. We can create this file in the build machine, copy the below contents to the that file and then copy that file back to the Micro SD card’s boot partition.

Below is the contents of boot.cmd file

Vostro bpro # cat boot.cmd
setenv bootargs console=ttyS0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
load mmc 0:1 0x49000000 sun7i-a20-bananapro.dtb
load mmc 0:1 0x46000000 uImage-next
bootm 0x46000000 – 0x49000000
Vostro bpro #

The contents of the file are pretty simple in short, we are just setting up the bootargs, copying the bootable kernel image and its dtb from MicroSD card into the RAM. We then ask the bootloader to boot the copied image from the main memory.

We also need to create a corresponding binary file boot.scr and copy the same to the MicroSD card’s boot partition.

Vostro bpro # mkimage -C none -A arm -T script -d boot.cmd boot.scr
Image Name:
Created: Thu Feb 16 22:18:54 2017
Image Type: ARM Linux Script (uncompressed)
Data Size: 222 Bytes = 0.22 kB = 0.00 MB
Load Address: 00000000
Entry Point: 00000000
Image 0: 214 Bytes = 0.21 kB = 0.00 MB

Copy the boot.cmd and boot.scr to the MicroSD card’s boot partition.

Vostro bpro # cp boot.cmd /media/kasi/BCCA-7937/
Vostro bpro # cp boot.scr /media/kasi/BCCA-7937/
Vostro bpro # sync
Vostro bpro #

So MicroSD card’s boot partition should at least have the four files:

  1. Linux kernel image.
  2. Device tree blob.
  3. boot.cmd
  4. boot.scr

Now remove the Micro SD card, insert it in the target and follow the procedure to boot from Micro SD card. It should boot with the kernel which we have compiled.

Flashing the kernel image

There are many to ways to test the built kernel image. If we are early in our development phase and trying to freeze on a kernel version to choose then it would be better to boot the built kernel through tftp. From U-Boot cli, using tftp we can directly load the uImage and dtbs into the RAM and start execution from there. If there are any issues with kernel like any crashes or it doesn’t load any subsystem or if you want to try any other kernel version it is as easy as resetting the device and from U-Boot prompt try to loading another kernel image of your choice. This kind of development is very fast and a much preferred one. We have not used that procedure here. We are going to load the kernel image into the Micro SD card and make sure the boot loader loads the uImage from there. It is like having a static image and we don’t want that to change with time. As you can guess in this method you can stop any time in the bootloader prompt and try to load the kernel image which you want to test. With this you atleast you have a working kernel image and believe me it is very much useful when you making frequent changes to the kernel,

Few points to note if no log messages are seen in the serial port

If the kernel is not booting up then try to change the cmdline parameter:

Default may be like :

CONFIG_CMDLINE=”root=/dev/mmcblk0p2 rootwait console=ttyO2,115200″

Now change this to :

CONFIG_CMDLINE=”root=/dev/mmcblk0p2 rootwait console=ttyO0,115200″

In my case the CONFIG_CMDLINE kernel parameter was empty and i manually added the details and then compiled.

This is the bootlog for the kernel which is loading.

#### Lets get Started ####

U-Boot SPL 2016.11-00138-g136179b-dirty (Feb 11 2017 - 19:25:04)
 DRAM: 1024 MiB
 CPU: 912000000Hz, AXI/AHB/APB: 3/2/2
 Trying to boot from MMC1
 U-Boot 2016.11-00138-g136179b-dirty (Feb 11 2017 - 19:25:04 +0530) Allwinner Technology

CPU: Allwinner A20 (SUN7I)
 Model: LeMaker Banana Pro
 I2C: ready
 DRAM: 1 GiB
 *** Warning - bad CRC, using default environment

Setting up a 720x576i composite-pal console (overscan 32x20)
 In: serial
 Out: vga
 Err: vga
 SCSI: SATA link 0 timeout.
 AHCI 0001.0100 32 slots 1 ports 3 Gbps 0x1 impl SATA mode
 flags: ncq stag pm led clo only pmp pio slum part ccc apst 
 Net: eth0: ethernet@01c50000
 starting USB...
 USB0: USB EHCI 1.00
 USB2: USB EHCI 1.00
 scanning bus 0 for devices... 1 USB Device(s) found
 scanning bus 2 for devices... 1 USB Device(s) found
 Hit any key to stop autoboot: 0 
 switch to partitions #0, OK
 mmc0 is current device
 Scanning mmc 0:1...
 Found U-Boot script /boot.scr
 reading /boot.scr
 286 bytes read in 18 ms (14.6 KiB/s)
 ## Executing script at 43100000
 reading sun7i-a20-bananapro.dtb
 34451 bytes read in 30 ms (1.1 MiB/s)
 reading uImage-next
 3551000 bytes read in 235 ms (14.4 MiB/s)
 ## Booting kernel from Legacy Image at 46000000 ...
  Image Name: Linux-4.9.10
  Image Type: ARM Linux Kernel Image (uncompressed)
  Data Size: 3550936 Bytes = 3.4 MiB
  Load Address: 40000000
  Entry Point: 40000000
  Verifying Checksum ... OK
 ## Flattened Device Tree blob at 49000000
  Booting using the fdt blob at 0x49000000
  Loading Kernel Image ... OK
  Loading Device Tree to 49ff4000, end 49fff692 ... OK

Starting kernel ...

[ 0.000000] Booting Linux on physical CPU 0x0
 [ 0.000000] Linux version 4.9.10 (root@Vostro) (gcc version 4.7.3 (Sourcery CodeBench Lite 2013.05-24) ) #1 SMP Thu Feb 16 21:12:23 IST 2017
 [ 0.000000] CPU: ARMv7 Processor [410fc074] revision 4 (ARMv7), cr=10c5387d
 [ 0.000000] CPU: div instructions available: patching division code
 [ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
 [ 0.000000] OF: fdt:Machine model: LeMaker Banana Pro
 [ 0.000000] Memory policy: Data cache writealloc
 [ 0.000000] psci: probing for conduit method from DT.
 [ 0.000000] psci: Using PSCI v0.1 Function IDs from DT
 [ 0.000000] percpu: Embedded 14 pages/cpu @ef7c3000 s24704 r8192 d24448 u57344
 [ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 260202
 [ 0.000000] Kernel command line: console=ttyS0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
 [ 0.000000] PID hash table entries: 4096 (order: 2, 16384 bytes)
 [ 0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
 [ 0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
 [ 0.000000] Memory: 1028912K/1046952K available (5120K kernel code, 302K rwdata, 1328K rodata, 1024K init, 266K bss, 18040K reserved, 0K cma-reserved, 260520K highmem)
 [ 0.000000] Virtual kernel memory layout:
 [ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB)
 [ 0.000000] fixmap : 0xffc00000 - 0xfff00000 (3072 kB)
 [ 0.000000] vmalloc : 0xf0800000 - 0xff800000 ( 240 MB)
 [ 0.000000] lowmem : 0xc0000000 - 0xf0000000 ( 768 MB)
 [ 0.000000] pkmap : 0xbfe00000 - 0xc0000000 ( 2 MB)
 [ 0.000000] modules : 0xbf000000 - 0xbfe00000 ( 14 MB)
 [ 0.000000] .text : 0xc0008000 - 0xc0600000 (6112 kB)
 [ 0.000000] .init : 0xc0800000 - 0xc0900000 (1024 kB)
 [ 0.000000] .data : 0xc0900000 - 0xc094bb00 ( 303 kB)
 [ 0.000000] .bss : 0xc094d000 - 0xc098fb3c ( 267 kB)
 [ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1
 [ 0.000000] Hierarchical RCU implementation.
 [ 0.000000] Build-time adjustment of leaf fanout to 32.
 [ 0.000000] RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=2.
 [ 0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=32, nr_cpu_ids=2
 [ 0.000000] NR_IRQS:16 nr_irqs:16 16
 [ 0.000000] arm_arch_timer: Architected cp15 timer(s) running at 24.00MHz (phys).
 [ 0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x588fe9dc0, max_idle_ns: 440795202592 ns
 [ 0.000008] sched_clock: 56 bits at 24MHz, resolution 41ns, wraps every 4398046511097ns
 [ 0.000020] Switching to timer-based delay loop, resolution 41ns
 [ 0.000520] clocksource: timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns
 [ 0.000744] clocksource: hstimer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 12741736309 ns
 [ 0.000954] Console: colour dummy device 80x30
 [ 0.000988] Calibrating delay loop (skipped), value calculated using timer frequency.. 48.00 BogoMIPS (lpj=240000)
 [ 0.001003] pid_max: default: 32768 minimum: 301
 [ 0.001108] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
 [ 0.001120] Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes)
 [ 0.001831] CPU: Testing write buffer coherency: ok
 [ 0.002188] /cpus/cpu@0 missing clock-frequency property
 [ 0.002209] /cpus/cpu@1 missing clock-frequency property
 [ 0.002223] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
 [ 0.002259] Setting up static identity map for 0x40100000 - 0x40100058
 [ 0.014013] CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
 [ 0.014121] Brought up 2 CPUs
 [ 0.014143] SMP: Total of 2 processors activated (96.00 BogoMIPS).
 [ 0.014150] CPU: All CPU(s) started in HYP mode.
 [ 0.014155] CPU: Virtualization extensions available.
 [ 0.015039] devtmpfs: initialized
 [ 0.025102] VFP support v0.3: implementor 41 architecture 2 part 30 variant 7 rev 4
 [ 0.025424] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
 [ 0.025508] pinctrl core: initialized pinctrl subsystem
 [ 0.026553] NET: Registered protocol family 16
 [ 0.026916] DMA: preallocated 256 KiB pool for atomic coherent allocations
 [ 0.028310] hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint registers.
 [ 0.028323] hw-breakpoint: maximum watchpoint size is 8 bytes.
 [ 0.043731] reg-fixed-voltage usb1-vbus: could not find pctldev for node /soc@01c00000/pinctrl@01c20800/usb1_vbus_pin@0, deferring probe
 [ 0.043789] reg-fixed-voltage usb2-vbus: could not find pctldev for node /soc@01c00000/pinctrl@01c20800/usb2_vbus_pin@0, deferring probe
 [ 0.044658] reg-fixed-voltage gmac-3v3: could not find pctldev for node /soc@01c00000/pinctrl@01c20800/gmac_power_pin@0, deferring probe
 [ 0.044703] reg-fixed-voltage vmmc3: could not find pctldev for node /soc@01c00000/pinctrl@01c20800/vmmc3_pin@0, deferring probe
 [ 0.045188] SCSI subsystem initialized
 [ 0.045702] usbcore: registered new interface driver usbfs
 [ 0.045764] usbcore: registered new interface driver hub
 [ 0.045823] usbcore: registered new device driver usb
 [ 0.046072] pps_core: LinuxPPS API ver. 1 registered
 [ 0.046081] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
 [ 0.046104] PTP clock support registered
 [ 0.046337] Advanced Linux Sound Architecture Driver Initialized.
 [ 0.047329] clocksource: Switched to clocksource arch_sys_counter
 [ 0.048193] simple-framebuffer 7fe79000.framebuffer: framebuffer at 0x7fe79000, 0x178e00 bytes, mapped to 0xf0900000
 [ 0.048211] simple-framebuffer 7fe79000.framebuffer: format=x8r8g8b8, mode=656x536x32, linelength=2880
 [ 0.054974] Console: switching to colour frame buffer device 82x33
 [ 0.061038] simple-framebuffer 7fe79000.framebuffer: fb0: simplefb registered!
 [ 0.070899] NET: Registered protocol family 2
 [ 0.071494] TCP established hash table entries: 8192 (order: 3, 32768 bytes)
 [ 0.071578] TCP bind hash table entries: 8192 (order: 4, 65536 bytes)
 [ 0.071706] TCP: Hash tables configured (established 8192 bind 8192)
 [ 0.071786] UDP hash table entries: 512 (order: 2, 16384 bytes)
 [ 0.071851] UDP-Lite hash table entries: 512 (order: 2, 16384 bytes)
 [ 0.072073] NET: Registered protocol family 1
 [ 0.072630] RPC: Registered named UNIX socket transport module.
 [ 0.072646] RPC: Registered udp transport module.
 [ 0.072652] RPC: Registered tcp transport module.
 [ 0.072658] RPC: Registered tcp NFSv4.1 backchannel transport module.
 [ 0.073358] hw perfevents: enabled with armv7_cortex_a7 PMU driver, 5 counters available
 [ 0.074455] futex hash table entries: 512 (order: 3, 32768 bytes)
 [ 0.075395] workingset: timestamp_bits=30 max_order=18 bucket_order=0
 [ 0.084942] NFS: Registering the id_resolver key type
 [ 0.084994] Key type id_resolver registered
 [ 0.085003] Key type id_legacy registered
 [ 0.085910] bounce: pool size: 64 pages
 [ 0.086168] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 249)
 [ 0.086180] io scheduler noop registered
 [ 0.086188] io scheduler deadline registered (default)
 [ 0.086369] io scheduler cfq registered
 [ 0.091873] sun7i-a20-pinctrl 1c20800.pinctrl: initialized sunXi PIO driver
 [ 0.159910] Serial: 8250/16550 driver, 8 ports, IRQ sharing disabled
 [ 0.163184] console [ttyS0] disabled
 [ 0.183386] 1c28000.serial: ttyS0 at MMIO 0x1c28000 (irq = 44, base_baud = 1500000) is a U6_16550A
 [ 0.860034] console [ttyS0] enabled
 [ 0.887063] 1c29000.serial: ttyS1 at MMIO 0x1c29000 (irq = 45, base_baud = 1500000) is a U6_16550A
 [ 0.919511] 1c29c00.serial: ttyS2 at MMIO 0x1c29c00 (irq = 46, base_baud = 1500000) is a U6_16550A
 [ 0.929281] [drm] Initialized
 [ 1.027402] ahci-sunxi 1c18000.sata: controller can't do PMP, turning off CAP_PMP
 [ 1.034922] ahci-sunxi 1c18000.sata: SSS flag set, parallel bus scan disabled
 [ 1.042117] ahci-sunxi 1c18000.sata: AHCI 0001.0100 32 slots 1 ports 3 Gbps 0x1 impl platform mode
 [ 1.051088] ahci-sunxi 1c18000.sata: flags: ncq sntf stag pm led clo only pio slum part ccc 
 [ 1.060607] scsi host0: ahci-sunxi
 [ 1.064386] ata1: SATA max UDMA/133 mmio [mem 0x01c18000-0x01c18fff] port 0x100 irq 33
 [ 1.074158] libphy: Fixed MDIO Bus: probed
 [ 1.078335] CAN device driver interface
 [ 1.083187] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
 [ 1.089773] ehci-platform: EHCI generic platform driver
 [ 1.095330] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
 [ 1.101608] ohci-platform: OHCI generic platform driver
 [ 1.108801] sunxi-rtc 1c20d00.rtc: rtc core: registered rtc-sunxi as rtc0
 [ 1.115594] sunxi-rtc 1c20d00.rtc: RTC enabled
 [ 1.120198] i2c /dev entries driver
 [ 1.124807] axp20x-i2c 0-0034: AXP20x variant AXP209 found
 [ 1.145077] input: axp20x-pek as /devices/platform/soc@01c00000/1c2ac00.i2c/i2c-0/0-0034/axp20x-pek/input/input0
 [ 1.155782] axp20x-regulator axp20x-regulator: regulators node not found
 [ 1.166362] axp20x-i2c 0-0034: AXP20X driver loaded
 [ 1.172378] IR NEC protocol handler initialized
 [ 1.176915] IR RC5(x/sz) protocol handler initialized
 [ 1.181991] IR RC6 protocol handler initialized
 [ 1.186519] IR JVC protocol handler initialized
 [ 1.191054] IR Sony protocol handler initialized
 [ 1.195665] IR SANYO protocol handler initialized
 [ 1.200380] IR Sharp protocol handler initialized
 [ 1.205077] IR MCE Keyboard/mouse protocol handler initialized
 [ 1.210909] IR XMP protocol handler initialized
 [ 1.215898] Registered IR keymap rc-empty
 [ 1.220304] input: sunxi-ir as /devices/platform/soc@01c00000/1c21800.ir/rc/rc0/input1
 [ 1.228497] rc rc0: sunxi-ir as /devices/platform/soc@01c00000/1c21800.ir/rc/rc0
 [ 1.236649] input: MCE IR Keyboard/Mouse (sunxi-ir) as /devices/virtual/input/input2
 [ 1.244827] sunxi-ir 1c21800.ir: initialized sunXi IR driver
 [ 1.251429] sunxi-wdt 1c20c90.watchdog: Watchdog enabled (timeout=16 sec, nowayout=0)
 [ 1.271661] sunxi-mmc 1c0f000.mmc: Got CD GPIO
 [ 1.327548] sunxi-mmc 1c0f000.mmc: base:0xf08f7000 irq:28
 [ 1.334355] sun4i-ss 1c15000.crypto-engine: no reset control found
 [ 1.342181] sun4i-ss 1c15000.crypto-engine: Die ID 0
 [ 1.348748] usbcore: registered new interface driver usbhid
 [ 1.354324] usbhid: USB HID core driver
 [ 1.359837] NET: Registered protocol family 17
 [ 1.364305] can: controller area network core (rev 20120528 abi 9)
 [ 1.370615] NET: Registered protocol family 29
 [ 1.375060] can: raw protocol (rev 20120528)
 [ 1.379346] can: broadcast manager protocol (rev 20161123 t)
 [ 1.385007] can: netlink gateway (rev 20130117) max_hops=1
 [ 1.390789] Key type dns_resolver registered
 [ 1.395193] Registering SWP/SWPB emulation handler
 [ 1.428973] ata1: SATA link down (SStatus 0 SControl 300)
 [ 1.454390] mmc0: host does not support reading read-only switch, assuming write-enable
 [ 1.465019] mmc0: new high speed SDHC card at address 59b4
 [ 1.471173] mmcblk0: mmc0:59b4 MS 14.7 GiB 
 [ 1.477152] mmcblk0: p1 p2
 [ 1.527430] sun7i-dwmac 1c50000.ethernet: no reset control found
 [ 1.533441] Ring mode enabled
 [ 1.536493] DMA HW capability register supported[ 1.541052] Normal descriptors
 [ 1.547871] libphy: stmmac: probed
 [ 1.551283] eth%d: PHY ID 001cc915 at 0 IRQ POLL (stmmac-0:00) active
 [ 1.557735] eth%d: PHY ID 001cc915 at 1 IRQ POLL (stmmac-0:01)
 [ 1.564659] ehci-platform 1c14000.usb: EHCI Host Controller
 [ 1.570342] ehci-platform 1c14000.usb: new USB bus registered, assigned bus number 1
 [ 1.578260] ehci-platform 1c14000.usb: irq 30, io mem 0x01c14000
 [ 1.607342] ehci-platform 1c14000.usb: USB 2.0 started, EHCI 1.00
 [ 1.614431] hub 1-0:1.0: USB hub found
 [ 1.618267] hub 1-0:1.0: 1 port detected
 [ 1.623015] ehci-platform 1c1c000.usb: EHCI Host Controller
 [ 1.628654] ehci-platform 1c1c000.usb: new USB bus registered, assigned bus number 2
 [ 1.636535] ehci-platform 1c1c000.usb: irq 34, io mem 0x01c1c000
 [ 1.667344] ehci-platform 1c1c000.usb: USB 2.0 started, EHCI 1.00
 [ 1.674337] hub 2-0:1.0: USB hub found
 [ 1.678168] hub 2-0:1.0: 1 port detected
 [ 1.682877] ohci-platform 1c14400.usb: Generic Platform OHCI controller
 [ 1.689551] ohci-platform 1c14400.usb: new USB bus registered, assigned bus number 3
 [ 1.697452] ohci-platform 1c14400.usb: irq 31, io mem 0x01c14400
 [ 1.772259] hub 3-0:1.0: USB hub found
 [ 1.776054] hub 3-0:1.0: 1 port detected
 [ 1.780795] ohci-platform 1c1c400.usb: Generic Platform OHCI controller
 [ 1.787495] ohci-platform 1c1c400.usb: new USB bus registered, assigned bus number 4
 [ 1.795404] ohci-platform 1c1c400.usb: irq 35, io mem 0x01c1c400
 [ 1.872271] hub 4-0:1.0: USB hub found
 [ 1.876067] hub 4-0:1.0: 1 port detected
 [ 1.881492] random: fast init done
 [ 1.937362] sunxi-mmc 1c12000.mmc: base:0xf0ac3000 irq:29
 [ 1.942849] sunxi-rtc 1c20d00.rtc: setting system clock to 1970-01-01 00:53:01 UTC (3181)
 [ 1.951450] vcc3v0: disabling
 [ 1.954424] vcc5v0: disabling
 [ 1.957448] ALSA device list:
 [ 1.960412] No soundcards found.
 [ 1.970267] sunxi-mmc 1c12000.mmc: smc 1 err, cmd 8, RTO !!
 [ 1.976914] EXT4-fs (mmcblk0p2): mounted filesystem without journal. Opts: (null)
 [ 1.984541] VFS: Mounted root (ext4 filesystem) readonly on device 179:2.
 [ 1.992269] devtmpfs: mounted
 [ 1.996430] Freeing unused kernel memory: 1024K (c0800000 - c0900000)
 [ 2.010456] mmc1: queuing unknown CIS tuple 0x80 (2 bytes)
 [ 2.017536] mmc1: queuing unknown CIS tuple 0x80 (3 bytes)
 [ 2.024633] mmc1: queuing unknown CIS tuple 0x80 (3 bytes)
 [ 2.032922] mmc1: queuing unknown CIS tuple 0x80 (7 bytes)
 [ 2.053943] mmc1: new high speed SDIO card at address 0001
 [ 2.100241] EXT4-fs (mmcblk0p2): warning: mounting unchecked fs, running e2fsck is recommended
 [ 2.202115] EXT4-fs (mmcblk0p2): re-mounted. Opts: block_validity,delalloc,barrier,user_xattr
 Starting logging: OK
 Initializing random number generator... done.
 Starting network: OK
 Starting dropbear sshd: OK

Welcome to Buildroot -- Kasi
buildroot login: root
# uname -a
Linux buildroot 4.9.10 #1 SMP Thu Feb 16 21:12:23 IST 2017 armv7l GNU/Linux

It took just two seconds to boot the kernel.

This is the kernel which we just compiled and loaded onto the target but wait from where did we get the filesystem, how did i get access to the shell where i can do whatever i want. Let us discuss the same in the next blog. See you soon.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s