Android Image content using DragonFace (and ImgRepacker, a bit)

19 16159
ChrisP  
Edited by ChrisP at Sat Nov 1, 2014 12:54

I took some time to identify the way DragonFace is exporting various data from an android image and to figure how it can be used to go deeper in android image tweaking.
The main data source for partition structure is the file sysconfig.lhs exported in temp file during image loading by DragonFace.
File size found in sysconfig.lhs are number of blocks of 512 bytes.

I tried to see how to change the default kernel but for now I do not get yet how to manage the u-boot and just get a sdcard freezing during boot (just after the A20 image).
This is a summary of the various partition present in a 4.2 image, what is exported in temp folder, for some of them where the files are exported in DragonFace subfolders, and what proved or potential action can be done to tweak the Android image.

It could be usefull for some people I hope. Please feel free to comment/extend/correct anything

The Android 4.2 structure is then this one:
  
id
  

dev/
block/*


Size


Name


Target fs mount point


file


Type


Description


temp File
exported by Dragon
Face


Folder exported by DragonFace


Modification possible in DragonFace




mbr


8MiB












mbr.lhs






0


nanda


16MiB


bootloader





bootloader
.fex


vfat


Files to assist the bootloader. Think battery status images etc. also  u-boot.bin, script.bin and .ini lives here


bootloader
.lhs


DF/fsop/bootfs ??? File DF/fsop/bootfs.ini let think that  but report a size of 128MiB


To be defined


1


nandb


16MiB


env





env.fex


raw


Enviroment to assist u-boot.








To be defined. Good candidate to redefine MAC address once proper edition method will be identified


2


nandc


32MiB


boot





boot.fex


raw


Holds the kernel (and its ramdisk) in ANDROID mkbootimg form


bootimg
.lhs


DF/cpfop/bootfs + ramdisk in DF/cpfop/bootfs/skel


Kernel can be pushed in DragonFace/cpfop/bootfs but due to apparent  privilege issue, additionnal actions are needed:
  1 - Duplicate DragonFace/cpfop/bootfs to DragonFace/cpfop/rootfs
  2 - execute DragonFace/cpfop/pack_boot.bat
  3 - rename DragonFace/cpfop/bootfsnew.fex to DragonFace/cpfop/bootfs/boot.fex


3


nandd


0.5GiB


system


/system


system.fex


ext4


Android's /system partition


system.lhs + working file .tmp


DF/fsop/system


Simple file copy in DragonFace/fsop/system


4


nande


1GiB


data


/data





ext4


Android /data partition








To be defined



5


nandf


16MiB


misc








raw


Partition used to pass data amongst various stages of the boot chain  (e.g. boot into recovery mode, fastboot etc)








To be defined


6


nandg


32MiB


recovery





recovery
.fex


raw


Android's recovery partition


recovery
.lhs


DF/cpfop/recovery + ramdisk in DF/cpfop/recovery/skel


Kernel can be pushed in DragonFace/cpfop/recoveryfs


7


nandh


32MiB


cache


/cache





ext4


Mounted as /cache and appear to contain backup information








To be defined


8


nandi


16MiB


private


/mnt/private





vfat


Mounted as /mnt/private








To be defined


9


nandj


256MiB


databk








raw


data image Backup








To be defined


10


nandk


768 MiB


sysrecovery





sysrecovery
.fex


vfat ??


system image backup, disactivated in sysconfig.lhs








To be defined


11


nandl


N/A


UDISK


/mnt/sdcard
+ /mnt/secure
/asec


diskfs.fex


vfat


Mounted by vold as /mnt/sdcard and /mnt/secure/asec








Apparently  no source file are needed.
Is created on first image boot to take all remaining room available on sdcard. Investigation could be nice to check if this partition or datablk could be a way to offer default configuration for applications, like xbmc



The Android 4.4 structure is a little bit different:
id
dev/
block/*
Size
Name
Target fs mount  point
file
Type
Description
temp File exported by DragonFace
Folder exported  by DragonFace
Modification  possible in DragonFace
mbr
8MiB
mbr.lhs
0
nanda
16MiB
bootloader
bootloader
.fex
vfat
Files to assist the bootloader. Think  battery status images etc. also u-boot.bin, script.bin and .ini lives here
bootloader
.lhs
DF/fsop/bootfs  ??? File DF/fsop/bootfs.ini let think that but report a size of  128MiB
To  be defined
1
nandb
16MiB
env
env.fex
raw
Enviroment to assist u-boot.
To be defined. Good candidate to redefine MAC address once proper edition method will be identified
2
nandc
16MiB
boot
boot.fex
raw
Holds the kernel (and its ramdisk) in  ANDROID mkbootimg form
bootimg.lhs
DF/cpfop/bootfs  + ramdisk in DF/cpfop/bootfs/skel
Kernel  can be pushed in DragonFace/cpfop/bootfs but due to apparent privilege issue,  additionnal actions are needed:
    1 - Duplicate DragonFace/cpfop/bootfs to DragonFace/cpfop/rootfs
    2 - execute DragonFace/cpfop/pack_boot.bat
    3 - rename DragonFace/cpfop/bootfsnew.fex to  DragonFace/cpfop/bootfs/boot.fex
3
nandd
736MiB
system
/system
system.fex
ext4
Android's /system partition
system.lhs  + working file .tmp
DF/fsop/system
Simple  file copy in DragonFace/fsop/system
4
nande
640GiB
data
/data
ext4
Android /data partition
To  be defined
5
nandf
16MiB
misc
raw
Partition used to pass data amongst  various stages of the boot chain (e.g. boot into recovery mode, fastboot etc)
To  be defined
6
nandg
32MiB
recovery
recovery
.fex
raw
Android's recovery partition
recovery
.lhs
DF/cpfop/recovery  + ramdisk in DF/cpfop/recovery/skel
Kernel  can be pushed in DragonFace/cpfop/recoveryfs
7
nandh
640GiB
cache
/cache
ext4
Mounted as /cache and appear to contain  backup information
To  be defined
8
nandi
256MiB
databk
raw
data  image Backup
To  be defined
9
nandj
16MiB
private
/mnt/private
vfat
Mounted as /mnt/private
To  be defined
10
nandk
N/A
UDISK
/mnt/sdcard  + /mnt/secure
/asec
diskfs.fex
vfat
Mounted by vold as /mnt/sdcard and
/mnt/secure/asec
Apparently  no source file are needed.
Is created on first image boot to take all remaining room available on sdcard. Investigation could be nice to check if this partition or datablk could be a way to offer default configuration for applications, like xbmc

   






ChrisP  
Edited by ChrisP at Sat Nov 1, 2014 12:26

For reference, I made a file mapping between what is accessible from DragonFace and what is available from imgRepacker from Redscorpio ( http://forum.xda-developers.com/showthread.php?t=1753473 )

RedScorpio  ImgRepacker dump filesDragonface  temp folder files
SizeFileNameContentNatureSizeFilename
Animated boot logo (expanded)<DIR>bootanimation
<DIR>_iso
470548852
system.fex/System ext4 sparse filesystem
470548852
system.lhs
/System temporary fileext4 sparse filesystem
470548852
~ex3721.tmp
11102208
recovery.fexRecovery
11102208
recovery.lhs
10584064
boot.fexKernel + Ramdisk (boot Android)
10584064
bootimg.lhs
5018624
bootloader.fexFiles to assist the bootloader.  Think battery status images etc. also u-boot.bin, script.bin and .ini lives  here
5018624
bootloader.lhs
Animated boot logo (compressed)
3686400
logo.lhs
655360
u-boot.fexUboot (Boot1)
655360
boot1.lhs
177288
bootlogo.lhs
132096
usbtool.fexdll file
131072
env.fexEnviroment to assist u-boot.
81920
cardtool.fexdll file
65536
sunxi_mbr.fexmbr
65536
mbr.lhs
60676
sys_config.fexA20 PAD file (equivalent build.prop ??)
60676
sysconfig1.lhs
24576
boot0_nand.fexInitial bootloader for Nand (Boot0)
24576
boot0.lhs
24576
boot0_sdcard.fexInitial bootloader for sdcard (Boot0)
24576
cardboot0.lhs
16384
dlinfo.fexSD Partition table ?
16384
dlinfo.lhs
7552
fes1.fex(ram test, exe)
7552
fes1.lhs
3561
sys_partition.fexPhoenixCard Partition schema
3561
sysconfig.lhs
2585
image.cfgFex filelist
1770
cardscript.fexCard Script config file
512
diskfs.fexEmpty diskfs (zeroed)
512
split_xxxx.fexguid list ?
512
DF\fsop\bootfs\magic.bin
4
Vboot.fexVerification file, regenerated  during rebuild
4
Vbootloader.fexVerification file, regenerated  during rebuild
4
Venv.fexVerification file, regenerated  during rebuild
4
Vrecovery.fexVerification file, regenerated  during rebuild
4
Vsystem.fexVerification file, regenerated  during rebuild

afcajax  
Keep up the good work! Based on this thread: http://zeustoolkit.moonfruit.com/building-livesuit-img/4583660804, i found that CPFOP\bootfs\skel\init.sun7i.rc may also be an interesing file

mattrix  
I have tried modifying CPFOP\bootfs\skel\init.sun7i.rc but the changes are ignored.
I think DragonFace is just showing this \skel\ folder but doesn't actually re-pack it?

Did you find this?

mattrix  
This is interesting:
http://forum.xda-developers.com/showthread.php?t=2318587

"u can use the simg2img binary to make the system.fex file to a mountable image by using [simg2img <system.fex system.img>]
now mount it...make a directory called system, type these commands in the shell , [sudo mount -o loop system.img system ] this will mount the system.img inside the folder. now to make life simpler type [sudo nautilus] (on ubuntu) n start the file manager with super user access. n navigate to the system folder. now u can change files,delete unwanted stuff etc. after ur done with it pack the system directory using the make_ext4fs binary,type [ make_ext4fs -s -l 500M -a system {location of the system directory} <filename.fex> ] u will get ur system.fex file which u can pack in a livesuit image and flash"

ChrisP  
I had some issue with the bootfs repackaging. I had to launch the pack_boot.bat script in CPFOP after manually copying bootfs to rootfs folder. Try to open a cmd, go to DF/CPFOP folder and run manualy the pack_boot.bat script. Remove the first command of the script (echo off) to check what it's doing.

Regarding the sim2img, it's exactly equivalent to the way DragonFace export system.lhs to fsop/system and back to system.lhs. I tried it when I explored the imgrepacker way of unpacking the img file, and it works well too.

mattrix  
After you used sim2img, what did you use in Windows to then extract the ext4 image?
I couldn't find any command line programs to do it (automate)

ChrisP  
On Windows, I only use DrangonFace to extract system content. But I believe it should be possible using linux-equivalent commands from cygwin.

Adromir  
I havent found a convenient way too yet. What i am able to do is to mount the image as a DVD-Rom. But you need to have a ext driver installed to be able to read the Files on it, like http://www.ext2fsd.com/ .

Or using the ext4 unpacker (http://sourceforge.net/projects/androidicsjbext/?source=directory) is a way. On its Scourceforge page they say it has a cli mode, which would be what i need, but I havent been able to make it work yet.

I found a couple of Linux Libraries for working with the Images (like simg2img, make_4extfs) ported to windows but I havent tried them out yet. If they work, maybe its possible to just port the other tools too (like over cygwin or with mingwin)

dlanor  
Edited by dlanor at Tue Nov 11, 2014 02:54

Just remember that after copying files to a Windows environment for modification, and then copying the results back to the Android partitions, all their Linux-type access permission flags may be messed up. For some system files it may be important to restore those flags to their original values, in order for the system to work properly. When we do this through DragonFace, it carries the responsibility of restoring everything properly, but when using other methods we must ensure this ourselves...

The same also applies when attempting to add new scripts or drivers to the system, as it's important to ensure that the runtime Android system regards those files as valid and executable. So for such cases it's best to set the permission flags the same as those of other similar scripts and drivers already in the system.

Best regards: dlanor

You have to log in before you can reply Login | Sign Up

Points Rules