[+]RESTOCK - stock restore, repartition, repair and reset, including USB driver fix

Search This thread

dkn92

New member
Jan 29, 2023
2
0
Using TWRP please flash k23m-persist-fix2.zip (on the first post).
added twrp n the rest of the addon except ElementalX. then was about the proceed to install persist-fix but device jus booted into OS. so looks like it jus needed some time.

Huge thank you @k23m
Now this is off topic but my touchscreen doesnt work. any idea what part needs to be replaced? i use a mouse via OTG for now. if the touchscreen is jus a simple cable replacement, i'll happily do it.
 

crucial929

Senior Member
Jul 10, 2008
288
40
Covington , ky
any insight? i cant get it past the Google screen or boot into recovery

...
(bootloader) Device tampered: false
(bootloader) Device unlocked: false
(bootloader) SB=Y
OKAY [ 0.005s]
finished. total time: 0.005s
(bootloader) version-bootloader: FLO-04.08
(bootloader) version-baseband: none
(bootloader) version-hardware: rev_e
(bootloader) version-cdma: N/A
(bootloader) variant: flo 32G
(bootloader) serialno: 05fa1656
(bootloader) product: flo
(bootloader) secure_boot: enabled
(bootloader) lock_state: unlocked
(bootloader) project: flo
(bootloader) off-mode-charge: yes
(bootloader) uart-on: no
(bootloader) partition-type:bootloader: emmc
(bootloader) partition-size:bootloader: 0x0000000000aee000
(bootloader) partition-type:recovery: emmc
(bootloader) partition-size:recovery: 0x0000000000a00000
(bootloader) partition-type:boot: emmc
(bootloader) partition-size:boot: 0x0000000001000000
(bootloader) partition-type:system: ext4
(bootloader) partition-size:system: 0x0000000034800000
(bootloader) partition-type:cache: ext4
(bootloader) partition-size:cache: 0x0000000023000000
(bootloader) partition-type:userdata: ext4
(bootloader) partition-size:userdata: 0x00000006a3ffbe00
all:
finished. total time: 0.033s
...
(bootloader) partition[1].name = radio
(bootloader) partition[1].first_lba = 131072
(bootloader) partition[1].last_lba = 306143
(bootloader) partition[1].size 87536 KB
(bootloader) partition[2].name = modemst1
(bootloader) partition[2].first_lba = 393216
(bootloader) partition[2].last_lba = 399359
(bootloader) partition[2].size 3072 KB
(bootloader) partition[3].name = modemst2
(bootloader) partition[3].first_lba = 399360
(bootloader) partition[3].last_lba = 405503
(bootloader) partition[3].size 3072 KB
(bootloader) partition[4].name = persist
(bootloader) partition[4].first_lba = 524288
(bootloader) partition[4].last_lba = 554287
(bootloader) partition[4].size 15000 KB
(bootloader) partition[5].name = m9kefs1
(bootloader) partition[5].first_lba = 655360
(bootloader) partition[5].last_lba = 656919
(bootloader) partition[5].size 780 KB
(bootloader) partition[6].name = m9kefs2
(bootloader) partition[6].first_lba = 656920
(bootloader) partition[6].last_lba = 658479
(bootloader) partition[6].size 780 KB
(bootloader) partition[7].name = m9kefs3
(bootloader) partition[7].first_lba = 786432
(bootloader) partition[7].last_lba = 787991
(bootloader) partition[7].size 780 KB
(bootloader) partition[8].name = fsg
(bootloader) partition[8].first_lba = 787992
(bootloader) partition[8].last_lba = 794135
(bootloader) partition[8].size 3072 KB
(bootloader) partition[9].name = sbl1
(bootloader) partition[9].first_lba = 917504
(bootloader) partition[9].last_lba = 920503
(bootloader) partition[9].size 1500 KB
(bootloader) partition[10].name = sbl2
(bootloader) partition[10].first_lba = 920504
(bootloader) partition[10].last_lba = 923503
(bootloader) partition[10].size 1500 KB
(bootloader) partition[11].name = sbl3
(bootloader) partition[11].first_lba = 923504
(bootloader) partition[11].last_lba = 927599
(bootloader) partition[11].size 2048 KB
(bootloader) partition[12].name = aboot
(bootloader) partition[12].first_lba = 927600
(bootloader) partition[12].last_lba = 937839
(bootloader) partition[12].size 5120 KB
(bootloader) partition[13].name = rpm
(bootloader) partition[13].first_lba = 937840
(bootloader) partition[13].last_lba = 938863
(bootloader) partition[13].size 512 KB
(bootloader) partition[14].name = boot
(bootloader) partition[14].first_lba = 1048576
(bootloader) partition[14].last_lba = 1081343
(bootloader) partition[14].size 16384 KB
(bootloader) partition[15].name = tz
(bootloader) partition[15].first_lba = 1179648
(bootloader) partition[15].last_lba = 1180671
(bootloader) partition[15].size 512 KB
(bootloader) partition[16].name = pad
(bootloader) partition[16].first_lba = 1180672
(bootloader) partition[16].last_lba = 1180673
(bootloader) partition[16].size 1 KB
(bootloader) partition[17].name = sbl2b
(bootloader) partition[17].first_lba = 1180674
(bootloader) partition[17].last_lba = 1183673
(bootloader) partition[17].size 1500 KB
(bootloader) partition[18].name = sbl3b
(bootloader) partition[18].first_lba = 1183674
(bootloader) partition[18].last_lba = 1187769
(bootloader) partition[18].size 2048 KB
(bootloader) partition[19].name = abootb
(bootloader) partition[19].first_lba = 1187770
(bootloader) partition[19].last_lba = 1198009
(bootloader) partition[19].size 5120 KB
(bootloader) partition[20].name = rpmb
(bootloader) partition[20].first_lba = 1198010
(bootloader) partition[20].last_lba = 1199033
(bootloader) partition[20].size 512 KB
(bootloader) partition[21].name = tzb
(bootloader) partition[21].first_lba = 1199034
(bootloader) partition[21].last_lba = 1200057
(bootloader) partition[21].size 512 KB
(bootloader) partition[22].name = system
(bootloader) partition[22].first_lba = 1310720
(bootloader) partition[22].last_lba = 3031039
(bootloader) partition[22].size 860160 KB
(bootloader) partition[23].name = cache
(bootloader) partition[23].first_lba = 3031040
(bootloader) partition[23].last_lba = 4177919
(bootloader) partition[23].size 573440 KB
(bootloader) partition[24].name = misc
(bootloader) partition[24].first_lba = 4194304
(bootloader) partition[24].last_lba = 4196351
(bootloader) partition[24].size 1024 KB
(bootloader) partition[25].name = recovery
(bootloader) partition[25].first_lba = 4325376
(bootloader) partition[25].last_lba = 4345855
(bootloader) partition[25].size 10240 KB
(bootloader) partition[26].name = DDR
(bootloader) partition[26].first_lba = 4456448
(bootloader) partition[26].last_lba = 4456463
(bootloader) partition[26].size 8 KB
(bootloader) partition[27].name = ssd
(bootloader) partition[27].first_lba = 4456464
(bootloader) partition[27].last_lba = 4456479
(bootloader) partition[27].size 8 KB
(bootloader) partition[28].name = m9kefsc
(bootloader) partition[28].first_lba = 4456480
(bootloader) partition[28].last_lba = 4456481
(bootloader) partition[28].size 1 KB
(bootloader) partition[29].name = metadata
(bootloader) partition[29].first_lba = 4587520
(bootloader) partition[29].last_lba = 4587583
(bootloader) partition[29].size 32 KB
(bootloader) partition[30].name = userdata
(bootloader) partition[30].first_lba = 4718592
(bootloader) partition[30].last_lba = 60424158
(bootloader) partition[30].size 27852783 KB
(bootloader) partition[31].name =
(bootloader) partition[31].first_lba = 0
(bootloader) partition[31].last_lba = 0
(bootloader) partition[31].size 0 KB
(bootloader) partition[32].name =
(bootloader) partition[32].first_lba = 0
(bootloader) partition[32].last_lba = 0
(bootloader) partition[32].size 0 KB
(bootloader) partition[33].name =
(bootloader) partition[33].first_lba = 0
(bootloader) partition[33].last_lba = 0
(bootloader) partition[33].size 0 KB
(bootloader) partition[34].name =
(bootloader) partition[34].first_lba = 0
(bootloader) partition[34].last_lba = 0
(bootloader) partition[34].size 0 KB
(bootloader) partition[35].name =
(bootloader) partition[35].first_lba = 0
(bootloader) partition[35].last_lba = 0
(bootloader) partition[35].size 0 KB
(bootloader) partition[36].name =
(bootloader) partition[36].first_lba = 0
(bootloader) partition[36].last_lba = 0
(bootloader) partition[36].size 0 KB
(bootloader) partition[37].name =
(bootloader) partition[37].first_lba = 0
(bootloader) partition[37].last_lba = 0
(bootloader) partition[37].size 0 KB
OKAY [ 0.150s]
finished. total time: 0.150s
product: flo
finished. total time: 0.003s
flo found, OK



i'm guessing bad eMMC
 
Last edited:

packzap

New member
Jan 30, 2023
2
1
I'm having problems getting back to the stock Google OS for this Nexus 7 2013 wifi tablet. I had Lineage 18.1 on it, but was not happy with the glitchy performance. I ran your Restock2 .bat and it setup everything correctly after reboot to Android 6.0.1. However, later upon powering down and then powering up the Nexus 7, it just goes to the Google Android screen with the 4 colorful rotating icons and doesn't complete the boot process.

I ran restock2.bat again and at the reboot process it just stays showing the 4 colorful Google rotating icons at screen center and goes no further.

Any hints on a good next step to proceed. Thanks so much.
 

packzap

New member
Jan 30, 2023
2
1
Wow, I think flashing "k23m-persist-fix2.zip" did the trick! It's booting now into Android successfully and things look to be working. Plus reboots now work correctly.

Oh, I would sure like to get a better understanding on what makes Android and this Nexus 7 tick. Thanks so much for your valuable help!!!! (y)

[To reiterate what i did, for those viewing this thread, or for me, if I have to this again in a year or so:
Install Restock2, then the addons from that package and at least option #1 TWRP. If the Nexus 7 does not boot correctly afterward, for example only into the 4 revolving icons, then flash k23m-persist-fix2.zip to the tablet. Do this by rebooting to recovery mode, which brings up the TWRP screen. Choose Advanced, ADB sideload and sideload k23m-persist-fix2.zip onto the tablet. After completion, the tablet should hopefully boot correctly into Android 6.0.1]


Again, incredible thanks to k23m for the outstanding advice and utilities! 🥇🙂
 
Last edited:
  • Like
Reactions: k23m

tab7inch

Member
Mar 12, 2023
6
0
Hello, My N7 deb with stock ROM was working ok. One night while charging it started rebooting, I then turned it off and never managed to start it again. I thought it was a battery issue so I bought a new one and replaced it. Still no sign. Connected to PC it was in EDL (9006) so, after a bit of search (and most probably a few mistakes due to my inexperience where I messed up the partitions trying to fix).

Then I finally found the @k32m's guide. I'm able to flash the N7 with MiFlash but I can't complete restock2 as it is reported as not unlocked, similarly I can't push the official image from Google.
Code:
fastboot devices
sees my device but not
Code:
adb
. The log from
Code:
Restock
is attacked. Any hint? Thanks in advance
 

Attachments

  • getlog.log
    7.4 KB · Views: 4

k23m

Senior Member
Jan 3, 2016
1,001
593
I have reset my deb by installing Restock which I've done countless times in the past. But this time my deb is so slow and unresponsive it's virtually unusable. Any suggestions will be greatly appreciated. Thanks

- run "fstrim.bat" from Restock2
- re-seat the wide silver ribbon cable


I'm able to flash the N7 with MiFlash but I can't complete restock2 as it is reported as not unlocked

Run "safe-unlock.bat" from Restock2 but skip the MiFlash step as it is already done.
 

tab7inch

Member
Mar 12, 2023
6
0
- run "fstrim.bat" from Restock2
- re-seat the wide silver ribbon cable




Run "safe-unlock.bat" from Restock2 but skip the MiFlash step as it is already done.
thanks for the help @k23m. It seems the suggested "safe-unlock.bat" is stuck waiting to get an answer from the devices seen from adb after trying to boot TWRP. On the screen I still see Android bootloader (with the open droid), and on the console many "*". I'm still letting safe-unlock run (since about 1h) but not much hope I'll get anything. Attached a log collected from safe-unlock still in the "data" folder.

In my previous attempts (before trying restock) I managed to run TWRP. By typing fastboot boot TWRP.img (that's basically what the safe-unlock does where I'm stuck now). I can access to some part of the menu but I can't properly use the bottom slide in the home to "unlock" the device (it's like I can move the slide up to half the bar and then comes back to the left position). I've made the same attempt with a few version of twrp but unfortunately same issue.

Any additional suggestion?
 

Attachments

  • unlock.log
    13.9 KB · Views: 2

k23m

Senior Member
Jan 3, 2016
1,001
593
fstrim.bat won't run; it doesn't seem to recognize the TWRP is running on the N7. What shall I try next? Thanks

Next, check the ribbon cable (it really can slow N7 down), then return to fstrim and do whatever it takes to run it.


I still see Android bootloader (with the open droid), and on the console many "*".

This wait for ******* issue is hardware related. Try another PC/OS/cable like this user https://forum.xda-developers.com/t/iiiii-cross-custom-rom-scripted-setup.4092215/post-88093697

Otherwise, as you can boot TWRP and use it partially, run safe-unlock's commands manually. Make sure to restore GPT partition table first, reboot, then proceed with the unlock command.
 

tab7inch

Member
Mar 12, 2023
6
0
Next, check the ribbon cable (it really can slow N7 down), then return to fstrim and do whatever it takes to run it.




This wait for ******* issue is hardware related. Try another PC/OS/cable like this user https://forum.xda-developers.com/t/iiiii-cross-custom-rom-scripted-setup.4092215/post-88093697

Otherwise, as you can boot TWRP and use it partially, run safe-unlock's commands manually. Make sure to restore GPT partition table first, reboot, then proceed with the unlock command.
thanks again for helping here @k23m

I've used a different cable and port (even if both the cables are pretty new)

so by restoring GPT partitions (as per the command in safe-unlock) and then booting TWRP, adb don't see any device. If I restart the N7 by pressing the power button, the PC sees it as QHSUSB_DLOAD. So I need to re-run MiFlash to get again a sign of life on the screen

skipping the GPT restore fastboot flash gpt gpt_both0.bin instead I can reach the end of the safe-unlock with the attached result
 

Attachments

  • unlock-231100,15.log
    13.5 KB · Views: 3

Ignass

Member
Mar 22, 2013
40
4
Any ideas whats wrong? Was working fine with lineage os, just flashed aosp and it works fine.

...
Sending 'system' (843549 KB) OKAY [ 28.562s]
Writing 'system' OKAY [ 38.499s]
archive does not contain 'system_dlkm.img'
archive does not contain 'system_ext.img'
archive does not contain 'vendor.img'
archive does not contain 'vendor_dlkm.img'
Erasing 'userdata' OKAY [ 0.162s]
mke2fs 1.46.6-rc1 (12-Sep-2022)
mke2fs: Illegal or malformed device name while trying to determine filesystem size
C:\adb/mke2fs failed: 1
fastboot: error: Cannot generate image for userdata
Press any key to exit...
 
Last edited:

k23m

Senior Member
Jan 3, 2016
1,001
593
skipping the GPT restore fastboot flash gpt gpt_both0.bin instead I can reach the end of the safe-unlock with the attached result

But the result is a GPT still in its primal stage, useless for unlock or Android. Try another PC like the above-quoted user, and re-run the script.

mke2fs: Illegal or malformed device name while trying to determine filesystem size

Did you "Restore original partitions?" If not, do it. Furthermore...

ERRORS
Run getlog.bat and include "getlog.log" in your post. If possible, also run relog.bat and attach "relog-xxxxxx.zip" to your post.
 

Ignass

Member
Mar 22, 2013
40
4
But the result is a GPT still in its primal stage, useless for unlock or Android. Try another PC like the above-quoted user, and re-run the script.



Did you "Restore original partitions?" If not, do it. Furthermore...
i have restored partitions. tried restock2 and it flashed everything but bootlooped on android logo.
Flashed "Bad_Boyz_Nexus_7_MOB30X_6.0.1_stock_systemless_rooted_TWRP.zip" and it booted right up, that will be good enough
 

tab7inch

Member
Mar 12, 2023
6
0
But the result is a GPT still in its primal stage, useless for unlock or Android. Try another PC like the above-quoted user, and re-run the script.



Did you "Restore original partitions?" If not, do it. Furthermore...
after changing the PC, I've also tried to reseat the ribbon cable but still same issue.
Open to any suggestions
 

k23m

Senior Member
Jan 3, 2016
1,001
593
tried restock2 and it flashed everything but bootlooped on android logo.

You've missed this bold red note on the front page, maybe I need to increase font size...

If Android is stuck on boot logo, with TWRP flash k23m-persist-fix2.zip



Any other GPT partition schema I can try to use?

There is only one - the N7 GPT. Do it manually:

Code:
fastboot flash gpt gpt_both0.bin
fastboot reboot-bootloader
fastboot boot twrp-3.2.3-0-deb.img
adb shell "printf '\x06' | dd of=/dev/block/mmcblk0p12 bs=1 count=1 seek=5241856"
adb reboot bootloader

If everything fails then your N7 is actually faulty - https://forum.xda-developers.com/ne...13-qa/fix-nexus-7-2013-bricked-stuck-t3310608
 

tab7inch

Member
Mar 12, 2023
6
0
You've missed this bold red note on the front page, maybe I need to increase font size...







There is only one - the N7 GPT. Do it manually:

Code:
fastboot flash gpt gpt_both0.bin
fastboot reboot-bootloader
fastboot boot twrp-3.2.3-0-deb.img
adb shell "printf '\x06' | dd of=/dev/block/mmcblk0p12 bs=1 count=1 seek=5241856"
adb reboot bootloader

If everything fails then your N7 is actually faulty - https://forum.xda-developers.com/ne...13-qa/fix-nexus-7-2013-bricked-stuck-t3310608
thanks I've tried to push the commands again but still the same flash gpt bricks the device

I've also tried to run the QPST memory debug (output attached just in case you may have a look). Not much hopes at this stage but is there any final test I can do to understand if it's the eMMC or else?
 

Attachments

  • CODERAM.BIN
    160 KB · Views: 2

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    I have 2 Nexus 7 debs which are rooted and running Followmsi's custom Lineage 20-20230507-UNOFFICIAL-deb ROM based on Android 13. I've used Restock several times, but my debs are really slow and plagued with the three following error messages: Settings, System UI, and Process System "isn't responding." Is there something I can do to go back to original status while cleaning up all the anomalies, above, at the same time, so it performs as it should, and then root it again and install a custom ROM?
    Thanks
    Post #114

    I made a script file for it. 😉
    fstrim - [github] - Link

    Cheers. :cowboy:
    1
    Post #114

    I made a script file for it. 😉
    fstrim - [github] - Link

    Cheers. :cowboy:
    Shouldn't be required anymore since discard is back in the fstab 😯
    1
    Post #114

    I made a script file for it. 😉
    fstrim - [github] - Link

    Cheers. :cowboy:
    I have used that script every time I've run Restock, but unfortunately it obviously hasn't worked. Thanks
  • 36
    RESTOCK is a new Nexus 7 2013 repair and factory reset tool for Windows. The NRT app (Nexus Root Toolkit) is similar but is old, closed-source, unsupported, abandoned, does no eMMC diagnostics and most importantly - it offers no repartitioning. Unlike NRT, Restock is specialized and optimized for Nexus 7'13 only, with streamlined operation and minimal user input.

    If fastboot mode is available, then no matter what software problems like bootloops or softbricks are observed, or what custom ROM you had used before - Restock will restore your tablet to original, latest stock image, factory setup in 10 minutes (more time for one-off components download if necessary). Unforeseen issues should be reported in this thread and hopefully will be resolved within 24 hours.

    If fastboot mode is not available, try the unbricking guide first.

    For hardware issues, check this thread.

    FEATURES

    • supports both flo and deb variants
    • small app download size (2.5MB)
    • automatic latest stock image (mob30x) and USB driver download from official google.com locations
    • robust, reliable USB device detection and driver installation - tested on Windows: XP-32, W7-32/64, W10-64(1809)
    • eMMC memory test and diagnostics
    • automatic device unlocking
    • option of repartition to original factory layout
      - precise and reliable for any eMMC size, including 64GB and 128GB mods
      - required for repartition scripts which check for original layout and flashing specific custom ROMs like e.g. Ubuntu Touch
      - advised for selling in original factory condition and resolving difficult ROM flashing issues and starting from scratch
    • minimal user interaction and fully scripted auto-processing
    • the Restock script is open for inspection, corrections and improvements; post your comments and suggestions here
    USAGE

    1. download the attached zip file
    2. unzip it
    3. double-click on "restock.bat"
    4. follow the prompts
    SAMPLE OUTPUT
    Code:
    Nexus 7'13 Restock v1 @2019 k23m
    SUPPORT - http://bit.ly/2C35sLZ
    WARNING - installing factory image will ERASE ALL DATA from the device
    Enter device name [flo OR deb]: flo
    
    Downloading USB drivers and the latest factory image.
    If not deleted, will not be downloaded again.
    
    --  https://dl-ssl.google.com/android/repository/latest_usb_driver_windows.zip
    Resolving dl-ssl.google.com... 74.125.24.190, 74.125.24.91, 74.125.24.93, ...
    Connecting to dl-ssl.google.com|74.125.24.190|:443... connected.
    WARNING: cannot verify dl-ssl.google.com's certificate, issued by 'CN=GTS CA 1O1,O=Google Trust Services,C=US':
      Unable to locally verify the issuer's authority.
    HTTP request sent, awaiting response... 200 OK
    Length: 8682859 (8.3M) [application/zip]
    Saving to: 'latest_usb_driver_windows.zip'
    latest_usb_driver_windows.zip  14%[======>                              ]   1.21M   383KB/s    eta 19s
    ...
    
    --  https://dl.google.com/dl/android/aosp/razor-mob30x-factory-52684dff.zip
    Resolving dl.google.com... 172.217.25.46
    Connecting to dl.google.com|172.217.25.46|:443... connected.
    WARNING: cannot verify dl.google.com's certificate, issued by 'CN=GTS CA 1O1,O=Google Trust Services,C=US':
      Unable to locally verify the issuer's authority.
    HTTP request sent, awaiting response... 200 OK
    Length: 505296115 (482M) [application/zip]
    Saving to: 'razor-mob30x-factory-52684dff.zip'
    
    razor-mob30x-factory-52684dff  86%[=============================>       ] 417.98M   410KB/s    eta 2m 57s
    ...
    
    1. boot the Nexus in fastboot mode: when OFF press POWER + VOLUME DOWN
    2. when in the bootloader menu, connect it to your PC
    3. wait a few seconds, then...
    Press any key to continue . . .
    ...
    ...
    INFO:   Successfull installation of 'd:\restock\data\usb_driver\android_winusb.inf'.
    INFO:   Returning with code 0x1
    
    Device not found...
    1. disconnect it from PC
    2. reboot to bootloader again
    3. reconnect it to PC
    Press any key to continue . . .
    
    Verify...
    eMMC test...
    If it freezes here, the chip is faulty and needs replacement.
    eMMC OK
    Lock status...
    GPT...
    
    Partitions had been changed.
    Restore original partitions? [y/n]: y
    Wait...
    sending 'bootloader' (3911 KB)...
    OKAY [  0.141s]
    writing 'bootloader'...
    OKAY [  1.518s]
    finished. total time: 1.658s
    rebooting into bootloader...
    OKAY [ -0.000s]
    finished. total time: 0.008s
    Wait...
    sending 'gpt' (35 KB)...
    OKAY [  0.016s]
    writing 'gpt'...
    OKAY [  0.109s]
    finished. total time: 0.141s
    rebooting into bootloader...
    OKAY [ -0.000s]
    finished. total time: 0.012s
    
    If error, copy and post it, include restock.log
    
    http://bit.ly/2C35sLZ
    
    Note: Android flash takes 2 minutes, initial boot takes 7 minutes.
    
    Press any key to continue . . .
    sending 'bootloader' (3915 KB)...
    OKAY [  0.125s]
    writing 'bootloader'...
    OKAY [  1.377s]
    finished. total time: 1.502s
    rebooting into bootloader...
    OKAY [  0.000s]
    finished. total time: 0.007s
    archive does not contain 'boot.sig'
    archive does not contain 'recovery.sig'
    archive does not contain 'system.sig'
    --------------------------------------------
    Bootloader Version...: FLO-04.08
    Baseband Version.....: none
    Serial Number........: xxxxxxxxx
    --------------------------------------------
    checking product...
    OKAY [  0.016s]
    checking version-bootloader...
    OKAY [  0.000s]
    sending 'boot' (7422 KB)...
    OKAY [  0.234s]
    writing 'boot'...
    OKAY [  1.000s]
    sending 'recovery' (8166 KB)...
    OKAY [  0.266s]
    writing 'recovery'...
    OKAY [  0.328s]
    erasing 'system'...
    OKAY [  1.143s]
    sending 'system' (843549 KB)...
    OKAY [ 26.516s]
    writing 'system'...
    OKAY [ 39.986s]
    erasing 'userdata'...
    OKAY [ 23.750s]
    formatting 'userdata' partition...
    Creating filesystem with parameters:
        Size: 28856791040
        Block size: 4096
        Blocks per group: 32768
        Inodes per group: 8192
        Inode size: 256
        Journal blocks: 32768
        Label:
        Blocks: 7045115
        Block groups: 215
        Reserved block group size: 1024
    Created filesystem with 11/1761280 inodes and 154578/7045115 blocks
    sending 'userdata' (139085 KB)...
    writing 'userdata'...
    OKAY [ 12.434s]
    erasing 'cache'...
    OKAY [  0.437s]
    formatting 'cache' partition...
    Creating filesystem with parameters:
        Size: 587202560
        Block size: 4096
        Blocks per group: 32768
        Inodes per group: 7168
        Inode size: 256
        Journal blocks: 2240
        Label:
        Blocks: 143360
        Block groups: 5
        Reserved block group size: 39
    Created filesystem with 11/35840 inodes and 4616/143360 blocks
    sending 'cache' (10984 KB)...
    writing 'cache'...
    OKAY [  0.891s]
    rebooting...
    finished. total time: 107.057s
    Press any key to exit...



    RESTOCK 2

    SCRIPTS
    • restock.bat - the main script: stock install, repair, repartition and factory reset
    • addons.bat - install TWRP custom recovery, mob30x-fix1, root/Magisk, ElementalX-N7-6.17 kernel
    • fstrim.bat - faster eMMC writes: dispatches TRIM command for all unused filesystem blocks
    • safe-unlock.bat - unlock without data loss
    • getlog.bat - diagnostics #1
    • relog.bat - diagnostics #2
    ADDONS
    These addons should be installed immediately after RESTOCK and before Android setup:
    1. TWRP deb/flo custom recovery (it must be flashed before the other addon options)
    2. MOB30X-FIX1 - improved Android 6.0.1 stock MOB30X installation, info: https://forum.xda-developers.com/showthread.php?t=4021757 In short, it adds WiFi 'Skip' setup option and removes old GApps to increase space on the system partition
    3. root/Magisk - https://github.com/topjohnwu/Magisk
    4. ElementalX-N7-6.17 custom kernel - I recommend to preset "doubletap2wake" and "battery life extender". For car use also preset "USB OTG + charge mode", info: https://forum.xda-developers.com/showthread.php?t=2389022
    ERRORS
    If you see errors, copy and report them. Run getlog.bat and include "getlog.log" in your post. If possible, also run relog.bat and attach "relog-xxxxxx.zip" to your post.

    FSTRIM
    For optimal eMMC performance run fstrim.bat from time to time.

    SAFE UNLOCK
    Unlock your device without data loss. MiFlash is described in the Unbricking Guide:
    https://forum.xda-developers.com/showpost.php?p=75360854&postcount=199
    Do not proceed unless you have read the unbricking guide and downloaded all components.



    OPTIONS

    Try mob30x-fix1 for improved Android 6.0.1 stock installation.

    Next consider CROSS : 1-click installation of secure, up-to-date Android 7-to-11 custom ROMs, including TWRP, repartition, root, etc. as easily as RESTOCK.



    NOTE

    If Android is stuck on boot logo, with TWRP flash k23m-persist-fix2.zip
    3
    Then from Windows install the ZIP file you provided? It's my first time using TWRP.

    • get Restock2
    • run addons.bat
    • "Flash TWRP?" --> YES and follow the instructions
    • when TWRP is up and running, MTP-transfer k23m-persist-fix2.zip to it
    • from TWRP install k23m-persist-fix2.zip
    • reboot

    🤞

    PM me if you have further questions.
    2
    Did not even realize this was new! Thanks for making such a wonderfull tool! Currently using it to flash flo, and it works great!
    Will install lineage after this tho :p

    Code:
    1. boot the Nexus in fastboot mode: when OFF press POWER + VOLUME DOWN
    2. when in the bootloader menu, connect it to your PC
    3. wait a few seconds, then...
    Press any key to continue . . .
    Verify...
    eMMC test...
    If it freezes here, the chip is faulty and needs replacement.
    eMMC OK
    Lock status...
    GPT...
    
    If error, copy and post it, include restock.log
    
    [url]http://bit.ly/2C35sLZ[/url]
    
    Note: Android flash takes 2 minutes, initial boot takes 7 minutes.
    Press any key to continue . . .
    sending 'bootloader' (3915 KB)...
    OKAY [  0.131s]
    writing 'bootloader'...
    OKAY [  1.581s]
    finished. total time: 1.719s
    rebooting into bootloader...
    OKAY [  0.009s]
    finished. total time: 0.014s
    archive does not contain 'boot.sig'
    archive does not contain 'recovery.sig'
    archive does not contain 'system.sig'
    --------------------------------------------
    Bootloader Version...: FLO-04.08
    Baseband Version.....: none
    Serial Number........: 07206d7c
    --------------------------------------------
    checking product...
    OKAY [  0.003s]
    checking version-bootloader...
    OKAY [  0.004s]
    sending 'boot' (7422 KB)...
    OKAY [  0.239s]
    writing 'boot'...
    OKAY [  0.397s]
    sending 'recovery' (8166 KB)...
    OKAY [  0.265s]
    writing 'recovery'...
    OKAY [  0.448s]
    erasing 'system'...
    OKAY [  0.743s]
    sending 'system' (843549 KB)...
    OKAY [ 26.422s]
    writing 'system'...
    OKAY [ 51.719s]
    erasing 'userdata'...
    OKAY [  9.570s]
    formatting 'userdata' partition...
    Creating filesystem with parameters:
        Size: 13342060544
        Block size: 4096
        Blocks per group: 32768
        Inodes per group: 8144
        Inode size: 256
        Journal blocks: 32768
        Label:
        Blocks: 3257339
        Block groups: 100
        Reserved block group size: 799
    Created filesystem with 11/814400 inodes and 91881/3257339 blocks
    sending 'userdata' (137198 KB)...
    writing 'userdata'...
    OKAY [ 12.298s]
    erasing 'cache'...
    OKAY [  0.051s]
    formatting 'cache' partition...
    Creating filesystem with parameters:
        Size: 587202560
        Block size: 4096
        Blocks per group: 32768
        Inodes per group: 7168
        Inode size: 256
        Journal blocks: 2240
        Label:
        Blocks: 143360
        Block groups: 5
        Reserved block group size: 39
    Created filesystem with 11/35840 inodes and 4616/143360 blocks
    sending 'cache' (10984 KB)...
    writing 'cache'...
    OKAY [  1.029s]
    rebooting...
    
    finished. total time: 103.239s
    Press any key to exit...
    2
    I had this mad idea to install Android 11 on my old and unused Nexus 7 but right after the first try with the repartitioning, my microusb stopped working (forever)... so my tab started sitting on the table totally empty with a messed partition.
    Hopefully a friend of mine had a Nexus 7 with broken screen so I just took its motherboard (avoiding the microusb soldering) and did all over again the procedure.
    Again I had problems with the connection but this time was the cable. Infact even if kept perfectly/unused I've found that not all my cables were good for this procedure so I just used a Samsung cable and everything worked.
    So, just giving an advice: before doing everything, just test your ports and cables :)
    Aaaand big thanks to all the devs who keep alive this great device, especially @k23m who guided me through all this procedure!
    2
    Well, it finally booted! But it took some attempts... Seems like there were problems in both mmcblk0p23 (cache) and mmcblk0p30 (data), so tried fastboot format cache and fastboot format userdata, but somehow it didnt work. What it finally make it boot was to format data and format cache from TWRP. What a nightmare!
    I'm afraid, it's not over. The eMMC flash memory IC is faulty and with no spare NAND blocks the issue will unpredictably show up at random partitions. If it works now, then do not flash any new ROM again, keep it read-only as much as possible and the Nexus will be still usable. Note that the lifespan of your 16GB eMMC is half of the more common 32GB model. It is possible to replace eMMC and even upgrade it to 64GB, more info is here.
    :good: