FORUMS

[DEV][TOOL][F2FS/EXT4] Agnostic-kernel - Partition-agnostic kernel flasher [13/11/14]

342 posts
Thanks Meter: 525
 
By frantisek.nesveda, Senior Member on 12th May 2014, 03:21 PM
Post Reply Email Thread
Agnostic-kernel - filesystem independent kernel flasher

WARNING!
Please, make a backup or be prepared to roll back to a working state somehow. You are using this tool on your own responsibility. You have been warned!
If anything goes wrong, flashing another kernel that was working for you before should return your device to a working state.


Repository on GitHub

This is a recovery tool primarily made for kernel/ROM developers, but anyone is welcome to use it, provided he knows what to do. It was made to enable kernel developers to have a single .zip with the kernel which will work on all partition layouts like All-F2FS, Data-F2FS and All-EXT4 (the standard layout).
It takes a boot.img, unpacks it during the installation, finds out what partition layout is used on the device, changes the fstab in the ramdisk accordingly, repacks the boot.img and flashes it.


Instructions for kernel/ROM developers/flashaholics who wish to incorporate this tool:
  1. Make sure your kernel is compiled with F2FS drivers.
  2. Download agnostic-kernel-template.zip
  3. Replace the boot.img-placeholder in the .zip with your boot.img.
  4. OPTIONAL: change the fstab in fstab/ folder to specify any mount options you wish to use. Make sure you include a line for each partition and filesystem combination you want to use.
  5. OPTIONAL: change the updater-script to print any additional messages or make modifications to the kernel after flashing.

Instructions for users who wish to try this tool:
  1. Choose one of the prepacked kernels you wish to install and download it.
  2. Install it via recovery.

Instructions for people who wish to port it to other devices:
  1. Change the asserts in updater-script to check for your device name.
  2. Change the fstab in the fstab/ folder. Make sure you include a line for each partition and filesystem combination you want to use.
  3. Change the FSTAB variable in tools/repack-and-flash.sh to contain the name of your fstab file.
  4. Change the BOOT_PARTITION variable to contain the path to your /boot partition device.

Currently supported partition layouts:
  • /system on EXT4 or F2FS
  • /cache on EXT4 or F2FS
  • /data on EXT4 or F2FS
Filesystem changes are supported only on these partitions because the Nexus 7 doesn't have any other EXT4 partitions by default.
If you want to add support for some other device specific layout (F2FS formatted SD card comes to mind, for example), feel free to do so or contact me, but it may require some changes to your recovery too.

Tested on:
KernelsRecoveriesROMs
  • ROM shouldn't matter, I tested on various 4.4 / 5.0 ROMs and even without a ROM and it always worked.
Downloads
Pre-packed kernels:
Kernel from SlimROM by @legolas93
3.2.5-XPerience-19 by @TeamMex

Empty template for devs:
agnostic-kernel-template.zip
You can download other kernels using agnostic-kernel in their respective threads.

Credits:
If you wish to incorporate or modify this tool, please, mention me somewhere, thanks
The Following 42 Users Say Thank You to frantisek.nesveda For This Useful Post: [ View ] Gift frantisek.nesveda Ad-Free
12th May 2014, 03:21 PM |#2  
OP Senior Member
Thanks Meter: 525
 
More
Changelog:

13th November 2014
This is a highly recommended update for all developers using agnostic-kernel.
  • Now completely ROM independent
  • Updated Android Kitchen to version 1.6 - thanks, @osm0sis!
  • Fixed an issue with Android Kitchen binaries using /system/bin/linker which was not always available.
    • First I did an ugly hack to solve the issue...
    • and then I found out that the updated Android Kitchen binaries are statically linked now and the ugly hack was not needed anymore.
  • Changes to the way fstab is generated - now it uses only one file and deletes unneeded lines from it - inspired by @Metallice
  • Added more error-checking
  • Some other small fixes and improvements
  • Tested on a lot of recoveries and partition layouts.
13th May 2014
  • Fixed an issue with the zip which could arise when /system was not mounted before the install.
  • Tested on a lot of recoveries and partition layouts.
12th May 2014
  • Initial release.
The Following 7 Users Say Thank You to frantisek.nesveda For This Useful Post: [ View ] Gift frantisek.nesveda Ad-Free
12th May 2014, 11:44 PM |#3  
aosp's Avatar
Inactive Recognized Developer
Thanks Meter: 5,028
 
Donate to Me
More
Add settings to enable/disable f2fs forcing mode so we can switch on …
…the fly. Force will force all wipe/format calls to use f2fs or ext4 depending on the selection. Also added code to ensure settings are re-written back to internal sd after a super wipe. Also removed fstab code to determine the mode since we now have a setting for it

http://goo.gl/NTamfl

