How to get started with Embedded Android on the Wandboard: Building and Deploying the Bootloader, Kernel and Android Root File System

wandboard

The community based Wandboard project (http://www.wandboard.org) is a very interesting open Freescale iMx6 hardware platform. The most recent release of the Android 4.2.2 Source Code for the board makes it an ideal candidate to prototype an Embedded Android System.

For this Blog Post we are using:
Android 4.2.2 wandboard repo sources
IMX Kernel 3.0.35+ (supplied by the Android sources)
U-Boot IMX Fork (supplied by the Android sources)
Host: Ubuntu 12.10 64 Bit (username: user)

Understanding how Android Boots

In this blog post we are looking a bit closer in how to get started with booting the platform using the patched Linux Kernel and u-boot. Both come with the Android Source code which is available for downloading with Android’s repo tool.

Building the Android OS , Kernel and U-Boot is done very conveniently. However, understanding the deployment and optimizing it for a real and practical Embedded Android application requires additional understanding and adjustments to the source. This blog post shows how to download the sources, build them and simplify the deployment to the SD-Card to understand the various parts of the Embedded System more deeply.

Boot Sequence on the Wandboard

The Wandboard by default seeks for a bootloader on the primary MMC slot at an offset of 1024 bytes into the device. If found, then the bootloader is executed. For development with the wandboard the u-boot bootloader is used. Its purpose is to load and start the Linux Kernel image and pass on the desired Kernel Command Arguments. These parameters are used to pass the Kernel adjustable configuration settings in order to boot up properly. As soon as the Kernel is started, u-boot is dismissed and Linux takes over the entire hardware (with its own device drivers etc.).

Last but not least the user space is started by the Kernel. By default the executable “init” on the root partition is executed as the first user space executable. In our case Android will take over eventually and from there on operate the Wandboard.

SD-Card Deployment

If you ever had a look at any Embedded Android SD-Card image, you most probably noticed a very complicated Partition Layout.

The same goes for the default Android SD-Card Layout. Here is an excerpt of the deployment

script of the Wandboard:

dd if=u-boot.bin of=${node} bs=1k seek=1 skip=1
dd if=/dev/zero of=${node} bs=512 seek=1536 count=16
dd if=boot.img of=${node}1
dd if=recovery.img of=${node}2
dd if=system.img of=${node}5

By default, the Android Root File System distincts itself from the classical Embedded Linux by splitting up the root mount point into a “system”, a “cache” and a “data” mountpoint (all used as partitions. Whereas the “root” mount point only exists in the devices RAM as “initramfs” or “initramdisk”.

data/
dev/
init*
init.rc*
init.usb.rc
init.wandboard.usb.rc
sbin/
system/
ueventd.goldfish.rc
default.prop
fstab.wandboard
init.goldfish.rc
init.trace.rc
init.wandboard.rc*
proc/
sys/
ueventd.freescale.rc
ueventd.rc

The above files are found in the devices “initramdisk” and thus extracted into the RAM every time the device boots and afterwards mounted to “/”.

The highlighted “system” and “data” folder serve as mounting point for the system / data partition.

The “initramdisk” itself is usually appended to the Kernel (zImage) as compressed archive.

The reasoning behind separating system and data partition is to be able to have the system mount point as read-only and therefore protect integrity. Of course it is possible to remount the system partition at any point, even on a tablet or smartphone, it requires root permission though.

The reasoning behind separating the system partition from the root mount point is a bit more obscure though. Most probably this serves in the standard distribution as additional layer of integrity for the system-crucial “init” binary and “init.*.rc” scripts.

From an Embedded System approach, the separation of the root mount point and the system partition is not optimal, since in development and also in production, it is always helpful to be able to make adjustments to the init scripts. Also having a ramdisk does not benefit performance of the system in any way. The distinction between system and data partition certainly has its perks though. By assuring that in day-to-day mode the system partition is used as read-only, this assures that the device will be able to be “factory-reset” by just wiping the data partition.

Desired SD-Card Layout for Deployment
Desired SD-Card Layout

The above illustration describes the desired sdcard layout. Note that the root file system partition is optimally a merge of both the initramdisk and the “system” partition and the initramdisk is therefore obsolete.

With the current Android 4.2.2 it is save to dimension the “Root File System” partition to about 300 MB. More is never a bad idea. The “Boot” Partition will hold the Kernel Image (uImage) and thus can be less than 5 MB. However, assuming you are in the possession of a 4 GB SD-Card, just give it 50 MB, you never know.

Android likes to cache stuff, so there is a cache partition. Depending on your SD-Card capacity I suggest you give it a nice 500 MB.
The Data partition should be where all the rest of the space is allocated. It is used for not only the user application data but also system persistent system data.

Partitioning an SD-Card on Ubuntu

To partition an SD-Card the “gparted” tool is optimal. It can be installed using the package manager.

sudo apt-get install gparted
sudo gparted

With the gparted the partitions are created pretty easily as described in the illustration. Just note that the first partition should be started a few Megabytes into the Disk, so later u-boot can be placed accordingly to where it is expected by the hardware.

gparted

Source Code initialization and Compiling

There is an entire article about how to set up the build environment on your host (preferably a 64 bit ubuntu 12.04+).

Most importantly download all the build tools for Android.

If you build on Ubuntu 13.04, use the following command:

sudo apt-get install git-core gnupg flex bison gperf build-essential \
  zip curl libc6-dev libncurses5-dev x11proto-core-dev \
  libx11-dev:i386 libreadline6-dev:i386 \
  libgl1-mesa-dev g++-multilib mingw32 openjdk-6-jdk tofrodos \
  python-markdown libxml2-utils xsltproc zlib1g-dev:i386 \
  ia32-libs u-boot-tools minicom lib32ncurses5-dev \
  uuid-dev:i386 liblzo2-dev:i386

If you build on Ubuntu 13.10, use the following command:

sudo apt-get install git-core gnupg flex bison gperf build-essential \
  zip curl libc6-dev libncurses5-dev x11proto-core-dev \
  libx11-dev:i386 libreadline6-dev:i386 \
  libgl1-mesa-dev g++-multilib mingw32 openjdk-6-jdk tofrodos \
  python-markdown libxml2-utils xsltproc zlib1g-dev:i386 \
  u-boot-tools minicom lib32ncurses5-dev \
  uuid-dev:i386 liblzo2-dev:i386

Update 16.08.2013, Added uuid-dev, liblzo2-dev to fix build error:
external/mtd-utils/mkfs.ubifs/mkfs.ubifs.h:48:23: fatal error: uuid/uuid.h: No such file or directory
external/mtd-utils/mkfs.ubifs/compr.c:28:23: fatal error: lzo/lzo1x.h: No such file or directory

Note that since the last few updates on Ubuntu, some of the packages won’t install anymore, so far you can ignore the errors.

To make sure all errors are purged, use the following command to force installation.

apt-get install -f

Initialize the Android Source Code of the Wandboard team and build environment (assuming your username is “user”):

sudo mkdir /opt/android
sudo chown -R user.user /opt/android
cd /opt/android
curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ./repo
chmod a+x ./repo 
./repo init -u git://www.wandboard.org/android/manifest.git -m default.xml
./repo sync -j4

The last command triggers the download (according to Google it’s about 8.5G). So grab a cup of coffee.

Before building the source an adjustment needs to be made. Android expects to compile with the Oracle Java binaries. However, it will compile just fine with the “open-jdk” implementation. To disable the error when compiling with the open-jdk package the file “build/core/main.mk” needs to be adjusted.

Comment out the “$(error stop)” on line 141 and 157

#$(error stop)

Building Android, Kernel and Bootloader

In order to start the build execute the following commands.

cd /opt/android
. build/envsetup.sh
choosecombo 1 wandboard 3
make -j4

As a result all necessary components for deployment are built. Time to get a cup of coffee again, this will take quite a while.

Build Errors source in 99% of all cases in a package not having been installed properly or having tried to install some obsolete package. This is sometimes the case when the Ubuntu package sources get updated. Usually examining the error message and googeling for it is the most fruitful recipe for such errors.

Kernel: uImage under kernel_imx/arch/arm/boot/
Bootloader: u-boot.bin (-6dl.bin -6quad.bin) under out/target/product/wandbooard/
Root/System: root/ system/ under out/target/product/wandbooard/

Further more Android features a recovery image where updates can be flashed and the data partition can be wiped etc. For the purpose of most Embedded Setups this can probably be ignored, however, I am letting myself convince otherwise for certain purposes.

Recovery: recovery/ under out/target/product/wandbooard/

Note that the u-boot source code used is a fork from the freescale team and therefore does not support all the recent features (such as ext4, environment loading, etc.). Over the past years u-boot has become ridiculously feature rich, to a point where you don’t even require a boot partition any more and just load your Kernel from an ext4 root partition. There is actually mainline support for the wandboard in the current u-boot version and you should consider trying it out. For this post we are sticking with the supplied version though, since with a few simple modifications it will suffice to get a first boot. Consider using the upstream version for your production builds though.

Building the Bootloader

The sources of u-boot are found under bootable/bootloader/uboot-imx.
You can build u-boot manually using make:

cd /opt/android/bootable/bootloader/uboot-imx
export CROSS_COMPILE=/opt/android/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-
# make the proper config, in our case for the wandboard dual
make wandboard_android_dl_config
make -j4

The result is the u-boot.bin. You can verify the bootloader’s functionality already by copying it onto the SD-Card.

# assuming the SD-Card is located under /dev/mmcblk0
# depending on your reader it might be under /dev/sdX
# be careful here! if applied to the wrong device
# such as your main hd, your host will not boot properly
# anymore
sudo dd if=u-boot.bin of=/dev/mmcblk0 bs=1k seek=1 skip=1
# also note that this command is different when using
# the mainline u-boot.imx file

Now insert the SD-Card into the primary slot (the one on the smaller PCB) and set up the serial console. See this link on how to set up minicom properly. You need a F-F Null-Modem Cable and (probably) a USB-Serial Converter to start debugging. Connect your host machine with the Wandboard and start minicom.

sudo minicom wandboard

You should see now a console prompt of a (failing) boot attempt.

In order to load the uImage from the first partition of the SD-Card we need to modify the u-boot configuration of the wandboard. Also we want to add the kernel command line arguments found in the Makefile under “device/fsl/wandboard/BoardConfig.mk”

bootargs=console=ttymxc0,115200 init=/init video=mxcfb0:dev=hdmi,1280x720M@60,if=RGB24,bpp=32 video=mxcfb1:off video=mxcfb2:off fbmem=28M vmalloc=400M androidboot.console=ttymxc0 androidboot.hardware=freescale
# also add our custom arguments for the root device
# ... root=/dev/mmcblk0p2 rootfstype=ext4 rootwait rw earlyprintk

So we edit the file “wandboard_android.h”

cd /opt/android/bootable/bootloader/uboot-imx
vim include/configs/wandboard_android.h

In the file we adjust the u-boot environment settings.

#define CONFIG_EXTRA_ENV_SETTINGS                                       \
                "netdev=eth0\0"                                         \
                "ethprime=FEC0\0"                                       \
                "fastboot_dev=mmc2\0"                                   \
                "bootargs=console=ttymxc0,115200 init=/init "           \
                        "video=mxcfb0:dev=hdmi,1280x720M@60,if=RGB24,"  \
                        "bpp=32 video=mxcfb1:off video=mxcfb2:off "     \
                        "fbmem=28M vmalloc=400M "                       \
                        "androidboot.console=ttymxc0 "                  \
                        "androidboot.hardware=freescale "               \
                        "root=/dev/mmcblk0p2 rw "                               \
                        "rootfstype=ext4 rootwait\0"    \
                "bootcmd=ext2load mmc 2:1 0x12000000 uImage;"           \
                        "bootm 0x12000000;\0"                           \
                "splashimage=0x30000000\0"                              \
                "splashpos=m,m\0"                                       \
                "lvds_num=1\0"
#endif

Note: This is a really ugly way to configure u-boot. Ideally you would import an environment from the boot partition “uEnv.txt” and load it on boot up. This way you can always change the boot environment variables any time and thus allow the system to be more modular. However, in the fork of uboot-imx the environment import seems not to work properly which forces us to go with this dirty adjustment. One way to get this done is to use the upstream u-boot source code instead of the imx fork (the wandboard dual and solo are supported there already).

Once the header file is edited, save it and compile u-boot once more.

export CROSS_COMPILE=/opt/android/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-
make clean
make mrproper
make wandboard_android_dl_config
make -j4

# mrproper cleans the old config (also used in the kernel)

The result should be a new u-boot.bin file in the current folder. Inser the SD-Card once more and copy it onto the device node.

sudo dd if=u-boot.bin of=/dev/mmcblk0 bs=1k seek=1 skip=1

The only thing missing to boot the kernel now is the uImage on the SD-Card.

cd /opt/android
sudo cp kernel_imx/arch/arm/boot/uImage /media/user/BOOT/
sync
sudo umount /media/user/*

Plug the SD-Card back into the wandboard and see the Kernel booting over minicom.
You will get a kernel panic though since there is no “init” on the root partition yet.

Deploying the Android Root File System

The next step is to somehow bring the contents of root/ and system/ together and fit them into the “ROOT” partition on the SD-Card. This would be an extremely straight forward task if it wasn’t for the all important permissions of the files and folders of the Android Root File System. However, there are some tools which enable us to get the job done.

First of all we will create a new directory called “deploy” where we are merging the root/ and system/ folder in order to copy it 1:1 to the SD-Card once set up.

cd /opt/android
mkdir deploy
cd deploy

First of all: We copy the contents of the root/ folder into it and adjust the permissions.

cp -a ../out/target/product/wandboard/root/* .
sudo chown -R 2000.root *
sudo chmod 644 *.rc
sudo chmod 644 *.prop

If you have a look at the files in system/ you will notice, that the permissions and stats are not at all relating to the Android deployed files. There is a tool however, to create a tarball with all the correct file stats for the system partition.

cd /opt/android
build/tools/mktarball.sh out/host/linux-x86/bin/fs_get_stats out/target/product/wandboard/ system system.tar system.tar.bz2

As a result you will get a system.tar.bz2 under your /opt/android folder. Now we extract it with the “-p” directive to assure the file stats and permissions are retained.

cd /opt/android
# following command will take a while to run
build/tools/mktarball.sh out/host/linux-x86/bin/fs_get_stats out/target/product/wandboard/ system system.tar system.tar.bz2
sudo tar -xpvf system.tar.bz2 -C deploy/

If you have a look at the resulting files you will notice that the permissions are now correctly applied for the Android system partition.

ll deploy/system/
drwxr-xr-x 12 root   root    4096 Jun 14 09:46 ./
drwxrwxr-x  8 user     user  4096 Jun 18 14:06 ../
drwxr-xr-x  2 root   root    4096 Jun 18 14:15 app/
drwxr-xr-x  4 root     2000  4096 Jun 18 14:14 bin/
-rw-r--r--  1 root   root    1617 Jun 13 23:15 build.prop
drwxr-xr-x 10 root   root    4096 Jun 18 14:14 etc/
drwxr-xr-x  2 root   root    4096 Jun 18 14:14 fonts/
drwxr-xr-x  2 root   root    4096 Jun 18 14:14 framework/
drwxr-xr-x  8 root   root   20480 Jun 18 14:14 lib/
drwxr-xr-x  3 root   root    4096 Jun 13 23:48 media/
drwxr-xr-x  7 root   root    4096 Jun 14 00:01 usr/
drwxr-xr-x  4 root     2000  4096 Jun 14 00:48 vendor/
drwxr-xr-x  2 root     2000  4096 Jun 18 14:14 xbin/

There is one more step of adjustment. The file “deploy/fstab.wandboard” should now be adjusted to represent the new partition layout.

cd /opt/android
sudo vim deploy/fstab.wandboard
/dev/block/mmcblk0p4    /data    ext4    nosuid,nodev,nodiratime,noatime,nomblk_io_submit,noauto_da_alloc,errors=panic    wait
/dev/block/mmcblk0p3    /cache   ext4    nosuid,nodev,nomblk_io_submit   wait

That’s it. You can now deploy the contents of deploy/ to the SD-Card.

cd /opt/android
sudo cp -a deploy/* /media/user/ROOT/ --verbose
sync
sudo umount /media/user/*

Plug back in your SD-Card and you should see your Android build booting on your minicom.

Read-Write access on Root Partition

# adjust init.rc, change line 148
mount rootfs rootfs / ro remount
# to
mount rootfs rootfs / rw remount

ADB Debug over Network

# adjust init.rc, add this around
# line 397
setprop service.adb.tcp.port 5555
# at line 482 start always adbd
on property:ro.secure=0
   start adbd

Compiling Busybox

Usually you want to have a few more tools at hand when you play around with an Embedded System. Busybox is probably one of the most popular candidates for that.

Download and compile Busybox:

cd /opt/android
git clone git://busybox.net/busybox.git
cd busybox
wget http://www.nexus-computing.ch/files/android-build -O examples/android-build
wget http://www.nexus-computing.ch/files/android_4.2.2_defconfig -O configs/android_4.2.2_defconfig
make android_4.2.2_defconfig
chmod a+x examples/android-build
examples/android-build
# ... this will compile busybox with the correct flags etc.
# the android-build script will search for the android source
# root directory at ../../
# now copy busybox to /system/bin or use it with
# make install
# I only tested it by executing it "busybox vi" style
sudo cp busybox /media/user/ROOT/system/bin
sudo chmod /media/user/ROOT/system/bin/busybox
sudo chown root.2000 /media/user/ROOT/system/bin/busybox

Please note that not all the busybox functionality was tested and probably some of it will intersect with Android’s native “toolbox” implementation.

Liked this post? Add a comment below to let us know!
Looking for professional Android Training or Android Engineering? See Nexus-Computing for more.

41 Replies to “How to get started with Embedded Android on the Wandboard: Building and Deploying the Bootloader, Kernel and Android Root File System”

  1. Thank you for sharing this guide: it addresses several “newbie” questions I’ve been trying to suss out through the wandboard.org forums.

    One remaining question from someone just getting started: how and where in this process can you configure the kernel before building it?

    Following a similar guide for Linux on Wandboard (https://eewiki.net/display/linuxonarm/Wandboard), the build step pops up an ncurses menu system where you can select/deselect kernel options, but I’m not getting anything similar following the build instructions for Android on Wandboard. What am I missing?

    Thanks for any help,

    –Matt

    1. Hi Matt,

      Thank you so much, I am happy the article is helping you out.

      For configuring the kernel you would have to go into the Kernel directory and doing about those steps:

      cd /opt/android/
      export ARCH=arm
      export CROSS_COMPILE=/opt/android/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-
      cp arch/arm/configs/wandboard_android_defconfig .config
      # now configure the kernel
      make menuconfig
      make -j4 uImage
      

      assuming your android source lies under /opt/android

      Tell me if that worked for you.

      All the best
      Manuel

      1. Hi Manuel. That worked perfectly for getting me into an interactive kernel config menu, thank you! I ended up with no wireless–not sure what’s up with that, as I didn’t touch any network items in .config and it’s not throwing errors to the serial terminal during boot –but I should be able to suss that out with some tinkering. Thanks again! –Matt

  2. Thanks a lot for this guide. Woth that I was able to do a complete Android build.
    I used Ubuntu 12.04 LTS 64 bit. I had some problems with make menuconfig for kernel configuration.
    Libncurses5-dev was not enough, after installing lib32ncurses5-dev it worked for me.

    Best regards
    Markus

  3. Hi,

    I really appreciate your work! It helped me to build finally an Android image by myself.
    But unfortunately I am lost right now to bring the content to the SD card. :/
    It seems I am unable to mix the information found in different locations to a working result.
    Especially I have no clue about how to make the partitions to work. I used the script found under ./device/fsl/common/tools/fsl_sdcard-partitions.sh, but it is not suitable in the mix with the above mentioned change of wandboard_android.h (I need to use uImage instead of boot.img now)
    Would it be possible to show me an alternative deloyment script or help me with a modified fsl-sdcard-partitions.sh? Your help would be really more than appreciated at this point!
    Thanks in advance …

    Michael

    1. Hey Michael!

      Thank you, glad you enjoyed the post ๐Ÿ™‚

      Regarding Partitioning:
      Have you tried out “gparted”?
      Do it manually, this way you also get a feel of how your layout looks instead of just following some voodoo magic ๐Ÿ™‚
      I will upload a screenshot to the post to give you an idea.

      All the best
      Manuel

      1. Hi Manuel,

        great hint … with the new screenshot I finally finished the first part! ๐Ÿ™‚

        So I guess I can continue from here and continue to follow your Howto.
        Maybe one last question at this point. What I get from the console is:

        U-Boot 2009.08-00687-gb87aa36-dirty (Aug 17 2013 – 17:05:27)

        CPU: Freescale i.MX6 family TO1.2 at 792 MHz
        Thermal sensor with ratio = 182
        Temperature: 31 C, calibration data 0x57f4ed69
        mx6q pll1: 792MHz
        mx6q pll2: 528MHz
        mx6q pll3: 480MHz
        mx6q pll8: 50MHz
        ipg clock : 66000000Hz
        ipg per clock : 66000000Hz
        uart clock : 80000000Hz
        cspi clock : 60000000Hz
        ahb clock : 132000000Hz
        axi clock : 264000000Hz
        emi_slow clock: 132000000Hz
        ddr clock : 528000000Hz
        usdhc1 clock : 198000000Hz
        usdhc2 clock : 198000000Hz
        usdhc3 clock : 198000000Hz
        usdhc4 clock : 198000000Hz
        nfc clock : 24000000Hz
        Board: i.MX6Q-WandBoard: unknown-board Board: 0x63012 [POR ]
        Boot Device: SD
        DRAM: 2 GB
        MMC: FSL_USDHC: 0,FSL_USDHC: 1,FSL_USDHC: 2
        *** Warning – bad CRC or MMC, using default environment

        In: serial
        Out: serial
        Err: serial
        Gotr MAC = 00:1F:7B:B4:01:70
        Net: got MAC address from IIM: 00:1f:7b:b4:01:70
        FEC0 [PRIME]
        Hit any key to stop autoboot: 0
        Loading file “uImage” from mmc device 2:1 (xxc1)
        2836400 bytes read
        ## Booting kernel from Legacy Image at 12000000 …
        Image Name: Linux-3.0.35+
        Image Type: ARM Linux Kernel Image (uncompressed)
        Data Size: 2836336 Bytes = 2.7 MB
        Load Address: 10008000
        Entry Point: 10008000
        Verifying Checksum … OK
        Loading Kernel Image … OK
        OK

        Starting kernel …

        3 questions here:

        1. Is it correct that there is mentioned unknown board name?
        2. Do I need to worry about the warning Bad CRC at the beginning?
        3. In earlier test versions I realized an output at the beginning mentioning a found BOOT_ARGS line (I don’t see it anymore)

        I don’t know if it is in your interest if I ask such special questions here. So if you want to use me a different communication channel please tell me.

        Again many thanks for your quick help at this point! ๐Ÿ™‚

        Kind regards,
        Michael

  4. Hi

    i am following the tutorial but i receive soon compiling errors:
    “No rule to make target wpa_supplicant/drivers.mk”

    and the process stops.

    I am also trying to change screen resolution to 1920×1080 to uboot and uImage and flash it back to demo Wandboard image but the resolution is still fixed to 1280×720. Any idea?

    1. Hi Michele,

      can’t tell you much about the first part of your question. Regarding the second part I tried the same approach as you at the beginning. Didn’t work. Later I realized that I was always flashing to mmcblk0 but needed to use sdc (in my case) as target. Additionally I am not sure if it’s possible to mix the demo image with the u-boot. Lastly I got the new resolution while following the complete tutorial (means different partitioning, different type of deployment). But maybe Manuel can enlighten us more at this point ๐Ÿ™‚
      One last point: You checked the correct typo (e.g. spaces) of all issued commands while following this howto?

      Regards,
      Michael

  5. Hi,
    last week I finally got the Wandboard Quad. Now I am trying to get the U-Boot to work. I think I did everything mentioned above, but I am not successful.
    This is my output:

    U-Boot 2009.08-00687-gb87aa36-dirty (Aug 19 2013 – 00:13:25)

    CPU: Freescale i.MX6 family TO1.2 at 792 MHz



    MMC: FSL_USDHC: 0,FSL_USDHC: 1,FSL_USDHC: 2
    In: serial
    Out: serial
    Err: serial
    Gotr MAC = 00:1F:7B:B4:00:09
    Net: got MAC address from IIM: 00:1f:7b:b4:00:09
    FEC0 [PRIME]
    Hit any key to stop autoboot: 0
    booti: bad boot image magic
    fastboot is in init……flash target is MMC:2
    Bad partition index:5 for partition:system
    USB Mini b cable Connected!
    fastboot initialized
    USB_SUSPEND

    At all it looks similar to the post from Michael, thanks for that.
    I think the problem is located in the environment variables, e.g. “bootcmd”. It calls “booti mmc2” instead of “ext2load”.
    When I print the environment variables I get the following:

    WANDBOARD QUAD U-Boot > printenv
    bootdelay=2
    baudrate=115200
    ipaddr=192.168.1.103
    serverip=192.168.1.101
    netmask=255.255.255.0
    loadaddr=0x10800000
    rd_loadaddr=0x11000000
    netdev=eth0
    ethprime=FEC0
    fastboot_dev=mmc2
    bootcmd=booti mmc2
    splashimage=0x30000000
    splashpos=m,m
    lvds_num=1
    ethact=FEC0
    bootargs=console=ttymxc0,115200 init=/init video=mxcfb0:dev=hdmi,1280x720M@60,i0
    stdin=serial
    stdout=serial
    stderr=serial

    I also tried out to set the macro CONFIG_EXTRA_ENV_SETTINGS in other includes than wandboard_android.h, but with same result.
    If I stop autoboot and do the call for ext2load manually the kernel image is found and boot starts, but hangs up. I think this is because not all bootargs are set correctly.
    Do you have any idea what is going wrong?

    Best regards
    Markus

  6. Hi Markus,

    not sure what you did exactly. Even that I didn’t try to mix the boot args (old one was booti)

    I used the complete set as mentioned in the article, so changed e.g. booti with ext2load too. Here are the lines again which I use in wandboard_android.h:


    "bootargs=console=ttymxc0,115200 init=/init " \
    "video=mxcfb0:dev=hdmi,1280x720M@60,if=RGB24," \
    "bpp=32 video=mxcfb1:off video=mxcfb2:off " \
    "fbmem=28M vmalloc=400M " \
    "androidboot.console=ttymxc0 " \
    "androidboot.hardware=freescale " \
    "root=/dev/mmcblk0p2 rw " \
    "rootfstype=ext4 rootwait" \
    "bootcmd=ext2load mmc 2:1 0x12000000 uImage;" \
    "bootm 0x12000000;"

    Compiling the stuff is half the way (no other changes are required). Please take a look at this point to the right location of uImage as well. What I did else was preparing the SD card as shown in the GParted screenshot in the upper article. Finally I followed the rest of the description. It means you won’t write a boot.img or something like this to the card but copy the stuff (e.g. uImage) to the card instead. If you follow this way all should work as expected. In my case I have a fresh Android installation running at 1080p right now. ๐Ÿ™‚

    Kind regards,
    Michael

    1. Hi Michael,

      thank you for your thoughts on this. I tried it again, again and again, but it seems that the define for CONFIG_EXTRA_ENV_SETTINGS in wandboard_android.h is useless. I copied it from article above so I think should be OK. This is the only change in the U-Boot source.
      When I stop autoboot afterwards set the bootargs in U-Boot prompt with “setenv” and call ext2load manually then uImage is loaded and I can boot and start Android successfully, so I assume location of uImage is correct. In the meantime I also recreated the SD card partitions and now have exactly the same one as in the article.
      I use card reader via USB and write the u-Boot to sdb insetad mmcblk0. As U-boot starts I guess this isn’t the problem.
      I want to know the why the setting for CONFIG_EXTRA_ENV_SETTINGS is useless?
      In your U-boot output I found the warning
      *** Warning รขโ‚ฌโ€œ bad CRC or MMC, using default environment
      which isn’t listened in my output.

      Do you use the Wandboard QUAD?

      Best regards
      Markus

      1. Hi Markus,

        yes … I use the quad as well. Now clue so far what is different on your side. But 2 hints, maybe they can help:

        1. Take care that you write the correct u-boot.img to the card. Don’t use the one from the out folder, because it differs from your recompiled version (check it better against timestamps and sizes).
        2. I modified the following line while recompiling u-boot:

        make wandboard_android_dl_config !!!use wandboard_android_quad_config here!!!
        make -j4

        Hope this helps!?

        Kind regards,
        Michael

  7. Hi Michael,

    thank you for your reply. Good to here that QUAD basically works. I already took care of your 2 hints. I used the one in the folder uboot-imx and another config than wandboard_android_quad_config causes that u-boot won’t start in console.
    I assume you use the u-boot.bin file, too. It looks like the modification of CONFIG_EXTRA_ENV_SETTINGS doesn’t work. In the mean time I tested it on another machine with Ubuntu 12.04 64bit, same result.
    I really hope the problem is not because of using VMware Virtual Box but I can’t imagine.

    Well I think I have to study u-boot and look why the CONFIG_EXTRA_ENV_SETTINGS in wandboard_android.h aren’t used, discarded or overwritten during runtime.

    Best regards
    Markus

  8. Hi Markus,

    I use VMware as well to build the image, so this shouldn’t be the reason at all. Seems you did all as me in this case. The only thing which I did change else was to modify the BoardConfig.mk too (commented the old ARGS line and activated the new one with the higher resolution). I would send you my files as well, but don’t know if it is good practice here to share mail adresses.

    Kind regards,
    Michael

    1. Hi Michael,

      thank you for your offer. I added
      bootargs=console=…. … root=/dev/mmcblk0p2 rootfstype=ext4 rootwait rw earlyprintk
      in BoardConfik.mk but I didn’t comment out the original
      BOARD_KERNEL_CMDLINE := console …

      I wondered that the article uses bootargs= instead of BOARD_KERNEL_CMDLINE:=. I’ll now do it like this: BOARD_KERNEL_CMDLINE :=bootargs=console…
      Anyway, I thought that BoardConfig isn’t used in Bootloader when calling make for u-boot manually. To be sure I will do it like you, clean and recompile complete Android source.

      If that doesn’t help it would be nice if you could send me your boardConfig.mk, wandboard_android.h and also your u-boot.bin. I have the same partition layout as above in the article, I think you did the same way. Therefore I’ll ask the post author to send you my email address.

      Thank you.

      1. Hi Markus,

        I don’t think that your changes are the reason for the problems.
        Yesterday I tried to flash another card (it was containing an old Android demo image from Wandboard). But what the hell … the same image as before didn’t work anymore!?! :O
        I tried a lot of things, recompiled the complete Android sources again, changed different settings in my wandboard_android.h (e.g. #define CONFIG_BOOTDELAY 10) … nothing helped. It was always using booti, searching for a system partition, used wrong boot_delay and so on (nothing of it anymore in my sources). Later I decided to use dd if=/dev/zero of=/dev/sdc for more than the first 1024 bytes (alternate I reformatted the whole disk in a second trial). What shall I say: after these steps I got my old bad CRC message back (???) but it worked finally again as expected. Now it uses correct boot delay, uses uImage and starts up with 1080p. Could you please verify these observations and tell me if it works in this way too on your side?

        Kind regards,
        Michael

        1. Hi Michael,

          just refreshed the browser and got your message.
          Yes, dd if=/dev/zero of=/dev/sdc solves the problem.

          Looks like we solved similar problem at the same time, but it seems your ideas came a little bit faster than mine.

          Best regards
          Markus

      2. Hi all,

        just solved the problem with u-boot, it was trivial as it is that often:
        Before I created the partition table and the partitions on the SD card it was prviously flashed with other test images from wandboard.org. The only way which help was writing zero to beginning of SD card:
        sudo dd if=/dev/zero of =/dev/sdx
        I did break after a couple of seconds. Then I recreated the SD card partition layout, deployed the Android Root File System again and it works. *** Great ***.
        Confusing thing was that U-Boot runned with correct build date and time but modified strings were not used correctly.

        Read-Write access on root partition is essential otherwise Android startup hangs.

        @Michael
        You were completely right with “compiling the stuff is half the way”.

        Best regards,
        Markus

  9. Hi Markus,

    glad to hear! ๐Ÿ™‚
    Just one question: you get the “bad CRC or MMC” message now too?
    I wonder, what is the reason for it or more specifically, if this malfunction is the reason that we got the u-boot working now. I hate it to not understand the reasons … :/

    Kind regards,
    Michael

    1. Hi Michael,

      yes, now I have same message “bad CRC or MMC”, too. I have no idea where it comes from.
      Currently I am trying to get the 7″ touch display from future to work.
      I try it by modifying bootargs in BoardConfig.mk and and wandboard_android.h. Hope this works otherwise I need fresh new ideas.

      Best regards
      Markus

  10. Hey! Thanks for your post, great work!
    I was able compile the source with no errors.. But there is no “boot” folder in ../kernel_imx/. I have a “uImage” file in /out/target/product/wandboard/ … is that possibly the correct file?

    Thanks for for any help!
    Frime

    1. Hey Frime,

      The image should also bi under kernel_imx/arch/arm/boot/uImage.
      Anyhow, I think you can use the one in the out dir too (maybe it’s even a soft link?)

      All the best
      Manuel

    2. Oh .. okay, i have following error:

      W/zip (38189): ftruncate failed 475136: Invalid argument
      java.util.zip.ZipException: error in opening zip file
      at java.util.zip.ZipFile.open(Native Method)
      at java.util.zip.ZipFile.(ZipFile.java:132)
      at java.util.jar.JarFile.(JarFile.java:151)
      at java.util.jar.JarFile.(JarFile.java:130)

      zip package is installed.. has anybody an idea?
      Thanks again ๐Ÿ™‚
      Frime

      1. Hi Frime,

        Maybe check all of your installed packages again. Perhaps one is missing or due to some updates obsolete. As Manuel said in his post this is the root cause in 99% of compiler or linker errors.

        Best regards
        Markus

  11. Hi!

    Great guide!

    According Wandboard.org u-boot image ist
    $ dd if=~/wandboard/myandroid/out/target/product/wandboard/u-boot-6dl.bin of=/dev/sdX bs=1K seek=1 skip=1
    $ dd if=~/wandboard/myandroid/out/target/product/wandboard/boot.img of=/dev/sdX1
    $ dd if=~/wandboard/myandroid/out/target/product/wandboard/recover.img of=/dev/sdX2

    according your guide and …/myandroid/device/fsl/common/tools/fsl-sdcard-partition.sh it is
    dd if=u-boot.bin of=${node} bs=1k seek=1 skip=1
    dd if=/dev/zero of=${node} bs=512 seek=1536 count=16

    do I have to remove
    dd if=/dev/zero of=${node} bs=512 seek=1536 count=16
    from script if I use u-boot-6dl.bin instead of u-boot.bin?

    Thanks for your answer!

    Best regards,a
    Lukas

    1. Hey Luke,

      Thanks a lot! ๐Ÿ™‚

      I think that is not necessary. I believe the script just wipes the space until the first partition begins. The example worked fine though without deleting the stuff.

      All the best
      Manuel

  12. Hey!
    Thanks for this article! I was able to follow your steps and have now a 100% own built Android ๐Ÿ˜€
    But i need a newer Kernel version. The drivers for my Quanta TouchPanel are included since kernel version 3.3 … Can you give me a hint how to get a newer kernel version working for this setup? Thank you very much!!

    Best,
    Don

  13. Good day to everyone. I just want to know how to wipe an android tablet using an SD card with scripts on it? Thank you very much…

  14. Hi,
    Very good work. I am able to compile the android. Till last month I was able to build the sd card as well. But yesterday when I tried the same method using gparted and booted my Wandboard Quad, it is giving error

    *** Warning – bad CRC or MMC, using default environment

    In: serial
    Out: serial
    Err: serial
    Gotr MAC = 00:1F:7B:B4:05:F6
    Net: got MAC address from IIM: 00:1f:7b:b4:05:f6
    FEC0 [PRIME]
    Hit any key to stop autoboot: 0
    booti: bad boot image magic
    fastboot is in init……flash target is MMC:2
    Bad partition index:5 for partition:system
    USB Mini b cable Connected!
    fastboot initialized
    USB_SUSPEND
    =======================================

    I wrote zeros on the entire 4GB sdcard as Markus suggested. But that didnt work for me. I didnt change the uboot code.
    Replacing the contents in all partitions of a prebuilt SD card with the newly build uImage, u-boot-6quad.bin, and file-system I can boot successfully. I dont know what went wrong while going for partioning the sdcard with gparted.

    Any idea?

  15. I solved this issue by setting bootagrs to
    console=ttymxc0,115200 init=/init video=mxcfb0:dev=hdmi,1280x720M@60,if=RGB24,bpp=32 video=mxcfb1:off video=mxcfb2:off fbmem=28M vmalloc=400M androidboot.console=ttymxc0 androidboot.hardware=freescale root=/dev/mmcblk0p2 rw rootfstype=ext4 rootwait

  16. Hello,

    I built the kernel by your script and I have empty folder in Root/System: root/ system/ under out/target/product/wandbooard/

    1. Sorry for previous comment, I posted it accidentally.

      /———————————————————————–/

      Hello,

      I built the kernel by your script and I have empty folder in
      Root/System: root/ system/ under out/target/product/wandbooard/ .
      Is this correct behaviour?

  17. hallo,
    i need to compile android 4.2.2 for wandboar quad c1. Just wandboard.org repository give a lot of errors like “conection error, conection time out” and command “./repo sync -j4” ends with something like “fatal error”. It seems there is a wandboard server error or there is no more some files on this server. Where i can get full source for android 4.2.2 for wandboard quad c1?
    regards

  18. Hallo,
    i need android 4.2.2 on wandboard quad c1. After i made “./repo sync -j4”, after info “Fetching project external/ppp” i become a lot of “fatal: unable to connect to http://www.wandboard.org:
    http://www.wandboard.org[0: 160.153.43.198]: errno=Die Wartezeit f?r die Verbindung ist abgelaufen” and at the end “Fetching projects: 3% (11/345) error: Cannot fetch external/ppp
    error: Exited sync due to fetch errors”
    I tryed it on another pc’s too- it’s the same. I found in www that i am not alone there with this problem.
    How can i fix it?
    Regards

  19. Hi,

    I am trying to change boot delay from 5 sec to 3 sec but no affect. I am seeing always “Hit any key to stop autoboot :5”. Please suggest where exactly i need to change boot delay for wand board. I am newbie to this linux kernel driver. Please help me to solve this issue.
    Actually i am changing following file
    bootable/bootloader/uboot-imx/include/configs$ vim wandboard.h
    In that file changing #define CONFIG_BOOTDELAY 5 to #define CONFIG_BOOTDELAY 3.

Leave a Reply

Your email address will not be published. Required fields are marked *


*