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

Search This thread

frantisek.nesveda

Senior Member
Jan 10, 2012
342
524
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:
Kernels
Recoveries
ROMs
  • 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 :)
 

Attachments

  • agnostic-kernel-3.2.5-XPerience19.zip
    6.3 MB · Views: 253
  • agnostic-kernel-SlimKernel-020514.zip
    4.8 MB · Views: 250
  • agnostic-kernel-template.zip
    1.3 MB · Views: 324
Last edited:

frantisek.nesveda

Senior Member
Jan 10, 2012
342
524
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.
 
Last edited:

aosp

Inactive Recognized Developer
Aug 12, 2010
2,135
4,997
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
 
  • Like
Reactions: estape11

frantisek.nesveda

Senior Member
Jan 10, 2012
342
524
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.
 

frantisek.nesveda

Senior Member
Jan 10, 2012
342
524
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.
 
  • Like
Reactions: Monfro

frantisek.nesveda

Senior Member
Jan 10, 2012
342
524
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.
 

frantisek.nesveda

Senior Member
Jan 10, 2012
342
524
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.
 

RoryB

Inactive Recognized Developer
Sep 4, 2008
2,921
766
Lexington
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.
 

frantisek.nesveda

Senior Member
Jan 10, 2012
342
524
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
 

Top Liked Posts

  • There are no posts matching your filters.
  • 42
    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:
    Kernels
    Recoveries
    ROMs
    • 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 :)
    7
    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.
    5
    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.
    4
    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.
    2
    awesome work :)