Difference between revisions of "How to make a debian rootfs for MIPS CI20"

From eLinux.org
Jump to: navigation, search
m (network/dns errors under chroot)
(Loading the rootfs tarball with chroot)
Line 76: Line 76:
  
 
At times, it is handy to load the rootfs tarball on the main desktop using qemu and chroot.
 
At times, it is handy to load the rootfs tarball on the main desktop using qemu and chroot.
Under debian based distros, the method is given below.
+
Under debian based distros, the method is given below (assuming that your rootfs is called "rootfs" and you're root).
 
 
{target_dir} is where your rootfs tarball is.
 
{target_qemu} is where your qemu-mipsel-static binary is.
 
{target_arch} is mipsel
 
  
 
To load
 
To load
  
  mount "${target_dir}/proc" >/dev/null 2>&1
+
  mount rootfs/proc >/dev/null 2>&1
  mount "${target_dir}/sys" >/dev/null 2>&1
+
  mount rootfs/sys >/dev/null 2>&1
  cp "${target_qemu}" "${target_dir}/usr/bin/qemu-${target_arch}-static"
+
mount -o bind /dev rootfs/dev
  chroot "${target_dir}" /bin/bash
+
  cp /usr/bin/qemu-mipsel-static rootfs/usr/bin/
 +
  chroot rootfs /bin/bash
  
 
Type exit to quit shell.
 
Type exit to quit shell.
  
 
  # Clean up.
 
  # Clean up.
  chroot "${target_dir}" apt-get clean
+
  chroot rootfs apt-get clean
  rm -f "${target_dir}/usr/bin/qemu-${target_arch}-static"
+
  rm -f rootfs/usr/bin/qemu-mipsel-static
  umount "${target_dir}/proc" >/dev/null 2>&1
+
  umount rootfs/proc >/dev/null 2>&1
  umount "${target_dir}/sys" >/dev/null 2>&1
+
  umount rootfs/sys >/dev/null 2>&1
 +
umount rootfs/dev >/dev/null 2>&1
  
 
To make a tarball with that folder again
 
To make a tarball with that folder again
  cd ${target_dir}
+
  cd rootfs
 
  tar -capf ../rootfs.tar *
 
  tar -capf ../rootfs.tar *
 
=== network/dns errors under chroot ===
 
=== network/dns errors under chroot ===

Revision as of 03:01, 20 August 2015

Making a debian rootfs tarball for MIPS CI20

Start by running

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

Then run mkdebrootfs. Get the script from mkdebianrfs

sudo ./mkdebianrfs.sh --tar mipsel wheezy rootfs.tar.bz2

The script will ask to set up the local keyboard format and a root password.

The script will setup core debian and then give you root access via chroot. Installing the following packages via chroot is much faster than native installation.

apt-get update
apt-get install xfce4
apt-get install lightdm
apt-get install wicd
apt-get install iceweasel
apt-get install pulseaudio
apt-get install bluez

Add a user using

adduser ci20

Follow the on-screen steps for setting a password and the username

If you want the user to autologin, edit

nano /etc/lightdm/lightdm.conf

And edit the following lines

[SeatDefaults]
autologin-user=ci20

/sbin contains quite a few useful commands such as ifconfig. But /sbin is not added to the default PATH environment for new users.

First switch to the new user using

su ci20

Then, to add /sbin to the default PATH environment edit .bashrc

nano /home/ci20/.bashrc

And add the following line at the end.

export PATH=$PATH:/sbin

Exit the ci20 user by running 'exit'. Exit the root user by running 'exit' again.

The rest of the mkdebianrfs script will now make a rootfs tarball that you can use to make a bootable sd card

Factory default rootfs tarball

Lots of tiny steps went into making the factory default rootfs. Some are listed below.

  • extract linux kernel modules.tar
  • copy uImage to /boot/vmlinux.img
  • copy brcm firmware to /lib/firmware/iw8103
  • extract the SGX demos into /usr/local/bin/SGX
  • make the pvrsrvkm module with respect to the release kernel and copy it to /lib/modules/3.0....
  • extract the userland pvr driver to the rootfs
  • check permisions for userland xorg.
  • add contents of /etc/powervr.ini
  • add user ci20 to groups pulse-audio, audio, sudo, netdev

Loading the rootfs tarball with chroot

At times, it is handy to load the rootfs tarball on the main desktop using qemu and chroot. Under debian based distros, the method is given below (assuming that your rootfs is called "rootfs" and you're root).

To load

mount rootfs/proc >/dev/null 2>&1
mount rootfs/sys >/dev/null 2>&1
mount -o bind /dev rootfs/dev
cp /usr/bin/qemu-mipsel-static rootfs/usr/bin/
chroot rootfs /bin/bash

Type exit to quit shell.

# Clean up.
chroot rootfs apt-get clean
rm -f rootfs/usr/bin/qemu-mipsel-static
umount rootfs/proc >/dev/null 2>&1
umount rootfs/sys >/dev/null 2>&1
umount rootfs/dev >/dev/null 2>&1

To make a tarball with that folder again

cd rootfs
tar -capf ../rootfs.tar *

network/dns errors under chroot

If ping www.elinux.org doesn't work inside chroot and does outside, before chrooting in the folder, run

echo "nameserver 8.8.8.8" > {target_dir}/etc/resolv.conf

This adds the google open dns to resolve hosts.