[How To] Load ramdisk files not packed with the kernel, and modifying for F2FS cache - Asus Transformer TF700

When I first installed KatKiss 6, I had to unpack and repack kernels in order to try out different combinations of zImage, ramdisk files, and modules. Many people may not want to go through the trouble, but there is an easier way to do that.
So, why do we want to try different combinations of zImage, ramdisk files, and modules? To see if performance is better could be an incentive, but the main reason is that sometimes a different combination of zImage, ramdisk files, and modules may fix things that are not working properly. For example, with cm kernel, GPS can't get good signals in the PAC ROM 5.1.1 I compiled. The problem is solved by using ramdisk of Cyanogenmod, and zImage and modules of Grimlock kernel 5.1.1.
Actually, @_that mentioned the two ways that can accomplish this back in January, but I went with the more complicated one because I had little knowledge of programming. I finally figured out how to do that the easier way recently.
The downside is that you must use a zImage supporting preinit in order to load ramdisk files that are not packed in the kernel. that kernel and Grimlock kernel both support preinit.
If you don't use kexecboot, zImage will always be from the kernel you installed for internal ROM. If it's a ROM2SD installation, the ramdisk files will be from the kernel you choose during ROM2SD installation. The modules are usually copied from internal during ROM2SD installation.
If you want to change zImage, then you have to flash a different kernel to /boot partition. If you want to change ramdisk file for ROM2SD installation, then you need to first delete the boot/ folder on the /system partition of the micro SD card. Then you can flash the kernel containing the ramdisk files between rom2sd1.zip and rom2sd2.zip following the method by @_that. Alternatively, you can also use the ones in this post. The differences are that the updated scripts from ZOMBi-POP will copy modules from internal /system, instead of using the ones packed by @_that.
If you want to use that kernel with KatKiss 6, you have to load ramdisk files from KatKernel to use with zImage of that kernel. To load different ramdisk files for a ROM installed on internal storage, you need to revise '20detect-microsd' file in internal /system/boot/preinit.d/ , which will copy ramdisk files from internal /system/boot/ramdisk to /. You can download the one I used, which is attached. The following lines are added to the original file.
Code:
else
# copy ramdisk files from internal /system/boot/ramdisk to /
$BB cp -a /system/boot/ramdisk/* / || echo "failed to copy ramdisk files from /system/boot/ramdisk"
You certainly need to extract the ramdisk files to internal /system/boot/ramdisk/ . To do that, you can use the attached extract ramdisk to internal system.zip. Just replace the 'boot.blob' inside with the one you'd like to use. Basically, it's the rom2sd2.zip from @_that, but without the scripts doing revision for ROM2SD.
At least for some ROMs, you can see performance gain with F2FS /cache. If you want to try to see if F2FS /cache works better for you. You can convert /cache to F2FS with TWRP 2.8.+. Just go to Wipe->Advanced Wipe, select Cache, and Change file system to F2FS. You also need to revise 'fstab.cardhu' in /system/boot/ramdisk/ for all the ROMs you are running. Just replacing the line for /cache with the following one
Code:
/dev/block/mmcblk0p2 /cache f2fs noatime,nosuid,nodev,errors=panic wait,encryptable=footer
Alternatively, you can use attached extract ramdisk to internal system f2fs cache .zip or rom2sd2 f2fs cache.zip when extracting the ramdisk files to internal or ROM2SD /system. The following line is added to 'extract-ramdisk.sh' so that 'fstab.cardhu' will be revised during extraction.
Code:
sed -i '/mmcblk0p2/{;s/ext4/f2fs/;s/barrier=.,//;s/nodiratime,//;s/noauto_da_alloc,//;s/nomblk_io_submit,//;}' $f
I am able to use different zImages for internal and external ROMs and choose which one to boot with kexecboot. If someone is interested in how to set that up, please just ask in the comments.

There is a 'boot.blob' (I beleive it's for PAC511) in 'extract ramdisk to internal system f2fs cache .zip' You need to replace it with the one you'd like to use, or delete it and flash your kernel before flashing this zip.

Related

[Q] Boot Process

I've looked in quite a few threads, including the custom mix ROMs. What I want to know is who has knowledge of how this thing boots? I've noticed on the 2 droids I've messed with you upgrade them with an update.zip and basically an empty file on the SD card.
I'm guessing the update.zip contains a squashfs or something similar along with a kernel, but I don't know for sure. Who can explain exactly what happens on boot, what devices it looks for filesystems/loop filesystems on etc?
muqali said:
I've looked in quite a few threads, including the custom mix ROMs. What I want to know is who has knowledge of how this thing boots? I've noticed on the 2 droids I've messed with you upgrade them with an update.zip and basically an empty file on the SD card.
I'm guessing the update.zip contains a squashfs or something similar along with a kernel, but I don't know for sure. Who can explain exactly what happens on boot, what devices it looks for filesystems/loop filesystems on etc?
Click to expand...
Click to collapse
The best way to learn about this stuff is by tearing down existing .zip flashers and reading about how boot.img files are built and trying to build your own.
The boot process is controlled by the bootloader (the thing that displays the Viewsonic birds logo and decides whether you are trying to boot into recovery, APX mode, or a standard boot).
The ZIP files that you flash actually run a script that writes an .IMG file contents to one or more partitions.
Most ROM flashers have two images they flash - a boot.img and a system.img. The system.img is a filesystem image of the system partition. The boot.img consists of two parts - a kernel and a ramdisk image (well, and a boot header). The kernel is the Linux kernel that's been compiled to provide all the core system functionality for Android. The ramdisk image (which is a GZIPed CPIO file) contains the init.rc file that does all the initialization, mounting of the main filesystem images and so on.
Once everything is mounted and configured, the Android ROM itself boots up.
I recommend reading this page for more info:
http://android-dls.com/wiki/index.php?title=HOWTO:_Unpack,_Edit,_and_Re-Pack_Boot_Images
Hope that helps!
That's more or less what I wanted, but for our device do you know the exact boot order? Mtd partitions then SD sd2 and maybe a USB disk? I'd really like to put a custom Roman on the sd2 and leave the rom factory.
muqali said:
That's more or less what I wanted, but for our device do you know the exact boot order? Mtd partitions then SD sd2 and maybe a USB disk? I'd really like to put a custom Roman on the sd2 and leave the rom factory.
Click to expand...
Click to collapse
I *think* (could be wrong) that both the externalSD (/sdcard2) and the USBDISK (/usbdisk) are mounted dynamically, via vold.
At least that's the way I understood it...
There's a thread here in this forum, about (dual) booting Ubuntu, that does something along the lines of what you're asking about...
Jim
rcgabriel said:
The best way to learn about this stuff is by tearing down existing .zip flashers and reading about how boot.img files are built and trying to build your own.
The boot process is controlled by the bootloader (the thing that displays the Viewsonic birds logo and decides whether you are trying to boot into recovery, APX mode, or a standard boot).
The ZIP files that you flash actually run a script that writes an .IMG file contents to one or more partitions.
Most ROM flashers have two images they flash - a boot.img and a system.img. The system.img is a filesystem image of the system partition. The boot.img consists of two parts - a kernel and a ramdisk image (well, and a boot header). The kernel is the Linux kernel that's been compiled to provide all the core system functionality for Android. The ramdisk image (which is a GZIPed CPIO file) contains the init.rc file that does all the initialization, mounting of the main filesystem images and so on.
Once everything is mounted and configured, the Android ROM itself boots up.
I recommend reading this page for more info:
http://android-dls.com/wiki/index.php?title=HOWTO:_Unpack,_Edit,_and_Re-Pack_Boot_Images
Hope that helps!
Click to expand...
Click to collapse
rcgabriel,
When you do an nvflash (ala bekit's), does the contents of bootloader.bin end up getting stored permanently on the Gtab's internal SDcard? And, whenever the Gtab is booted, the code in that bootloader is the first code that runs, deciding, as you said, whether or not to do a recovery or execute the boot.img?
Thanks,
Jim
Isn't the bootloader on one of the MTD partitions and not the sdcard? What I'm having the hardest time wrapping my head around is how this system boots in comparison to an x86 Debian 5.0 system.
The basic picture I have is that there is the rom/flash portion of the boot process and then the kernel and real filesystem are loaded and mounted. But using these custom roms, is it changing the flash and bootloader or just the kernel and OS? Meaning where exactly is the first thing the CPU hits to boot? Flash MTD partitions for the bootloader. Then is the kernel on the mtd partitions or on some separate partition on sdcard.
Since you can basically stick 2 files on an external uSD and send it into upgrade mode, can't you customize the filesystem contained in a zip and then stick it in and have a custom system with whatever you wanted added or removed?

[Q] How can I convert a Stock ROM to CWM?

I want to build an own ROM, well at least try.
After few experiments -with different success- I modded existing custom ROMs.
Now I want to release an own modded ROM and for that I need a CWM-version of Stock ROM OR -better- Ho I can convert StockROM to CWM-zip.
Rodsengard said:
I want to build an own ROM, well at least try.
After few experiments -with different success- I modded existing custom ROMs.
Now I want to release an own modded ROM and for that I need a CWM-version of Stock ROM OR -better- Ho I can convert StockROM to CWM-zip.
Click to expand...
Click to collapse
I think after you extract and mod system.rfs you should use dsixda kitchen to make the rom and add the boot.img file to zip file created then use CWM to Install the rom
The most important thing is after u have created your system,boot.img and other folder if u added a new folder in your base rom then u need to make a updater script .B-)
Sent from my GT-S5830 using xda premium
Yea but still if I place extracted system rfs AND boot.img from CSC how do I get a running updatescript, respectively what has to be in such an update script?
Don´t tell me "just place metainf folder from out of any other rom into it", cuz in that early dev-phase the metainfs of all other roms are useless, cuz they are almost ext4 and the "just extracted stock" isn´t ext4 so the metainfs of the other ROMs won´t work. ^^
Anyone else to help here?
from some Update-script i think you should do those step:
Remember end each script with ";"
Code:
unmount ("/system")[COLOR="red"];[/COLOR]
1-Format all system like you install new Windows
Code:
format("[COLOR="red"]ext4[/COLOR]", "EMMC", "/dev/block/stl[COLOR="Red"]12[/COLOR]")
Change the red with right values: rfs,ext2,3,4(file system), 12 or 13 or 14( system,data,cache partition)
With ext4 you must have a kernel support ext4
2-After format you have to mount them to copy files
Code:
mount("[COLOR="red"]ext4[/COLOR]", "EMMC", "/dev/block/stl[COLOR="red"]12[/COLOR]", "/[COLOR="red"]system[/COLOR]")
3-Extract files from zip to ROM
Code:
package_extract_dir("[COLOR="red"]system[/COLOR]", "/[COLOR="red"]system[/COLOR]")
extract system folder in ZIP to /system
Do same thing to data, cache if you have them in ZIP.
4-Fix permission
nah i dont know to much about this
You have to change permission to right state if not i dont know what happen next
Code:
set_perm([COLOR="Red"]0[/COLOR], [COLOR="red"]0[/COLOR], [COLOR="red"]0777[/COLOR], "[COLOR="red"]/system/bin/a2sd[/COLOR]")
Set permission to one file or one folder(not its contain)
Code:
set_perm_recursive ([COLOR="red"]0[/COLOR], [COLOR="red"]0[/COLOR], [COLOR="red"]0755[/COLOR], [COLOR="red"]0644[/COLOR], "[COLOR="red"]/system[/COLOR]")
Set permission to it and all thing in it
5- Link file
ahh hard to know
You should ask someone else but me
Code:
symlink [COLOR="red"]busybox[/COLOR] [COLOR="red"]SYSTEM:xbin/zcip[/COLOR]
6- Unmount partition
Code:
unmount("[COLOR="Red"]/system[/COLOR]")
And if you have your own boot.img
Code:
assert(package_extract_file("boot.img", "/tmp/boot.img"),
write_raw_image("/tmp/boot.img", "boot"),
delete("/tmp/boot.img"));
This is really basic. So may be it wont work
For advance: update-script syntax - A guide for ROM devs, modders, and themers
Anyone: how to compile kernel for fit? I almost give up cause i dont know much about linux, I tried samsugn source but my device never boot. If anyone could help this Noob, Noob 's very thank you
Thank you very much. This should be helpful

[Q] How to pack zImage binary kernel in CWM zip for TF101

Hi, i'm trying to flash my custom kernel with CWM recovery. I've seen some zip to update TF's kernel that use a kernelblob but i didn't realized how to create this binary file.
I've compiled kernel from source code from AsusTek files (Eee Pad Kernel Code for Android 3.2 OS (V8.6.5.7)) and i have zImage and modules (.ko).
Someone know how can i pack this things to flash my kernel with CWM?
Coniglioz said:
Hi, i'm trying to flash my custom kernel with CWM recovery. I've seen some zip to update TF's kernel that use a kernelblob but i didn't realized how to create this binary file.
I've compiled kernel from source code from AsusTek files (Eee Pad Kernel Code for Android 3.2 OS (V8.6.5.7)) and i have zImage and modules (.ko).
Someone know how can i pack this things to flash my kernel with CWM?
Click to expand...
Click to collapse
Just to create a CWM compatible kernel zip , it's a combination of the things below:
1) Fetch one of the many kernel zip files like from Roach or Clemsyn that are in the development forum to use as a template. Unzip it somewhere in a clean folder and you'll just be replacing modules & zImage (or whatever it is called, almost certainly *blob* something) then next step.
2) Most of what you need to create the insecure boot image is in here:
http://forum.xda-developers.com/showthread.php?t=1193737
3) Most of what you need to create the new blob is in here:
http://forum.xda-developers.com/showthread.php?t=1068548&highlight=blobpack
4) Now move your new modules from your freshly built custom kernel (do a $find {kerneldir} -iname '*.ko' ). Copy them over /system/lib/modules/* in the unzipped template zip from 1) and get rid of any that you didn't create yourself as well.
4.5) copy the blobpack'd file you created from zImage to whatever it was called in the unzipped zip template (say, boot.img to blob or kernelblob or whatever it was called so the script in the zip works).
5) zip the entire contents making sure you're starting at the right base directory into a new customized zip file. That's it you're done. If it doesn't work you might just have created a bum kernel.
Theory of this in a nutshell. There is no way to do the anykernel.zip method because the tf101 will only accept a blob on those encoded partitions so you have to get the blob and boot tools and use them and since all of the kernel zipfiles use it, you've got easy templates.
I'm not mentioning CWM in here because you would just have to create a bigger blob which is I think covered in any thread you search out that has 'blobpack' in it, like Rayman's. The catch-22 of doing recovery + kernel in one blob is that you have no way to boot the thing should things go haywire, unless you're just talking about CWM and it's kernel.
Good luck -
Hashi
Thanks, I blobbed my custom zImage.
I used this zip update as template: http://forum.xda-developers.com/showthread.php?t=1226717
I'll post this kernel with raw hid input support after testing all the functionalities!

[Q] What's in the firmware blob?

I'm currently looking at the latest firmware update zip file (WW_epad_user_10_4_4_18_UpdateLauncher.zip), hoping it contains driver binaries etc. that could be reused in a custom rom (a script that downloads the latest official firmware and extracts needed bits is legal -- just distributing the drivers and all might not be).
The content is another zip file, that in turn contains a META-INF directory with information and an updater, and one huge file called "blob" that probably contains all we care about.
Has anyone investigated that "blob" file yet?
Unfortunately it doesn't seem to be an ext4 image like what you'd flash with "fastboot flash system"...
If nobody else has done it, I'll look into this more myself, but obviously if it's already been done, no need to start over.
The blob can be unpacked using BlobTools (https://github.com/AndroidRoot/BlobTools). It contains partition images:
PT ... Tegra Partition Table
EBT ... bootloader
SOS ... recovery kernel image
LNX ... Android kernel image
APP ... /system partition
The kernel images can again be split into the kernel itself and the initramfs image, and APP is an ext4 image.

[TOOL] [WIN/LINUX/MAC/ANDROID] [4.4.x] Grouper EXT4 to F2FS ROM Converter

This is a simple script that will convert any grouper EXT4 ROM to F2FS. The script will simply swap out boot.img (i.e. the kernel) and edit the updater-script to replace EXT4-specific lines with F2FS-specific lines. The included boot.img may be replaced with any grouper F2FS boot.img.
NOTE: If you have not reformatted your device for F2FS, you're not ready to use this tool yet. This tool will make a ROM F2FS-compatible, it will not convert your device to F2FS. To reformat your device to F2FS, start here: http://forum.xda-developers.com/showthread.php?t=2678140
Windows instructions:
1) Unzip the windows zip to any empty folder.
2) Place your EXT4 ROM zip in the same folder, make sure there are no other zips in this folder.
3) Run EXT4_to_F2FS_grouper.bat.
Linux / Mac instructions:
1) Ensure you have sed, zip, and unzip installed. And note that this is a bash script.
2) Unzip the linux_mac zip to any empty folder.
3) Place your EXT4 ROM zip in the same folder, make sure there are no other zips in this folder.
4) cd into your converter folder.
5) Run "chmod +x EXT4_to_F2FS_grouper.sh". This only needs to be done once.
6) Run "./EXT4_to_F2FS_grouper.sh".
Android instructions:
1) Ensure you have a zip binary, likely located at /system/xbin. If not, flash zip_binary_flashable.zip from recovery.
2) Ensure you have busybox. Stericson's 1.22.1 definitely works: https://play.google.com/store/apps/details?id=stericson.busybox. Others may not, try Stericson's before reporting problems.
3) Unzip the android zip to any empty folder on the SD card.
4) Place your EXT4 ROM zip in the same folder, make sure there are no other zips in this folder.
5) Open an Android terminal
6) Run "su" (there's problems with unzipping when not root for some reason)
7) cd into your converter folder
8) Run "sh f2fs.sh"
Mediafire Downloads: https://www.mediafire.com/folder/k70lnuoqldzxr/EXT4_to_F2FS_grouper
Google Drive mirror: https://drive.google.com/folderview?id=0B_Yk7pLJ4-VhcWZLS0p1T2lWeUU&usp=sharing
Changelog:
7/11/14: Very minor change to Linux tool to make it compatible with the Mac terminal.
7/8/14: Windows, Linux, & Android tools handle /data mounting (for SlimKat).
7/1/14: Initial release, included boot.img is stock LiquidSmooth 06-27-2014 recompiled for F2FS.
Credits:
@NABENDU1 for the original grouper F2FS ROM conversion tool that inspired this: http://forum.xda-developers.com/showthread.php?t=2731666
@johansenmo for the assistance in making the Linux tool Mac compatible.
@legolas93 for the F2FS work: http://forum.xda-developers.com/showthread.php?t=2678140
My other projects:
LiquidSmooth-OFFICIAL for maguro: http://forum.xda-developers.com/gal...m-official-liquidsmooth-kitkat-4-4-3-t2667078
LiquidSmooth-OFFICIAL for toro: http://forum.xda-developers.com/gal...m-liquidsmooth-v3-1-kitkat4-4-3-toro-t2575560
LiquidSmooth-OFFICIAL for toroplus: http://forum.xda-developers.com/gal...m-official-liquidsmooth-kitkat-4-4-3-t2672510
LiquidSmooth-UNOFFICIAL for maguro: http://forum.xda-developers.com/gal...aguro-toro-t2793275/post53641446#post53641446
LiquidSmooth-UNOFFICIAL for toro: http://forum.xda-developers.com/galaxy-nexus/verizon-develop/rom-liquidsmooth-v3-1-toro-t2793284
LiquidSmooth-UNOFFICIAL for toroplus: http://forum.xda-developers.com/galaxy-nexus/sprint-develop/rom-liquidsmooth-v3-1-toroplus-t2793281
LiquidSmooth-UNOFFICIAL for grouper: http://forum.xda-developers.com/showthread.php?t=2709385
F2FS Converter tools for Galaxy Nexus ROMs: http://forum.xda-developers.com/galaxy-nexus/development/tool-galaxy-nexus-ext4-to-f2fs-rom-t2794702
Ting APNs to fix LTE: http://forum.xda-developers.com/galaxy-nexus/general/ting-flashable-zip-fixed-lte-android-4-t2428999
Verizon APNs to fix MMS: http://forum.xda-developers.com/android/software/tool-verizon-mms-apn-patch-t2833914
Click to expand...
Click to collapse
[poo]
Has anyone tried this yet? Away from pc so can't give insight but looks promising
Sent from my HTC One XL using XDA Premium 4 mobile app
pjcanales said:
Has anyone tried this yet? Away from pc so can't give insight but looks promising
Sent from my HTC One XL using XDA Premium 4 mobile app
Click to expand...
Click to collapse
Lots of people have been using my Galaxy Nexus version and the code is practically identical. http://forum.xda-developers.com/galaxy-nexus/development/tool-galaxy-nexus-ext4-to-f2fs-rom-t2794702
[poo]
OP updated with 7/8 release of Windows, Linux, and Android tools.
[poo]
F2fs really makes the difference...should be the default partition for everyone
Sent from my Nexus 7 using XDA Free mobile app
I can't get the converted CM11 nightly for 7 July to boot on my Nexus 7, it stuck on CM boot animation looping.
This is what I did:
1. flash TWRP 2.7.1.1 with F2FS support
2. change file system for /system, /cache and /data to f2fs
3. reboot into recovery again
4. flash the converted ROM and reboot system
Did I do something wrong?
thedesp said:
I can't get the converted CM11 nightly for 7 July to boot on my Nexus 7, it stuck on CM boot animation looping.
This is what I did:
1. flash TWRP 2.7.1.1 with F2FS support
2. change file system for /system, /cache and /data to f2fs
3. reboot into recovery again
4. flash the converted ROM and reboot system
Did I do something wrong?
Click to expand...
Click to collapse
Looks like you did everything right to me. Normally any issues with the ROM expecting EXT4 and getting F2FS (or vice versa) or the boot.img result in getting stuck at the Google logo. Since you've actually progressed to the CM boot animation, something else is going on. I ran CM11 7/7 through my Windows tool and everything looks like it should. Have you tried installing a different F2FS kernel immediately after flashing the converted CM11? Have you tried installing any other F2FS ROM?
[poo]
just tried OmniROM and it stuck at boot animation also.
Same result when flashing another kernel (M-Kernel)
thedesp said:
just tried OmniROM and it stuck at boot animation also.
Same result when flashing another kernel (M-Kernel)
Click to expand...
Click to collapse
Are you all f2fs, cache, system, and data?
[poo]
Yes
/system /cache /data are all f2fs
Tried again with CM11 M8 + M-Kernel and it worked!!
Still don't know why...
thedesp said:
Yes
/system /cache /data are all f2fs
Tried again with CM11 M8 + M-Kernel and it worked!!
Still don't know why...
Click to expand...
Click to collapse
That's odd. But ok, I'll take it.
[poo]
OP updated. The Linux tool is now Mac compatible.
[poo]
Working for Stock Rom?
I have the stock rom from Google, it should work on it too right?
(nakasi-lrx21p-factory-93daa4d3.zip)
I'm trying this as I type. Will report results soon.
EDIT: I tried the windows version according to the instructions and it gives the error: boot.img is not supported archive. Incorrect function and cannot find archive.
EDIT2: Okay. I realize it won't work with the factory image.

Categories

Resources