Home > AllWinner A1X, Linux > How to Create Your Own Debian / Ubuntu Image for Mele A1000 (AllWinner A10 Based STB)

How to Create Your Own Debian / Ubuntu Image for Mele A1000 (AllWinner A10 Based STB)

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.

Mele A1000 Debian Serial Port Output

Mele A1000 Debian 6.0.4 Terminal

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 mnt2

mount | 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.

  1. Wipe out the SD card partition table:
    sudo dd if=/dev/zero of=/dev/sdb bs=1M count=1
  2. Create 2 partitions with fdisk:
    sudo 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.

  3. Format partition 2:
    sudo mkfs.ext4 /dev/sdb2
  4. Copy the u-boot and kernel binaries to your SD card
    sudo dd if=mele_u-boot.bin of=/dev/sdb bs=1024 seek=8
    sudo 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:

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:

sudo cp -a 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:

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:

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):

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):

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:

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:

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.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter

  1. mac me
    April 28th, 2012 at 22:27 | #1

    really good writeup .. thx

  2. guiguid
    May 4th, 2012 at 01:22 | #2

    Very good tutorial !

  3. suzuke
    May 8th, 2012 at 04:05 | #3

    I make Ethernet work by adding one line into the evb.fex file,
    “emac_power = port:PH15″
    insert this line in the end of [emac_para] setting.

    I also replaced the MAC=”000000000000″ by the one on my machine which can be found on the RJ45 network Interface, but I am not sure whether it is necessary

  4. suzuke
    May 8th, 2012 at 04:14 | #4

    Since the HTML syntax, I cannot reply the correct setting.
    So I share my evb.fex at http://dl.dropbox.com/u/15543924/evb.fex

  5. May 8th, 2012 at 09:28 | #5

    @ suzuke
    Thanks for the file suzuke! Sorry about the quote issue in WordPress comments.

  6. suzuke
    May 8th, 2012 at 19:58 | #6

    Known issues: It seems only work with wicd.

  7. May 10th, 2012 at 00:08 | #7

    @ suzuke
    Thanks, I also work for me. Also I have VGA image, have you changed something else?

  8. opk
    May 11th, 2012 at 06:21 | #8

    You can also use Debian armhf instead of armel as that works fine. I had my debian setup before you posted this and didn’t bother copying over the files that you put in a10_opengles.tar.bz2. Do they get used for anything and/or work at all?

  9. May 11th, 2012 at 09:07 | #9

    @ opk
    Currently they are not used, but are needed if want to use the GPU for 2D/3D acceleration. Btw, I’ve tried es2gears but it fails. If you want to play videos, there is the CedarX library, which is also delivered in binary form.

    All those binaries are only available for armel for now and would not work for armhf.

  10. suzuke
    May 11th, 2012 at 12:53 | #10

    @ chiribe
    I also modified “disp_init” setting according to Steev’s recommendation in BarryK’ blog.
    Here is the url : “http://bkhome.org/blog/?viewDetailed=02808″

  11. Saravana
    May 11th, 2012 at 16:41 | #11

    Hi,
    Nice one I’m gonna try it.

    In the below point 4 you mean is SD card and not CF card right ?

    4.Copy the u-boot and kernel binaries to your CF card

  12. May 11th, 2012 at 17:46 | #12

    @ Saravana
    Yes, you are right. I’ve corrected the typo.

  13. Saravana
    May 11th, 2012 at 17:52 | #13

    @ cnxsoft
    That was fast. Also one more typo your first HyperLinK ” A10 MMC Page” works but not the second. Sorry for pointing all silly errors.

  14. May 11th, 2012 at 20:38 | #14

    @ Saravana
    Thanks. Anything else let me know. :)

  15. robertjw
    May 16th, 2012 at 11:12 | #15

    The section containing “sudo cp -a debian_armel_squeeze/* mnt…” is missing line breaks. This results in not being able to see the last command. (view source in your browser shows the commands in full).

  16. May 16th, 2012 at 15:08 | #16

    @ robertjw
    Thanks, it is fixed now. WordPress sometimes does strange things when switching between Viewer and HTML tabs…

  17. jchaos
    May 21st, 2012 at 16:30 | #17

    It works great thnx for all the information. There is only one problem; The SD card interface is very slow. Therefore i would like to install the linux image on a Harddisc.
    Is it possible and how can i do that?

  18. May 21st, 2012 at 16:42 | #18

    @ jchaos
    If you are using Ubuntu 12.04 make sure you select Ubuntu 2D, the default Unity 3d interface will be very slow.
    As for installing the Linux image in the hard disk, it’s possible. But I don’t have a 2.5″ SATA hard disk, so I don’t know the exact procedure. I think some people have done it on arm-netbook mailing list, by changing evb.bin, the boot loader parameters and possibly recompiling the kernel.

  19. Mathew
    June 12th, 2012 at 15:20 | #19

    Hi,
    I dont suppose you can release the compliled versions of debian and ubuntu ready for install onto an SD Card? Im having major issues trying to compile and get it working?

    Thanks
    Mathew

  20. June 12th, 2012 at 15:52 | #20

    @ Mathew
    Since at the time it was not really stable, I just provided the instructions to build it. But the image will be available soon, or at least much simpler instructions (e.g. 3 lines instructions). It still have some issues with the latest bootloader before I can provide those. In the meantime, you can also use Ubuntu 10.04 image mentioned at the top of the post.

  21. June 13th, 2012 at 04:52 | #21

    Hi,

    I’m stuck with rootstock because I’m on Mac. I’ve done almost everything but still cannot build Ubuntu 12 image. Has anybody built it already?

    Regards,
    Alexander

  22. June 13th, 2012 at 21:19 | #22

    @ Alexander What ? you don’t already have a dualBoot with Linux ?

  23. June 13th, 2012 at 22:31 | #23

    @ Mathew
    @ Alexander
    You can try the new method (about 3 steps) to create an SD card image with Ubuntu 12.04 (Linaro version):
    http://www.cnx-software.com/2012/06/13/hardware-packs-for-allwinner-a10-devices-and-easier-method-to-create-a-bootable-ubuntu-12-04-sd-card/

  24. June 15th, 2012 at 18:34 | #24
  25. June 15th, 2012 at 21:08 | #25

    @ Alexander
    Yes, this is based on Ubuntu 10.04 release with kernel 3.0.8+ and probably based on the instructions above.
    This easy to replace Ubuntu 10.04 rootfs with Ubuntu 12.04 rootfs. I suppose this image works, but it does not work with kernel 3.0.31 because SATA is now enable. I might receive a Z802 soon, so I might be able to investigate.

  26. mac me
    June 29th, 2012 at 04:19 | #26

    Hi,

    I just got a couple of Mele A10 boards and had a bash at cross compiling Debian Wheezy (ARMHF) .. which all seemed to go smoothly BUT .. what a nighmare the GIT UBOOT are at the moment .. no matter what i tried i couldnt get them to work .. gave up in the end after reading stories about the GIT code being broken e.t.c. … in the end used the image of a known UBOOT bootable linaro server and copied my Kernel/script.bin/boot.scr in to ROOT partition (deleting existing) and likewise copied my ROOTFS/modules in to ROOTFS partition… modified (i’m a newbie) script.bin and boot.scr as best i could figure.

    First time it booted .. yay its worked then it turned out the damned ext4 fs was read only :-(
    did a fsck and rebooted and it has booted in to a read/write ext4 root fs and allowed me to zap the wifi, update the time etc.

    when i do a blkid surprisingly I see that the nand is mounted as well ? and i would much prefer the UBOOT and RFS partitions as /dev/sda1 and dev/sda2 ? anyone any tips to achieve this ? (my decoded boot.scr is below)

    /dev/nanda: SEC_TYPE=”msdos” LABEL=”Volumn” TYPE=”vfat”
    /dev/nandd: UUID=”57f8f4bc-abf4-655f-bf67-946fc0f9f25b” TYPE=”ext4″
    /dev/nande: UUID=”57f8f4bc-abf4-655f-bf67-946fc0f9f25b” TYPE=”ext4″
    /dev/nandh: UUID=”57f8f4bc-abf4-655f-bf67-946fc0f9f25b” TYPE=”ext4″
    /dev/nandi: LABEL=”PRIVATE” UUID=”7C0A-07DE” TYPE=”vfat”
    /dev/nandk: LABEL=”APOLLO” UUID=”B066-07DE” TYPE=”vfat”
    /dev/mmcblk0p1: SEC_TYPE=”msdos” UUID=”0289-5CB8″ TYPE=”vfat”
    /dev/mmcblk0p2: UUID=”5b266b42-62d0-4e29-9130-3de71a0434c4″ TYPE=”ext4″

    and my boot.scr :
    setenv bootargs console=ttyS0 root=/dev/mmcblk0p1 extra ‘rootfstype=ext4 rootwait’
    ext2load mmc 0 0x43000000 boot/script.bin
    ext2load mmc 0 0x48000000 boot/uImage
    bootm 0x48000000

    the only other obvious issue is that the device just reboots when i enter “shutdown now” and perversely seems to enter some kind of powered (light is on) limbo when i enter “reboot” in a terminal .. i’d at least like to get it to shutdown cleanly and ideally switch off if anyone has any ideas ??

    finally if anyone has any ideas i’d love to be able to use the on/off switch to power the device down again

    aster disabling the GUI login (and using SSH) i get (reading in top) 364MB RAM total available and at idle (with SSH/top running) 23M used and 341M free (once i get the kernel stable i’ll work on a new kernel version with anything non headless i can find switched off)

    anyone have any tips for some lightweight benchmarking app to test (incl FPU) .. not graphics though

    once i get it stable and clean i’m happy to post the Mele Debian headless Wheezy image if it helps other newbies like me

    usb drives are recognised fine .. dont have a spare SATA drive to test at the moment and would love to know if SATA works fine .. likewise i’m keen to test the cpu utilisation of using ethernet (anyone have an idea how to test)

    thx in advance

    ian

    ian

  27. June 29th, 2012 at 09:37 | #27

    @ mac me
    To build u-boot, kernel from source, you can try the scripts I did for the hardware packs:
    http://www.cnx-software.com/2012/06/13/hardware-packs-for-allwinner-a10-devices-and-easier-method-to-create-a-bootable-ubuntu-12-04-sd-card/

    For server, you can just use “mele-a1000-server” as the product. There is no display, but you’ll have maximum memory. And then you can just create an SD card image with something like “./a1x-media-create.sh /dev/sdb hardware_pack.7z wheezy_rootfs.tar.bz2″

    sda is for SATA or USB, but the SD card slot is connected via the SD card I/F of the CPU, that’s why the device is seen as mmcblk0.

  28. mac me
    June 30th, 2012 at 04:43 | #28

    @cnxsoft
    hi,

    thx for the reply and the scripts … im happy just to have it up and running at the mmt and ready to move on now to get the build a bit better with more memory and a clean shutdown

    what about the nand being mounted ? is that normal ?

    thx

    ian

  29. July 1st, 2012 at 10:14 | #29

    @ mac me
    The NAND flash is not mounted in the image is currently use (ALIP).

    I’ve seen you also asked about testing Ethernet performance. I used iperf and top. http://www.cnx-software.com/2012/06/22/ubuntu-12-04-server-armhf-image-for-mele-a1000a2000/comment-page-2/#comment-9283

    But there may be a better way to test that.

  30. M.C.
    July 4th, 2012 at 03:38 | #30

    Do you still get any hardware acceleration on this board if you replace the original Android with a Linux distro? I’m talking mainly about hardware video decoding.

  31. July 4th, 2012 at 09:26 | #31

    @ M.C.
    Not really.
    There is some code (https://github.com/amery/allwinner-a10-video) but it does not appear to work.
    There is a working sample in http://hands.com/~lkcl/mele-ubuntu-lucid.img.lzma, I think it’s only available in binary.
    Finally, one of XBMC developers has already obtained the cedarx libs and sample code, but AFAIK it’s not available publicly yet.

  32. Ashwin Jain
    September 21st, 2012 at 13:00 | #32

    Hey,

    we want to cross compile some of the drivers and put it on this ubuntu image. Can you please provide us the source code of the kernel used, so that we can cross compile those drivers.

  33. Cyk
    October 3rd, 2012 at 23:23 | #34

    Hi.
    Is there a method to switch the HDMI output from YCrCb to RGB, and to use Other resolutions, like 1024*768?

    Background: I don’t have a Mele, but an A10 stick that has only a HDMI output. I want to use a DVI Monitor with an adapter. This works, but colours and aspect ratio are off.

  34. Peter
    November 8th, 2012 at 00:58 | #35

    Is there any way to get puppy arcade(http://scottjarvis.com/page105.htm) running on the MK802?

  35. November 8th, 2012 at 09:29 | #36

    @Peter
    It looks like Puppy Arcade is actually an OS based on Puppy Linux, and AFAIK there is no ARM port just now, so somebody needs to work on it.

    You may get a better answer on Puppy Arcade website.

  1. May 4th, 2012 at 16:22 | #1
  2. May 10th, 2012 at 03:30 | #2
  3. June 10th, 2012 at 15:59 | #3
  4. June 13th, 2012 at 22:09 | #4
  5. June 14th, 2012 at 16:07 | #5
  6. June 14th, 2012 at 20:23 | #6
  7. July 10th, 2012 at 10:36 | #7
  8. February 1st, 2013 at 05:01 | #8