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

Difference between revisions of "Rock/ubuntu"

(Created page with "__TOC__ This page describe how to customize a ubuntu image for radxa rock. === Install required packages === sudo apt-get install qemu-user-static binfmt-support === Ge...")
 
(Chroot and post configuration)
 
(23 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 +
{{rock_header}}
 +
{{Languages|rock/ubuntu}}
 +
 
__TOC__
 
__TOC__
  
Line 7: Line 10:
  
 
=== Generate the image ===
 
=== Generate the image ===
     dd if=/dev/zero of=rock_rootfs.img bs=1M count=1024
+
     dd if=/dev/zero of=rootfs.ext4 bs=1M count=1024
     mkfs.ext4 -F rock_rootfs.img
+
     mkfs.ext4 -F -L linuxroot rootfs.ext4 #kernel use the label linuxroot to mount the rootfs as /
     sudo mount -o loop rock_rootfs.img /mnt
+
     sudo mount -o loop rootfs.ext4 /mnt
The fast way is to make a ubuntu image is downloading a recent pre-built ubuntu rootfs from [https://releases.linaro.org/latest/ubuntu/raring-images linaro]
+
The fast way is to make a ubuntu image is downloading a recent pre-built ubuntu rootfs from [https://releases.linaro.org/latest/ubuntu/ linaro]
     wget https://releases.linaro.org/13.08/ubuntu/raring-images/alip/linaro-raring-alip-20130826-474.tar.gz
+
     wget http://releases.linaro.org/14.10/ubuntu/trusty-images/alip/linaro-trusty-alip-20141024-684.tar.gz
     sudo tar zxvf linaro-raring-alip-20130826-474.tar.gz -C /mnt
+
     sudo tar zxvf linaro-*.tar.gz -C /mnt
 
     cd /mnt
 
     cd /mnt
 
     sudo mv binary/* .
 
     sudo mv binary/* .
 
     sudo rmdir binary
 
     sudo rmdir binary
 +
Copy the kernel modules you built from [[rock/Booting_Linux | Building the kernel]]
 +
    sudo mkdir -p /mnt/lib/modules
 +
    sudo cp -r /path/to/linux-rockchip/modules/lib/modules/3.0.36+ /mnt/lib/modules
  
 
=== Prepare chroot ===
 
=== Prepare chroot ===
Line 22: Line 28:
 
     sudo mount -t devpts devpts /mnt/dev/pts
 
     sudo mount -t devpts devpts /mnt/dev/pts
 
     sudo mount -t proc proc /mnt/proc
 
     sudo mount -t proc proc /mnt/proc
=== Chroot and post configuartion ===
+
=== Chroot and post configuration ===
 
     sudo chroot /mnt
 
     sudo chroot /mnt
Now we are in the target rootfs.
+
'''Now we are in the target rootfs, let's continue to configure the system.'''
 +
 
 +
Change the default shell to bash.
 +
    root@target:# rm /bin/sh && ln -s /bin/bash /bin/sh
 +
Install the pre-installed packages
 +
    root@target:# apt-get update
 +
    root@target:# apt-get install ssh vim usbutils wpasupplicant wireless-tools
 +
Add a script to link the mtd blocks to names
 +
    root@target:# vim /usr/local/bin/mtd-by-name.sh
 +
Add the following
 +
    #!/bin/sh -e
 +
    # mtd-by-name link the mtdblock to name
 +
    # radxa.com, thanks to naobsd
 +
    rm -rf /dev/block/mtd/by-name/
 +
    mkdir -p /dev/block/mtd/by-name
 +
    for i in `ls -d /sys/class/mtd/mtd*[0-9]`; do
 +
        name=`cat $i/name`
 +
        tmp="`echo $i | sed -e 's/mtd/mtdblock/g'`"
 +
        dev="`echo $tmp |sed -e 's/\/sys\/class\/mtdblock/\/dev/g'`"
 +
        ln -s $dev /dev/block/mtd/by-name/$name
 +
    done
 +
Add the mtd-by-name script to rc.local to get executed every time system boots
 +
    root@target:# vim /etc/rc.local
 +
Add this line before '''exit 0'''
 +
    /usr/local/bin/mtd-by-name.sh
 +
'''Now we are done! :D'''
 +
    root@target:# exit
 +
    sync
 +
    sudo umount /mnt
 +
Now you have '''rootfs.ext4''' as the rootfs image for RR.
 +
 
 +
--------------------------------------------------------------------
 +
 
 +
=== Trouble shooting ===
 +
==== bluez package configure error ====
 +
<pre>
 +
Setting up bluez (4.101-0ubuntu8b1) ...
 +
reload: Unknown instance:
 +
invoke-rc.d: initscript dbus, action "force-reload" failed.
 +
start: Job failed to start
 +
invoke-rc.d: initscript bluetooth, action "start" failed.
 +
dpkg: error processing bluez (--configure):
 +
subprocess installed post-installation script returned error exit status 1
 +
dpkg: dependency problems prevent configuration of blueman:
 +
blueman depends on bluez (>= 4.25); however:
 +
Package bluez is not configured yet.
 +
...
 +
 
 +
</pre>
 +
It turns out the bluez package needs the dbus service running in order to configure properly. The following works:
 +
 
 +
    service dbus start
 +
    dbus start/running, process 24551
 +
    dpkg --configure bluez
 +
 
 +
==== Non root user can not use the network ====
 +
Edit /etc/group and add
 +
    inet:x:3003:root
 +
    net_raw:x:3004:root
 +
and then run
 +
    gpasswd -a username inet
 +
 
 +
=== Alternative way ===
 +
 
 +
[http://androtab.info/radxa_rock/ubuntu/ you can prepare your own ubuntu rootfs on Radxa Rock]
 +
 
 +
[[Category: Distributions]]
 +
[[Category: Tutorial]]
 +
[[Category: Ubuntu]]

Latest revision as of 11:25, 21 January 2015

This page describe how to customize a ubuntu image for radxa rock.

Install required packages

   sudo apt-get install qemu-user-static binfmt-support

Generate the image

   dd if=/dev/zero of=rootfs.ext4 bs=1M count=1024
   mkfs.ext4 -F -L linuxroot rootfs.ext4 #kernel use the label linuxroot to mount the rootfs as /
   sudo mount -o loop rootfs.ext4 /mnt

The fast way is to make a ubuntu image is downloading a recent pre-built ubuntu rootfs from linaro

   wget http://releases.linaro.org/14.10/ubuntu/trusty-images/alip/linaro-trusty-alip-20141024-684.tar.gz
   sudo tar zxvf linaro-*.tar.gz -C /mnt
   cd /mnt
   sudo mv binary/* .
   sudo rmdir binary

Copy the kernel modules you built from Building the kernel

   sudo mkdir -p /mnt/lib/modules
   sudo cp -r /path/to/linux-rockchip/modules/lib/modules/3.0.36+ /mnt/lib/modules

Prepare chroot

   sudo cp /usr/bin/qemu-arm-static /mnt/usr/bin
   sudo modprobe binfmt_misc
   sudo mount -t devpts devpts /mnt/dev/pts
   sudo mount -t proc proc /mnt/proc

Chroot and post configuration

   sudo chroot /mnt

Now we are in the target rootfs, let's continue to configure the system.

Change the default shell to bash.

   root@target:# rm /bin/sh && ln -s /bin/bash /bin/sh

Install the pre-installed packages

   root@target:# apt-get update
   root@target:# apt-get install ssh vim usbutils wpasupplicant wireless-tools

Add a script to link the mtd blocks to names

   root@target:# vim /usr/local/bin/mtd-by-name.sh

Add the following

   #!/bin/sh -e
   # mtd-by-name link the mtdblock to name
   # radxa.com, thanks to naobsd
   rm -rf /dev/block/mtd/by-name/
   mkdir -p /dev/block/mtd/by-name
   for i in `ls -d /sys/class/mtd/mtd*[0-9]`; do
       name=`cat $i/name`
       tmp="`echo $i | sed -e 's/mtd/mtdblock/g'`"
       dev="`echo $tmp |sed -e 's/\/sys\/class\/mtdblock/\/dev/g'`"
       ln -s $dev /dev/block/mtd/by-name/$name
   done

Add the mtd-by-name script to rc.local to get executed every time system boots

   root@target:# vim /etc/rc.local

Add this line before exit 0

   /usr/local/bin/mtd-by-name.sh

Now we are done! :D

   root@target:# exit
   sync
   sudo umount /mnt

Now you have rootfs.ext4 as the rootfs image for RR.


Trouble shooting

bluez package configure error

Setting up bluez (4.101-0ubuntu8b1) ...
reload: Unknown instance: 
invoke-rc.d: initscript dbus, action "force-reload" failed.
start: Job failed to start
invoke-rc.d: initscript bluetooth, action "start" failed.
dpkg: error processing bluez (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of blueman:
blueman depends on bluez (>= 4.25); however:
Package bluez is not configured yet.
...

It turns out the bluez package needs the dbus service running in order to configure properly. The following works:

   service dbus start
   dbus start/running, process 24551
   dpkg --configure bluez

Non root user can not use the network

Edit /etc/group and add

   inet:x:3003:root
   net_raw:x:3004:root

and then run

   gpasswd -a username inet

Alternative way

you can prepare your own ubuntu rootfs on Radxa Rock