Thursday, March 22, 2012

Android mini2440 W35

Android on FriendlyARM Mini2440 with W35 LCD


I got mini2440 board from FriendlyARM with W35 LCD (320x240) and I want to run Android at this board. The FriendlyARM Download site provide only android for mini2440 with T35 LCD ported by shinlek. If you force to use it, the display and touchscreen will not work well because the screen become rotated 90', this is caused by the width and depth are not match. we need to adjust the kernel to make it work correctly.


Below step to install the android T35 lcd version:
Download these file on windows
USB download driver setup or USB download driver (inf)
DNW download tool (Windows)
for win7 64 bit download driver and uploader from here:
SuperVivi Transfer Tool for Mini2440/6410 - V0.3.5 !
And below the image binary:
Android T35 128M 2009-08-25

Extract usb-downloaddr-setup_20090421.zip and install it or extract usb-downloaddr_20090421.zip. Connect the USB cllient port to PC and let the driver install correctly. To check it extrack and run dnw.exe from dnw.zip, go to tools-> usb transmit, if mini2440 not detected it will show some error. Extract the android-shinelk-T35-128M_20090825.zip it consist of:

  • mini2440T35_android.img
  • supervivi-128M
  • zImage
Attach Serial port, run hyperterminal or similar terminal, put S2 switch to boot supervivi and press reset.

Erase the nand flash using "x" then format it using "f"
Upload the kernel by pressing "k" follow by transmit the "zImage" file via dnw.exe

Also Upload the yaffs filesyste using "y" on terminal, and upload from dnw the "mini2440T35_android.img"
Last step, upload the supervivi for android to make them available at boot time using "v" command and upload the  "supervivi-128M" via dnw too.

The result is:


 


To correct the LCD size, we need to recompile the kernel and made some changes on LCD and Touchscreen size definition.

From Googling i got these useful link for compilation:
http://pauljones.id.au/blog/2010/07/using-buildroot-on-a-mini2440/
http://cchia-cwp.blogspot.com/2010/05/running-buildroot-system.html
link for w35 lcd definition:
http://www.gossamer-threads.com/lists/linux/kernel/1393616?do=post_view_flat#1393616

To do those recompilation of  the kernel, i'm using virtual mechines running ubuntu on windows. 
The windows still needed to upload the binary image files using windows tool.

To make the Ubuntu available for developing kernel install as follow:

# sudo apt-get install libncurses5-dev bison g++ flex gettext texinfo patch git-core libtool autoconf subversion

then download all needed files:
Android Kernel 2009-08-25
Android FS 2009-08-25
ARM-Linux GCC 4.4.3 
Make yaffs2 image

untar those files to your working directory
example:
# tar -xzvf  arm-linux-gcc-4.4.3.tgz
This is the toolchains contains executable gcc.


# tar -xzvf  android-kernel_20090825.tgz
we got the kernel source code

Optionally you can also rebuild the file system using both files
# tar -xzvf  android-fs_20090825.tgz
we got the filesystem source

# linux-mkyaffs2image.tgz

Last one we got tools for creating yaffs2 filesystem, copy or untar them as root on top filesystem, it will copy the mkyaffs2image and mkyaffs2image-128M to /usr/bin/ directory. Make them executable first using "sudo chmod a+x mkyaffs2image*". To build the yaffs2 images, just run "mkyaffs2image-128 fs/ rootfs.yaffs2". the result will have the same content as the "mini2440T35_android.img" file. You may skip this proses if no further changes are not going to be made on file system.

Now lets go to kernel directory, make the default config for mini2440 by copying config_mini2440_t35 to .config

# cp config_mini2440_t35 .config

and run

# ARCH=arm CROSS_COMPILE=/arm-linux- make menuconfig

Changes the dir_toolchains to extracted toolchains follow by prefix of the gcc, this will make the kernel source prepared for our board. exit and save. don't do any changes.

Next, edit the arch/arm/mach-s3c2440/mach-mini2440.c using vi or other editor such as gedit. find this line:

if defined(CONFIG_FB_S3C2410_N240320)
 
above those line, insert the lines below and edit above lines as other's lcd choices as follow:

/* LCD-W35i 3.5" display (LQ035Q1DG06)*/
#if defined(CONFIG_FB_S3C2410_W35)

/*7, clock */
#define LCD_PIXCLOCK 70000 

/* 320, 68, 66, 4, xres, margin_right, margin_left, hsync */
#define LCD_WIDTH 320
#define LCD_RIGHT_MARGIN 68
#define LCD_LEFT_MARGIN 66
#define LCD_HSYNC_LEN 4

/*240, 4, 4, 9, yres, margin_top, margin_bottom, vsync */
#define LCD_HEIGHT 240
#define LCD_UPPER_MARGIN 4
#define LCD_LOWER_MARGIN 4
#define LCD_VSYNC_LEN 9


//#if defined(CONFIG_FB_S3C2410_N240320)
#elif defined(CONFIG_FB_S3C2410_N240320)
.....

Save it, those lines add option  CONFIG_FB_S3C2410_W35 for lcd display type.To make them appear on menuconfig edit the drivers/video/Kconfig, find these lines:

.....
choice
    prompt "LCD select"
    depends on FB_S3C2410
    help
       S3C24x0 LCD size select


and add these lines below:

config FB_S3C2410_W35
        boolean "LCD-W35i 3.5inch display (LQ035Q1DG06)"
        depends on FB_S3C2410
        help
           3.5 inch 320x240 LQ035Q1DG06


config FB_S3C2410_T320240.......

save it and test it using command:

# ARCH=arm CROSS_COMPILE=/arm-linux- make menuconfig

see that the new option for lcd display appear. choose our new display and save it. Our work hasn't completed yet, we still need to adjust the touchscreen area. To do so edit the drivers/input/touchscreen/s3c2410_ts.c, find these lines,

            spin_lock(&myTS_lock);
            if(myTS[7]){
                disX = ((myTS[0] * xp) + (myTS[1] * yp) + myTS[2]) / myTS[6];
                    disY = ((myTS[3] * xp) + (myTS[4] * yp) + myTS[5]) / myTS[6];
                //printk(KERN_INFO "disX: %d, disY: %d\n", disX, disY);
                disX = disX * 1024 / 240;
                disY = disY * 1024 / 320;
            }else{
                disX = xp;
                disY = yp;
            }
            spin_unlock(&myTS_lock);


From above you can find the the number 240 and 320, we just need to exchange them. as follow:

                disX = disX * 1024 / 320;
                disY = disY * 1024 / 240;



save it. Do make a backup file incase any fault made during changes. To recompile the kernel you need to point the toolchains to extracted directory. Here's the command look like:

# ARCH=arm CROSS_COMPILE=/arm-linux- make zImage

You can sit by and watch all those lines going trough your screen for some times. After sccess build you'll get your result on arch/arm/boot/zImage, copy it and send to your windows running dnw.exe.
Upload it to your board using the same method as previously done. hit "b" on supervivi to boot. Here's the successful result.




Aha.. we got fine result. Now the android running on 320x420 lcd. But wait, those languange are chinese. I find myself desperetly try to find where the languange setting. For you, i'm capturing those step, just follow below step to change the languange to english.


Click on the hammer and wrench icon (seting), scroll down to the last and click the second from the bottom,
it says "locale & text" but in Chinese font. For sure you can ask Chinese people, he :P.

Click the first menu, then scroll down to english or other languange as you prefer.


Here we get android displayed in English.


Last, you'll need to flash the reflash supervivi for android to make them start at boot time. If you don't re-flash the supervivi, you'll get blank screen after booting or you can switch the boot to supervivi and keep pressing "b" to boot. Just do as above step of flashing the android, but this time choose "v" on supervivi and upload the supervivi-128m.bin using dnw.exe.

I uploaded the result below:
zImage_w35
AndMini2440w35.img
supervivi-128M

I made backup on kernel changes below, for short extract them to kernel android, and replace existing. Run Make menuconfig, changes LCD display to 320x240, the rest will follow. Also you can review the changes i made and adopted to yours.
kernel-changes.tar

I hope you enjoy your mini2440 on W35 lcd which happen to my device run very fast as fast as a turtle run, haik!

12 comments:

  1. i have mini2440 with the same problem, LCD goes black right after running the kernel, i am use vanilla Linux kernel 3.1.4 now i try to follow your guide
    i hope its work thanks.

    ReplyDelete
    Replies
    1. I hope these blog help you, i uploaded the pre-compiled that work with my board.

      Delete
  2. Thanks for your guide!!!

    ReplyDelete
  3. Hi,

    Good job!!
    One other way to change the language is to modify those properties:
    persist.sys.country = "your choice"
    persist.sys.language = "your choice"
    in the "default.prop" file and then rebuild the filsystem.

    I got one question do you succeed to have "adb" with mini2440??

    Thanks

    ReplyDelete
    Replies
    1. yes i could do that, thank you. I haven't tested adb yet. may be you had do that, please inform me the result here.

      Delete
  4. I am learning embedded linux using a mini2440 board. I have windows 7 as the host OS on my laptop and I have ubuntu 10.4 installed as the guest OS in virtual box. Ubuntu is able to detect all other USB devices connected but neither Windows nor Ubuntu is able to detect the mini2440. I read in their forums that mini2440 usb drivers are not compatible with windows 7. Will the setup you have provided help me?

    ReplyDelete
    Replies
    1. yes, you can use supervivi transfer tools from code google at this link: http://code.google.com/p/supervivi-transfer-tool/downloads/list

      Delete
  5. Excellent work! I too learned embedded linux using a mini2440 dev board with W35 LCD screen. Now I'm going to try following your guide.

    ReplyDelete
  6. I would like to introduce myself, I'm dr Susetyo from Jakarta. I once have ordered from PT Patra Aksa Jaya, Bandung, concerning an instrument stimulator in 2006. I now would like to look for pak Doni who had made that instruement. Would you be so kind to give me information about him please? Thank you

    ReplyDelete
    Replies
    1. Hi dr. Susetyo, Last time i meet him was on my way home after work few years ago (arround 2006-2008 i think), his mobile phone number was not work anymore. May be you could contact the new pt. pattra, there's a website of them at: http://ptpattra.com/files/index.php. there's a phone's number available. I hope you can reach Pak Doni, and also send my regards to him.

      Delete
  7. Did your steps ported android in vertical alignment to W35 display ???

    I have successfully ported android on mini2440 board with W35 display . However my GUI is in landscape mode(horizontally aligned) which must be in portrait mode (vertically aligned). Please give me sugges
    tions .

    ReplyDelete
  8. hello i bought a mini2440 and want to install android, but the image files for android are no longer available on friendlyarm website. where can i get them from?

    ReplyDelete