Jump to content


Photo

Hudl backup script (under review & re-write)

- - - - -

  • Please log in to reply
20 replies to this topic

#1
glossywhite

glossywhite

    Hardcore

  • Members
  • PipPipPipPipPipPip
  • 2,017 posts

Under review - needs heavy work.


Edited by glossywhite, 29 October 2013 - 06:49 PM.

  • 1

#2
CaptainMidnight

CaptainMidnight

    Diehard

  • Members
  • PipPipPipPip
  • 358 posts
  • Gender:Male
  • Location:Northeast
  • Devices:hudl1/2, HTC One S, M8 Box

Hi just found this, looks ideal for a way to fully backup/image my hudl now that it's been rooted/tweaked/configured just how I want it.

 

Just a couple of questions please: -

 

1) I presume nothing is not backed up (except additional SD card if fitted)?

2) I also presume to reflash a backup back, I don't have to blank the whole hudl first - as this wasn't required when performing Paul's root procedure?

 

Again thanks for the script.


  • 0

#3
CaptainMidnight

CaptainMidnight

    Diehard

  • Members
  • PipPipPipPip
  • 358 posts
  • Gender:Male
  • Location:Northeast
  • Devices:hudl1/2, HTC One S, M8 Box

Out of interest in my setup had to increase the 'pause 10' to something bigger (I just doubled it to 20) as the script rebooted the hudl but couldn't recognise it connected to the computer in time before trying to start reading from it.


Edited by CaptainMidnight, 26 October 2013 - 12:30 PM.

  • 1

#4
glossywhite

glossywhite

    Hardcore

  • Members
  • PipPipPipPipPipPip
  • 2,017 posts

Out of interest in my setup had to increase the 'pause 10' to something bigger (I just doubled it to 20) as the script rebooted the hudl but couldn't recognise it connected to the computer in time before trying to start reading from it.

 

Brill - that's a good idea :)
 

Hi just found this, looks ideal for a way to fully backup/image my hudl now that it's been rooted/tweaked/configured just how I want it.

 

Just a couple of questions please: -

 

1) I presume nothing is not backed up (except additional SD card if fitted)?

2) I also presume to reflash a backup back, I don't have to blank the whole hudl first - as this wasn't required when performing Paul's root procedure?

 

Again thanks for the script.

 

I made the script back up ALL partitions. I have no idea about flashing them back yet - I've not tried it as yet, but I can safely tell you that having backed up my hudl with this, saved my device when I had flashed a generic RockChip CWM into /recovery and it didn't work; I just had to flash the backed-up, original hudl /recovery image and the device was back to normal.

My rationale is that it is better to have backed-up images than not to have them, even if they cannot be used (yet). If I get around to restoring the images, thus proving them to work properly, I'll publish the script here and document it.

Thank you :)


Edited by glossywhite, 26 October 2013 - 07:18 PM.

  • 0

#5
CaptainMidnight

CaptainMidnight

    Diehard

  • Members
  • PipPipPipPip
  • 358 posts
  • Gender:Male
  • Location:Northeast
  • Devices:hudl1/2, HTC One S, M8 Box

How about this - comparing your backup script with Paul's short script for reading out and then writing back the original/modded system.img I notice in your script above have you not got the 'offset' and 'sizes' the wrong way round? From the command line help of rkflashtool both read and write modes require 'offset' then 'size'.

 

We know Paul's script correctly writes the modified system.img file.....not sure how you didn't end up with a semi dead hudl though based on this?

 

(presume you are both using the same version of rkflashtool) 


  • 0

#6
glossywhite

glossywhite

    Hardcore

  • Members
  • PipPipPipPipPipPip
  • 2,017 posts

How about this - comparing your backup script with Paul's short script for reading out and then writing back the original/modded system.img I notice in your script above have you not got the 'offset' and 'sizes' the wrong way round? From the command line help of rkflashtool both read and write modes require 'offset' then 'size'.

 

We know Paul's script correctly writes the modified system.img file.....not sure how you didn't end up with a semi dead hudl though based on this?

 

(presume you are both using the same version of rkflashtool) 

Oops! 

uhm... "lol"?  :wub:

 

Will review and re-release, later or mid-week. Thanks for noticing - the syntax was totally wrong, yup!


Edited by glossywhite, 29 October 2013 - 06:12 PM.

  • 0

#7
CaptainMidnight

CaptainMidnight

    Diehard

  • Members
  • PipPipPipPip
  • 358 posts
  • Gender:Male
  • Location:Northeast
  • Devices:hudl1/2, HTC One S, M8 Box

Original backup script offset/size details corrected and PM'd to you - thanks for the initial draft, helped me leap frog some learning stepping stones.


  • 0

#8
CaptainMidnight

CaptainMidnight

    Diehard

  • Members
  • PipPipPipPip
  • 358 posts
  • Gender:Male
  • Location:Northeast
  • Devices:hudl1/2, HTC One S, M8 Box
Plan on updating and providing all the detail / working scripts etc tomorrow afternoon. Scripts have been adjusted and proved working by myself and recent upgrade / downgrade ROM testing. Full credit to glossywhite for the initial script.

  • 0

#9
paultr2

paultr2

    Newbie

  • Members
  • Pip
  • 14 posts
  • Devices:hudl
I know this is a bit cheeky because I can guess how much work it is to work out how to take a backup let alone document it but if you have the time would you make a moron proof walkthrough of the backup process ? (Assuming basic PC skills) Also is it possible to do this with free apps or do you need the paid for version of any of them?
Cheers Paul

  • 0

#10
CaptainMidnight

CaptainMidnight

    Diehard

  • Members
  • PipPipPipPip
  • 358 posts
  • Gender:Male
  • Location:Northeast
  • Devices:hudl1/2, HTC One S, M8 Box

Standard disclaimer:-

:excl: This information is provided as a best effort forum post - you are ultimately solely responsible for your own actions, if you don't understand what you are doing and haven't read any of the other forum posts to gain a background knowledge about modding your hudl and/or don't have enough knowledge of a linux environment - you continue at your own risk...... :excl:

Before starting this procedure, please ensure the following conditions are setup: -

  • You are using a 64bit linux distro (unless you replace the 64bit version of rkflashtool with the 32bit version which is listed in SifJar's thread "[TOOLS] Useful tools for tinkerers") - may not be available yet!
  • On your hudl ensure that in settings>Developer Options> USB debugging is ticked.
  • Download to your linux desktop the following file hudl_scripts.zip
  • Extract the contents of this zip file to a folder on your desktop i.e. hudl
  • Ensure you have a minimum of 2GB disk space available.

Creating a hudl backup:

1. Open a terminal window in you linux distro (Accessories - Terminal), if you're using the unity desktop do the equivalent.
This will open a blank terminal window on your desktop, it will probably be started in your user account area, you can check this by typing: ls

2. Change the terminal directory to the huld folder on your desktop: cd Desktop/hudl

3. Ensure you can see the extracted files: -

ls -l
................. adb
................. hudl_backup.sh
................. hudl_restore.sh
................. rkflashtool-linux

4. Ensure the backup/restore scripts hudl_backup.sh and hudl_restore.sh are marked as executable:-
chmod +x hudl_*.sh

5. Connect your hudl via the usb cable to your computer and wait a couple of minutes to give your computer a chance to detect it - in my version of Ubuntu, nothing happens i.e. no display message or auto-play type dialog box, it just sees it.

6. To create a hudl backup run the following: sudo ./hudl_backup.sh
(this command may now ask for your password - depends on distro version)

7. Follow the on screen prompts to create a backup: (basically press "any key" and wait.............)

If all is working ok, you'll see a rolling address read line and ultimately you'll end up with the following files in your directory:-

hudl_parameters.img
hudl_misc.img
hudl_kernel.img
hudl_boot.img
hudl_recovery.img
hudl_backup.img
hudl_cache.img
hudl_kpanic.img
hudl_system.img
hudl_factory.img
hudl_image_sha1_sums.txt

In the hudl_backup.sh script, the 'offset' and 'size' values that rkflashtool-linux uses have been obtained from the hudl_paramters.img file (they are displayed in reverse). These are crucial to ensuring the correct partition locations are used. The last file generated is a text file containing he sha1 hash values for the other files.

The rest of the data partition (i.e. all the other space, including your downloaded apps and stuff) isn't backed-up via this script, hense use something like "Titanium Backup Pro" to backup anything you want to keep and save it to an EXTERNAL SD CARD, before factory resetting your hudl. (You may want to factory reset your hudl if you flashed back a previous recovery or a new stock ROM etc). You could extend the script and include this user data area, but that would eat up another 12/13GB :(

 

hudl_backup.sh script: -

#!/bin/bash
chmod +x ./rkflashtool-linux

echo
echo
echo
echo

read -p "About to BACKUP Your Hudl - PRESS ANY KEY to CONTINUE or CTRL-C to ABORT..."
./adb reboot bootloader
sleep 20

./rkflashtool-linux p > hudl_parameters.img
./rkflashtool-linux r 0x00002000 0x00002000 > hudl_misc.img
./rkflashtool-linux r 0x00004000 0x00004000 > hudl_kernel.img
./rkflashtool-linux r 0x00008000 0x00008000 > hudl_boot.img
./rkflashtool-linux r 0x00010000 0x00010000 > hudl_recovery.img
./rkflashtool-linux r 0x00020000 0x00020000 > hudl_backup.img
./rkflashtool-linux r 0x00040000 0x00100000 > hudl_cache.img
./rkflashtool-linux r 0x00140000 0x00002000 > hudl_kpanic.img
./rkflashtool-linux r 0x00142000 0x00200000 > hudl_system.img
./rkflashtool-linux r 0x00342000 0x00020000 > hudl_factory.img

date > hudl_image_sha1_sums.txt

sha1sum hudl_*.img >> hudl_image_sha1_sums.txt

./rkflashtool-linux b

echo =================================================================================================
echo ===    HUDL now backed up and REBOOTING. If reboot fails, hold down power button.             ===
echo ===                                                                                           ===
echo ===       SHA1 CHECKSUMS OF ALL IMAGES HAVE BEEN SAVED TO "hudl_image_sha1_sums.txt"          ===
echo =================================================================================================
echo
echo
echo             Originally created by Glossywhite - updated by CaptainMidnight
echo
echo

Restoring a hudl backup:

 

1. [Optional] You could factory reset your hudl before proceeding (maybe you are changing the build or ROM version and it's probably preferable to wipe the old settings etc - please remeber unless you want to loose it - backup your personal stuff, use something like 'Titanium Backup Pro' or whatever you prefer and save it to an EXTERNAL SD CARD. In the hudl go to Settings > Backup & Reset > Factory data reset

 

2. With the hudl rebooted, once again connect your hudl via the usb cable to your computer and wait a couple of minutes to give your computer a chance to detect it.

3. Open a terminal window in your linux distro (Accessories - Terminal), if you're using the unity desktop do the equivalent.
This will open a blank terminal window on your desktop, it will probably be started in your user account area, you can check this by typing: ls

4. Change the terminal directory to the huld folder on your desktop: cd Desktop/hudl

 

5. To restore the hudl using your previous backup images run the following: sudo ./hudl_restore.sh
(this command may now ask for your password - depends on distro version)

 

6. Once completed the hudl should reboot and your ready to configure it as you like. :)

 

hudl_restore.sh script: -

#!/bin/bash
chmod +x ./rkflashtool-linux

echo
echo
echo
echo

read -p "About to RESTORE Your Hudl - PRESS ANY KEY to CONTINUE or CTRL-C to ABORT..."

./adb reboot bootloader
sleep 20

./rkflashtool-linux w 0x00002000 0x00002000 < hudl_misc.img
./rkflashtool-linux w 0x00004000 0x00004000 < hudl_kernel.img
./rkflashtool-linux w 0x00008000 0x00008000 < hudl_boot.img
./rkflashtool-linux w 0x00010000 0x00010000 < hudl_recovery.img
./rkflashtool-linux w 0x00020000 0x00020000 < hudl_backup.img
./rkflashtool-linux w 0x00040000 0x00100000 < hudl_cache.img
./rkflashtool-linux w 0x00140000 0x00002000 < hudl_kpanic.img
./rkflashtool-linux w 0x00142000 0x00200000 < hudl_system.img
./rkflashtool-linux w 0x00342000 0x00020000 < hudl_factory.img

./rkflashtool-linux b

echo =========================================================================================
echo ===     HUDL now restored and REBOOTING. If reboot fails, hold down power button.     ===
echo =========================================================================================
echo
echo
echo             Originally created by Glossywhite - updated by CaptainMidnight
echo
echo

This backup and restore process detailed above has flaws just like anything else - it's not meant to completely backup/restore EVERYTHING on you hudl :huh: - it's presented here purely as a way to backup/restore your current build ROM. That means your downloaded data and stuff is as ever your responsibility to backup/restore.

 

Using the above method enabled me play about with different stock ROM images etc and is purely something I have found very useful - it's not necessarily the easiest way to achieve a backup if your flashed CWM recovery i.e. nandroid backups etc.

 

It's listed here in case you find it useful or learn something by listing it :D I certainly gained a better understanding of android. :ninja:

 

Sorry it took a little longer than anticipated to post, enjoy.

 

 

14/11/2013 Update:

 

If you also wanted to backup / restore  the remaining userdata partition you would need to add this line to the script.

./rkflashtool-linux r 0x00362000 0x01C9E000 > hudl_userdata.img

Remebering to change the mode/direction for a restore.

./rkflashtool-linux w 0x00362000 0x01C9E000 < hudl_userdata.img

Edited by CaptainMidnight, 14 November 2013 - 10:12 AM.

  • 3

#11
greyrider

greyrider

    Regular

  • Members
  • PipPip
  • 78 posts
  • Gender:Male
  • Location:South Wales - the bit next to England
  • Devices:Hudl Ainol Fire Archos 101

Amazing work, thank you!

 

Now....how are you at cooking Roms? :)


  • 0

.

.

"Whatever...."

.

.


#12
paultr2

paultr2

    Newbie

  • Members
  • Pip
  • 14 posts
  • Devices:hudl
perfect - cheers :)

  • 0

#13
CaptainMidnight

CaptainMidnight

    Diehard

  • Members
  • PipPipPipPip
  • 358 posts
  • Gender:Male
  • Location:Northeast
  • Devices:hudl1/2, HTC One S, M8 Box
Thanks for the responses, as I said this was a joint effort building on glossywhite's initial backup script.

Cooking my own ROM - maybe someday, if I get enough tinkering and dev time, who knows....

  • 0

#14
Mr Lawrence

Mr Lawrence

    Newbie

  • Members
  • Pip
  • 5 posts
  • Gender:Male
  • Devices:Hudl Nook HD+ Nexus S

Great work the two of you :D  i`ve used the script a couple of times now and works a treat i`ve backed up the works hudl`s which dont have "usb debuging" i have to keep them locked down so no "Developer options" here!! I put them into bootloader mode with vol+ and reset pin whilst connected via usb ran the script it throws up an error no device (expected) just leave it about 30 seconds and it carries on backing up :P .I then used that backup to reflash my own rooted/tweaked hudl and it is now back to standard :blink: I will re-root and set it backup how I want again.I do have a question what do i have to set the parameters to so that i can back up everything including user data apps etc?? I know this will not include the external sd card and that it will be approx 16gb so may take a while but i dont mind the wait.

Thank you again for the time and effort that you have put into this

 


  • 0

#15
CaptainMidnight

CaptainMidnight

    Diehard

  • Members
  • PipPipPipPip
  • 358 posts
  • Gender:Male
  • Location:Northeast
  • Devices:hudl1/2, HTC One S, M8 Box

Ok, well I wondered how long it would take before someone asked that ......... :D

 

Well here goes: -

 

Before we get to the answer, maybe it's worth building up to it. As can be seen in the scripts above, rkflashtools-linux is passed 2x parameters per partition. These values are obtained from the first partition or should I say parameter block which is backed-up i.e. hudl_parameters.img - in this file they are listed in 'reverse'  :rolleyes:

 

hudl_parameters.img is viewable in a text editor and here it is: -

FIRMWARE_VER:4.1.1
MACHINE_MODEL:rk30sdk
MACHINE_ID:007
MANUFACTURER:RK30SDK
MAGIC: 0x5041524B
ATAG: 0x60000800
MACHINE: 3066
CHECK_MASK: 0x80
PWR_HLD: 0,0,A,0,1
KERNEL_IMG: 0x60408000
#RECOVER_KEY: 1,1,0,20,0
CMDLINE:console=ttyFIQ0 androidboot.console=ttyFIQ0 board.ap_has_alsa=0 init=/init initrd=0x62000000,0x00800000 mtdparts=rk29xxnand:0x00002000@0x00002000(misc),0x00004000@0x00004000(kernel),0x00008000@0x00008000(boot),0x00010000@0x00010000(recovery),0x00020000@0x00020000(backup),0x00100000@0x00040000(cache),0x00002000@0x00140000(kpanic),0x00200000@0x00142000(system),0x00020000@0x00342000(factory),-@0x00362000(userdata) 

The numbers pre-seeding each partition are the partitions 'size' and 'offset' in reverse order. Also 'offset' and 'size' are in units (blocks) of 512 bytes.

 

So we know the 'offset' for userdata will be 0x00362000, but what about the size? (it's '-' or everything else!)

 

Well it should be 16GB converted to 512 byte units - sum(of all previous partition 512 byte block units)

 

i.e. 17179869184 / 512 = 33554432 or in hex  400000000 / 200 = 2000000 (total number of blocks)

 

2000000 - ( 2000 + 4000 + 8000 + 10000 + 20000 + 100000 + 2000 + 200000 + 20000 ) = 1CA0000

 

So...............

 

You would(should) need to add this line to the bottom of the rklashtool-linux section: -

./rkflashtool-linux r 0x00362000 0x01CA0000 > hudl_userdata.img

My linux partition is low on space, so I haven't been able to verify the above - I'd be interested to hear from anyone who does do this - fairly confident it's right but a practical confirmation would be good.

 

Oh yes, on the other comment of the error and delay, if you are going to place the hudl in bootloader / flash mode by yourself, just delete following lines (as you are probably already aware): -

./adb reboot bootloader
sleep 20

As these just place the hudl in bootloader for you, BUT are designed to wait enough time for it to be recognised again by linux before carrying on.  :)

 

(initial response detialing the above went a bit iffy on the maths  :o)


Edited by CaptainMidnight, 12 November 2013 - 09:38 PM.

  • 0

#16
Mr Lawrence

Mr Lawrence

    Newbie

  • Members
  • Pip
  • 5 posts
  • Gender:Male
  • Devices:Hudl Nook HD+ Nexus S

Thanks for the reply my maths is poor at best! Well after i reinstalled ubuntu (my hard drive chose today to die) :( i added the line to the script and ran it the user data partion was backed up and shows as 15.4gb this took about 35 minutes it stopped at the offset shown in the screenshot (hopefully)but the script carried on for approx another 10 minutes before rebooting.It didnt throw up any errors either.Here are the screen shots i took if they are any help.Attached File  Screenshot from 2013-11-13 00:04:16.png   650.34KB   7 downloadsAttached File  Screenshot from 2013-11-12 23:34:03.png   429.04KB   7 downloads

Thanks again for all you work this is a bit of a vertical learning curve for me!But enjoying it :P


  • 1

#17
CaptainMidnight

CaptainMidnight

    Diehard

  • Members
  • PipPipPipPip
  • 358 posts
  • Gender:Male
  • Location:Northeast
  • Devices:hudl1/2, HTC One S, M8 Box
Looks promising - the ultimate test would be a restore though. I've got another machine with more free disk space which I'll setup and give it a go on, but that won't be until tonight.

We are all learning - just different things!

  • 0

#18
CaptainMidnight

CaptainMidnight

    Diehard

  • Members
  • PipPipPipPip
  • 358 posts
  • Gender:Male
  • Location:Northeast
  • Devices:hudl1/2, HTC One S, M8 Box
Hmm. Looks like we might be 0x2000 out as I would have thought it would have ended under the 0x02000000 number (after a closer look in the morning).

That would be the logical answer as looking back forgot the 'misc' partition started at 0x2000 doh!

Edited by CaptainMidnight, 13 November 2013 - 07:22 AM.

  • 0

#19
TurboPask

TurboPask

    Newbie

  • Members
  • Pip
  • 23 posts

Hi,

from an adb shell, type "df" command to know size of each partition of your device.

 

This article can be usefull:

 

http://techblogon.co...layout-details/


Edited by TurboPask, 13 November 2013 - 09:11 AM.

  • 0

#20
CaptainMidnight

CaptainMidnight

    Diehard

  • Members
  • PipPipPipPip
  • 358 posts
  • Gender:Male
  • Location:Northeast
  • Devices:hudl1/2, HTC One S, M8 Box

Finally, I've updated post #10 with the correct userdata backup value i.e. 0x01C9E000 NOT 0x01CA0000 which was 0x02000 out :blush:

 

TurboPask - that's a good article, but it didn't help when I'd forgotton to take into account the first partition after the parameters.img starts at 0x00002000 and so I haven't added that previous space into the equation and we're dealing with 512 byte block units.


Edited by CaptainMidnight, 14 November 2013 - 10:30 AM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users