Firefly Open Source Community

   Login   |   Register   |
New_Topic
Print Previous Topic Next Topic

Making "snapshot"

403

Credits

10

Prestige

12

Contribution

intermediate

Rank: 3Rank: 3

Credits
403
Posted at 11/20/2014 09:18:10      1#

This is a brief document about this packing process.


1. Copy following files to your packing directory.

a. Control files
- ATTACHMENT/package-file (describes package content of update.img)
- ATTACHMENT/parameter (parameter for Ubuntu, contains eMMC partition info)
- ATTACHMENT/update-script (not used for Linux, for completion only)
- ATTACHMENT/recovery-script (not used for Linux, for completion only)
- ATTACHMENT/misc-zero.img (boot command, zero will lead to normal boot)

b. RKTools
- RKTools/linux/Linux_Upgrade_Tool_v1.2/rockdev/afptool (RK firmware packing tools)
- RKTools/linux/Linux_Upgrade_Tool_v1.2/rockdev/rkImageMaker (RK image maker)

c. Bootloader and your images
- SDK/RKTools/bootloader/uboot-emmc/RK3288Loader_uboot_V2.17.02.bin, renamed to RKLoader.bin
- Your linux-rootfs.img (ext4 filesystem image, for Linux root)
- Your linux-boot.img (See wiki doc http://wiki.t-firefly.com/index.php/Fir ... _kernel/en to create your own)
- Your resource.img (In SDK/kernel, after successful kernel compilation)

2. do the packing
First, cd to your packing directory. Then run the following commands:

./afptool -pack ./ update_tmp.img
./rkImageMaker -RK32 RKLoader.bin update_tmp.img update.img -os_type:androidos
rm -f update_tmp.img

Now, your update.img is ready to serve.

rk-pack-linux-control-files.zip (1.99 KB, Down times: 12)
Reply

Use props Report

403

Credits

10

Prestige

12

Contribution

intermediate

Rank: 3Rank: 3

Credits
403
Posted at 12/17/2014 09:39:29      2#

Hi tedd77. The op topic is making "snapshot", which involves packing all the image files into one big firmware file (update.img).




All my instructions are for those who would like to compile everything from scratch.




- Your linux-rootfs.img (ext4 filesystem image, for Linux root)

See wiki page:?
http://wiki.t-firefly.com/index.php/Fir ... ntu_rfs/en



- Your linux-boot.img and?resource.img?(In SDK/kernel, after successful kernel compilation)





http://wiki.t-firefly.com/index.php/Fir ... _kernel/en






Of course, you can extract those images from our released firmware file.?

Try to run?AndroidTool (
http://wiki.t-firefly.com/index.php/Fir ... lash_Image

),

switch to "Advanced Function" tab, and you'll find the "Unpack" button.

First browse the firmware file and then click "Unpack".





Reply

Use props Report

403

Credits

10

Prestige

12

Contribution

intermediate

Rank: 3Rank: 3

Credits
403
Posted at 12/20/2014 11:28:30      3#

There're many ways of copying out the linux root filesystem.

The easy way, is using rkflashkit or alike to backup the linuxroot partition


Another way,  is copying out the files in linuxroot, by mounting a SD card/usb disk etc:

a. Insert your sd card/usb disk.


b. Check the path (usually under /media/firefly), and cd into that.

    $ cd /media/firefly/your_sd_card


c. Check your rootfs's size:

    $ sudo du -hxs /
    1.8G /

d. Create the ext4fs image file:

    $ sudo dd if=/dev/zero of=new_ubuntu.img bs=1M count=2000

    $ sudo mkfs.ext4 -m0 new_ubuntu.img

NOTE: 1. bs * count should be greater than your size of root partition (add about 200~300M for extra space)

          2. If you're using the vfat filesystem in the sdcard, the vfat has a file limit of 4GiB bytes.


c. Mount the image file:

    $ sudo mkdir -p /mnt/new

    $ sudo mount -o loop new_ubuntu.img /mnt/new


d. Copy files:

    $ sudo cp -ax /  /mnt/new/


e. Umount the image file:

    $ sudo umount /mnt/new


Now your root files are copied into new_ubuntu.img, which can be flashed back later on.

And the first time you flashed the image back, you'd better run a resize2fs on the linuxroot partition:

    $ sudo resize2fs /dev/block/mtd/by-name/system

Reply

Use props Report

403

Credits

10

Prestige

12

Contribution

intermediate

Rank: 3Rank: 3

Credits
403
Posted at 12/20/2014 11:39:37      4#

For rkflashkit alike tools to work, the device must be set to "upgrade mode".?

?
http://wiki.t-firefly.com/index.php/Fir ... h_image/en

?has the detail.
Reply

Use props Report

403

Credits

10

Prestige

12

Contribution

intermediate

Rank: 3Rank: 3

Credits
403
Posted at 12/22/2014 11:07:02      5#

Hi tedd77, I've revised the instructions a bit. Please do a mkfs.ext4 before mounting it.


Afer the loop mount, please use a "df -h" command to see if the free space is big enough to hold your Linux rootfs files.


It's best to use rkflashkit to backup in your case.


Here's my output of rkflashkit:

-----------------------8<-------------------8<--------------------------

$ sudo rkflashkit part
Found devices:
0x2207:0x320a

============= 2014-12-22 11:03:55 ============


Loading partition information

PARMxFIRMWARE_VER:4.4.2
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: 0x62008000
#FDT_NAME: rk-kernel.dtb
#RECOVER_KEY: 1,1,0,20,0
CMDLINE:console=ttyFIQ0 androidboot.hardware=rk30board androidboot.console=ttyFIQ0 board.ap_has_alsa=0 root=/dev/block/mtd/by-name/linuxroot rw rootfstype=ext4 init=/sbin/init initrd=0x62000000,0x00800000 mtdparts=rk29xxnand:0x00002000@0x00002000(uboot),0x00002000@0x00004000(misc),0x00008000@0x00006000(resource),0x00008000@0x0000e000(kernel),0x00010000@0x00016000(boot),0x00010000@0x00026000(recovery),0x0001a000@0x00036000(backup),0x00040000@0x00050000(cache),0x00002000@0x00090000(kpanic),0x00180000@0x00092000(system),0x00002000@0x00212000(metadata),0x00200000@0x00214000(userdata),0x00620000@0x00414000(linuxroot),-@0x00a34000(user)

Partitions:
uboot        (0x00002000 @ 0x00002000)    4 MiB
misc         (0x00002000 @ 0x00004000)    4 MiB
resource     (0x00008000 @ 0x00006000)   16 MiB
kernel       (0x00008000 @ 0x0000e000)   16 MiB
boot         (0x00010000 @ 0x00016000)   32 MiB
recovery     (0x00010000 @ 0x00026000)   32 MiB
backup       (0x0001a000 @ 0x00036000)   52 MiB
cache        (0x00040000 @ 0x00050000)  128 MiB
kpanic       (0x00002000 @ 0x00090000)    4 MiB
system       (0x00180000 @ 0x00092000)  768 MiB
metadata     (0x00002000 @ 0x00212000)    4 MiB
userdata     (0x00200000 @ 0x00214000) 1024 MiB
linuxroot    (0x00620000 @ 0x00414000) 3136 MiB

-----------------------8<-------------------8<--------------------------


You can see the linuxroot partition above, right ? Then you can backup it by issueing command:


    $ sudo rkflashkit backup @linuxroot  mylinuxroot.img

Reply

Use props Report

403

Credits

10

Prestige

12

Contribution

intermediate

Rank: 3Rank: 3

Credits
403
Posted at 12/23/2014 09:41:26      6#

Woud you please post the AndroidTool snapshot with failure message?




I personally like to flash individual image with rkflashkit:




sudo rkflashkit flash @linuxroot ?your_linux_root.img




or launch its friendly GUI:

sudo rkflashkit

select the partition and image file and flash.


Reply

Use props Report

403

Credits

10

Prestige

12

Contribution

intermediate

Rank: 3Rank: 3

Credits
403
Posted at 12/24/2014 14:33:13      7#
Ahha, you're using the pure Ubuntu firmware. That's the reason you don't have the system partitiion etc.

The correctly flash command is (fixed in my previous post):

sudo rkflashkit flash @linuxroot your_linux_root.img

and you can get the usage by:

rkflashkit help


Reply

Use props Report

403

Credits

10

Prestige

12

Contribution

intermediate

Rank: 3Rank: 3

Credits
403
Posted at 12/26/2014 16:02:40      8#




Sorry, tedd77, I though it just worked, but it didn't.

Especially I've been using rkflashkit and never met your problem.

I did not notice your linuxroot partition is special, in that the size is ommited ('-'), which means to use rest of the storage.

(I spent most of my time in dual firmware.)




But rkflashkit already has the solution, you can specify "SIZE@OFFSET(PART)" instead of "@PART", like:

sudo rkflashkit flash 0x202000@0x0002e000(linuxroot) linux-rootfs-ubuntu-14.04.img reboot




The size and offset are both using units of sector (512 bytes).

Since it is error-proned, I write a script named "flash-linux-root" to do this.

Please save the attachment file "flash-linux-root.txt" as "flash-linux-root.sh", and do a chmod before use:

chmod 755 flash-linux-root.sh




Then run it:

./flash-linux-root.sh /path/to/your/linux-rootfs-ubuntu-14.04.img 0x0002e000




This is my output of running this:

$ ~/flash-linux-root.sh linux-rootfs-ubuntu-14.04.img 0x0002e000
About to run:
sudo rkflashkit flash 0x202000@0x0002e000(linuxroot) linux-rootfs-ubuntu-14.04.img reboot
Press enter to continue...
Found devices:
0x2207:0x320a
[('202000', '0x0002e000')]
============= 2014-12-26 15:49:17 ============

Writing file linux-rootfs-ubuntu-14.04.img to partition 0x00202000@0x0002E000
writing flash memory at offset 0x0002e000
.....




Hope it finally helps. Thanks.





Reply

Use props Report

403

Credits

10

Prestige

12

Contribution

intermediate

Rank: 3Rank: 3

Credits
403
Posted at 12/29/2014 10:18:24      9#

Annoying forum attachment which won't accept *.txt, *.sh, except .zip file.




Please uncompress the zip file first.
Reply

Use props Report

You need to log in before you can reply Login | Register

This forum Credits Rules

Quick Reply Back to top Back to list