Olimex A20 Android Building

(UPDATE) Feb 13th. Found out why it won’t run. See at the bottom for the fix.

Using this information you can have a trouble free build of the source but sadly, the built image does not run on my board so I have documented this here in the hopes that others can get the build to complete and then we are in a position to sort out why it does not run.

At the present time (12th Feb 2014) the build still does run but I am hoping that by posting this up someone will figure out why this does not work.

To get started, you will need a Linux Ubuntu (Google recommended) system to build the source. If you are already running Ubuntu, then you are ready to get started. I’ve built this using Ubuntu 12.04 but other versions should work too, they’ve just not been tested. Google has kindly documented the installation requirements for the build environment, so use this link to make sure your system is setup correctly.

Google Setup Instructions

Once you have done this, go and grab the source from Olimex here.

Android 4.2 and Linux 3.4

Create a directory on your system to extract the source to. I created an android directory and then inside that an olimex-a20 directory. From your home directory, do the following from a terminal window.

mkrdir android
cd android
mkdir olimex-a20

Copy the source files you downloaded into this directory and then use tar to extract them.

tar zxvf android4.2.tar.gz
tar zxvf lichee-v2.0.tar.gz

You should now have both the Linux kernel source and the Android source now on your machine. You are almost ready to build them but I included 1 more step and that was to setup the cross compiler that comes with the source. Assuming you used the same directory names I showed above, you now need to add the PATH to the cross compiler to your .bashrc file. Edit the file and add the following to it. These lines assume you used the directory names above.

PATH=$PATH:$HOME/android/olimex-a20/android4.2/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin
PATH=$PATH:$HOME/android/olimex-a20/android4.2/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6/

Now we are ready to build the kernel. This will take a little while depending on your computers speed so be patient.

cd lichee
./build.sh -psun7i_android

Once this completes, you will have the Linux kernel and now is time to build Android. If you build as per the Olimex instructions, the system will fail due to a setting for SATA. SATA is not currently supported in Android so I simply commented out the lines for this. Locate the following file and open it for editing.

android4.2/device/softwinner/olinuxino-a20/overlay/base/core/res/res/xml/storage_list.xml

And comment out or delete the SATA entry at the bottom. You can now build without errors.

<!-- storage android:mountPoint="/mnt/sata"
 android:storageDescription="@string/storage_sata"
 android:primary="false"
 android:removable="true"
 android:emulated="false" 
 android:mtpReserve="0" 
 android:maxFileSize="0" / -->

The extract-bsp lines copies the kernel image for when you run pack later. If after you run lunch and you don’t see the olinuxino-a20_eng option (should be option 15) then simply run the source build.envsetup.sh file again. I found that I needed to run this twice for it to appear.

cd ../android4.2
cd device/softwinner/
tar zxfv olinuxino-a20.tgz
cd ../../
source build/envsetup.sh
lunch      #select olinuxino-a20_eng
extract-bsp
make -j4

This will take quite a while and in my case about 5 hours so grab a coffee and relax for a bit. Once this is complete, you now need to pack the image. This is where the Olimex source build instructions will fail because the configuration directory and settings are missing and may explain why the final image fails to run on my system. So, to get this to work we need to create a directory called olinuxino-a20 in this location (Linux source directory)

cd ~/android/lichee/tools/pack/chips/sun7i/configs/android
mkdir olinuxin-a20

Once you do this, download the following files and extract them into this directory.

System Configuration Files

I’ve built these files based on what I could find on a number of Google Searches and comparing the converted script.bin file in the original Olimex image. If anyone sees and error in these or have the correct files, please post a comment about it.

There is a couple of lines in the sys_config.fex file you might want to change depending on your needs. Another user on the Olimex forum and I have identified that to get the unit to boot on applying power, you need to change the following line in the [target] settings. Setting this value to 0 causes the unit to power up and go to standby mode if you have a battery connected. You then need to press the power button to get it to start. If you set this to 1, the system will boot up on applying DC power even if the battery is connected and the unit was powered down through the power switch or via software.

power_start = 1

The other change is to tell Phoenixsuit where to write the image to. This is 0 for NAND and 1 for SDCARD. I use SDCARD for testing images and once I get a working image, I change this to 0 and run pack again. No need to rebuild the source.

storage_type = 1

Now just run pack and it should generate the output image. It will be shown in RED the location of this file. Now use Phoenixsuit to load this to your board.

Hopefully this will get you building the source code and at this present time, I am unable to get it past the following error. If you have the serial debug you will most likely see a number of untracked PID exits in the output if the system has the same failure as myself. If you type LOGCAT into the debug you will get more detailed debugging information but start a capture before you do this as the output generates a lot of information. Below is a partial dumb of the information I am seeing.

I/SurfaceFlinger( 1944): GraphicBufferAlloc::createGraphicBuffer 
W/SurfaceFlinger( 1944): hw_get display module Failed!
D/SurfaceFlinger( 1944): display dispatcher enabled
W/SurfaceFlinger( 1944): wifidisplay dispatcher disable
I/SurfaceFlinger( 1944): GraphicBufferAlloc::createGraphicBuffer 
I/SurfaceFlinger( 1944): EGL informations:
I/SurfaceFlinger( 1944): vendor : Android
I/SurfaceFlinger( 1944): version : 1.4 Android META-EGL
I/SurfaceFlinger( 1944): extensions: EGL_KHR_image EGL_KHR_image_base EGL_KHR_image_pixmap EGL_KHR_gl_texture_2D_image EGL_KHR_gl_texture_cubemap_image EGL_KHR_gl_renderbuffer_image EGL_KHR_fence_sync EGL_EXT_create_context_robustness EGL_ANDROID_image_native_buffer 
I/SurfaceFlinger( 1944): Client API: OpenGL_ES
I/SurfaceFlinger( 1944): EGLSurface: 8-8-8-8, config=0x60000014
I/SurfaceFlinger( 1944): OpenGL ES informations:
I/SurfaceFlinger( 1944): vendor : ARM
I/SurfaceFlinger( 1944): renderer : Mali-400 MP
I/SurfaceFlinger( 1944): version : OpenGL ES-CM 1.1
I/SurfaceFlinger( 1944): extensions: GL_EXT_debug_marker GL_OES_byte_coordinates GL_OES_fixed_point GL_OES_single_precision GL_OES_matrix_get GL_OES_read_format GL_OES_compressed_paletted_texture GL_OES_point_size_array GL_OES_point_sprite GL_OES_texture_npot GL_OES_query_matrix GL_OES_matrix_palette GL_OES_extended_matrix_palette GL_OES_compressed_ETC1_RGB8_texture GL_OES_EGL_image GL_OES_draw_texture GL_OES_depth_texture GL_OES_packed_depth_stencil GL_EXT_texture_format_BGRA8888 GL_OES_framebuffer_object GL_OES_stencil8 GL_OES_depth24 GL_ARM_rgba8 GL_OES_EGL_image_external GL_OES_EGL_sync GL_OES_rgb8_rgba8 GL_EXT_multisampled_render_to_texture GL_OES_texture_cube_map GL_EXT_discard_framebuffer GL_EXT_robustness GL_OES_depth_texture_cube_map 
I/SurfaceFlinger( 1944): GL_MAX_TEXTURE_SIZE = 4096
I/SurfaceFlinger( 1944): GL_MAX_VIEWPORT_DIMS = 4096 x 4096
D/SurfaceFlinger( 1944): Screen acquired, type=0 flinger=0x411eb370
D/SurfaceComposerClient( 1468): ComposerService reconnected
F/libc ( 1468): Fatal signal 11 (SIGSEGV) at 0x00000010 (code=1), thread 1954 (BootAnimation)
I/AwesomePlayer( 1147): setDataSource_l(URL suppressed)
I/ServiceManager( 1147): Waiting for service window...
F/libc ( 1944): Fatal signal 11 (SIGSEGV) at 0x00000084 (code=1), thread 1945 (SurfaceFlinger)
I/DEBUG ( 1142): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG ( 1142): Build fingerprint: 'softwinners/olinuxino_a20/olinuxino-a20:4.2.2/JDQ39/20140211:eng/test-keys'
I/DEBUG ( 1142): Revision: '0'
I/DEBUG ( 1142): pid: 1468, tid: 1954, name: BootAnimation >>> /system/bin/bootanimation <<<
I/DEBUG ( 1142): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000010

If you have success, please post a comment.

(UPDATE Feb 13th 2014) 
I have found out why it won’t run. The display.sun7i.so file is missing and not included. It seems to be a conditional flag issue and I have gotten around this by removing the check.

Locate this file

/android4.2/device/softwinner/wing_common/Android.mk

and edit the 2 lines below to add the # to them (comment out the lines)

#ifneq ($(filter wing%,$(TARGET_DEVICE)),)
include $(call all-makefiles-under,$(LOCAL_PATH))
#endif

Save the file and now run make-j4 and pack to create the image for NAND or SD as above. It should now work albiet in Chinese and on my unit, the LCD keeps going on and off.

Somehow this is not the actual build configuration that Olimex claims it to be for the images on their website but at least we now have a partially working system to start creating customs builds with. I’ll update the blog entry and I find out more.

Advertisements