[Galaxy S II General] hawkerpaul:
There's been quite a bit of discussion lately regarding modems and the Radio Interface Layer (RIL)

The usual modem CWM files install the modem.bin file and nothing else. Ideally your modem's RIL files should also be installed, as the modem and RIL should be fully compatible with each other in order for it to work optimally. If they are not matching, you may (emphasis on the "may"!!) not be getting the most out of your modem.

For this modem/RIL compatibility, other files that came bundled in official firmware for its particular modem are required.

The app GetRIL attempts to rectify this problem.

These modem-particular files are (and I'm still looking for more possibilities):

1. /system/lib/libril.so

2. /system/lib/libsec-ril.so

3. /system/lib/libsecril-client.so

4. /system/lib/libsecril-client-sap.so(4.0.4+)

5. /system/bin/drexe (thanks to E:V:A)

(Filenames containing "sec" means "Samsung Electronics Corporation" by the way)

The above RIL files can be obtained from official firmware .md5 file (or your custom ROM's zip file) and are particular to whichever verison of modem it was bundled with. So for example, if a firmware was bundled with XXLPX modem, the RIL files in the lib folder will be the files particular to the XXLPX modem (unless a ROM developer has put in a modem.bin in the installer zip that differs to that of the original firmware....be aware of this possibility.)

I assume all the modem CWM files that we have been installing in the past have been created by the general public who have downloaded firmware and posted up a convenient modem flash file, so I have now created a more complete modem flashable file that does Modem+RIL.

The scripts I've written install the modem as normal, but also install the system/lib files, thereby installing a modem with 100% correct RIL. The script also backs up the current RIL files to internal sd card under MyBackups folder.

What will a modem with matching RIL give me?

It almost certainly will not improve your signal strength. My findings are however suggesting you have an improved chance of obtaining better network connectivity (eg. E, G, 3G, H, H+). For example, I am now consistently getting a H+ connection where previously I would only be getting H at best. This will obviously improve your speeds during browsing, and my findings are also suggesting that the better the network connection, the more chance you have for Fast Dormancy to work as it should, thereby saving battery.

Only flash Modem/RIL taken from 4.1.2 onto 4.1.2. Do NOT flash these on previous versions as they will not work properly.

It is also recommended NOT to flash Modem/RIL taken from firmwares previous to 4.1.2 onto 4.1.2.

If you want to try older modems on 4.1.2, then flash MODEM ONLY WITHOUT RIL.

These Modem/RIL files have been extracted from official Samsung firmwares.

Do not

attempt to flash Modem/RIL files onto CM/AOSP/AOKP based ROMs as results cannot be guaranteed. You may end up with no network or baseband if you flash on anything other than Samsung based ROMs, so do so at your own risk!!!!

The following Modem+RIL combinations have been uploaded so far:

Android 4.1.2

BULS1 (Taken from XWLSD) (Vodaphone)

BVLS2 (Taken from ORALSS GT-I9100P) (Orange)

BVLS4 (Orange UK)

DDLS9 (XWLSK India)

JHLS2 (Taken from JHLS4)

NELS1 (H3G Italy, 3UK)

T_JJLS2

UGMA5

UHMS1 (Taken from UHMS8)

XXLS8 (Taken from XWLS8)

XXLS6 (Taken from XXLSJ JB leak)

XXLS9 (Taken from XWLSH)

XXMS2 (Taken from XWLSN)

XXMS3

XWMS3 (Taken from XWLSW)

ZSLSJ

Android 4.0.4

BOLP7 (T-Mobile-Germany)

BOLP9 (T-Mobile-Germany)

BVLPE (Orange-UK)

BULPG (Vodafone-Germany)

DDLPB

JHLPC (Orange-Israel)

NELP4 (Three-UK)

UHLPH

XXLQ5

XXLQ6

ZSLPN

ZSLPQ

Android 4.0.3

BOLP5

BOLP7 (T-Mobile-Netherlands)

BULP6 (Vodafone)

BULP7 (Vodafone)

DVLP3 (Telstra-Australia)

BVLP7 (Orange-UK)

BVLPD (Orange-Romania)

T_DCLP4 (Thailand)

DDLPA

T_DOLP4 (Telecom-New Zealand)

DULP4

DXLP7

DXLP9

DXLPA

JHLP9 (Orange-Israel)

T_JJLP8 (Pelephone-Israel)

T_HZLP2 (Mirs-Israel)

MUGLD3

NELP2 (3-UK)

NELP3 (3-UK)

NELP4 (3-UK)

UHLPG

XXLPW

XXLBR (O2-UK)

XXLPS

XXLPX

Android 2.x (GB)

XXKI4

XXKH3

Downoad Here

Download Here

My HUGE thanks goes out to ApriliaM3 for hosting the scripts.

Please give him the thanks he deserves. :)

Big thanks go out to all the contributors below for providing the following ModemRIL scripts: :good:

adotkdotjh: UGMA5

ApriliaM3: BOLP5, DXLPA, NELP3, ZSLPQ

Bieniu: XXLQ5

Christian Nothing: BULS1 (modem only)

codebeard: T_HZLP2, T_JJLP8, T_JJLS2, T_DCLP4, T_DOLP4 (all for GT-I9100T)

citytrader: UHLPH, XXLPS, ZSLPN

diffusal: DULP4

dmagician: JHLS2

FeuchtVonLipwig: BOLP7

gGabi: JHLP9, JHLPC

goolby: XXKH3

Hayth: NELS1 (3 UK)

Ibsonic: BOLP7

lmihaila: BVLPD

Juzman: DVLP3, XXLPS (includes libril.so)

Kenzneth

krezee: DDLPB

luigimak: DDLS9, NELS1, UHMS1, XXLS9, XXMS2

l_ryuzaki: DDLPB (India)

luigimak: BVLS4, XXMS3

mattisfaction: NELP2, NELP4, XXLBR

n-zocker: BOLP9

rogers11: BULP6, BULP7, BULPG

tom_car: DXLP9, DXLP7

sefrcoko: MUGLD3

tariq2kn: XXLS9

Troubadour666: XWMS3

Zaldi00: 250S-LPO, 250K-LPO (Korea)

Uploaded by myself: BULS1, BVLS2, BVLP7, BVLPE, DDLPA, NELP4 (from XWLPY), UHLPG, XXKI4, XXLQ6, XXLPW, XXLPX, XXLS6, XXLS8

(T_) - GT-I9100T-specific modems

After flashing you should have a compatible Modem/RIL combination.

NOTE: As you would now be using Samsung's intended RIL files for your modem, if you run GetRIL after running a ModemRIL script and GetRIL reports a mis-match after flashing one of the ModemRIL scripts, then barring a mistake by Samsung themselves or the script's author by building RIL files from a different modem/firmware, then it is a problem with GetRIL's database and/or logic on how it decides if there is a mis-match.

Backup of RIL Files

If a ModemRIL installer has been created for the original modem that was bundled with your firmware, then dont worry at all about backup/restore. The appropriate ModemRIL file is the best method to get you back onto your firmware's intended setup. However you can still use the backup/restore scripts below if desired.

The intended method of backing up your RIL files is to keep a copy of your firmware's original RIL files. To achieve this, it is best to get into the habit of flashing RIL-Backup once you have flashed new firmware before you start playing about with different modems. This only becomes a necessity if a ModemRIL installer has not yet been created for the firmware's original modem. If one has been created, I wouldn't worry about it too much, but you may still want to run RIL-Backup as habit. RIL-Backup will remove any existing backup found and create a copy in /sdcard/MyBackups/BackupRIL. This way, you can always revert back to the intended RIL of your firmware if need be. As a safeguard, my ModemRIL scripts will also backup the current RIL files if no previous backup was found. If a backup is detected, then it will be skipped. Just remember if you rely on the backup created by ModemRIL scripts and do not use RIL-Backup after flashing a new ROM, then the restore may not necessarily be of the original RIL files that came with your new firmware.

RIL_Backup will force a backup of your current RIL files. Remember, best practice is to run this once directly after flashing new firmware/ROM, before installing different modems.

Restore RIL Files

If you need to restore back to your original/previous modem/RIL then simply run the ModemRIL script from this thread for that modem.

If a ModemRIL installer has not been created for the modem you need to revert back to, then you can run the RIL-Restore script. You will then need to flash the previous modem using a modem-only CWM flashable file.

RIL_Restore will attempt to restore the original RIL files backed up by RIL-Backup or by one of these scripts.

Note on possibe BootLoops

The modem.bin and all the RIL files contained in the ModemRIL scripts came from whichever firmware the modem was bundled within. Therefore it is possible that there could be issues if trying to install these on anything other than the firmware version that the modem/RIL originated from. This is why the originating firmware version is stated above. I can only test on my current ROM (NEAT LPI which is ICS 4.0.3). If after flashing there is incompatibility issues with your particular firmware version, the best course of action would be to flash the ModemRIL file for your firmware's original modem.

I only want to install the Modem without RIL

If you just want to install the modem only from any of the Modem+RIL files then:

1. Download the Modem_RIL.zip file you require

2. Create your Modem-only zip from this

This modem-only zip file can be created in one of two ways:

I already have a Modem-only zip file but for another modem

1. Rename this (or copy) to Modem_xxxxx.zip for the Modem you are wanting to flash

2. Open this zip file along with the Modem_RIL file you just downloaded with 7Zip

3. Ensure you can see a file called modem.bin in both archives

4. Drag the modem.bin file from the Modem_RIL file into the Modem_xxxxx.zip file

5. Save+exit

6. Flash Modem_xxxxx.zip through CWM

I don't have any Modem-only zip files

Simply remove the system folder from the Modem_RIL zip file:

1. Rename (or copy) ModemRIL_xxxxx.zip to Modem_xxxxx.zip

2. Open the zip with 7Zip

3. Right click the system folder and choose Delete

4. Exit 7Zip. You will now be good to go for a modem-only flash

5. Flash Modem_xxxxx.zip through CWM

However, for completeness you may want to also change the updater-script accordingly. To do this:

1. Get hold of an updater-script from an existing modem-only zip

2. If you don't have one, download updater_script_Modem_Only and rename this file to updater_script

3. Open your Modem_xxxxx.zip file and navigate to META-INF/com/google/android

4. Drag+drop updater-script into the zip

If you don't change the updater-script, then there is no harm done. No RIL will be installed (as its been removed from the zip), you will just see RIL-related messages in the installer which you can ignore.

How to make your own ModemRIL script

Step 1 - Get the files you need

You need to use the zip/tar/md5 file of the original ROM so that we know we have a RIL that is best suited to the modem it came bundled with. From this you can extract the modem.bin file, and also all the required RIL files listed above.

Extract files from a custom ROM (.zip)

You can very easily extract the necessary files from a custom ROM (Eg. Neat ROM)

1. Open the zip file by using 7Zip

2. Find modem.bin and drag it onto your desktop

3. Navigate to /system/lib and /system/bin

4. Drag the files mentioned above to your desktop

To get the required files from an official Samsung download (.tar.md5) file is a little more tricky:

Extract files from an official Samsung download (.tar.md5)

For this you will need the following installed on your PC:

Java Runtime, sgs2toext4.jar and Linux Reader from www.diskinternals.com.

It will be easier for later if you create a shortcut on your desktop to the DiskInternals Linux Reader

1. Open the md5 file, open it with 7Zip and extract modem.bin and factoryfs.img (ignore any no current record error)

2. Double click sgs2toext4.jar (you need to have java installed on your PC for this to work)

3. Drop the file factoryfs.img file inside sgs2toext4.jar This will generate factoryfs.ext4.img

4. Drop factoryfs.ext4.img onto your DiskInternals Linux Reader shortcut you created on your Desktop. This will open the app.

5. Double click Linux Ext Volume 1 (or similar)

6. Navigate to the /system/lib and /system/bin folders and look for the RIL files above. Android 4.0.4+ will have file (4.). Save these files to your PC.

At this point you should now have the neccessary files saved onto your PC. Ie:

modem.bin

/system/lib/libril.so

/system/lib/libsec-ril.so

/system/lib/libsecril-client.so

/system/lib/libsecril-client-sap.so (4.0.4+)

/system/bin/drexe

You can now use these files to create your own ModemRIL installer script:

Step 2 - Build the script

1. Download any one of the existing ModemRIL scripts and make a copy. For my personal template, use BVLP7.

2. Rename this copy to the ModemRIL you are going to build

3. Open the .zip file with 7Zip

4. At the root of the zip, drop your modem.bin file so that the existing version of this file is overwritten

5. Navigate into the system/lib folder

6. Remove all the existing (.so) files

7. Drop any lib files you saved into this folder.

8. Navigate into the system/bin folder

9. Remove all the existing files

10. Drop any bin files you saved into this folder.

The ModemRIL zip file is now done. The following steps are optional, but recommended for completeness and to avoid confusion when installing:

8. Go back up to the root folder and navigate to META-INF/com/google/android

9. Drag+drop the file called updater-script onto your desktop

10. Right click this file and edit this with Notepad++. Do not edit with Windows Notepad, as you will corrupt the carriage-return characters.

11. Edit the 4th line of this file to show the name of the modem/RIL you are building

12. Save the file in Notepad++

13. Drag the amended updater-script file back into your open zip archive, overwriting the existing script

You're done!

Changelog

16/10/2012

* New backup logic. RIL files are now only backed up once. ModemRIL script will skip the backup if a backup is found.

* RIL_Backup.zip intended to be run after flashing a new ROM, or to force a RIL backup

24/09/2012

* Include /system/bin/drexe

* Backup of existing RIL files made to internal (not external) SD Card

Note on Changelogs

The latest changes above have been incorporated into the ModemRIL files that I have uploaded.

They may not necessarily be included in files uploaded by other contributors. It is up to individual contributors to decide whether or not to include any of my changes in the scripts they have uploaded

Latest scripts

Below are links to the latest versions of scripts/shells which can be used for building a ModemRIL installer.

For an example zip to use for your overall template, use BVLP7 then edit as per the instructions above.

updater-script (main installer script)

BackupTest.sh (test for existing backup)

BackupRIL.sh (backup current RIL if no previous backup)

Below are links to the latest versions of scripts/shells which can be used in RIL-Backup:

updater-scipt (rename to updater-script)

BackupOrigRIL.sh (forces backup of RIL files)

Below are links to the latest versions of scripts/shells which can be used in RIL-Restore:

updater-script (rename to updater-script)

RestoreRIL.sh (restores backed up files)

Feel free to use my scripts as installer templates to create your own ModemRIL CWM zip files for different modems.

Just make sure you link them up on here to share for everyone! :D

Modem-only related links

pulser_g2/geko95gek GS2 Shipped modem collection

Veyka's Index of GS2 Radios

Pan24's modem links

Turkbey's modem links