openlgtv - yet another LG LCD TV hack firmware

NOTE: Development has been stalled for some time now. If anyone is interested in helping, please contact me.

openlgtv is an attempt to open up the LG TV operating system for software developers and hackers.
It's a complete Linux distrubition based on buildroot, and modified to run on the LG TVs such as 47LH7000. As of version 20100318_040925, all TV features should work just fine with this firmware, thanks to LG giving me new kernel sources. There were some serious DVB related problems before.

This project started when I saw the lg-hack.info forum, and noticed LG has released source codes for the TV. But there was no full Linux distro project - just modified versions the LG's rootfs image. I decided I'd take different approach than other firmware modifications - port buildroot Linux distribution into the TV.

The development focus is currently in making a nice, easily hackable/modifiable platform, build tools, etc, rather than Web GUIs or such.
If you're not confortable with configuring the system using SSH shell interface, you might be better off with LGMOD v1.2, as it has a web GUI.
The build system is currently almost fully automatical - only few commands, and you have images for all 4 different platforms.

This is a work in progress - if you want to contribute, please contact me:
email: mikko a korkalo d fi
IRC: #openlgtv @ FreeNode
You can find me by nickname keitsi @ IRCnet, freenode and QuakeNet IRC networks.

Features

- A full buildroot environment, with dynamically linked uclibc, network devices support, etc
- *Lots* of extra command line tools, for example a working nano editor, strace, pimped up busybox. Full list: commands on rootfs | commands on external flash
- support ASIX usbnet ethernet adapters (also some others when using external usb flash)
- Kernel and userspace PTY support for telnetd, dropbear, screen, etc
- Working SSH/SFTP server and client (dropbear)
- Wireless extensions should work in theory. I haven't tested. iwconfig, wpa_supplicant, required kernel features, etc are included.
- extra kernel modules and features (List of extra kernel modules). There are also some other features compiled in, such as ext2, PTY support and wireless extensions.
- Filesystems: ext2 compiled in, ext3 as a module on external flash, ntfs-3g+fuse on external flash
- Overall, a much prettier environment to do your hacks in.
- Possibility to have custom init hooks - add scripts in /mnt/lg/user/init_1.sh, /mnt/lg/user/init_2.sh, /mnt/lg/user/init_3.sh and /mnt/lg/user/init_4.sh, and they will get executed in different phases of init.
- Some configs in /etc are editable (symlinked for now, I'm considering integrating openwrt's mini_fo filesystem driver to make this prettier)
Screenshots / pictures:

Download pre-compiled images

Downloads

There are 4 different kernels available:
Kernel image extensionTV models
config-flashEuropean LCD TVs and other DVB LCD models
config-flash-pdpEuropean Plasma/PDP TVs and other DVB PDP models
config-flash-s6-atscUS LCD TVs and other ATSC LCD models
config-flash-s5US PDP/Plasma TVs and other ATSC PDP models
I have received confirmation from LG that this information is correct - however they didn't say which models are supported by this kernel.

Download source source for openlgtv

For sources and compile information, go here: sources/

Download uClibc 0.9.30.2 toolchain

For custom toolchain binaries, to produce either statically or dynamically compiled programs, go here: uclibc-toolchain/
I don't know if it's possible to compile a working kernel with this. I haven't tried - I use mips2_fp_le toolchain from LG for kernel compilation.

Known problems

1. syslog is broken.

Fixed problems

1. Fixed in version 20100318_040925: Channel searching with DVB-C is broken (don't try - it will just clear all your channels!!). This also happens with other firmware hacks such as LGMOD v1.1 and Pawel Chojnacki's v0.02 image.

2. Fixed in version 20100318_040925: Channel information / tv guide / subtitles (that are not encoded as part of video) are unavailable with DVB-C. This also happens with other firmware hacks such as LGMOD v1.1 and Pawel Chojnacki's v0.02 image. Some bits and pieces are missing of LG's kernel sources.

3. Need to verify if this is really fixed - workaround shouldn't be required anymore?: RELEASE program puts on key lock every once in a while. RELEASE has been wrapped using empty, and we're sending it the unlock command every 5 seconds. Thanks to Pawel Chojnacki for finding this.

4. Fixed in version 20100318_040925: Lots of extra debug flood by the RELEASE program, lines such as this: "ad52a38d 0d1427fc 05bc06ad". I don't know if these are fatal, annoying as hell for the very least. You can see them with command "cat /tmp/REL.out" if they are present. This also happens with other firmware hacks such as LGMOD v1.1 and Pawel Chojnacki's v0.02 image (for me, at least).

5. Fixed in version 20100304_1267715080: I had problems with my ASIX usb-network adapter, there was a kernel bug in asix.c causing this. I updated to driver from manufacturer's site - my usb-ethernet adapter is now working 100%.

6. Fixed in version 20100318_040925: When changing DVB-C channels, the interface (RELEASE program) will occasionally get stuck. Reboot helps here. With moderate DVB-C usage, this will maybe happen 1-5 times per day.

Requirements

- LG DTV, tested with: 47LH7000.
- Serial cable for flashing.
- Linux environment with serial port.
- Basic linux knowledge.
- Money to buy a new TV if your TV blows to pieces.
- Backups of your original TV (rootfs and kernel images, at least).

Flashing instructions

WARNING: These images are highly experimental and you are maybe at your own if something goes wrong. You should really back up your original firmware before continuing here. Make sure you are able to flash back your original firmware from u-boot.

Unless you are stupid, crazy, ready to sacrifice your TV, or a combination of those, don't do it. You have been warned.

Also, this guide is specifically for LH7000 series. I don't know if it applies directly to other models.

1. change u-boot bootargs parameter a bit: (we add a serial console, so we can see boot messages)

mstar # setenv bootargs root=/dev/mtdblock3 rootfstype=squashfs ro lpj=105984 console=ttyS0,115200n8r
mstar # saveenv

1. Flash kernel & rootfs images

1.1. Connect to TV's serial console

- Start minicom, and connect to TV's serial console.
- Reboot the TV, and keep hitting the Esc key until you see a "mstar #" shell prompt (this is the u-boot bootloader shell).
- Hit enter to clear the Esc keypresses. You will maybe get an error about it, just ignore.

1.2. Flash rootfs and kernel images using u-boot console

- Type command "loadz kernel" into u-boot console:
mstar # loadz kernel [ENTER]
- In minicom, hit CTRL-A + S. Choose zmodem.
- Browse the kernel image file or type the path directly, and send it. It will take about 3-4 minutes to complete.

- When done, type command "loadz rootfs" into u-boot console:
mstar # loadz rootfs [ENTER]
- The same way, press CTRL-A + S and browse the rootfs image, and send it. This should take about 2 minutes.

- When done, reboot the TV to boot into openlgtv:
mstar # reboot

2. Copy ext2 image to external USB stick (optional - only needed for extra programs)

2.1. Edit flash stick's partition table, make first partition whatever you like, and second partition type "Linux"
# cfdisk /dev/sdX (in my case, sdX should be sdb)

2.2. Option one: transfer ext2 image from workstation to USB stick (if you don't have ethernet on your TV, or want to transfer the image faster)
- Copy the ext2 image to an external USB flash to *second* partition, so that it will be available as /dev/sda2 on LG TV: (assuming /dev/sdb2 is usb flash second partition)
# dd if=openlgtv.latest.extra.ext2 of=/dev/sdb2
- Grow the ext2 filesystem to make full use of the partition (debian users - apt-get install e2fsprogs )
# ext2resize /dev/sdb2

2.2. Option two: Boot into openlgtv shell, and transfer ext2 image over SSH to directly to external USB flash on TV (if you have ethernet on your TV, i.e. using usb-ethernet adapter)
Due to the constraints of the MIPS processor, transferring 100MB+ image over SSH is slow. But this way you don't need to move around to remove the USB stick. ;-)

- After installing and booting the openlgtv rootfs, run this in your workstation:
$ dd if=openlgtv.latest.extra.ext2 | ssh root@my.tv.ip "dd of=/dev/sda2"
- Then, reboot the TV, or run this at openlgtv shell:
# mount /mnt/extra

Usage instructions

- You have a getty login prompt in serial console by default. You can login with username "root" and password "openlgtv". Remember that root password will be kept between reflashes (saved in /mnt/lg/user/etc/shadow and /mnt/lg/user/etc/passwd)
- openlgtv works without the external USB flash - there are just some extra programs which might be useful to you.
- Default root password is "openlgtv"
- Default IP address for eth0 is 10.22.0.123/24.
- USB-ethernet adapters with ASIX chip (asix.ko kernel module) should work without any configuration changes. Tested: A-Link NA1GU adapter.
- You may edit network configuration in /etc/network/interfaces (debian-like syntax)
- Dropbear SSH shell should be started by default. Log in with root/openlgtv.
- Some files in /etc are not editable - editable configurations are automatically copied to /mnt/lg/user, and symlinks from /etc are pointing to /mnt/lg/user partition. I am considering better ways to do this (see TODO), but this will work for now.
- You can communicate with RELEASE using the fifos /tmp/REL.in and /tmp/REL.out. The same way as in Pawel Chojnacki's v0.02 image. Example:
$ cat /tmp/REL.out &
$ cat > /tmp/REL.in

TODO

- Integrate mini_fo filesystem driver from openwrt, to make root filesystem editable?
- Compile more programs. Suggestions?
- Proper module dependencies and modprobe command.
- Clean up the build system. Integrate openlgtv build scripts fully with buildroot. No more duplicate rootfs directories.
- Run RELEASE with strace (strace works already!), and see what comes up :)
- Hack kernel to make DTS passthrough work (there is already some research done)

(c) 2010 Mikko Korkalo