Skip to content

Instantly share code, notes, and snippets.

@throwaway96
Last active December 17, 2024 23:29
Show Gist options
  • Save throwaway96/827ff726981cc2cbc46a22a2ad7337a1 to your computer and use it in GitHub Desktop.
Save throwaway96/827ff726981cc2cbc46a22a2ad7337a1 to your computer and use it in GitHub Desktop.
Enabling debug and getting root on LG webOS by modifying NVM

Warnings

What you do with this information is your own responsibility. If you brick your TV trying this, it's not my fault. You should probably have some electronics experience if you want to attempt this.

This is going to involve opening your TV and attaching wires to the pins of an integrated circuit. If you're not comfortable with that, this is not for you.

This document is a work in progress.

debugstatus

LG TVs since at least the era of NetCast and "Global Platform" (webOS predecessors) have had the notion of a debug level, generally called "debugstatus". There are three modes: DEBUG, EVENT, and RELEASE. TVs normally operate in RELEASE mode. DEBUG mode enables a variety of logging and other debugging features in webOS, including access to the bootloader console and debug menus via serial. EVENT is similar to DEBUG, although it may not enable as much logging and has other relatively minor differences.

NVM

In older versions of webOS, debugstatus is stored in what LG calls "NVM" alongside a bunch of other configuration data, such as the baud rate for serial communications. You can find the relevant structures and enumerations in LG's GPL packages. Of note:

  • debugstatus on webOS: DEBUG is 3, EVENT is 4, and RELEASE is 5

    debug level value (webOS) value (NetCast/GP)
    DEBUG_LEVEL 3 0
    EVENT_LEVEL 4 1
    RELEASE_LEVEL 5 2

    From lg_modeldef.h

  • baud rate: 2400 is 0, 9600 is 2, 115200 is 7

    baud rate value
    2400 0
    4800 1
    9600 2
    14400 3
    19200 4
    38400 5
    57600 6
    115200 7
    460800 8

    SYS_BAUDRATE_T from cmnio_type.h

Although I've seen a default baud rate of 115200 in bootloader code, in practice the default seems to be 9600.

In all the cases I've encountered on webOS, debugstatus is a single byte at offset 0x1a1 in NVM. I'll use 0x1a1 throughout this document, but it may be different for your model. The best way of determining the correct offset is reverse engineering your bootloader (or programs that access NVM such as RELEASE), but the GPL package for your TV model should also provide the necessary information (except for LX SoCs, since lxboot is not open source). After dumping the contents of the EEPROM, you should verify that the structure matches your expectations.

History

Before webOS 5 (released on 2020 models), LG stored NVM in an I²C EEPROM IC. NVM is entirely unencrypted on webOS 3.5 (2017) models. In webOS 4.0 (2018), LG started encrypting debugstatus in NVM, although other config settings remained accessible. In webOS 4.5 (2019), they attempted to obfuscate debugstatus a bit by calling it "Doption". With webOS 5 (2020), NVM was removed and replaced by "bootdb", which is stored in an encrypted eMMC partition named dbboot.

ICs

The ICs I've seen being used for NVM are usually 256Kbit (32Kbyte) in SO-8 packages. Sometimes larger EEPROMs up to 1Mbit are used, but these seem to be mostly on less mainstream products. You may also find I²C EEPROM ICs (potentially smaller ones like 24C08 or 24C02) for HDMI stuff (EDID), which are not relevant here.

Rohm BR24G256F-3

A "4G25" marking (with a lot number underneath) indicates a Rohm BR24G256F-3 (datasheet). (There is also a -5 part supporting 1MHz operation and more write cycles that LG sometimes uses in more recent models. The differences shouldn't matter here.)

EEPROM IC marked "4G25"
The NVM EEPROM IC on a 43LJ5500-UA board (webOS 3.5; 2017; MStar M2R SoC) marked 4G25.

FMD FT24C256A

The Fremont Micro Devices (FMD) FT24C256A-ESR (datasheet) is commonly used for NVM. It is marked "FT24C256A".

ST M24M01

The AN-WL100W main board stores NVM on a 1Mbit STMicroelectronics M24M01 (datasheet) EEPROM marked "24H01RP".

Atmel AT24C256C

The AT24C256C I²C EEPROM from Microchip (formerly Atmel) often appears in schematics as an alternative to the Rohm part, and I have seen it on non-webOS boards. Like the others, it's in an SOIC-8 package. The key markings for identifying it are a first line starting with ATML (usually ATMLH followed by three numbers forming a date code) and a second line starting with 2EC. See the datasheet for more information on the markings.

Hardware Requirements

You'll need a test clip unless you want to solder wires directly to the EEPROM IC's leads or otherwise find a way to connect to the I²C bus. Mini-grabbers (random example) may work. The I²C bus may be brought out to an unpopulated connector footprint (or, if you're really lucky, an actual connector) somewhere. There are other devices on the board that use I²C, but I don't know whether they're on the same bus.

Test Clip

A SOIC-8/SOP-8 test clip, such as the Pomona 5250, fits over the IC and provides easy access to the pins. Note that there are much cheaper generic test clips available from the usual sources (e.g., eBay, Amazon, AliExpress).

test clip on 43LJ5500-UA
A cheap test clip on the NVM EEPROM IC of a 43LJ5500-UA board.

Programmer

Any device that speaks I²C can potentially work. For example, a board based on the WCH CH341A or FTDI FT2232H (e.g., FT2232H Mini-Module) should work. An FT232H-based board can work, but note that the pre-2020 version of the Adafruit FT232H Breakout only has a 5V power output pin (see Notes below), although the I/O voltage should be fine. A Bus Pirate should theoretically work, although I had trouble with a Bus Pirate v4; I was able to detect the EEPROM and dump its contents, but the data was corrupted. I switched to using a Raspberry Pi 3 (Model B+), which gave me fewer problems, and ultimately allowed me to sucessfully change debugstatus. I used pins 3 and 5 of the 40-pin header, which are SDA and SCL, respectively. These pins correspond to /dev/i2c-1 in Linux by default.

Serial

Once you have DEBUG, you'll need a way to communicate with one of the TV's serial interfaces: RS-232 on a DE-9 connector or 3.5mm jack (if present), a 3.3V UART, or USB to serial adapter. If you are using a PC, you can accomplish this with a USB to serial adapter. If you're going to use the UART, make sure your adapter is configured to use 3.3V. If you are using something like a Raspberry Pi, you may be able to connect directly to its UART pins, although I haven't tried this. If you want to go the USB to serial route on the TV side, you may need two USB to serial adapters, at least one of which is PL2303-based.

Notes

While the EEPROM ICs themselves will tolerate 5V, you'll be backpowering parts of the board that are expecting 3.3V, so make sure your I²C adapter uses 3.3V.

I²C is pretty tolerant of less-than-ideal connections, especially at the lower speeds in use here.

Apparently at least some models can boot with an invalid or entirely missing NVM EEPROM. (As far as debugstatus goes, it'll default to RELEASE.)

Modification

The general idea is to attach a test clip to the EEPROM IC and use some I²C master device to access it. Then you should:

  1. Back up contents of EEPROM. (You may want to do this multiple times and make sure you always get the same result.)
  2. Make sure the value at offset 0x1a1 is 5. (If it's not, and you're sure you dumped the EEPROM correctly, I'd like to hear about it.)
  3. Write 3 to 0x1a1.
  4. Read the contents of EEPROM.
  5. Make sure everything is the same as before except the byte at 0x1a1 being 3 instead of 5.

After DEBUG

Confirmation

First, you should check that you have DEBUG. You should see this in the Instart menu:
Instart with DEBUG

There are several ways to launch the Instart menu. The intended method is probably via IR (e.g., with a service remote or IR blaster), but you can also use a Luna request. My super hacky SSAP client can send the necessary request. This predefined request should work on webOS 3.0+:
predefined Instart request

The password is almost certainly 0413.
password prompt

Enabling Serial Access

You can use the Instart menu to enable serial access: in System 1 set Baudrate to something sensible (like 115200), and in System 2, set RS-232C Control to On.

Serial

After enabling serial access, you'll need to connect to a serial port. The baud rate will be what you set earlier. Some models have RS-232 on a DE-9 connector, which may work, but most will have a 3.3V UART edge connector (and/or a UART on a 4-pin wafer connector). A potentially easier option is using two USB to serial adapters back-to-back, ultimately connecting from the TV's USB port to one on a PC. You can also connect from any of these options (except RS-232) to a Raspberry Pi via the appropriate pins in the P1 (GPIO) header.

You'll need to connect the GND, RX, and TX pins. (Don't connect anything to +3V3.) Connect the two GNDs first. The RX and TX pins should probably be swapped (i.e., RX on the TV to TX on your serial adapter and vice versa).

Edge Connector

The pinout of the edge connector is:

  1. +3V3
  2. RX
  3. GND
  4. TX

edge connector
UART edge connector.

On the boards I've seen, each data line has a 100Ω series resistor providing a bit of protection, but after that they probably run straight to the SoC, so be careful. The RX line is pulled up to 3.3V with a 10kΩ resistor.

The dimensions of the edge connector happen to match those of a SOIC-8 test clip. With a bit of padding (such as cardboard) underneath the board, a test clip will stay on well enough. If you can't get that to work, it's possible to solder wires to the test pads on the bottom of the board. There's usually a group of four with the same signals as the edge connector somewhere nearby. I'm not sure how they're arranged, so check what pin each one corresponds to with a multimeter.

USB to Serial

You can also use a USB to serial device in one of the TV's USB ports, although only certain types will work. Your best bet is a PL2303-based adapter. Some LG TVs have been known to specifically check for an Aten UC232A, but I haven't had any problems with generic (even possibly counterfeit) PL2303 devices.

Using a USB to serial adapter connected to the TV means you'll likely need another one to connect to your PC. Make sure you remember to swap TX and RX: TX on one goes to RX on the other. Connect the GND pins, but don't connect the VCC/+3V3 pins.

Debug Menu

NOTE: Some LX SoCs prohibit access to certain debug menu commands—including those that open a shell—without AccessUSB authentication. I've also encountered this on an MStar LM15U signage board. These restrictions may be more common on signage (and other commercial) models. There are likely workarounds, but I'm currently unable to help with this.

From the serial debug menu you can spawn a root shell. Press F9 to open the menu, and use the sh command to start the shell. (On newer models, you may just have to press s for shell access. You can usually press h for a list of available keys.)

Root Shell

Once you have the root shell, you need to use it to achieve persistent root access. First, force-enable dev mode by creating a directory named /var/luna/preferences/devmode_enabled. You may have to remove the existing file with that name. Make sure the LG Developer Mode app is uninstalled, or it will cause problems. Once you've created the devmode_enabled directory, reboot so that processes such as the app installer know that dev mode is enabled.

With dev mode enabled, you can install Homebrew Channel. Use the following commands to download and install it:

curl -L -o /home/root/hb.ipk https://github.com/webosbrew/webos-homebrew-channel/releases/download/v0.6.3/org.webosbrew.hbchannel_0.6.3_all.ipk

luna-send-pub -i 'luna://com.webos.appInstallService/dev/install' '{"id":"com.ares.defaultName","ipkUrl":"/home/root/hb.ipk","subscribe":true}'

You'll have to terminate luna-send-pub with control+C when it's done.

Once Homebrew Channel is installed, run its elevation script from the root shell:

/media/developer/apps/usr/palm/services/org.webosbrew.hbchannel.service/elevate-service

Homebrew Channel

General information about Homebrew Channel and root can be found in my crashd guide.

I recommend you block updates using the Homebrew Channel settings (although this is not totally effective). I also prefer to disable telnet, enable SSH, and set up an SSH key.

Older Platforms

Remember that on NetCast and Global Platform, DEBUG is 0 and RELEASE is 2, so you'd be changing 2 to 0.

The board in the AN-WL100W wireless transmitter box has an MStar Saturn7 SoC that runs Global Platform 2 (GP2). The general structure of NVM data is similar to more modern models, but it includes fewer fields. (However, it is on a 1 megabit EEPROM, which probably means it stores unknown other data.) There doesn't seem to be a baud rate setting in NVM. Its debugstatus byte appears to be at offset 0x185, and would be changed from 2 to 0 for DEBUG. I still haven't been able to get any further access, though.

Resources

@throwaway96
Copy link
Author

@Rutge-R
Did you already enable DEBUG?

Yes, that sounds like it will work. You can also use the USB/serial adapter with a PC. If your serial adapter is PL2303-based, you can connect its USB side to your TV and its TTL serial side to your Pi's UART pins. In any case, make sure your serial adapter is using 3.3V I/O.

You could also just connect directly from the TV board's UART to the Pi's UART pins. If you have a SO-8 test clip and your TV board has a UART edge connector, I recommend trying to clip onto it (with a bit of cardboard stuffed underneath to hold everything in place) before you go the soldering route.

@Rutge-R
Copy link

Rutge-R commented Sep 13, 2023

Yes, soldering leaves little room for error. The USB adapter uses 3.3v yes, but didn't use it when connecting RPI <-> PC. In this whole process the 3.3v is only used when dumping the EEPROM for debug mode, right? Actually I was wondering if I could get a console with debug still on RELEASE. It was a pain connecting the (cheap Chinese) testclip on to the chip and couldn't get a good response. Could you tell me how was the wiring when you used your RPI to the EEPROM? I also have a RPI3B. There is also have a free 4-pin connector left of the UART connector pins. You might know what it's for?. My EEPROM chip is the 4G25 83853 (2017).

@throwaway96
Copy link
Author

throwaway96 commented Sep 13, 2023

@Rutge-R
Yes, you should only connect the power when you're using it to power the EEPROM. I'm talking about the I/O voltage. Some USB/serial adapters use a fixed voltage of (usually) 3.3V or 5V, and some have a switch/jumper to select it. If you use 5V I/O on a device that's expecting 3.3V, you may damage it. (And using a 3.3V adapter with a 5V system may not work.)

You will almost certainly not be able to access the debug menu when in RELEASE mode.

The only EEPROM pins I connected to my RPi were ground, power (3.3V), SDA (to GPIO 2/pin 3), and SCL (GPIO 3/pin 5).

The 4-pin wafer connector is also for the UART. I believe it has the same pinout as the edge connector in this case. I have a cable for UART access via those connectors, but I had to create it from an existing LG cable because I can't get the connectors and don't know of anything compatible. The original connectors are part of the Yeonho 12507 series (1.25mm pitch). The board-mount male SMD connectors are Yeonho 12507WS-04L (vertical) and 12507WR-04L (right-angle), and the female connector is 12507HS-04L. If anyone is aware of a compatible connector series that's more readily available (or a source of the Yeonho ones), please let me know. (LG also occasionally uses Yeonho 12505WS, which is a Molex Picoblade knockoff.)

@Rutge-R
Copy link

Rutge-R commented Sep 14, 2023

You sure have an incredible amount of knowledge (LG in particular?). I ordered an original Pomona SOIC8 testclip, to do this right. I will let you know how it went. Thanks again.

@Rutge-R
Copy link

Rutge-R commented Sep 18, 2023

Did some digging in an old Pioneer receiver and found this handy cable. Putting some tape on connector #1 (+3.3v) and clipping the ribbon cable upside down would be a fine solution, right? So when the cable moves it wouldn't accidently hit the +3.3v connector. You were right about the voltages that the USB <-> serial cable delivers besides the red 5v cable. The RX & TX are 3.3v luckily.

Based on some DMESG output it seems like that there's some serial console active on /dev/ttyAMA0 which the output of 'cat /proc/tty/drivers' confirms (with DEBUG still on RELEASE). By the way, wouldn't the 'accessUSB' route be another alternative for putting DEBUG status on DEBUG? You ever tried ?

@Rutge-R
Copy link

Rutge-R commented Sep 20, 2023

Got this info with PC connected to the serial wafer pins of the tv (minicom as application). Tomorrow the pomona testclip arrives, but not looking forward to the procedure. This output looks like something familiar?:

Welcome to minicom 2.8

OPTIONS: I18n
Port /dev/ttyUSB0, 04:18:42

Press CTRL-A Z for help on special keys

M16PLUS:
e
12f4635 Mar 8 2016 16:55:59
( RSA+nonAES)(0:0500,0010)
(P) Decrypting hash.......OK
(P) Comparing hashes......OK

( RSA+nonAES)(0:0500,0010)
(S) Decrypting hash.......OK
(S) Comparing hashes......OK
[M16PB1]
[DDR-SK]0[4]
[Bx][DDR:2.0GB_ADV]
[0] Loading image.........OK
[0] Comparing hashes......OK
[N] To 0x70000000, 152070 us

@throwaway96
Copy link
Author

@Rutge-R

Yeah, that's normal output for M16P early boot (115200 8N1). You're not going to be able to get into the debug menus though. If "RS-232C Control" is enabled (and the baud rate is set properly) in the instart menu, you'll probably be able to use TV-Link commands once webOS is fully started (try ka 00 ff). However, when you type debug you'll get a message about AccessUSB not being present (Access USB is NOT opened!!!).

AccessUSB devices use public-key cryptography (RSA, I believe) for authentication, so assuming the crypto is competently implemented that's basically a dead end. (Unless you have a quantum computer significantly more advanced than any publicly known.) I don't know anyone who has ever had access to a legit AccessUSB device. This guy made a "working" clone, but he had to replace the AccessUSB public key on his TV (which requires already having root).

@Rutge-R
Copy link

Rutge-R commented Sep 21, 2023

Allright, I followed your steps and I managed to get DEBUG. I thought it would be easy once the testclip is connected. But dumping the EEPROM and getting the modified one in the chip was far from that. Ran in to the same problem as mentioned by others here. But my solution was definitely not smbus and/or python. I used a tool called 'i2ceeprom' and compiled it for the C24256 chip (in my case). That gave me the full 32768 bytes file. Changed offset 0x1a1 in 3 and copied it back with 'dd' after loading the at24 module and giving access to the EEPROM with 'echo 24c256 0x50 > /sys/bus/i2c/devices/i2c-0/new_device'. After that 'dd if=moddedrom.bin of=/sys/bus/i2c/devices/1-0050/eeprom bs=1 count=32768'. Only thing left is to get to root via the serial terminal. I put rs-232 control on and the baudrate to 115200 in in-start. What console did you use to get root with F9?

Update I believe either my RX or TX connection was failing, so I could only receive output.

@Rutge-R
Copy link

Rutge-R commented Sep 21, 2023

I got in! Thank you so so so much for this tutorial. I've learned a lot and achieved what I wanted.

Copy link

ghost commented Oct 29, 2023

Hi,
I am thinking about „rooting“ my OLED65G19 (FW 03.36.50) because the Software method seems to be a no go right now.

Does anyone have experience with this Model or similar ones?

The TV is insured so i am pretty much on the safe side but i would like to avoid the hassle.

Is there any Reason it would not work on this model?

Thanks again for this awesome Tutorial…

If i do proceed, ill definately document it with a lot of Pictures.

thanks in advance

EDIT: I was just told, that the crashd Method should work just fine with my TV and FW. So i will give that another try and then update my Post accordingly…

@throwaway96
Copy link
Author

@kuruptor

No, you can't enable DEBUG like this on a G1. Those run webOS 6, which stores that kind of data in bootdb.

Copy link

ghost commented Nov 1, 2023

@throwaway96

Thank You for your reply. But i actually found out, that this Model (OLED65G19) with the current (newest) fw can indeed be rooted via your crashd Method.

I managed to root it yesterday and just wanted to thank you again for your awsome work.

thanks

DeKu

@Blackspell01
Copy link

Hi, I am thinking about „rooting“ my OLED65G19 (FW 03.36.50) because the Software method seems to be a no go right now.

Does anyone have experience with this Model or similar ones?

The TV is insured so i am pretty much on the safe side but i would like to avoid the hassle.

Is there any Reason it would not work on this model?

Thanks again for this awesome Tutorial…

If i do proceed, ill definately document it with a lot of Pictures.

thanks in advance

EDIT: I was just told, that the crashd Method should work just fine with my TV and FW. So i will give that another try and then update my Post accordingly…

The crashd method doesnt work on this software version unfortunately :(
Im sitting in the same boat rn, cant find a way to get this tv rooted

Copy link

ghost commented Nov 3, 2023

Hi,
are you sure? Because i did root my LG OLED65G19 with the above Firmware (newest one) via crrashd Method. It did work, and i have root access via ssh, HomeBrew App Installed and Developer App uninstalled..

I can send you proof if you like…

Before i rooted via crashd, i tried to downgrade the Firmware which didnt work, so i gave this one a shot and it worked..

Copy link

ghost commented Nov 3, 2023

@Blackspell01

Have you tried the crashd Method? Where exactly in the Process do you get stuck?

@throwaway96
Copy link
Author

@Blackspell01

The latest production G1 firmware is vulnerable to crashd, and probably the latest prerelease firmware as well.

Copy link

ghost commented Nov 3, 2023

@Blackspell01

Use this Guide and read it carefully:

https://gist.github.com/throwaway96/e811b0f7cc2a705a5a476a8dfa45e09f

On my G19 i had to toggle the Switch for the „KEY-SERVER“ (LG Developer Mode App) 1-2 times and the “EXTEND“ Switch for the Dev Manager App to get a Connection.

If you still need help just write some more Information. You can use the “openlgtv“ Discord Channel, too.

@Blackspell01
Copy link

@kuruptor @throwaway96
I have an LG OLED C1 TV but with the same software verion (03.36.50).
Maybe it is different for the C1. I get stuck when trying to establish the telnet connection.
In RootMyTV/RootMyTV.github.io#85 it is also confirmed that the version is not rootable.
But you both give me hope, I will try it again.

Copy link

ghost commented Nov 3, 2023

@Blackspell01

Do not use that Guide. Use the one linked in above. https://gist.github.com/throwaway96/e811b0f7cc2a705a5a476a8dfa45e09f

Believe me, your Version is rootable. Read the Guide carefully, It really is not complicated. I was stuck just like you because i used the same Guide. But this one is different. Don't forget to disable QuickStart+, and when rebooting, just turn off your TV and unplug it for 5-10 secs.

You'll see that it will work.

Copy link

ghost commented Nov 4, 2023

@Blackspell01

Here are some Pics.... Do you have any news? Did you succeed in rooting your C1?

IMG_2256
IMG_2257
IMG_2258

@Blackspell01
Copy link

Blackspell01 commented Nov 5, 2023

@Blackspell01

Do not use that Guide. Use the one linked in above. https://gist.github.com/throwaway96/e811b0f7cc2a705a5a476a8dfa45e09f

Believe me, your Version is rootable. Read the Guide carefully, It really is not complicated. I was stuck just like you because i used the same Guide. But this one is different. Don't forget to disable QuickStart+, and when rebooting, just turn off your TV and unplug it for 5-10 secs.

You'll see that it will work.

OMG thank you so much!
This method indeed worked for me and I have rooted my TV successfully now.
Do you know wether I can turn on QuickStart+ afterwords or has this setting to be turned off?

Copy link

ghost commented Nov 5, 2023

@Blackspell01

Yes, you can use QuickStart+ again. Don‘t forget to accept the necessary EULA‘s. Otherwise SSH won‘t start at boot.

And one other thing. If you have QuickStart+ enabled, let the TV settle for a few Seconds after Bootup before you open the HomeBrew App. Otherwise it may show that you are in Failsafe mode…

I had to accept nearly all of the Agreements for SSH to start at boot…

@FLASH993
Copy link

Would this method work for rooting a 2017 OLED55C7P-U?

@Rutge-R
Copy link

Rutge-R commented Feb 23, 2024

Yes.

@FLASH993
Copy link

So is using the Raspberry Pi, to act as a programmer and also connect wirelessly to the PC?

@FLASH993
Copy link

I haven't opened the TV yet. I am trying to get a good understanding of everything, then order the supplies, and then attack.

@throwaway96
Copy link
Author

@FLASH993

Yes, you use the Raspberry Pi to program the I2C EEPROM. It doesn't matter how (or if) it's connected to a PC.

I really need to clean up and release my automated NVM mod tool one of these days... It probably needs a lot more testing though.

@FLASH993
Copy link

Oh... So I have USB to TTL from a project awhile back. This one to be exact: https://a.co/d/39LgUJ6. This should work, right? I just ordered the test clip from Digikey.

@throwaway96
Copy link
Author

You mean for controlling the Raspberry Pi from a PC? If so, it should be fine, but there are probably easier ways.

@FLASH993
Copy link

You mean for controlling the Raspberry Pi from a PC? If so, it should be fine, but there are probably easier ways.

No I am talking about from my laptop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment