Jump to content

Booting Ubuntu on the O2X


Guest ergoen

Recommended Posts

Guest theguv

I've spent some (much) time this week with trying to get ubuntu running on the optimus 2x. I have succeeded to boot and get the wifi, X11 and the touch screen sort-of working.

The ramdisk is completely replaced with a busybox executable, some symlinks to it and a shell script that mounts the necessary stuff (/dev/block/mmcblk1p2 as ext3), changes root directory and calls /sbin/init.

USING THE FOLLOWING WILL VOID ANY WARRANTY YOU MIGHT HAVE LEFT AND MIGHT ALSO BRICK YOUR PHONE!

Seriously, don't do this if you don't wish to risk the data on your phone.

I will be providing some demo images for people who don't have a build environment up and running. These images will not work particularly well, don't get your hopes up :P.

If you want to have a big linux installation (more than 3 GB) you can flash the images to the second partition on your external sd (obviously you have to create this yourself first). You can use the following boot image (which assumes that linux is on /dev/block/mmcblk1p2 with ext3:

https://ha.xxor.net/o2x/boot-20110813.img

I have also targzipped the modifications to the file system that were required to get stuff going here:

https://ha.xxor.net/o2x/o2x-20110813.tar.gz

This should be extracted directly to the root file system.

The kernel source code is up at https://github.com/ergoen/LG-Optimus-2x-linux-kernel

Things that have been done to get this to "work":

1. Boot partition

Apart from grabbing the busybox stuff from some nexus one boot image (I'm sorry whoever fixed it, I don't remember where I got it from :( ) the boot command line had to be modified a bit, changing stuff from the default usually ends up in a phone that won't boot, but I discovered that it's possible to append new arguments to the default ones. So the following have been appended:

console=tty0 root=/dev/mmcblk1p2 init=/sbin/init

The console=tty0 makes sure that you see stuff on the screen while ubuntu get's running. The last two are not necessary to boot, but ubuntu seem to like (need?) them (or at least the init=/sbin/init), since otherwise you never get to the login prompt on the screen.

2. The Ubuntu installation

To make it possible to communicate with the phone at all adbd was put into the /sbin/ folder and a symlink was created /system/ -> /. Also the "/sbin/adbd recovery &" command was added to rc.local to make it autostart.

2.1. Modules and wifi

We need the /lib/modules/2.6.32.9 directory. Most files inside that were generated using the "depmod" command, the exception is wireless.ko which was taken from android, the firmware and nvram files needed for the wifi chip to work were placed in the /lib/firmware/wl/ folder. To make the wifi module autoload with the proper firmware "wireless" was added to /etc/modules and the file /etc/modprobe.d/wireless.conf was created with the contents describing the location of the firmware and nvram.

To make the wifi autoconnect on boot the /etc/network/interfaces file was modified with the following contents:

auto wlan0

iface wlan0 inet dhcp

wpa-driver wext

wpa-conf /etc/wpa_supplicant.conf

(To make the wifi autoconnect to your wireless you need to run the command "wpa_passphrase networkname networkpassword > /etc/wpa_supplicant.conf using adb or chroot)

2.2. X11

Getting X up by running xinit produces a simple black screen on the phone. At first I thought the problem was that the refresh rate was set to 106 Hz, indeed changing it with xrandr and pushing a new mode got me a visible xterm on Kubuntu 11.04:

https://ha.xxor.net/o2x/xterm.jpg.

On Ubuntu 10.10 it even gave me a nice colored gdm screen:

https://ha.xxor.net/o2x/gdm.jpg

But the image I got there was static and wasn't being updated. Turns out the reason the screen was black earlier with the 106 Hz rate and the reason why the screen is now just showing an image is that the framebuffer device doesn't update the screen like it should..

By modifying the kernel source to redraw the screen every 50 ms (~20 Hz) it's possible to get a scren that works. This is an ugly hack in the tegra-fb driver though, so I'm open for suggestions on how to solve it in a better way!

2.3. Touchscreen

By default the only thing the touchscreen does is force the mouse up in the left corner, I think this is due to some multitouch thing. Some more kernel hacking (basically half-disabling multitouch) makes the touchscreen work.

Pictures:

https://ha.xxor.net/o2x/SAM_0671.jpg

https://ha.xxor.net/o2x/SAM_0672.jpg

Video:

http://vimeo.com/27662093

Thans to RaYmAn and lilstevie on #tegralinux for all their help this far!

3. Misc

(K)Ubuntu 11.04 uses a new version of libc which crashes with the current nvidia kernel (2.6.32.9) on this hardware (http://developer.nvidia.com/tegra/forum/errata-657451-tls-bit-20-cp15-c13-3), so I'm going back to Ubuntu 10.10 until someone ports a newer kernel to the Optimus 2x or this problem can be solved in another way.

edit 1: Ubuntu 10.10 with much more working X11 noted in section 2.2.1.

edit 2: X11 working even more, touchscreen works aswell!

edit 3: Landscape mode works with both X11 and the touchscreen now, getting ready for alpha 1!

Edited by theguv
Link to comment
Share on other sites

Guest theguv

Current status:

Working:

- adb (best way of controlling device currently)

- X11 (only framebuffer with hardcoded refresh rate of ~20Hz)

- landscape mode fixed! =D

- touchscreen (probably only single touch)

- wifi (only when running things from console, ubuntus network manager does not recognize it)

Not working:

- Basically everything else :P

Alpha 1:

http://www.multiupload.com/OAPZHA3XEN

Username 'ubuntu', password 'ubuntuxda'. Don't use this if you don't know how to restore the boot partition! (Or else you won't be able to boot back into android!)

Link to comment
Share on other sites

Guest mankian

impressive that! i was expecting another "ubuntu in the background accessible by VNC" job then I first read! but seems like the real thing. whats the battery life like?!

Link to comment
Share on other sites

Guest theguv

impressive that! i was expecting another "ubuntu in the background accessible by VNC" job then I first read! but seems like the real thing. whats the battery life like?!

It's not really useable as a main phone system considering nothing really works well :P

Battery life concerns will have to wait a looong time I think, first priority is to get stuff working right.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.