Android setup for USB Wi-Fi adapter

Purpose: make the Cubieboard2 running Android use the USB Wi-Fi adapter. By default, the Android images I found available did not have the required driver or better said, it was not being used.

Usefull:
http://taqlim.blogspot.ro/2013/06/belkin-f7d1101-wireless-usb-on-android.html
http://linux-sunxi.org/A20

Really good tutorial:
http://archive.miniand.com/wiki/Allwinner/Unpacking+and+building+LiveSuit+images+for+Hackberry.html

One Android images source:
http://docs.cubieboard.org/tutorials/cb2/installation/cubieboard2_android-4.2.2_releases

Linux tools:
http://dl.miniand.com/allwinnera10/system/image/tools.tar.gz

Packer:
http://forum.xda-developers.com/showthread.php?t=1753473

1. I used Android 4.2_v1.08 image.
2. Inpack the .img file with imgrepacker

./imgrepacker .img

Output:
imgrepacker (version 2.05 linux)
LiveSuit’s & PhoenixSuit’s firmware image unpacker/packer

(c) RedScorpio, Moscow, 2012-2014
RedScorpio@land.ru

==========================[ START ]==========================

— Firmware unpacking —

PhoenixSuit image format detected

– image.cfg creating –
image.cfg created

– Files extracting –
“/sys_config.fex” extracted (format: unknown)
“/sys_partition.fex” extracted (format: unknown)
“/split_xxxx.fex” extracted (format: unknown)
“/boot0_nand.fex” extracted (format: Allwinner BOOT0 file)
“/boot0_sdcard.fex” extracted (format: Allwinner BOOT0 file)
“/u-boot.fex” extracted (format: unknown)
“/fes1.fex” extracted (format: Allwinner BOOT0 file)
“/usbtool.fex” extracted (format: Windows PE file)
“/aultls32.fex” extracted (format: Compiled lua file)
“/aultools.fex” extracted (format: Compiled lua file)
“/cardtool.fex” extracted (format: Windows PE file)
“/cardscript.fex” extracted (format: unknown)
“/sunxi_mbr.fex” extracted (format: unknown)
“/dlinfo.fex” extracted (format: unknown)
“/bootloader.fex” extracted (format: FAT16 image)
“bootloader.fex.iso” created
“/Vbootloader.fex” extracted (format: unknown/empty?)
“/env.fex” extracted (format: unknown)
“/Venv.fex” extracted (format: unknown/empty?)
“/boot.fex” extracted (format: Android boot image)
“/Vboot.fex” extracted (format: unknown/empty?)
“/system.fex” extracted (format: sparse image)
“/Vsystem.fex” extracted (format: unknown/empty?)
“/recovery.fex” extracted (format: Android boot image)
“/Vrecovery.fex” extracted (format: unknown/empty?)
“/diskfs.fex” extracted (format: unknown)

==========================[ STOP ]==========================

3. Copy these files is a separate folder:
boot.fex
system.fex
recovery.fex

4. Rename boot.fex and recovery.fex to boot.img and recovery.img.

5. Use the slpit_booting.pl script from the linux tools archive:

./split_bootimg.pl boot.img

Now in the folder containing the split_bootimg script there are two new files. Unzip the ramdisk archive to a new folder.

mkdir ramdisk
cd ramdisk
gunzip -c ../boot.img-ramdisk.gz | cpio -i

6. Edit the file init.sun7i.rc by adding this line:
insmod /system/vendor/modules/rtl8192cu.ko

Usefull:

To get info about modules:
modinfo

To see the modules already loaded in the kernel:
lsmod

____________________
To access the system itself thee steps are needed:

1. Convert from .fex to .img:
./simg2img system.fex system.img

2. Make a new directory for the system and mount it
mkdir system
sudo mount -o loop system.img system

3. Restore the image to fex
sudo ./mkuserimg.sh -s system new-system.fex ext4 ../tmp 500M
The 500M part tells how much memory should be allocated for the image, if 500M does not work check the size of the orginal .img and use something similar, otherwise just increase until it executes successfully.

I was surprised to find a lot of drivers already included in the system.

system/vendor/modules$ ls
8188eu.ko gc0307.ko mali.ko scsi_wait_scan.ko
8189es.ko gc0308.ko mcs7830.ko sp0838.ko
8192cu.ko gc0309.ko mma7660.ko stk831x.ko
8723as.ko gc0329.ko mma8452.ko sun7i-ir.ko
8723au.ko gc2015.ko mma865x.ko sun7i-keypad.ko
afa750.ko gc2035.ko Module.symvers sun7i_tvd.ko
al3010.ko gpio-sunxi.ko mt9d112.ko sunxi_csi0.ko
asix.ko gspca_main.ko mt9m112.ko sunxi_csi1.ko
bcm20710a1.hcd gt2005.ko mt9m113.ko sunxi-ps2.ko
bcm4330.ko hdcp.ko mxc622x.ko sunxi-ts.ko
bma250.ko hi253.ko nand.ko sw_device.ko
camera.ko hi704.ko nvram_ap6210.txt ump.ko
cdc_ether.ko hid-logitech-dj.ko ov2643.ko usbnet.ko
dmard10.ko i2c_device_debug.ko ov2655.ko usb-storage.ko
example.ko kxtik.ko ov5640.ko uvcvideo.ko
fw_bcm40181a2_apsta.bin leds-sunxi.ko qf9700.ko videobuf-core.ko
fw_bcm40181a2.bin lis3de_acc.ko rtl8150.ko videobuf-dma-contig.ko
fw_bcm40181a2_p2p.bin lis3dh_acc.ko s5k4ec.ko

____________________________________________________________________

Ok… nothing worked!!!

After trying a lot to get the wi-fi adapter to work on Android I didn’t manage to do it, BUT AGAIN, the experience gave me an idea about browsing so I ended up here:

where I found the long lost Android image containing the driver. It worked flawlessly. (TODO: open it up and see how it was made)

Source: http://cubiuntu.com/2014/09/14/help-needed-cb_a20_android42_v1-05_8192cu-ddr432-en_us-img-lost/

Download link: http://www.4shared.com/file/EtaZ2Lisba/android-cb2-v105_sugar-8192cu.html

Further Android setup

First problem:
The only layer that truly works and supports perfectly hardware acceleration on the board was MXPlayer. However, due to licencing problems no more AC3 audio decoding software was included so it needs to be added manually.
Solution found here: http://forum.xda-developers.com/apps/mx-player/mx-player-custom-codec-dts-support-t2156254
Download the all-in-one zip pack of codecs then using MXPlayer’s settings (custom codec) point it to the location of the archive.

____________________________________________________________________

Second problem: the NAND memory is too small for video caching so I need to make Android 4.2.2 write to external USB hard-drive.
Solution found here: http://www.cnx-software.com/2012/08/26/how-to-allow-apps-to-write-files-to-usb-mass-storage-devices-in-android/

1. connect through adb to the board
2. mount the system
mount -o remount,rw /system
3. Make a copy of the file and edit it by adding in the body of android.permission.WRITE_EXTERNAL_STORAGE

cd /system/etc/permissions/
busybox cp platform.xml platform-old.xml
busybox vi platform.xml

reboot

Now the video streaming app can use an external device as cache storage place.

Advertisements