Developers working on AllWinner A10 have released an Ubuntu 10.04 LTS SD card image (4GB) for the Mele A1000.
I’ll show how you can create your own Debian or Ubuntu image based on this image for any size of SD Card using Debian 6.0 (Squeeze) and the recent Ubuntu 12.04 (Precise Pangolin) as example. The current image is not perfect, for example Ethernet doesn’t work (but you can still get network connectivity with WiFi), the NAND flash can not be accessed, the system does not appear to be very stable when running X and a few more issues. But this will be fixed by the developer community over time.

First download the SD card image
wget http://hands.com/~lkcl/mele-ubuntu-lucid.img.lzma
Install 7z (if you don’t have it yet) and decompress the file:
sudo apt-get install p7zip-full
7z x mele-ubuntu-lucid.img.lzma
The decompressed size is 4008706048, which might be larger than your 4GB SD Card (as it was my case). If you card is larger, you can simply dd the image to it:
dd if=mele-ubuntu-lucid.img of=/dev/sdX
where X is the letter corresponding to your SD Card device.
Let’s now have a look at the partitions in this image:
file mele-ubuntu-lucid.img
mele-ubuntu-lucid.img: x86 boot sector; partition 1: ID=0x83, starthead 33, startsector 2048, 32768 sectors; partition 2: ID=0x83, starthead 65, startsector 34816, 7794688 sectors, code offset 0x0
There are 2 partitions, let try to mount in 2 directories using the startsector value:
mkdir mnt
mkdir mnt2
sudo mount -o loop,offset=$((512*2048)) mele-ubuntu-lucid.img mnt
sudo mount -o loop,offset=$((512*34816)) mele-ubuntu-lucid.img mnt2mount | grep loop
/dev/loop0 on /home/jaufranc/edev/mele_A1000/mnt type vfat (rw,offset=1048576)
/dev/loop1 on /home/jaufranc/edev/mele_A1000/mnt2 type ext4 (rw,offset=17825792)
So we can now see the content of the 2 partitions:
- Partition 1 (FAT 32) – Linux 3.0.8 Kernel (uImage) + some binaries files (evb.bin, mele.bin and sys_config1.mele_mod.bin).
- Partition 2 (EXT-4) – Ubuntu 10.04 rootfs
There are some files specific to A10 in the rootfs, namely the kernel modules and OpenGL ES files, so we need to extract them in order to copy in the our new rootfs lateron.
cd mnt2
tar cjvf ../a10_modules_3.0.8.tar.bz2 lib/modules/3.0.8+/
tar cjvf ../a10_opengles.tar.bz2 lib/libUMP.so lib/libEGL.so lib/libGLESv2.so lib/libGLESv1_CM.so lib/libMali.so
cd ..
sudo umount mnt
sudo umount mnt2
We haven’t found the bootloader yet, but you may noticed there is a 1MB offset (512*2048) for the first partition, that because the partition table and the bootloader are located in the first 1MB of the SD Card as explained in A10 MMC Page. There are two part for U-boot: U-boot and the X-loader up-streaming(SPL), but they are both located in the first 1MB of the SD Card.
Now let’s make a copy of u-boot (and u-boot SPL) and the FAT 32 partition:
dd if=mele-ubuntu-lucid.img of=mele_u-boot.bin bs=1024 skip=8 count=1008
dd if=mele-ubuntu-lucid.img of=mele_kernel_3.0.8_vfat.bin skip=2048 count=32768
Now that we have all what’s needed from the SD card image, let’s create the root file system.
Here are the instructions to get a minimal Debian 6.0 (Squeeze) rootfs:
mkdir debian_armel_squeeze
sudo apt-get install debootstrap
sudo debootstrap --foreign --arch armel squeeze debian_armel_squeeze http://ftp.debian.org/debian
Here are the instructions to get a Ubuntu 12.04 (Precise Pangolin) desktop: (JLA check command in Ubuntu virtual box)
sudo apt-get install rootstock
sudo rootstock --fqdn ubuntu --login ubuntu --password ubuntu --imagesize 3G --seed ubuntu-desktop,openssh-server --serial ttyS0 --dist precise
Which ever command you choose it will take while, so in the meantime, let’s prepare the SD Card. I’ll only provide a summary here, for line by line details refer to the instructions provided in the Format section of A10 MMC page. I’ll use /dev/sdb as the drive letter, it may be different on your computer.
- Wipe out the SD card partition table:
1sudo dd if=/dev/zero of=/dev/sdb bs=1M count=1 - Create 2 partitions with fdisk:
1sudo fdisk /dev/sdb
The first partition must start at sector 2048 and its size must be 16MB.
The second partition must start at sector 34816 (I think this may slightly vary depending on your SD card) and fill the rest of the SD card. - Format partition 2:
1sudo mkfs.ext4 /dev/sdb2 - Copy the u-boot and kernel binaries to your SD card
12sudo dd if=mele_u-boot.bin of=/dev/sdb bs=1024 seek=8sudo dd if=mele_kernel_3.0.8_vfat.bin of=/dev/sdb1
Once the rootfs of your choice has been generated, first mount the ext4 partition:
1 |
sudo mount /dev/sdb2 mnt |
Then copy the rootfs to the SD card together with the kernel modules and OpenGL ES files. We are using Ubuntu 12.04 armel here, but if you want to use Ubuntu 12.04 armhf (hard-float) the OpenGL ES file might not work on this system, and AllWinner would have to release hard-float binaries.
For Debian:
1 2 3 4 5 |
sudo cp -a <code>debian_armel_squeeze/* mnt cd mnt sudo tar xjvf ../a10_modules_3.0.8.tar.bz2 sudo tar xjvf ../a10_opengles.tar.bz2 cd .. sudo umount mnt |
For Ubuntu:
1 2 3 4 5 6 |
cd mnt sudo tar xzvf ../armel-rootfs-201204060847.tgz sudo tar xjvf ../a10_modules_3.0.8.tar.bz2 sudo tar xjvf ../a10_opengles.tar.bz2 cd .. sudo umount mnt |
At this point the Ubuntu image is basically done and you should be able to see the desktop and login, as long as the Mele A1000 is connected to an HDMI display.
For Debian, you’ll need to complete the second stage of deboostrap and add the apt-get source list using the Mele A1000 serial console, basically following the instructions given in the section “Generating ARMEL Debian Squeeze Rootfs” of that post. Since Ethernet does not work and WiFi is then required for internet connectivity, you also need to go to http://www.debian.org/distrib/packages#search_packages, download the Debian Squeeze armel packages for libdbus-1-3, libiw30, libnl1, libpcsclite1, multiarch-support, wireless-tools_30 and wpasupplicant_0.6 and copy them to the ext4 partition or a USB thumbdrive to install it at a later stage. You can install the package with dpkg in the Mele A1000:
1 |
sudo dpkg --i *.deb |
If you’d like to use the network in your device (including apt-get), you’ll need to setup Wi-Fi. With Ubuntu, you can simply do so in the graphical interface like you would do in PC or use the following instructions for Debian. With Debian, create /etc/network/interfaces file as follows (assuming you are using WPA/WPA2):
1 2 3 4 |
auto wlan0 iface wlan0 inet dhcp wpa-ssid ESSID wpa-psk password |
Make sure the Wi-Fi module (8192cu) is loaded with lsmod. If not, run depmod -a and possibly restart your device.
Wi-Fi should start automatically, if not run “ifup wlan0”.
By default (due to a setting in the Android kernel provide), a normal user will not be able to access the network, to change that (for user ubuntu):
1 2 |
sudo groupadd -g 3003 aid_inet sudo usermod -a -G aid_inet ubuntu |
A final tip. In case you prefer to use VGA instead of HDMI, you can use this code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
int main(int argc, char const *argv[]) { unsigned long args[4]; int ret = -1; int disp = open("/dev/disp", O_RDWR, 0); args[0] = 0; args[1] = 0; args[2] = 0; args[3] = 0; ret = ioctl(disp,0x201,(unsigned long)args); //turn VGA off args[1] = 0x4; //set mode to 1024x768 ret = ioctl(disp,0x202,(unsigned long)args); //set the mode ret = ioctl(disp,0x200,(unsigned long)args); //turn VGA on again return 0; } |
The value in this code are based on drv_display_sun4i.h in the kernel code.
Build it and run it:
1 2 |
gcc vga_on.c -o vga_on sudo ./vga_on |
In case somebody tries those instructions and find some issues or have ideas for improvements, please let me know in the comments section as I may have missed some steps.

Jean-Luc started CNX Software in 2010 as a part-time endeavor, before quitting his job as a software engineering manager, and starting to write daily news, and reviews full time later in 2011.
Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress