Building a pre-rooted, de-knoxed stock ROM for S4 (i337m)

Will this work or will I royally #$%# my phone


  • Total voters
    26
Search This thread

The French Tickl3r

Senior Member
May 19, 2013
175
31
Montreal
Hello XDA-san

This is my first time working with cygwin and Android Kitchen and I wanted to make sure I didn't miss anything that will royally brick my s4. I have attached screenshots of my journey for reference.

I started with the stock ROM from you know where, version 4.4.2 (i337MOYAFNC1) and proceeded to remove the KNOX bootloader (using instructions from SilviuMik). I skipped the last step where it is re-md5, to continue on to the kitchen..

Using the de-knoxed tar file, I created a working folder for the ROM in the kitchen. It started unpacking, everthing went well. When i was prompted to choose if I wanted to extract the CSC, I said no.. because the DiskInternals Linux reader was giving me an error saying along the lines of cant read disk..

From my working folder, I proceeded to root & busybox, all went well. I then deodexed both the system apps and framework, all went well.

lastly, I made a build from the working folder. Selected all default options while doing so (see pictures) , signed the freshly minted rom and voila.

:cowboy:
 

broodplank1337

Inactive Recognized Developer
Nov 24, 2011
4,992
10,155
Nijmegen
www.broodplank.net
If the repacking was successful there is not much to fear about.

(You may want to lookup if there is any dependents (in the rom) by using the removed knox bootloader (atleast remove the knox apks I guess)

the CSC is really nothing important:

A common short code (CSC) is a short telephone number, usually consisting of five digits, that is used to address SMS and MMS messages from a cellular telephone. Common short codes may also be called mobile short codes or short numbers. Each common short code is designed to be unique to each operator.

Just include the one from the stockrom. btw, I have successfully manually unpacked the CSC file a year ago or so with simg2img, it only contained crap (samsung only files for altering behavior in TW rom and bloatware), the hidden partition or preload partition may also contain unwanted crap btw

So go ahead and flash it, your phone will not get bricked by this in any way.
 
  • Like
Reactions: The French Tickl3r

The French Tickl3r

Senior Member
May 19, 2013
175
31
Montreal
If the repacking was successful there is not much to fear about.

(You may want to lookup if there is any dependents (in the rom) by using the removed knox bootloader (atleast remove the knox apks I guess)

the CSC is really nothing important:



Just include the one from the stockrom. btw, I have successfully manually unpacked the CSC file a year ago or so with simg2img, it only contained crap (samsung only files for altering behavior in TW rom and bloatware), the hidden partition or preload partition may also contain unwanted crap btw

So go ahead and flash it, your phone will not get bricked by this in any way.

Hi broodplank1337, thhank you for your reply

So would it be better to go into my newly minted zip file and hunt down the knox apks / dependencies? Or should I flash the ROM then use root browser to get rid of them?

I found this list "

Delete the files in the following files in this order.


/system/app/KNOXAgent.apk
/system/app/KNOXAgent.odex
/system/app/KLMSAgent.apk
/system/app/KLMSAgent.odex
/system/app/KnoxAttestationAgent.apk
/system/app/KnoxAttestationAgent.odex
/system/app/KNOXStore.apk
/system/app/KNOXStore.odex
/system/app/ContainerAgent.apk
/system/app/ContainerAgent.odex

/system/lib/libknoxdrawglfunction.so

/system/app/ContainerEventsRelayManager.apk
/system/app/ContainerEventsRelayManager.odex
/system/app/KNOXStub.apk <--- delete if you have, some will not


Delete the following folders

/system/containers
/system/preloadedkiosk
/system/preloadedsso

/system/etc/secure_storage/com.sec.knox.store
/data/data/com.sec.knox.seandroid
/data/data/com.sec.knox.store
/data/data/com.sec.knox.containeragent
/data/data/com.samsung.android.walletmanager
 

broodplank1337

Inactive Recognized Developer
Nov 24, 2011
4,992
10,155
Nijmegen
www.broodplank.net
Hi broodplank1337, thhank you for your reply

So would it be better to go into my newly minted zip file and hunt down the knox apks / dependencies? Or should I flash the ROM then use root browser to get rid of them?

I found this list "

Delete the files in the following files in this order.


/system/app/KNOXAgent.apk
/system/app/KNOXAgent.odex
/system/app/KLMSAgent.apk
/system/app/KLMSAgent.odex
/system/app/KnoxAttestationAgent.apk
/system/app/KnoxAttestationAgent.odex
/system/app/KNOXStore.apk
/system/app/KNOXStore.odex
/system/app/ContainerAgent.apk
/system/app/ContainerAgent.odex

/system/lib/libknoxdrawglfunction.so

/system/app/ContainerEventsRelayManager.apk
/system/app/ContainerEventsRelayManager.odex
/system/app/KNOXStub.apk <--- delete if you have, some will not


Delete the following folders

/system/containers
/system/preloadedkiosk
/system/preloadedsso

/system/etc/secure_storage/com.sec.knox.store
/data/data/com.sec.knox.seandroid
/data/data/com.sec.knox.store
/data/data/com.sec.knox.containeragent
/data/data/com.samsung.android.walletmanager

Oh I thought you were building an odin rom? zip you say?
Anyways, just remove em from the system folder and test it's result. You can always test roms without damaging your device at any time, read: it's impossible for a ROM to brick a phone, the thing that can brick it is the kernel, but only if using a kernel from an other device or so.

so don't be afraid to test it, if it doesn't work just continue your work. if it works, good joob ;)
 

Surge1223

Recognized Contributor
Nov 6, 2012
2,622
7,466
Florida
Google Pixel 6 Pro
Oh I thought you were building an odin rom? zip you say?
Anyways, just remove em from the system folder and test it's result. You can always test roms without damaging your device at any time, read: it's impossible for a ROM to brick a phone, the thing that can brick it is the kernel, but only if using a kernel from an other device or so.

so don't be afraid to test it, if it doesn't work just continue your work. if it works, good joob ;)

One caveat to this, and this mostly applies to Verizon and AT&T users, but if you have upgraded to KitKat and kept root using SuperSu's survival mode and your planning to test a rom using Safestrap, you better make sure that the su binary is in xbin and bin (.ext/.su) and that the Superuser.apk is in /system/app. Also make sure that the permissions are set correctly for su (chmod 06755 chown 0.0) and have busybox in the rom as well, or at least have busybox install in the updater-script and make sure everything symlinks correctly.

The best thing to do when testing roms to avoid having to worry about losing root is to download Chainfire's SuperSu zip and flash it after you flash your rom you're testing (but before it reboots into the rom for the first time) the reason I even mention all of this is because currently we (Verizon and AT&T users) have no way to root a device thats taken a complete 4.4.2 OTA.
 
  • Like
Reactions: broodplank1337

broodplank1337

Inactive Recognized Developer
Nov 24, 2011
4,992
10,155
Nijmegen
www.broodplank.net
One caveat to this, and this mostly applies to Verizon and AT&T users, but if you have upgraded to KitKat and kept root using SuperSu's survival mode and your planning to test a rom using Safestrap, you better make sure that the su binary is in xbin and bin (.ext/.su) and that the Superuser.apk is in /system/app. Also make sure that the permissions are set correctly for su (chmod 06755 chown 0.0) and have busybox in the rom as well, or at least have busybox install in the updater-script and make sure everything symlinks correctly.

The best thing to do when testing roms to avoid having to worry about losing root is to download Chainfire's SuperSu zip and flash it after you flash your rom you're testing (but before it reboots into the rom for the first time) the reason I even mention all of this is because currently we (Verizon and AT&T users) have no way to root a device thats taken a complete 4.4.2 OTA.

Seriously? wow, thanks for mentioning, I can't believe what a pricks Verizon and AT&T are. Same count for Samsung that handles knox regulation in the USA (while not in other countries). In the USA you get pretty much screwed by the carriers and manufacturers the hard way.

In The Netherlands (where I live) it's even illegal to sell smartphones that are not unlocked by default. and the only thing a carrier may do is adding a CSC (Consumer Software Customization) package. This should be in the USA as well!

In the USA companies get to private / independent it seems. they should be regulated by national government rules. instead of making their own. (this keeps the crap like the problem you described away)

But Samsung should be regulated as well, there is no chance that will happen (south-korea), and their phones will contain more and more backdoors / suspicious daemons / methods of screwing you and so on, because who checks it, no one. Oh yes only someone, the NSA that adds even more of this stuff, like a VPN Interceptor, which no one is waiting for as well.

Anyways, life (or actually companies) is (are) a *****. Only strict regulation could solve this, but who still believes in regulation after seeing what the NSA all did, they broke like every single rule and forced companies to merge their crap (most likely, or a huge payment, but no single company actually likes that)
- NSA 'was allowed' to break in all PC's because that where outside the USA. that just ridiculous but true
- NSA applied their 'jizz' to all super famous apps like Facebook.

