[Nexus 4 General] Gigadroid:
How to unbrick your N4 ​

I'm not responsible for anything that happens with your device!

I accidently flashed a S4 ROM.

After I noticed that, I tried to flash a factory image, but it booted for a very long time and WiFi, signal and other radio stuff didn't work.

Then I searched for help here, but anything they suggested didn't work, so you might be thinking that the only solution would be to send the device for repair.

But I searched for a solution anyway and found it :D

So this is what you need to download:

Nexus 4 Unbrick.zip

For Nexus 4 16GB you also need to download this files:

Nexus 4 Unbrick 16 GB Files.zip

OK let's start:

First thing we need to do is extracting everything and installing the LGNPST (this is for Windows 8, but I don't see why it shouldn't work on other versions).

Open your extracted Nexus 4 files folder

Open the LGNPST folder

Install "LGUnitedMobileDriver_S4981MAN38AP22_ML_WHQL_Ver_3.8.1.exe", it's located under "LG_USB_Driver"

Install "LGNPSTv1.3_Lab_Verison_RightClickReg.exe", located in root of the folder

Install "LGNPST_GenericModels_Ver_5_0_12_0", located under "NPST Generic Components and Models"

Install "LGNPST_Components_Ver_5_0_20_0", also located under "NPST Generic Components and Models"

Copy the Models folder to C:\LG Electronics\LGNPST\

Start a command prompt as admin

Type: regsvr32 "C:\LG Electronics\LGNPST\Models\LGNPST_LS970.dll" (yes, I know this is a .dll for the Optimus G)

That's it ;)

If you got no ADB or fastboot drivers installed, install the Universal ADB Driver.

Now start the LGNPST and get your N4 into download mode:

Turn the phone off.

Make sure the phone is off.

Plug a USB cable into your PC, AND ONLY INTO YOUR PC. THE PHONE PART COMES NEXT.

Hold down the volume up and down buttons for 2 (two) seconds on your Nexus, and continue to hold the volume up and down buttons while pluging in the USB cable which is connected to your PC. Continue to hold the buttons until the download mode screen appears. Now step five.

Once the download mode screen comes up, let go of the volume buttons.

Thanks to [MENTION=4633526]Connor Baker[/MENTION] for sharing this method :)

Now you should get a screen like this:

Now your LGNPST should look like this:

In the bottom center you see DLL and BIN File.

Click on the folder symbol and select LGNPST_LS970.dll (and again, yes, I know it's for Optimus G, trust me I know what I'm doing)

Then select the .bin file you extracted before.

Now click start and it'll flash it.

Your N4 will reboot automatically, but the LGNPST reached only 85%, thats's normal (but please wait until the 67% changed to 85% before you close it)

The LGNPST will say you, that you should reboot again to download mode to finish the process, but the only thing it does is giving you an error message.

So now you have a developer firmware on your device and it's encrypted so you can do nothing.

Reboot into bootloader with Vol - and power button.

Now start flash_all.bat in the flashfactory folder and the program will do the things by itself.

Now you are completely on stock and should have a fully working device :D

Next steps for Nexus 4 16GB:

First thing I need to say: No, this doesn't work!

First step is rooting your phone (search through XDA if you don't know how; thanks to Rockstar600 for remembering me)

Copy the files you downloaded for the 16GB Version on your Nexus 4 (without the CWM Image).

If "dd" got renamed to "dd.bin" rename it back to "dd".

Install Root Browser or an similar app and copy the files to your /system directory.

Then flash the CWM Recory Image.

To do that open the folder that contains the Factory Image flashable with fastboot and do CTRL+Right Click in that folder and select "Open Command Prompt here" or something like that (don't know the exact name).

Get your device into fastboot mode with Vol- and Power.

Now type:

fastboot flash recovery recovery-clockwork-touch-6.0.4.7-mako.img

Then reboot into recovery.

I think you leaved CMD open.

So now type:

adb shell
mount /system
cp /system/dd /
chmod 755 /dd
/dd if=/dev/block/mmcblk0 of=/system/pgpt8G.img bs=512 count=34
/dd if=/dev/block/mmcblk0 of=/system/sgpt8G.img bs=512 skip=30777311
umount /data
umount /cache
umount /system
df -h

Now the output should look like this:

# df -h
Filesystem Size Used Available Use% Mounted on
tmpfs 911.7M 48.0K 911.6M 0% /dev

There shouldn't be a extra line.

If there is no extra line then continue with:

mount /system
/dd if=/dev/block/mmcblk0 of=/system/DDR bs=512 skip=15267840 count=2015
/dd if=/system/DDR of=/dev/block/mmcblk0 bs=512 seek=30775296 conv=notrunc
/dd if=/system/sgpt16G.img of=/dev/block/mmcblk0 bs=512 seek=30777311 conv=notrunc
/dd if=/system/pgpt16G.img of=/dev/block/mmcblk0 bs=512 seek=0 conv=notrunc
parted /dev/block/mmcblk0

Then type p and press enter and the output should look like this:

# parted /dev/block/mmcblk0
GNU Parted 1.8.8.1.179-aef3
Using /dev/block/mmcblk0
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
p
Model: MMC 016G92 (sd/mmc)
Disk /dev/block/mmcblk0: 15.8GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number Start End Size File system Name Flags
1 524kB 67.6MB 67.1MB fat16 modem
2 67.6MB 68.2MB 524kB sbl1
3 68.2MB 68.7MB 524kB sbl2
4 68.7MB 70.8MB 2097kB sbl3
5 70.8MB 71.3MB 524kB tz
6 71.3MB 94.4MB 23.1MB boot
7 94.4MB 117MB 23.1MB recovery
8 117MB 118MB 799kB m9kefs1
9 118MB 119MB 799kB m9kefs2
10 119MB 120MB 799kB m9kefs3
11 120MB 121MB 524kB rpm
12 121MB 121MB 524kB aboot
13 121MB 122MB 524kB sbl2b
14 122MB 124MB 2097kB sbl3b
15 124MB 124MB 524kB abootb
16 124MB 125MB 524kB rpmb
17 125MB 125MB 524kB tzb
18 125MB 126MB 524kB metadata
19 126MB 143MB 16.8MB misc
20 143MB 159MB 16.8MB ext4 persist
21 159MB 1040MB 881MB ext4 system
22 1040MB 1627MB 587MB ext4 cache
23 1627MB 15.8GB 14.1GB ext4 userdata
24 15.8GB 15.8GB 524kB DDR
25 15.8GB 15.8GB 507kB grow

Notice that userdata partition is 14.1GB in size :D

In case parted reports an error I suggest to return back to the old 8G partition tables, see below.

You can close parted with simply typing quit.

Now reboot the phone into bootloader: type reboot and hold 'Up' button to enter bootloader menu.

Then type:

fastboot erase userdata
fastboot -w

Now again start the flash-all.bat in your folder.

Now you have your 16GB back :D

Return back to the old 8G partition tables:

In case parted reported an error, put the old 8G partition tables back. This should not happen but never say never:

/dd if=/system/sgpt8G.img of=/dev/block/mmcblk0 bs=512 seek=30777311 conv=notrunc
/dd if=/system/pgpt8G.img of=/dev/block/mmcblk0 bs=512 seek=0 conv=notrunc

Fix for Bluetooth and MAC adress:

For bluetooth:

- In /persist directory create bluetooth directory. Under the new directory create a file named .bdaddr (don't miss the dot!)

Edit the file and put 6 random characters in it. Even better, if you can do this in a hex editor and put 6 random bytes, not just printable characters.

- Set execute and read permissions for everybody on /persist/bluetooth directory and change owner of .bdaddr to bluetooth:bluetooth and permission to 660 (read/write for owner and group and nothing else). In command line:

chown root:root /persist/bluetooth
chmod 755 /persist/bluetooth
chown bluetooth:bluetooth /persist/bluetooth/.bdaddr
chmod 660 /persist/bluetooth/.bdaddr

For mac address:

- In /persist directory create wifi directory. In the new directory create a file named .macaddr (don't miss the dot!)

Edit the file and put 12 random hex numbers in it (0-9, A-F), save.

- Set execute and read permissions for everybody on /persist/wifi directory and change owner of .macaddr to wifi:wifi and permission to 660 (read/write for owner and group and nothing else). In command line:

chown root:root /persist/wifi
chmod 755 /persist/wifi
chown wifi:wifi /persist/wifi/.macaddr
chmod 660 /persist/wifi/.macaddr

- run /system/bin/conn_init program. Can be run in root explorer(choose Linux Script Handler when you open it), or in adb shell:

su
/system/bin/conn_init

Then reboot and check if the changes got applied in settings ;)

Donate

Every $ helps me ;) : Donate

Credits

Koush for his ADB Driver

Jhoopes517 for his tutorial to install LGNPST

FLYN's thread about unbricking a Nexus 4, because I got the parts for LGNPST from there

foil for his .tot files

Jbele for his picture from download mode xD

Google for the factory images

dvhexer for his guide to convert 8GB to 16GB