Please enable javascript, or click here to visit my ecommerce web site powered by Shopify.
Jump to: navigation, search

Difference between revisions of "Rock/Booting Linux"

(Generate the boot.img)
 
(20 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
{{rock_header}}
 +
 
{{Languages|rock/Booting Linux}}
 
{{Languages|rock/Booting Linux}}
  
 
__TOC__
 
__TOC__
  
=== Requirement ===
+
== Requirement ==
  
 
* a radxa rock board (check your [[Rock/hardware revision|hardware revision]])
 
* a radxa rock board (check your [[Rock/hardware revision|hardware revision]])
 
* a desktop/laptop running Linux(64bit preferred)
 
* a desktop/laptop running Linux(64bit preferred)
 
* a micro usb cable, one side plugged in to the OTG port of radxa rock, the other side plugged in to the usb port on desktop/laptop
 
* a micro usb cable, one side plugged in to the OTG port of radxa rock, the other side plugged in to the usb port on desktop/laptop
 +
 +
== Prepare the build environment ==
 +
 +
=== Install the packages ===
 +
 +
Install packages for building kernel if you don't have them on your host.
 +
 +
    sudo apt-get install build-essential lzop libncurses5-dev libssl-dev
 +
If build on 64bit machine, also need to install:
 +
    sudo apt-get install libc6:i386
  
 
=== Install the toolchain ===
 
=== Install the toolchain ===
  
Install ARM toolchain and building kernel related packages if you don't have them on your host.
+
Refer [[Rock/install_toolchain | install toolchain]]
  
    sudo apt-get install gcc-arm-linux-gnueabihf build-essential lzop libncurses5-dev libssl-dev
+
you can use any toolchain if you are sure it works, or you may have to fix any error introduced by toolchain.
    export ARCH=arm
+
    export CROSS_COMPILE=arm-linux-gnueabihf-
+
  
 
=== Get the source code ===
 
=== Get the source code ===
  
     git clone -b radxa/stable-3.0 https://github.com/linux-rockchip/kernel_rockchip.git
+
     git clone -b radxa-stable-3.0 https://github.com/radxa/linux-rockchip.git
  
or download from this link and unzip it:
+
  or download here
 +
    http://pan.baidu.com/s/1jfOTo  (china)
  
    https://codeload.github.com/linux-rockchip/kernel_rockchip/zip/radxa/stable-3.0
+
== Build the kernel ==
  
=== Build the kernel ===
+
    cd linux-rockchip
  
    cd kernel_rockchip
+
if your Rock is pro(Mid 2014) or the new lite(Mid 2014), check out [[Rock/hardware_revision| hardware revision]]
    make radxa_rock_pro_linux_defconfig
+
    make -j8
+
  
The kernel will be at '''arch/arm/boot/Image'''
+
if you use the HDMI for dispaly device
 
+
    make radxa_rock_pro_linux_hdmi_defconfig
if your Rock is full or lite, use radxa_rock_linux_defconfig instead of radxa_rock_pro_linux_defconfig
+
or you use the LCD for the primary display device(hdmi dual display at the same time)
 +
    make radxa_rock_pro_linux_lvds_defconfig
  
 +
if your rock is full version(2013) or engineering sample or the old lite(2013), use radxa_rock_linux_defconfig, check out [[Rock/hardware_revision| hardware revision]]
 
     make radxa_rock_linux_defconfig
 
     make radxa_rock_linux_defconfig
 +
 +
    make -j8 kernel.img
 +
 +
The kernel will be at '''kernel.img''' (image for kernel partition) and '''arch/arm/boot/Image''' (raw binary)
 +
 +
if you want LZO compressed kernel, specify zkernel.img
 +
 +
    make -j8 zkernel.img
 +
 +
The kernel will be at '''kernel.img''' (image for kernel partition) and '''arch/arm/boot/zImage''' (compressed binary)
  
 
=== Build the kernel modules ===
 
=== Build the kernel modules ===
  
 
     mkdir modules
 
     mkdir modules
     export INSTALL_MOD_PATH=./modules
+
     make INSTALL_MOD_PATH=./modules modules modules_install
    make modules && make modules_install
+
    cd ..
+
  
Now you have all the kernel modules in '''modules/lib/modules/3.0.36+/'''.
+
Now you have kernel modules in '''modules/lib/modules/''' and firmwares for some devices in '''modules/lib/firmware/'''.
  
=== Generate the ramdisk ===
+
== Generate the image ==
  
 +
=== Generate the initramfs ===
 +
 +
    cd ..
 
     git clone https://github.com/radxa/initrd.git
 
     git clone https://github.com/radxa/initrd.git
 
     make -C initrd
 
     make -C initrd
  
 
=== Generate the boot.img ===
 
=== Generate the boot.img ===
 +
 
Install mkbootimg
 
Install mkbootimg
 +
 
     git clone https://github.com/neo-technologies/rockchip-mkbootimg.git
 
     git clone https://github.com/neo-technologies/rockchip-mkbootimg.git
 
     cd rockchip-mkbootimg
 
     cd rockchip-mkbootimg
Line 60: Line 84:
  
 
Make boot.img
 
Make boot.img
    mkbootimg --kernel kernel_rockchip/arch/arm/boot/Image --ramdisk initrd.img -o boot.img
 
  
Done. Now we have the kernel '''boot.img''' for RR.
+
    mkbootimg --kernel linux-rockchip/arch/arm/boot/Image --ramdisk initrd.img -o boot.img
 +
 
 +
Done. Now we have the '''boot.img''' (image for boot/recovery partition) for RR.
 +
 
 +
== Modify the parameter ==
 +
There is a demo for parameter for sdcard  you can get it  or copy it to parameter file, but before you use you should modify it as the following guide
 +
 
 +
wget http://dl.radxa.com/rock/images/parameter/parameter_linux_sd
 +
 
 +
The linux rootfs can be put on the different partition or media(nand or uSD card or USB disk), so you need to tell the kernel which is the right rootfs to mount. So change the root= command line in your parameter to the rootfs you want to mount. The examples are:
  
=== Modify the parameter ===
 
The linux rootfs maybe in the different partition or media(nand or uSD card or USB disk), so you need to tell the kernel which is the right rootfs to mount. So change the root= command line in your parameter to the rootfs you want to mount. The examples are:
 
 
     root=/dev/block/mtd/by-name/linuxroot        # rootfs in the nand partition named "linuxroot"
 
     root=/dev/block/mtd/by-name/linuxroot        # rootfs in the nand partition named "linuxroot"
 
     root=/dev/mmcblk0p1          # rootfs in the uSD card first partition
 
     root=/dev/mmcblk0p1          # rootfs in the uSD card first partition
Line 71: Line 101:
 
     root=LABEL=linuxroot        # rootfs in the partition with label "linuxroot", can be in uSD, U disk or USB hard drive.
 
     root=LABEL=linuxroot        # rootfs in the partition with label "linuxroot", can be in uSD, U disk or USB hard drive.
  
=== Next step ===
+
== Next step ==
  
 
Now you refer [[rock/flash the image| flash the image]] to flash the generated boot.img to "boot" [[rock/partitions | partition]] parameter to "parameter" partition of your radxa rock board. And download a [http://dl.radxa.com/rock/images/ubuntu/latest/ prebuilt rootfs] or [[rock/ubuntu |make your own rootfs]]. You will get linux system boot into ramdisk and then switch root to real rootfs.
 
Now you refer [[rock/flash the image| flash the image]] to flash the generated boot.img to "boot" [[rock/partitions | partition]] parameter to "parameter" partition of your radxa rock board. And download a [http://dl.radxa.com/rock/images/ubuntu/latest/ prebuilt rootfs] or [[rock/ubuntu |make your own rootfs]]. You will get linux system boot into ramdisk and then switch root to real rootfs.

Latest revision as of 02:58, 25 January 2016

Requirement

  • a radxa rock board (check your hardware revision)
  • a desktop/laptop running Linux(64bit preferred)
  • a micro usb cable, one side plugged in to the OTG port of radxa rock, the other side plugged in to the usb port on desktop/laptop

Prepare the build environment

Install the packages

Install packages for building kernel if you don't have them on your host.

   sudo apt-get install build-essential lzop libncurses5-dev libssl-dev 

If build on 64bit machine, also need to install:

   sudo apt-get install libc6:i386

Install the toolchain

Refer install toolchain

you can use any toolchain if you are sure it works, or you may have to fix any error introduced by toolchain.

Get the source code

   git clone -b radxa-stable-3.0 https://github.com/radxa/linux-rockchip.git
  or download here
   http://pan.baidu.com/s/1jfOTo  (china)

Build the kernel

   cd linux-rockchip

if your Rock is pro(Mid 2014) or the new lite(Mid 2014), check out hardware revision

if you use the HDMI for dispaly device

   make radxa_rock_pro_linux_hdmi_defconfig

or you use the LCD for the primary display device(hdmi dual display at the same time)

   make radxa_rock_pro_linux_lvds_defconfig

if your rock is full version(2013) or engineering sample or the old lite(2013), use radxa_rock_linux_defconfig, check out hardware revision

   make radxa_rock_linux_defconfig
   make -j8 kernel.img

The kernel will be at kernel.img (image for kernel partition) and arch/arm/boot/Image (raw binary)

if you want LZO compressed kernel, specify zkernel.img

   make -j8 zkernel.img

The kernel will be at kernel.img (image for kernel partition) and arch/arm/boot/zImage (compressed binary)

Build the kernel modules

   mkdir modules
   make INSTALL_MOD_PATH=./modules modules modules_install

Now you have kernel modules in modules/lib/modules/ and firmwares for some devices in modules/lib/firmware/.

Generate the image

Generate the initramfs

   cd ..
   git clone https://github.com/radxa/initrd.git
   make -C initrd

Generate the boot.img

Install mkbootimg

   git clone https://github.com/neo-technologies/rockchip-mkbootimg.git
   cd rockchip-mkbootimg
   make
   sudo make install
   cd ..

Make boot.img

   mkbootimg --kernel linux-rockchip/arch/arm/boot/Image --ramdisk initrd.img -o boot.img

Done. Now we have the boot.img (image for boot/recovery partition) for RR.

Modify the parameter

There is a demo for parameter for sdcard you can get it or copy it to parameter file, but before you use you should modify it as the following guide

wget http://dl.radxa.com/rock/images/parameter/parameter_linux_sd

The linux rootfs can be put on the different partition or media(nand or uSD card or USB disk), so you need to tell the kernel which is the right rootfs to mount. So change the root= command line in your parameter to the rootfs you want to mount. The examples are:

   root=/dev/block/mtd/by-name/linuxroot        # rootfs in the nand partition named "linuxroot"
   root=/dev/mmcblk0p1          # rootfs in the uSD card first partition
   root=/dev/sda1                # rootfs in the U disk or the USB hard drive first partition
   root=LABEL=linuxroot         # rootfs in the partition with label "linuxroot", can be in uSD, U disk or USB hard drive.

Next step

Now you refer flash the image to flash the generated boot.img to "boot" partition parameter to "parameter" partition of your radxa rock board. And download a prebuilt rootfs or make your own rootfs. You will get linux system boot into ramdisk and then switch root to real rootfs.