Archive for January, 2018


This is a guide (which isn’t short, unfortunately, sorry) on how to enable Samba support in your LG WebOS Smart TV.
If you want to know the story on how I came up with this, read part 1, part 2 and part 3.

If you just want the instructions, read on.
For those willing to build their own binaries for WebOS TVs, I’ve created a GCC toolchain which should work for most TVs. You can download it here.

Read mode

This part is about making Samba work in WebOS. If you want to know how it began and how to root WebOS, read part 1 and part 2.
If you just want the instructions, read part 4.

——

Now when I finally had complete and unrestricted access to the TVs OS, I started exploring the internals to check what was available and how to get Samba working.
My TV (LG 43UH603V-ZE) appears to be based on a Realtek RTD2999 chipset which has a four core ARM Cortex-53 CPU and PowerVR graphics. For short-term memory, the TV has 1.5 GB of RAM (of which about 1.1 GB are user-accessible) and for long-term storage, there’s a 4 GB eMMC flash module divided into several partitions (with only 635 MB for apps and media). Kernel version is 3.10.19.

Fortunately, the TVs kernel already had CIFS (which is a version of SMB) support built-in. But the helper program required for mounting (mount.cifs) was missing. For testing CIFS and possibly other ARM stuff in the future, I’ve installed an ARM port of Ubuntu 16.04 in a chroot, with an old 16 GB flash drive for storage (since the TV had very little free space).
Now I that I had Ubuntu with mount.cifs (cifs-utils) installed, I could start testing Samba on my TV. As expected, everything worked fine and I was able to mount all of my server’s Samba shares and access them inside Ubuntu.
Next part was to get the shares visible in WebOS built-in media player (or I should say players as there is one for Photos and Videos and one for Music).
The first problem was that I wanted my shares to be mounted at TV startup and outside of Ubuntu chroot and Ubuntu’s mount.cifs would not run outside chroot. I temporarily solved this with ugly LD_LIBRARY_PATH and ld.so hack (I do not recommend using it, I will put a link to a proper mount.cifs binary which would work without Ubuntu in part 4).
Second, I needed a location to mount the shares on so WebOS media player could seen them.
First, I tried to play with WebOS’s screenshot capture function, find the directory where it places the screenshots and mount my Samba shares there. But this did not work.
Then I’ve remembered about that small FAT32 partition which I’ve created on my USB flash drive (mainly so that the TV would not complain about unformatted flash) which was visible in WebOS media player.
I thought: what if I mounted my Samba shares onto folders inside that partition ? And.. IT WORKED ! WebOS media player could see all the files as if they were inside that small FAT32 partition. All my media played just fine, even that 4K BDRip (whooping 65mbps bitrate !) which I’ve mentioned earlier. Samba download speed was about 11.2 MB/s (close to maxing out TVs 100mbps ethernet) which is more that enough for pretty much anything the TV can play.

I now had a working way of using Samba in WebOS.
For persistence, I wrote a small script to automount shares at TV boot so that I could use them without having to manually mount them first. More about this in part 4.

If you also want to get Samba working on your WebOS TV, continue to part 4 where I’ll put a detailed guide on how to get this to work.

P. S.: You don’t need Ubuntu chroot for Samba. But if you also choose to use Ubuntu chroot, you will have the entire Ubuntu software library available on your TV. You could for example, fire up a BitTorrent client, run a Web server, PHP, Python or anything else you want. This is nice if you are a tinkerer, like me. If you need a guide for creating a chroot, let me know.

If you want to know how it began and what this is all about, do read part 1 of the post.
If you just want the instructions on how to root WebOS and add Samba support, read part 4.

———

I knew that my smart TV had Linux under the hood. At first, I needed to figure out how to get some kind of shell access to the TV. It turns out, LG does have an app called Developer Mode which offers shell access via SSH. I did try the app out and it did work but the shell access it offered was very limited.
All I had was access to an OpenSSH instance running as unprivileged user in a chroot-like jail.
To add Samba support, I needed root access to the TV’s OS. Since LG’s app did not offer any way of getting root, the only way was to try some kind of exploit, just like you do when rooting Android without custom recovery.
My first thought was to exploit CVE-2016-5195 (aka. the Dirty Cow bug) since it had source code available. So I’ve build the exploit and it out. And… it didn’t work. It turned out that my TVs firmware (version 05.30.01, released on October 31st, 2017) had a patched kernel which wasn’t vulnerable. Since I could not find any other public root exploits, I wasn’t able to root the TV with the firmware it had. The only thing I could think of is downgrading the TVs firmware to an earlier version (with a vulnerable kernel). Which isn’t straightforward, since WebOS normally only supports installing newer firmware versions, not older ones.
Fortunately, with the help of my skills and a tutorial available here: http://webos-forums.ru/post23624.html (in Russian, Google Translate link) I was able to downgrade the firmware to version 04.31.00.
I’ve also found a pre-packed exploit (based on the same Dirty Cow bug which I’ve tried to exploit before) for rooting WebOS with instructions here: http://webos-forums.ru/topic4650.html (again in Russian, Google Translate link). With it, I was able gain root access to WebOS.

That’s when the fun began. Read on to part 3.

I’ve always treated my TVs simply as monitors with some additional functionality, like a built-in tuner or a simple media player. I never treated them as real computers.
Even when my family bought our first smart TV back in 2014, I still treated it as a monitor, even though I did know that it had a real Unix-like OS under the hood.
That has changed when I got (well, inherited) my own Smart TV, an 2016 model LG 43UH603V-ZE running WebOS 3.3.1. I previously had an old LG feature TV and used a separate device (a Raspberry Pi 3 with Kodi) to play all my media.
But since I now had a smart TV, I wanted to play everything directly on it, without using a separate device. My main sources of media are IPTV and my home server (which also acts as a NAS). IPTV viewing wasn’t a problem as WebOS had several apps for that. Connecting my server to the TV was a different story. It turned out that WebOS does not have any kind of support for NAS devices at all. No Samba, no FTP and no way of streaming HTTP links. Nothing.
At first, I tried to resort to using Emby media server via TVs built-in browser (tried Emby’s app as well), but it was too cumbersome to use with a remote. Not to mention the flaws, like really long loading times, buggy resuming and totally unnecessary transcoding of media that my TV could play directly. For example, I could not play a 4K H265 BDRip without Emby trying to transcode it to H264 resulting in choppy video and overloaded server.

This got me thinking: is there any way to mod the TV to retrofit Samba support in a way which would play nice with WebOS ?
And I did find a way. Now on to part 2.

P.S.: Happy 2018, the year of the Yellow Dog ! (sadly the Linux distro with the same name died long ago…)

Copyright © 2008-2024 DDS Central. Powered by WordPress. Theme: Motion (modified by DDS Central)