gcc compiling option should be re-located, which is supposed to depends on the computer environment.
Compiling simg2img and make_ext4fs from Android v4.2.1 sources
The process is a bit different now.Let's assume that the
$AOSP_ROOT
variable points to our AOSP root (eg. export AOSP_ROOT="$HOME/Android/AOSP"
).- Download the https://android.googlesource.com/platform/system/core repository:
cd "$AOSP_ROOT"
[ ! -d "platform/system" ] && mkdir -p platform/system
cd platform/system
git clone https://android.googlesource.com/platform/system/core - Check out a revision of your choice:
cd core
git checkout android-4.2.1_r1 - Compile
simg2img
:
cd libsparse
gcc -o simg2img -Iinclude -lz simg2img.c sparse_crc32.c backed_block.c output_file.c sparse.c sparse_err.c sparse_read.c
gcc -o simg2img -Iinclude simg2img.c sparse_crc32.c backed_block.c output_file.c sparse.c sparse_err.c sparse_read.c
-lz
(When compiling, the link option should come at last on my computer. If not "undefined reference to xxxx" errors happened.)
- Unpack your Android image files (of course you should adjust the commands for the correct path to the IMG files):
cd ../../
./core/libsparse/simg2img system.img system.raw.img
./core/libsparse/simg2img userdata.img userdata.raw.img - Do whatever you want with the images (eg. you can use Paragon's
ExtFS on a Mac or just simply mount the images in linux via the loop
device). Eg.
mkdir /mnt/my_system /mnt/my_userdata
mount -t ext4 -o loop system.raw.img /mnt/my_system
mount -t ext4 -o loop userdata.raw.img /mnt/my_userdata
make_ext4fs
did get more complicated too:- Download the https://android.googlesource.com/platform/system/extras repository:
cd "$AOSP_ROOT/platform"
[ ! -d "system" ] && mkdir system
cd system
git clone https://android.googlesource.com/platform/system/extras - Check out a revision of your choice:
cd extras
git checkout android-4.2.1_r1 - Compile
make_ext4fs
:
cd ..
gcc -o make_ext4fs -Icore/libsparse/include -lz extras/ext4_utils/make_ext4fs_main.c extras/ext4_utils/make_ext4fs.c extras/ext4_utils/ext4fixup.c extras/ext4_utils/ext4_utils.c extras/ext4_utils/allocate.c extras/ext4_utils/contents.c extras/ext4_utils/extent.c extras/ext4_utils/indirect.c extras/ext4_utils/uuid.c extras/ext4_utils/sha1.c extras/ext4_utils/wipe.c core/libsparse/backed_block.c core/libsparse/output_file.c core/libsparse/sparse.c core/libsparse/sparse_crc32.c core/libsparse/sparse_err.c core/libsparse/sparse_read.c
PATH="$PATH:$(pwd)" ./extras/ext4_utils/mkuserimg.sh -s /mnt/my_system_dir my_system.img ext4 /tmp 512M
help Compiling simg2img and make_ext4fs from Android android-4.4_r1
ReplyDeleteNice howto, thanks for sharing!
ReplyDeleteI built it that way, but I receive an error: make_ext4fs results in "can't set android permissions - built without android support" when trying to execute make_ext4fs called by mkuserimg.sh
This can be fixed by adding the following when compiling make_ext4fs: "-Icore/include -DANDROID".
Cheers!
Can you please share the steps on how to build fro version android-5.1.1_r9.
ReplyDeleteThe files are changes now.
PLZ