Add code to analyze the fstab to determine whether we are in f2fs mod…
…e or ext4 mode

http://goo.gl/MJXQpE
The Following User Says Thank You to aosp For This Useful Post: [ View ] Gift aosp Ad-Free
13th May 2014, 06:23 AM |#4  
OP Senior Member
Thanks Meter: 525
 
More
Quote:
Originally Posted by aosp

Add settings to enable/disable f2fs forcing mode so we can switch on …
…the fly. Force will force all wipe/format calls to use f2fs or ext4 depending on the selection. Also added code to ensure settings are re-written back to internal sd after a super wipe. Also removed fstab code to determine the mode since we now have a setting for it

http://goo.gl/NTamfl

Add code to analyze the fstab to determine whether we are in f2fs mod…
…e or ext4 mode

http://goo.gl/MJXQpE

If I'm not mistaken, this is a code in a custom recovery that enables the user to select if he wants to format his partitions as F2FS or EXT4, similar to what the MultiROM recovery does after yesterday's update?

If so, I don't see the connection that your code has with my tool... My tool is a template for a recovery zip, in which kernel devs can place their boot.img, and when the user installs that zip with the boot.img, the script in that zip will check for which partitions does the user have formatted as F2FS and modify the fstab in the boot.img accordingly.
13th May 2014, 04:36 PM |#5  
OP Senior Member
Thanks Meter: 525
 
More
Updated all the zips with a bugfix. The Android Image Kitchen would not start on CWM when /system was not mounted, because it tried to use sh in /system/bin instead of /sbin.

Also, I tested the zips on more partition layouts and recoveries, and verified that it works right both on CWM and TWRP and on ALL-F2FS, Data-F2FS and ALL-EXT4.
The Following User Says Thank You to frantisek.nesveda For This Useful Post: [ View ] Gift frantisek.nesveda Ad-Free
15th May 2014, 03:41 AM |#6  
TeamMex's Avatar
Recognized Developer / Recognized Contributor
Flag Michoacán de Ocampo - México
Thanks Meter: 13,289
 
Donate to Me
More
awesome work
The Following 2 Users Say Thank You to TeamMex For This Useful Post: [ View ]
18th June 2014, 06:47 AM |#7  
chaostrodamis's Avatar
Senior Member
Thanks Meter: 99
 
More
How do we convert if we only have a zimage and no boot.img

Sent from my Nexus 7 using Tapatalk
19th June 2014, 10:22 AM |#8  
OP Senior Member
Thanks Meter: 525
 
More
Quote:
Originally Posted by chaostrodamis

How do we convert if we only have a zimage and no boot.img

The changes are all done to the ramdisk, so you can't do them without one, at least not with this method.
But, if you look how @sgt. meow does it in his Oxydo kernel, perhaps that is the way you could use. He unpacks the ramdisk from the currently installed kernel and then packs it with his zImage to a boot.img which he then flashes. This requires that the user first flashes another kernel with f2fs working, and then flashes your kernel.

Perhaps it would be easier if you packed your kernel with some ramdisk and then used it.
The Following 4 Users Say Thank You to frantisek.nesveda For This Useful Post: [ View ] Gift frantisek.nesveda Ad-Free
13th November 2014, 12:52 AM |#9  
OP Senior Member
Thanks Meter: 525
 
More
An updated version of agnostic-kernel is available in the OP. See post #2 for changelog.
Both the template zip and the two prepacked kernels are updated.

This is a highly reccomended update for all kernel developers, as it fixes compatibility issues with some ROMs (AOSP Lollipop, for example).

I've also published sources to my working folder on GitHub, if anyone is interested. There's nothing really important there, though.
The Following 5 Users Say Thank You to frantisek.nesveda For This Useful Post: [ View ] Gift frantisek.nesveda Ad-Free
13th November 2014, 02:20 AM |#10  
RoryB's Avatar
Inactive Recognized Developer
Flag Lexington
Thanks Meter: 771
 
Donate to Me
More
Thanks for the post in my thread. I've been trying to figure out how to edit the line in the file and kept running into roadblocks. I'll definitely take a peek. The other thing I am planning to do is pull the boot image from the phone instead of having it in the zip file.
13th November 2014, 03:08 AM |#11  
OP Senior Member
Thanks Meter: 525
 
More
Quote:
Originally Posted by RoryB

Thanks for the post in my thread. I've been trying to figure out how to edit the line in the file and kept running into roadblocks. I'll definitely take a peek. The other thing I am planning to do is pull the boot image from the phone instead of having it in the zip file.

You're welcome. And you could perhaps try pulling the boot.img with dd, something like this:
Code:
dd if=$BOOT_PARTITION of=/tmp/agnostic-kernel/boot.img
Post Reply Subscribe to Thread

Tags
ext4, f2fs, kernel, recovery, tool

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes