User:Rellla/Debian

From linux-sunxi.org
Jump to navigation Jump to search
  • apt-get install cmake shtool swig autoconf autotool automake libtool default-jre gawk gperf zip
  • g++-4.6-arm-linux-gnueabihf
  • symlinks gcc -> gcc-4.6 etc...
  • emdebian dependencies for 4.6-armhf toolchain are broken on sid (g++-4.6): do a "xapt -a armhf -m libstdc++6-4.6-dev" to fix

Recovered Debian page, after it was moved or deleted or whatever... I found it very useful, though.

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 Wheezy armhf-rootfs.

Setting up the cross compiling environment

Toolchain#Debian

Building a Debian-armhf rootfs

Set up your working directory and mount empty filesystem:

mkdir melehacking
cd melehacking
mkdir jessie
dd if=/dev/zero of=jessie.img bs=1M count=4096
mkfs.ext4 -F jessie.img
mount -o loop jessie.img jessie

Create Debian/stable/armhf filesystem using debootstrap:

debootstrap --verbose --arch armhf --variant=minbase --foreign jessie jessie 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 jessie/usr/bin
mkdir jessie/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 jessie/dev/pts
mount -t proc proc jessie/proc

Now chroot into your new filesystem:

chroot jessie/
# 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/ jessie main contrib non-free
deb-src http://ftp.debian.org/debian/ jessie main contrib non-free
deb http://ftp.debian.org/debian/ jessie-updates main contrib non-free
deb-src http://ftp.debian.org/debian/ jessie-updates main contrib non-free
deb http://security.debian.org/ jessie/updates main contrib non-free
deb-src http://security.debian.org/ jessie/updates main contrib non-free
END
apt-get update
  • Configure language:
export LANG=C
apt-get install apt-utils dialog locales
dpkg-reconfigure locales
# Choose de_DE.UTF-8 for both prompts, or whatever you want.
export LANG=de_DE.UTF-8
  • Install some important stuff:
apt-get install isc-dhcp-client udev netbase ifupdown iproute openssh-server iputils-ping wget \
net-tools ntpdate ntp vim nano less tzdata module-init-tools mc
  • Configure ethernet with dhcp and set hostname:
cat <<END > /etc/network/interfaces
auto lo eth0
allow-hotplug eth0
iface lo inet loopback
iface eth0 inet dhcp
END
echo sunxi > /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      /               ext4    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

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]