Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

Booting Ubuntu on the O2X

OP ergoen

11th August 2011, 07:35 PM   |  #1  
ergoen's Avatar
OP Senior Member
Flag Göteborg
Thanks Meter: 287
 
174 posts
Join Date:Joined: Jan 2011
Donate to Me
More
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/fo...-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!
Last edited by ergoen; 16th August 2011 at 12:14 AM.
The Following 18 Users Say Thank You to ergoen For This Useful Post: [ View ]
11th August 2011, 07:36 PM   |  #2  
ergoen's Avatar
OP Senior Member
Flag Göteborg
Thanks Meter: 287
 
174 posts
Join Date:Joined: Jan 2011
Donate to Me
More
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:
EDIT: Seems that multiupload has screwed up and this link was going to some crap, anyway this is not relevant anymore
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!)


Experiments:

Tried disabling the CONFIG_TEGRA_ERRATA_657451 switch in the kernel to make newer linux versions boot. This might be a bad idea in the long run, but this far things are working better than with the switch enabled..
Last edited by ergoen; 9th February 2013 at 10:11 PM.
The Following User Says Thank You to ergoen For This Useful Post: [ View ]
11th August 2011, 08:14 PM   |  #3  
Senior Member
Thanks Meter: 10
 
394 posts
Join Date:Joined: Nov 2007
I tried Ubuntu via chroot method posted in other thread, but I'm a noob.. Can you please explain what is different about your ubuntu?? Does it boot without Android and doesn't need VNC stuff?
11th August 2011, 08:22 PM   |  #4  
ergoen's Avatar
OP Senior Member
Flag Göteborg
Thanks Meter: 287
 
174 posts
Join Date:Joined: Jan 2011
Donate to Me
More
Yes, it boots instead of android when turning on the phone, but it doesn't work completely, so I mostly put it up here so that people could help test and fix/hack things.
The Following User Says Thank You to ergoen For This Useful Post: [ View ]
11th August 2011, 10:49 PM   |  #5  
Senior Member
Flag localhost
Thanks Meter: 39
 
238 posts
Join Date:Joined: Dec 2010
Donate to Me
More
You rock! Unfortunately I'm no dev, so can't help but hopefully others will, so we'll get a fully working linux on our phone, and maybe later even meego. Is there btw drivers for the gpu? Because hdmi, with usb host ofc, would be really useful!

Anyway, good job, really!
11th August 2011, 10:55 PM   |  #6  
Rypac's Avatar
Member
Thanks Meter: 40
 
93 posts
Join Date:Joined: Feb 2011
This looks great ergoen! I'm no dev either but I can't wait until it's available to everyone, I would love to have Ubuntu running on my O2x.

Best of luck!
11th August 2011, 11:15 PM   |  #7  
ergoen's Avatar
OP Senior Member
Flag Göteborg
Thanks Meter: 287
 
174 posts
Join Date:Joined: Jan 2011
Donate to Me
More
gpu drivers are closed source, and the ones released by nvidia require a newer kernel (2.6.38), so thats not really possible yet.

Newer kernel will be necessary anyway though, since the crashes I'm getting seems to be due to a bug in tegra which gets worked around in 2.6.36. I'm not skilled enough to perform that port though. I will of course give it a try, but most likely I'll go for some older version of ubuntu and/or perhaps meego instead.
12th August 2011, 02:31 AM   |  #8  
SimDroid's Avatar
Senior Member
Flag Where I live?
Thanks Meter: 84
 
476 posts
Join Date:Joined: Jun 2010
Donate to Me
More
Håller med tidigare poster. Would be awesome with native Ubuntu and Meego on the phone... keep up the good work, can't wait to follow this development.


Sent from my Optimus 2X using XDA Premium App
12th August 2011, 02:38 AM   |  #9  
SimDroid's Avatar
Senior Member
Flag Where I live?
Thanks Meter: 84
 
476 posts
Join Date:Joined: Jun 2010
Donate to Me
More
Quote:
Originally Posted by ergoen

... I realized that it tried to run the screen at 480x800@106Hz, which is hmm, wrong :P. So setting up a script at /etc/xprofile, which makes sure the refresh rate is 60Hz...

What would happen if you changed this to 72Hz instead? I saw that info when I was browsing System Information in some app. Im not a dev At. All. But tell me what you think it's probably a stupid question


Sent from my Optimus 2X using XDA Premium App
12th August 2011, 05:39 PM   |  #10  
ergoen's Avatar
OP Senior Member
Flag Göteborg
Thanks Meter: 287
 
174 posts
Join Date:Joined: Jan 2011
Donate to Me
More
I can give it a try later, not that it would make any difference :P.

edit: 72 Hz also seems to work, cool, that's higher refresh rate than my computer screen...
Last edited by ergoen; 12th August 2011 at 09:37 PM.

Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes