This is how I built and installed debian squeeze completely from source code onto an SD card, which is bootable on my Mele A2000 STB. It should also work on a Mele A1000. I did this build on a debian testing system. It should also work on ubuntu, but I haven't tried it.

(The information in this article has been published in other places; I have merely pulled it all together into a single article. I have tried to reference the original sources where appropriate.)

Note: A script has been written to automate everything in this article.

This link has the recommended latest source branches to retrieve: Each of these git branches has a wiki link with the latest build information. Be sure to read them.

We need to build 5 components:

  • u-boot
  • u-boot script (boot.scr)
  • kernel (uImage)
  • mele configuration file (script.bin)
  • root filesystem

Make a folder to work in.

mkdir /home/share/mele-hacking
cd /home/share/mele-hacking

Begin by erasing the first 2047 sectors of a 2GB or larger SD (or SDHC) card. This is to make sure we zero the u-boot environment. IMPORTANT: In all of the commands below, "/dev/sdh" is the name of my SD card device. Substitute your device. If you specify the wrong device, you could ruin your system. You've been warned. (Insert your card and do sudo dmesg to find out which device it is.)

dd if=/dev/zero of=/dev/sdh bs=512 count=2047  (substitute your SD card device!)

Partition the card so that the first partition begins at sector 2048 or later and is 16 MB in size. The second partition will take up the rest of the card. The space before the first partition is for the partition table, initial SPL loader, u-boot, and the u-boot environment. This link explains the Storage Map before the first partition:

The 1st partition is for the kernel (uImage), boot.scr, and script.bin. The 2nd partition is for the root filesystem. Even though the 1st partition type is Linux, it will be formatted FAT32 later. Here's what my card looks like:

$ sudo fdisk -l /dev/sdh

Disk /dev/sdh: 3965 MB, 3965190144 bytes
122 heads, 62 sectors/track, 1023 cylinders, total 7744512 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xb4e92fdc

   Device Boot      Start         End      Blocks   Id  System
/dev/sdh1            2048       34815       16384   83  Linux
/dev/sdh2           34816     7744511     3854848   83  Linux

Note: In theory, two partitions are not necessary, but as of 6 May 2012, there is a bug that prevents me from using a single ext4 partition. See

Install arm cross-compiler and tools. We are basically following the instructions here:

#  first read this:
#  edit /etc/apt/sources.list as approriate and advised above
sudo apt-get install emdebian-archive-keyring
sudo apt-get install gcc-4.4-arm-linux-gnueabi (or appropriate: gcc-4.3 or 4.5)
sudo apt-get build-essential git
sudo apt-get u-boot-tools (if u-boot-tools not found, try uboot-mkimage)

Retrieve, build and install u-boot. Basically, following instructions here:

git clone
cd uboot-allwinner
# OK if you get "Already on sun4i".
git checkout sun4i
make sun4i CROSS_COMPILE=arm-linux-gnueabi-

Write the initial SPL loader and u-boot according the Storage Map mentioned before. (Substitute your SD card device!)

dd if=spl/sun4i-spl.bin of=/dev/sdh bs=1024 seek=8  (if sun4i-spl.bin not found, try sunxi-spl.bin)
dd if=u-boot.bin of=/dev/sdh bs=1024 seek=32

Retrieve, build, and install the linux kernel to the 1st partition of SD card. Basically, following instructions here:

cd /home/share/mele-hacking
git clone git://
cd linux-allwinner
git checkout allwinner-v3.0-android-v2 (or whatever branch you want to compile)
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- sun4i_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j16 uImage modules
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- INSTALL_MOD_PATH=output modules_install

cd /home/share/mele-hacking
mkdir mnt
sudo mkfs.vfat /dev/sdh1  (substitute your SD card device!)
sudo mount /dev/sdh1 mnt
sudo cp linux-allwinner/arch/arm/boot/uImage mnt/

Retrieve and build the tools to compile/decompile configuration files. Basically, following instructions here:

git clone
cd sunxi-tools

Retrieve configuration file. There are a lot of them floating around. The script.bin file here worked pretty well for me:

Decompile script.bin file to script.fex.

cd /home/share/mele-hacking
sunxi-tools/bin2fex script.bin > myscript.fex

Alternatively, and this produces the exact same configuration,

cd /home/share/mele-hacking
wget -O sys_config1.fex
cp sys_config1.fex myscript.fex

You need the MAC address for the wired ethernet from your Mele. Either open up the box and get the address from the label, or boot the stock Android and go to Settings -> Network -> Wired Network Settings.

Edit the myscript.fex file. At the bottom, change the line

MAC = "0000000000"

to the MAC address of your Mele. For example,

MAC = "00CE39B68863"

Now compile the script to a .bin and install to the SD card.

sunxi-tools/fex2bin myscript.fex myscript.bin
sudo cp myscript.bin mnt/script.bin

Create a boot.cmd file with the following contents:

setenv console 'ttyS0,115200'
setenv root '/dev/mmcblk0p2'
setenv panicarg 'panic=10'
setenv extra 'rootfstype=ext4 rootwait'
setenv loglevel '8'
setenv setargs 'setenv bootargs console=${console} root=${root} loglevel=${loglevel} ${panicarg} ${extra}'
setenv kernel 'uImage'
setenv boot_mmc 'fatload mmc 0 0x43000000 script.bin; fatload mmc 0 0x48000000 ${kernel}; bootm 0x48000000'
setenv bootcmd 'run setargs boot_mmc'

Compile the boot.cmd file to an image in u-boot format and copy to the SD card.

mkimage -A arm -O u-boot -T script -C none -n "boot" -d boot.cmd boot.scr
sudo cp boot.scr mnt/

Note: boot.scr is needed to tell the kernel the type of root filesystem we have and also need to tell it to wait for the SD card driver to settle down. That's in the extra environment variable.

We are done with the first partition.

sudo umount mnt

Create an empty root filesystem. Basically, we are following the instructions from here:,5986

cd /home/share/mele-hacking
sudo apt-get install debootstrap
mkdir debian-rootfs
cd debian-rootfs
dd if=/dev/zero of=debian_rootfs.img bs=1M count=1024
sudo mkfs.ext3 -F debian_rootfs.img
mkdir mnt
sudo mount -o loop debian_rootfs.img mnt

Use debootstrap to retrieve debian root filesystem.

sudo debootstrap --verbose --arch armel --variant=minbase --foreign squeeze mnt

With the aid of binfmt_misc we are able to chroot into armel rootfs on a x86 machine and complete debootstrap second stage.

If building on Debian squeeze, we need to use a newer version of qemu-user-static to avoid errors like "qemu: Unsupported syscall: 341" when building packages. Add these lines to your /etc/apt/preferences file:

Package: *
Pin: release a=stable
Pin-Priority: 900
Package: *
Pin: release o=Debian
Pin-Priority: -10

If building on Debian squeeze, add this line to your /etc/apt/apt.conf.d/70debconf file:

APT::Default-Release "stable";

If building on Debian squeeze, add this line to your /etc/apt/sources.list file:

deb testing main contrib

If building on Debian squeeze, update your apt information:

sudo apt-get update

Then proceed as normal:

sudo apt-get install -t testing qemu-user-static
sudo apt-get install binfmt-support
# If building on Ubuntu, here is command
sudo apt-get install binfmt-support qemu-kvm-extras-static
sudo modprobe binfmt_misc
sudo cp /usr/bin/qemu-arm-static mnt/usr/bin
sudo mkdir mnt/dev/pts
sudo mount -t devpts devpts mnt/dev/pts
sudo mount -t proc proc mnt/proc
sudo chroot mnt/
# You should see "I have no name!@hostname:/#"
/debootstrap/debootstrap --second-stage
# At the end, you should see "I: Base system installed successfully."

Add apt sources.

cd /root
cat <<END > /etc/apt/sources.list
deb squeeze/updates main contrib non-free
deb-src squeeze/updates main contrib non-free
deb  squeeze main contrib non-free
deb-src  squeeze main contrib non-free
apt-get update

Configure language.

sudo mount -t devpts devpts mnt/dev/pts
sudo mount -t proc proc mnt/proc
sudo chroot mnt/
export LANG=C
apt-get install apt-utils
apt-get install dialog
apt-get install locales
cat <<END > /etc/apt/apt.conf.d/71mele
APT::Install-Recommends "0";
APT::Install-Suggests "0";
dpkg-reconfigure locales
# Choose en_US.UTF-8 for both prompts.
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 uboot-mkimage uboot-envtools vim nano less

Configure eth0 and dhcp.

cat <<END > /etc/network/interfaces
auto lo eth0
iface lo inet loopback
iface eth0 inet dhcp

Setup machine name of your choice.

echo debian > /etc/hostname

File system 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

Activate remote console and disable local consoles.

echo 'T0:2345:respawn:/sbin/getty -L ttyS0 115200 linux' >> /etc/inittab
sed -i 's/^\([1-6]:.* tty[1-6]\)/#\1/' /etc/inittab

Set the root password.


Exit chroot and clean up.

sudo umount mnt/proc
sudo umount mnt/dev/pts

Install the kernel modules into the root filesystem.

cd /home/share/mele-hacking
cd linux-allwinner
sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- INSTALL_MOD_PATH=../debian-rootfs/mnt modules_install

Transfer the root filesystem onto the SD card.

cd /home/share/mele-hacking
mkdir mnt2
sudo mkfs.ext4 /dev/sdh2  (substitute your SD card device!)
sudo mount /dev/sdh2 mnt2
sudo cp -a debian-rootfs/mnt/* mnt2/
sudo umount mnt2
sudo umount debian-rootfs/mnt

Put the SD card into the Mele A2000, connect ethernet and HDMI cables. Unplug, count to 5, and plug back in. Your TV won't display anything. After a few minutes, go to your router to determine the IP number DHCP assigned it. Then SSH to it. Example:

ssh root@


A few random tips.

X11 is not very stable and the Mali driver is being worked on. You can try running X11 with a frame buffer.

apt-get install module-init-tools
modprobe disp
modprobe lcd
modprobe hdmi

When I installed xfce4, it installed hal. As soon as the hal daemon started, I got an endless stream of "bus busy" errors. By forcing the hald not to start, I was able to work around it.

mv /usr/sbin/hald /usr/sbin/hald_disabled

I had better luck installing lxde instead of xfce4.

This wireless keyboard with trackball works without any changes: There are many others, I'm sure.