Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
View Poll Results: Will this work or will I royally #$%# my phone
Yes 10 58.82%
No 1 5.88%
Maybe 3 17.65%
I don't know 3 17.65%
Voters: 17. You may not vote on this poll

Post Reply

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

OP The French Tickl3r

20th March 2014, 05:32 PM   |  #1  
The French Tickl3r's Avatar
OP Senior Member
Flag Montreal
Thanks Meter: 29
 
172 posts
Join Date:Joined: May 2013
More
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.

Attached Thumbnails
Click image for larger version

Name:	android kitchen S4 part 1.jpg
Views:	897
Size:	134.1 KB
ID:	2640558   Click image for larger version

Name:	android kitchen S4 part 2.jpg
Views:	753
Size:	226.0 KB
ID:	2640559   Click image for larger version

Name:	android kitchen S4 part 3.jpg
Views:	644
Size:	140.0 KB
ID:	2640560   Click image for larger version

Name:	android kitchen S4 part 4.jpg
Views:	553
Size:	185.1 KB
ID:	2640561   Click image for larger version

Name:	android kitchen S4 part 5.jpg
Views:	496
Size:	121.4 KB
ID:	2640566   Click image for larger version

Name:	android kitchen S4 part 6.jpg
Views:	484
Size:	161.9 KB
ID:	2640567   Click image for larger version

Name:	android kitchen S4 part 7.jpg
Views:	488
Size:	155.0 KB
ID:	2640568   Click image for larger version

Name:	removing KNOX from Stock S4 Kitkat.jpg
Views:	496
Size:	118.3 KB
ID:	2640569  
The Following 3 Users Say Thank You to The French Tickl3r For This Useful Post: [ View ]
20th March 2014, 06:13 PM   |  #2  
broodplank1337's Avatar
Recognized Contributor / Recognized Developer
Flag Nijmegen
Thanks Meter: 10,090
 
4,943 posts
Join Date:Joined: Nov 2011
Donate to Me
More
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:

Quote:

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.
The Following User Says Thank You to broodplank1337 For This Useful Post: [ View ]
20th March 2014, 07:10 PM   |  #3  
The French Tickl3r's Avatar
OP Senior Member
Flag Montreal
Thanks Meter: 29
 
172 posts
Join Date:Joined: May 2013
More
Info 2
Quote:
Originally Posted by broodplank1337

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
21st March 2014, 01:35 PM   |  #4  
broodplank1337's Avatar
Recognized Contributor / Recognized Developer
Flag Nijmegen
Thanks Meter: 10,090
 
4,943 posts
Join Date:Joined: Nov 2011
Donate to Me
More
Quote:
Originally Posted by The French Tickl3r

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
The Following 2 Users Say Thank You to broodplank1337 For This Useful Post: [ View ]
23rd March 2014, 02:01 AM   |  #5  
Surge1223's Avatar
Recognized Contributor
Flag Iowa
Thanks Meter: 4,637
 
1,815 posts
Join Date:Joined: Nov 2012
Donate to Me
More
Quote:
Originally Posted by broodplank1337

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.
The Following User Says Thank You to Surge1223 For This Useful Post: [ View ]
23rd March 2014, 04:01 AM   |  #6  
broodplank1337's Avatar
Recognized Contributor / Recognized Developer
Flag Nijmegen
Thanks Meter: 10,090
 
4,943 posts
Join Date:Joined: Nov 2011
Donate to Me
More
Quote:
Originally Posted by Surge1223

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 bitch. 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

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 Following 3 Users Say Thank You to broodplank1337 For This Useful Post: [ View ]
25th March 2014, 09:52 PM   |  #7  
The French Tickl3r's Avatar
OP Senior Member
Flag Montreal
Thanks Meter: 29
 
172 posts
Join Date:Joined: May 2013
More
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..
26th March 2014, 01:25 AM   |  #8  
elesbb's Avatar
Senior Member
Thanks Meter: 4,441
 
6,900 posts
Join Date:Joined: Jun 2010
Donate to Me
More
Quote:
Originally Posted by broodplank1337

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 bitch. 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

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..

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.
27th March 2014, 01:44 AM   |  #9  
Senior Member
Flag 台灣
Thanks Meter: 687
 
763 posts
Join Date:Joined: Sep 2006
More
Quote:
Originally Posted by broodplank1337

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.
27th March 2014, 02:55 AM   |  #10  
garwynn's Avatar
Forum Moderator / Recognized Developer
Flag Chi-town
Thanks Meter: 7,797
 
4,780 posts
Join Date:Joined: Jul 2011
Donate to Me
More
Quote:
Originally Posted by sorg

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.

Post Reply Subscribe to Thread

Tags
android kitchen, i337m, knox, rogers, rooting
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes