Debian

From linux-sunxi.org
Jump to: navigation, search

Host system for this howto was a Debian/unstable.

Proceeding on other Debian Releases and Ubuntu (not tested) should be similar. Check emdebian.org and rhombus-tech.net. In this howto you will end up with a bootable sd-card containing a debian/testing/armhf-rootfs.

Contents

Setting up Cross Compile Environment

To install Cross-development Toolchains for Debian follow the instructions on emdebian.org. Edit your /etc/apt/sources.list as approriate and advised above:

deb http://www.emdebian.org/debian/ unstable main

Install Cross Compiler and build utilities:

apt-get update
apt-get install emdebian-archive-keyring
apt-get install gcc-4.6-arm-linux-gnueabihf g++-4.6-arm-linux-gnueabihf
apt-get install build-essential git debootstrap u-boot-tools

Create symlinks to specific version of the cross-compiler-tools:

ln -s /usr/bin/arm-linux-gnueabihf-gcc-4.6 /usr/bin/arm-linux-gnueabihf-gcc
ln -s /usr/bin/arm-linux-gnueabihf-gcov-4.6 /usr/bin/arm-linux-gnueabihf-gcov
ln -s /usr/bin/arm-linux-gnueabihf-g++-4.6 /usr/bin/arm-linux-gnueabihf-g++
ln -s /usr/bin/arm-linux-gnueabihf-cpp-4.6 /usr/bin/arm-linux-gnueabihf-cpp

Building a Debian-armhf rootfs

Set up your working directory and mount empty filesystem:

mkdir melehacking
cd melehacking
mkdir debfs-armhf
dd if=/dev/zero of=debfs_armhf.img bs=1M count=2048
mkfs.ext3 -F debfs_armhf.img
mount -o loop debfs_armhf.img debfs-armhf

Create Debian/unstable/armhf filesystem using debootstrap:

debootstrap --verbose --arch armhf --variant=minbase --foreign sid debfs-armhf http://ftp.debian.org/debian

To chroot into your new filesystem and finish debootstrapping, you have to do some more things:

apt-get install qemu-user-static binfmt-support
cp /usr/bin/qemu-arm-static debfs-armhf/usr/bin
mkdir debfs-armhf/dev/pts

After a reboot or umount of your filesystem, you have to do the following steps once again:

modprobe binfmt_misc
mount -t devpts devpts debfs-armhf/dev/pts
mount -t proc proc debfs-armhf/proc

Now chroot into your new filesystem:

chroot debfs-armhf/
# You should see "I have no name!@hostname:/#"
/debootstrap/debootstrap --second-stage
# At the end, you should see "I: Base system installed successfully."

At any time you can chroot into your filesystem and install armhf-packages via "apt-get install". Alternatively you can boot your rootfs and do the things there. But chrooting is a good way, to install dependencies and includes for things you want to cross compile using a more powerful host. Maybe you can chroot into your rootfs in order to set up a full build-environment for armhf and compile packages directly in chroot (not tested yet). For cross compiling you have to link to your headers only to the armhf-versions in rootfs while doing ./configure and make on your host rootfs.

Configure the new rootfs

Still staying in chroot, make some adaptions of your filesystem.

  • First add your apt-sources:
cat <<END > /etc/apt/sources.list
deb http://ftp.debian.org/debian/ sid main contrib non-free
deb-src http://ftp.debian.org/debian/ sid main contrib non-free
END
apt-get update
  • Configure language:
export LANG=C
apt-get install apt-utils dialog locales
cat <<END > /etc/apt/apt.conf.d/71mele
APT::Install-Recommends "0";
APT::Install-Suggests "0";
END
dpkg-reconfigure locales
# Choose en_US.UTF-8 for both prompts, or whatever you want.
export LANG=en_US.UTF-8
  • Install some important stuff:
apt-get install dhcp3-client udev netbase ifupdown iproute openssh-server iputils-ping wget \
net-tools ntpdate ntp vim nano less tzdata console-tools console-common module-init-tools
  • Configure ethernet with dhcp and set hostname:
cat <<END > /etc/network/interfaces
auto lo eth0
iface lo inet loopback
iface eth0 inet dhcp
END
echo debian > /etc/hostname
  • Create filesystem mounts:
cat <<END > /etc/fstab
# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/root      /               ext3    noatime,errors=remount-ro 0 1
tmpfs          /tmp            tmpfs   defaults          0       0
END
  • Activate remote console and disable some local consoles.
echo 'T0:2345:respawn:/sbin/getty -L ttyS0 115200 linux' >> /etc/inittab
sed -i 's/^\([3-6]:.* tty[3-6]\)/#\1/' /etc/inittab
  • Set the root password and exit:
passwd
exit

A prebuilt debian/sid/armhf-rootfs made with this tutorial can be downloaded here (rootpw="password"). Neither kernel nor kernel-modules are included.

Set up a bootable SD-card with debian-rootfs

  • Create u-boot, kernel, script.bin and boot.cmd following FirstSteps. Skip the toolchain section and set up cross compiler like described above.
  • Format the root partition of your sd-card, mount it and copy your newly created rootfs to your sd-card.
  • Don't forget the modules, you created while kernel-building!
  • If everything is set up right, you can now boot into your new debian and do whatever you want.

See also

[1] [2]

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox