Booting Ubuntu on the O2X

Search This thread

ergoen

Senior Member
Jan 29, 2011
201
307
Göteborg
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!
 
Last edited:

ergoen

Senior Member
Jan 29, 2011
201
307
Göteborg
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:
  • Like
Reactions: angel_boulevard

TacoLoco

Senior Member
Nov 28, 2007
529
34
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?
 

ergoen

Senior Member
Jan 29, 2011
201
307
Göteborg
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.
 
  • Like
Reactions: 16k

kruppin

Senior Member
Dec 17, 2010
239
38
localhost
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! :)
 

Rypac

Senior Member
Feb 7, 2011
95
38
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!
 

ergoen

Senior Member
Jan 29, 2011
201
307
Göteborg
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.
 

SimDroid

Senior Member
Jun 26, 2010
500
87
Where I live?
OnePlus 6T
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
 

SimDroid

Senior Member
Jun 26, 2010
500
87
Where I live?
OnePlus 6T
... 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 :p it's probably a stupid question


Sent from my Optimus 2X using XDA Premium App
 

ergoen

Senior Member
Jan 29, 2011
201
307
Göteborg
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:

manasgirdhar

Senior Member
Aug 7, 2009
1,045
399
Manchester
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 working, also X sort-of works (software fb). I have only slightly modified the kernel (built with CONFIG_SIGNALFD=y so that Meego wont complain in a related attempt to get that os booting). 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 not provide a complete root file system for two reasons:
1. It's pretty easy to make yourself, grab the omap3 kubuntu mobile image from the kubuntu site, or use rootstock from an ubuntu installation to build one yourself.
2. My upload sucks, and putting several hundred MB onto the interwebz would hurt me.

However, I have placed an image of my boot partition here (assumes you've got ubuntu on the second partition of the external memory card formatted with ext3):
https://ha.xxor.net/o2x/boot.img

I have also targzipeed the modifications to the file system that were required to get stuff going here:
https://ha.xxor.net/o2x/o2x.tar.gz
This should be extracted directly to the root file system you aquired earlier.

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/adbdb 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. After some troubleshooting and voodoo magic 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, and running it after xinit gets you a xterm!!! :D

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

Telling /etc/X11/xinit/xinitrc to run it makes sure that it gets set up properly by the startx script, unfortunately startx doesn't go through for me on kubuntu because of some weird error caused by a hardware problem in tegra: (http://developer.nvidia.com/tegra/forum/errata-657451-tls-bit-20-cp15-c13-3).
Unfortunately this (probably) means that either we'll have to stay with old versions of libc or get a newer kernel (2.6.36 contains fix). Old libc seems backwards, but porting a new kernel requires a bit more skill than I possess.

2.2.1. Ubuntu 10.10
Grabbed the image ubuntu-netbook-10.10-preinstalled-netbook-armel+omap.img.gz from http://cdimage.ubuntu.com/ubuntu-netbook/ports/releases/maverick/release/ . After first unpacking the tgz, then unpacking the raw disk image to partition images (with 7zip on windows) and then flashing the 1.img file to the second partition on my sdcard I managed to run a much more bug free ubuntu than before.
Ubuntu 10.10 (Maverick) uses an older version of som libraries that don't crash with the old o2x kernel.
This has lead to the following:
https://ha.xxor.net/o2x/gdm.jpg
Obviously touch screen isn't working properly (pressing it puts the pointer into the upper left corner :S) so can't get further than this currently.

3. Misc

avahi-daemon and cups seems to be crashing all the time and restarting, so removing them (apt-get purge if ubuntu/kubuntu) will make the boot much cleaner. Also I get lots of alignment trap kind of errors that shouldn't be there for different kinds of services, (due to tegra bug mentioned earlier).

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

Its good you got it to work.Saves me some work.I was gonna begin this project my self after the 19th when my exams end.Maybe i could help you.
 

kruppin

Senior Member
Dec 17, 2010
239
38
localhost
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...

Most computer screens usually support atleast 72hz also, it's just that it only works with d-sub, and sometimes only at a lower resolution.. It's possible to make special drivers to some screens to enable higher refresh rate through dvi also.

Anyway, it's good the screen on the phone refreshes at 72hz instead of 60 for android, but in linux I really don't see the benefit.. Doesn't hurt to have though. :) Btw, if we would stay on this kernel, can we use the drivers from android then? Shouldn't gpu also work? Or are the drivers limited and don't allow xorg for example? Sorry if it's stupid question, don't have that much knowledge how android works yet. :p
 

ergoen

Senior Member
Jan 29, 2011
201
307
Göteborg
Update: X11 and touchscreen work on Ubuntu 10.10 Maverick with new kernel (just a few hacks :p)!

manasgirdhar: sure! Lot's of things to do :p new kernel is needed for anything newer than ubuntu 10.10, and even here things like sound etc (cpu scaling maybe too) don't work.

kruppin: actually i removed the xorg.conf now, the phone thinks its running at 106 Hz and it works. Unfortunately in practice it goes at more like 20 Hz because of the hack I made to enable the fbdev output in the kernel. Android doesn't use X11, so those drivers wont be of any use. (I will post the kernel modifications to github soon)

edit: kernel source up on https://github.com/ergoen/LG-Optimus-2x-linux-kernel
 
Last edited:

zerocoolriddler

Senior Member
Jun 6, 2009
283
72
Büren
A List of Things working at 2nd Post would be nice.
So anybody could fast see Updates,... :)


Edit:
Have you tried some "cleaner" Linux like Debian?
 
Last edited:

ergoen

Senior Member
Jan 29, 2011
201
307
Göteborg
Alpha 1 is up in the second post for anyone who wants to test it (don't ^^).
I have not tried debian no, I thought ubuntu would be the easiest to google errors and bugs for :p.
 

pannonmage

Member
Jul 16, 2009
10
0
You are great! i was hopin' for this since I have mine. You should try to make usb(otg) work to get some devices going:) i will try to test it soon:rolleyes:
 

Wing_Zero85

Senior Member
Nov 2, 2010
323
43
That's amazing :) We have to test USB OTG function. If it works by default, I'll try this right now :)

It is possible to make a dual-boot: ubuntu and android?
 

ergoen

Senior Member
Jan 29, 2011
201
307
Göteborg
I don't think usb otg works since I am basically using the android version of the kernel, I also won't be able to try since I don't have a cable... (will buy one sooner or later).

Dual boot probably works if you flash the boot.img onto the recovery partition instead of the boot partition (/dev/block/mmcblk0p7 instead of /dev/block/mmcblk0p5). I have not tried this though. That way regular booting would give android and booting while holding volume down would give ubuntu, only problem with this is that cwm will be gone and the only way to fix broken things would be to flash with nvflash.
 

pannonmage

Member
Jul 16, 2009
10
0
well it is not a major deal if have cifs avail :) needs kernel support as well. Benee mentioned (might) some otg support, mayb u could ask.

also, you might give E17 a try, it is butter-fast, and has a touch module for keyboard (letter zooming.!..) LINK
this can be compiled on a lot of hw, and gives good response with fbdev non-accel drivers also.
and most linux apps work on it fine. ofc until we have 2d/3d accel and might try compiz/fusion as well :)

LINK
 

Micron88

Member
Apr 7, 2011
24
2
Great job ergoen!
I've worked on exactly the same some weeks ago but i never accomplished it. because i stuck creating a working ramdisk. Which toolchain do you use?

MfG
 

Top Liked Posts

  • There are no posts matching your filters.
  • 17
    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!
    4
    I would like to try it, but I don't want to reflash the whole boot partition, so I think I will implement multi-boot system inside clockworkmod recovery, like I did with spica a while ago ( forum.samdroid.net/f9/multi-boot-system-recovery-2640/ ). :)
    2
    i am still looking for a way to run linux on my o2x, is there any development still going on?
    2
    New ramdisk without the buggyness up at the same adress now.

    I'm using basically the same command as you to create the ramdisk (based on http://android-dls.com/wiki/index.php?title=HOWTO:_Unpack,_Edit,_and_Re-Pack_Boot_Images )

    Also the application "abootimg" can be used to create the final image, it's a bit more friendly than the mkbootimg tool.
    1
    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..