Even though it sounds like I say USA is the culprit thats not true, The netherlands have BREIN, which is the anti piracy company.

This asshole tim kuik has,

a. destroyed the piratebay for the whole world (even though it's recuping soon)
b. have done a million requests on removing uploaded movies (on newsgroups)

I really went OT all the way at this reply xd but you get my point :good:

The product gets made, then infected by the creator, then gets forced to merge nsa crap. after that it goes to the carrier which installs even more crap.

there is not a single bit of freedom left
 

The French Tickl3r

Senior Member
May 19, 2013
175
31
Montreal
Thank you both for these tips. Being a rather unexperienced cook, I would have never thought of these important details mentioned above.

it really is a shame how tightly service provider have our collective balls in a grasp..
 

elesbb

Senior Member
Jun 20, 2010
7,883
5,324
Seriously? wow, thanks for mentioning, I can't believe what a pricks Verizon and AT&T are. Same count for Samsung that handles knox regulation in the USA (while not in other countries). In the USA you get pretty much screwed by the carriers and manufacturers the hard way.

In The Netherlands (where I live) it's even illegal to sell smartphones that are not unlocked by default. and the only thing a carrier may do is adding a CSC (Consumer Software Customization) package. This should be in the USA as well!

In the USA companies get to private / independent it seems. they should be regulated by national government rules. instead of making their own. (this keeps the crap like the problem you described away)

But Samsung should be regulated as well, there is no chance that will happen (south-korea), and their phones will contain more and more backdoors / suspicious daemons / methods of screwing you and so on, because who checks it, no one. Oh yes only someone, the NSA that adds even more of this stuff, like a VPN Interceptor, which no one is waiting for as well.

Anyways, life (or actually companies) is (are) a *****. Only strict regulation could solve this, but who still believes in regulation after seeing what the NSA all did, they broke like every single rule and forced companies to merge their crap (most likely, or a huge payment, but no single company actually likes that)
- NSA 'was allowed' to break in all PC's because that where outside the USA. that just ridiculous but true
- NSA applied their 'jizz' to all super famous apps like Facebook.

Even though it sounds like I say USA is the culprit thats not true, The netherlands have BREIN, which is the anti piracy company.

This asshole tim kuik has,

a. destroyed the piratebay for the whole world (even though it's recuping soon)
b. have done a million requests on removing uploaded movies (on newsgroups)

I really went OT all the way at this reply xd but you get my point :good:

The product gets made, then infected by the creator, then gets forced to merge nsa crap. after that it goes to the carrier which installs even more crap.

there is not a single bit of freedom left

The NSA can screw a cow. USA is Freedom? Like hell. I live here and am starting to become ashamed of my country. I hate the government, more directly this president. Anyway, whats a VPN Interceptor? Sounds scary.. :eek:

But about the OP, can you build an Odin tar with the older Bootloaders in and newer system images to remove knox warranty and allow users to upgrade without screwing themselves? Last i checked, you needed a way to sign the tar file to match with the current bootloader checking.
 

sorg

Senior Member
Sep 5, 2006
1,059
1,136
台灣
the CSC is really nothing important:

CSC is "Country/Carrier Specific Config", not "common short code" ;)
While it's not so important, skipping it may produce many side effects in normal work.

The common way to deal with CSC is extract it and pre-integrate into system - that's what stock recovery is doing upon first boot after flash.
 

garwynn

Retired Forum Mod / Inactive Recognized Developer
Jul 30, 2011
5,179
8,589
NE Ohio
www.extra-life.org
CSC is "Country/Carrier Specific Config", not "common short code" ;)
While it's not so important, skipping it may produce many side effects in normal work.

The common way to deal with CSC is extract it and pre-integrate into system - that's what stock recovery is doing upon first boot after flash.

This doesn't always work. I used to try this with rooted dump/repacks for S4, N2 and E4GT and we got mixed results not including Samsung's cache.img. In Sprint's case this defaulted the carrier to XAS, an internal use only code that doesn't fully enable everything for Sprint. I don't recall if this was on images with a blank data.img only or "nodata" cases as well.
 

sorg

Senior Member
Sep 5, 2006
1,059
1,136
台灣
This doesn't always work. I used to try this with rooted dump/repacks for S4, N2 and E4GT and we got mixed results not including Samsung's cache.img. In Sprint's case this defaulted the carrier to XAS, an internal use only code that doesn't fully enable everything for Sprint. I don't recall if this was on images with a blank data.img only or "nodata" cases as well.

I've did it on GT-I9100, GT-I9300, SHV-E210K, GT-N7100, SHV-E330S. It worked always. Sometimes CSC is multi-CSC where you have to choose correct version.
I didn't use operator-specific models. So probably some additional steps required. But anyway, CSC from cache partition is simply copied to system by recovery. To be more precise, you can check command file in cache.img - this is where "magic" happens :)
 

navdeepavi

Senior Member
Jun 13, 2010
113
22
Punjab
Hi devs, i first time cooked prerooted deodexed rom from stock 4.4.2 rom using cygwin and andriod kitchen. every thing went well. my only question is can i remove modem from output zip as i don't want to use that modem.
 

Surge1223

Recognized Contributor
Nov 6, 2012
2,622
7,466
Florida
Google Pixel 6 Pro
As a follow up to the status 7 error, I spent quite a while figuring out what caused it and how to solve it. I posted this on another thread but ill quote myself here.

The status 7 failed to mount /preload error and why it happens:

Lets take a minute to go over why this happens and what it means. First what is /preload anyways? Well lets take a look at how it gets mounted, consider mount points below:


mount("ext4", "EMMC", "/dev/block/platform/msm_sdcc.1/by-name/system", "/system");

mount("ext4", "EMMC", "/dev/block/platform/msm_sdcc.1/by-name/hidden", "/preload");
We can infer from the point arguements that /preload is the mount point for the "hidden" partition. Well then what is this "hidden" partition then you ask? Well hidden contains some useless crap Samsung uses to verify integrity of the system partition when in recovery

So the idea is to wipe data/factory reset in recovery followed by making sure to flash hidden.img.ext4 prior to cache.img.ext4. I think my inclusion of cache.img.ext4 on accident in the first tar is the root of the cause so ive uploaded a new one that doesnt contain it so it wont fail at step 1.

So essentially you cant flash a a full-wipe or no-wipe Odin tar to go back. You have to use a custom made Odin tar. Also for people getting the status 7 error where /preload fails to mount after flashing cache the solution is to boot into stock recovery and factory data reset followed by flashing hidden.img.ext4 via Odin or Heimdall.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 4
    Hello XDA-san

    This is my first time working with cygwin and Android Kitchen and I wanted to make sure I didn't miss anything that will royally brick my s4. I have attached screenshots of my journey for reference.

    I started with the stock ROM from you know where, version 4.4.2 (i337MOYAFNC1) and proceeded to remove the KNOX bootloader (using instructions from SilviuMik). I skipped the last step where it is re-md5, to continue on to the kitchen..

    Using the de-knoxed tar file, I created a working folder for the ROM in the kitchen. It started unpacking, everthing went well. When i was prompted to choose if I wanted to extract the CSC, I said no.. because the DiskInternals Linux reader was giving me an error saying along the lines of cant read disk..

    From my working folder, I proceeded to root & busybox, all went well. I then deodexed both the system apps and framework, all went well.

    lastly, I made a build from the working folder. Selected all default options while doing so (see pictures) , signed the freshly minted rom and voila.

    :cowboy:
    3
    One caveat to this, and this mostly applies to Verizon and AT&T users, but if you have upgraded to KitKat and kept root using SuperSu's survival mode and your planning to test a rom using Safestrap, you better make sure that the su binary is in xbin and bin (.ext/.su) and that the Superuser.apk is in /system/app. Also make sure that the permissions are set correctly for su (chmod 06755 chown 0.0) and have busybox in the rom as well, or at least have busybox install in the updater-script and make sure everything symlinks correctly.

    The best thing to do when testing roms to avoid having to worry about losing root is to download Chainfire's SuperSu zip and flash it after you flash your rom you're testing (but before it reboots into the rom for the first time) the reason I even mention all of this is because currently we (Verizon and AT&T users) have no way to root a device thats taken a complete 4.4.2 OTA.

    Seriously? wow, thanks for mentioning, I can't believe what a pricks Verizon and AT&T are. Same count for Samsung that handles knox regulation in the USA (while not in other countries). In the USA you get pretty much screwed by the carriers and manufacturers the hard way.

    In The Netherlands (where I live) it's even illegal to sell smartphones that are not unlocked by default. and the only thing a carrier may do is adding a CSC (Consumer Software Customization) package. This should be in the USA as well!

    In the USA companies get to private / independent it seems. they should be regulated by national government rules. instead of making their own. (this keeps the crap like the problem you described away)

    But Samsung should be regulated as well, there is no chance that will happen (south-korea), and their phones will contain more and more backdoors / suspicious daemons / methods of screwing you and so on, because who checks it, no one. Oh yes only someone, the NSA that adds even more of this stuff, like a VPN Interceptor, which no one is waiting for as well.

    Anyways, life (or actually companies) is (are) a *****. Only strict regulation could solve this, but who still believes in regulation after seeing what the NSA all did, they broke like every single rule and forced companies to merge their crap (most likely, or a huge payment, but no single company actually likes that)
    - NSA 'was allowed' to break in all PC's because that where outside the USA. that just ridiculous but true
    - NSA applied their 'jizz' to all super famous apps like Facebook.

    Even though it sounds like I say USA is the culprit thats not true, The netherlands have BREIN, which is the anti piracy company.

    This asshole tim kuik has,

    a. destroyed the piratebay for the whole world (even though it's recuping soon)
    b. have done a million requests on removing uploaded movies (on newsgroups)

    I really went OT all the way at this reply xd but you get my point :good:

    The product gets made, then infected by the creator, then gets forced to merge nsa crap. after that it goes to the carrier which installs even more crap.

    there is not a single bit of freedom left
    2
    Hi broodplank1337, thhank you for your reply

    So would it be better to go into my newly minted zip file and hunt down the knox apks / dependencies? Or should I flash the ROM then use root browser to get rid of them?

    I found this list "

    Delete the files in the following files in this order.


    /system/app/KNOXAgent.apk
    /system/app/KNOXAgent.odex
    /system/app/KLMSAgent.apk
    /system/app/KLMSAgent.odex
    /system/app/KnoxAttestationAgent.apk
    /system/app/KnoxAttestationAgent.odex
    /system/app/KNOXStore.apk
    /system/app/KNOXStore.odex
    /system/app/ContainerAgent.apk
    /system/app/ContainerAgent.odex

    /system/lib/libknoxdrawglfunction.so

    /system/app/ContainerEventsRelayManager.apk
    /system/app/ContainerEventsRelayManager.odex
    /system/app/KNOXStub.apk <--- delete if you have, some will not


    Delete the following folders

    /system/containers
    /system/preloadedkiosk
    /system/preloadedsso

    /system/etc/secure_storage/com.sec.knox.store
    /data/data/com.sec.knox.seandroid
    /data/data/com.sec.knox.store
    /data/data/com.sec.knox.containeragent
    /data/data/com.samsung.android.walletmanager

    Oh I thought you were building an odin rom? zip you say?
    Anyways, just remove em from the system folder and test it's result. You can always test roms without damaging your device at any time, read: it's impossible for a ROM to brick a phone, the thing that can brick it is the kernel, but only if using a kernel from an other device or so.

    so don't be afraid to test it, if it doesn't work just continue your work. if it works, good joob ;)
    1
    If the repacking was successful there is not much to fear about.

    (You may want to lookup if there is any dependents (in the rom) by using the removed knox bootloader (atleast remove the knox apks I guess)

    the CSC is really nothing important:

    A common short code (CSC) is a short telephone number, usually consisting of five digits, that is used to address SMS and MMS messages from a cellular telephone. Common short codes may also be called mobile short codes or short numbers. Each common short code is designed to be unique to each operator.

    Just include the one from the stockrom. btw, I have successfully manually unpacked the CSC file a year ago or so with simg2img, it only contained crap (samsung only files for altering behavior in TW rom and bloatware), the hidden partition or preload partition may also contain unwanted crap btw

    So go ahead and flash it, your phone will not get bricked by this in any way.
    1
    Oh I thought you were building an odin rom? zip you say?
    Anyways, just remove em from the system folder and test it's result. You can always test roms without damaging your device at any time, read: it's impossible for a ROM to brick a phone, the thing that can brick it is the kernel, but only if using a kernel from an other device or so.

    so don't be afraid to test it, if it doesn't work just continue your work. if it works, good joob ;)

    One caveat to this, and this mostly applies to Verizon and AT&T users, but if you have upgraded to KitKat and kept root using SuperSu's survival mode and your planning to test a rom using Safestrap, you better make sure that the su binary is in xbin and bin (.ext/.su) and that the Superuser.apk is in /system/app. Also make sure that the permissions are set correctly for su (chmod 06755 chown 0.0) and have busybox in the rom as well, or at least have busybox install in the updater-script and make sure everything symlinks correctly.

    The best thing to do when testing roms to avoid having to worry about losing root is to download Chainfire's SuperSu zip and flash it after you flash your rom you're testing (but before it reboots into the rom for the first time) the reason I even mention all of this is because currently we (Verizon and AT&T users) have no way to root a device thats taken a complete 4.4.2 OTA.