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

Search This thread

RagManX

Senior Member
Sep 11, 2010
79
15
Memphis
Restock saved my hide after I tried to manually repartition my 16GB flo so I could load Lineage 18.1 (flox). Got myself back from bricked to functioning 6.0.1 which I then upgraded via CROSS to Lineage. Thanks so much for making this bulletproof.
 
  • Like
Reactions: k23m

fredskis

Senior Member
Dec 14, 2008
159
3
33
Brisbane
This is an amazing tool! I don't usually post but this definitely deserves a big thanks! I had used some other script/tool in the past to repartition for Lineage 18 and I was unable to get to 19.1 with any of the existing tools as they all expect stock partitioning.

Sending a virtual beer! 🍺
 
  • Like
Reactions: k23m

osm0sis

Senior Recognized Developer / Contributor
Mar 14, 2012
15,312
34,665
Halifax
GT-i9250
Google Nexus 4
This tool has always worked great for me.

It's inappropriate to promote a competing tool in a developer's thread. Please remove your link and adjust your attitude.
 

k23m

Senior Member
Jan 3, 2016
1,001
592
"this will make ur tablet get stuck at boot"

No, "ur" diagnosis is incorrect. This does not make it stuck, yfm, there is simply an additional issue with "ur" messed up tablet, which is easily resolved with k23m-persist-fix2.zip - available next to "this shXt".
 
  • Like
Reactions: osm0sis

Ripper2018

Member
Jan 29, 2018
18
4
127.0.0.1
xazzi.co.uk
After messing up the Data partition I am trying to use this to restore my N7 flo but I just get stuck in a loop, when I press any key it just starts again, any ideas?
Thanks

Downloading USB drivers and the latest factory image. If not deleted, will not be downloaded again. --2023-01-11 07:30:21-- https://dl-ssl.google.com/android/repository/latest_usb_driver_windows.zip Resolving dl-ssl.google.com... 66.102.1.136, 66.102.1.190, 66.102.1.93, ... Connecting to dl-ssl.google.com|66.102.1.136|:443... connected. HTTP request sent, awaiting response... 416 Requested range not satisfiable The file is already fully retrieved; nothing to do. Archive: latest_usb_driver_windows.zip replace usb_driver/androidwinusb86.cat? [y]es, [n]o, [A]ll, [N]one, [r]ename: A inflating: usb_driver/androidwinusb86.cat extracting: usb_driver/source.properties inflating: usb_driver/android_winusb.inf inflating: usb_driver/amd64/winusbcoinstaller2.dll inflating: usb_driver/amd64/WUDFUpdate_01009.dll inflating: usb_driver/amd64/WdfCoInstaller01009.dll inflating: usb_driver/amd64/NOTICE.txt inflating: usb_driver/androidwinusba64.cat inflating: usb_driver/i386/winusbcoinstaller2.dll inflating: usb_driver/i386/WUDFUpdate_01009.dll inflating: usb_driver/i386/WdfCoInstaller01009.dll inflating: usb_driver/i386/NOTICE.txt --2023-01-11 07:30:24-- https://dl.google.com/dl/android/aosp/razor-mob30x-factory-52684dff.zip Resolving dl.google.com... 172.217.169.46 Connecting to dl.google.com|172.217.169.46|:443... connected. HTTP request sent, awaiting response... 416 Requested range not satisfiable The file is already fully retrieved; nothing to do. Archive: razor-mob30x-factory-52684dff.zip replace razor-mob30x/flash-all.bat? [y]es, [n]o, [A]ll, [N]one, [r]ename: A inflating: razor-mob30x/flash-all.bat inflating: razor-mob30x/flash-base.sh extracting: razor-mob30x/image-razor-mob30x.zip inflating: razor-mob30x/flash-all.sh inflating: razor-mob30x/bootloader-flo-flo-04.08.img Press any key to continue . . .
 

Ruggerxpunk

Senior Member
Jul 8, 2010
725
157
Unfortunately, this is the message I'm getting

Checking...
Verify...
eMMC test...
If it freezes here, the chip is faulty and needs replacement.

I know it's self explanatory, but how could something actually be wrong with the chip?
This device has basically sat on the dresser for the past 10 years.

EDIT****
I think it was because the Bootloader wasn't unlocked yet.
Once I unlocked it, RESTOCK worked like a charm.
 
Last edited:

mr_bartek

Member
Jun 24, 2021
25
5
@k23m

Hey man, I have a Nexus 7 2013 LTE which boots into Fastboot and Recovery but doesn't boot into OS (stuck on animation). I've tried flashing newest and oldest official images but it's still stuck. Below are my logs. Looks like a persist partition issue but I don't know how to resolve it.
 

Attachments

  • Restock2.zip
    24.7 KB · Views: 5
Last edited:

dkn92

New member
Jan 29, 2023
2
0
@k23m
I used retock2 zip and restock.bat to return my N7 flo to og partition. everything worked fine and it went to the final step to reboot. however it stayed on google screen for 20m+ so i tried a reboot and it did that again. I am able to get to fastboot mode as well as twrp however device wont boot into os at all.

attaching getlog and relog op. hope you can help me out.
 

Attachments

  • relog-16042406.zip
    36.9 KB · Views: 1
  • getlog-1282023.zip
    4.1 KB · Views: 1

Top Liked Posts

  • There are no posts matching your filters.
  • 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! 🥇🙂
  • 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
    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
    @k23m
    I feel guilty pushing users your way but, you know more about this than I do.🙃
    Logs are attached to quoted post.
    I am not that familiar with k23m's scripts or processes.
    Sorry, I do not have much time this week so, I will not be able to look into it until the weekend.
    I replied to your post in this thread in hope that you may get help faster than I could provide.

    Cheers. :cowboy:

    Thanks ipdev, I am in contact with the user via PM already.

    Cheers!
    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: