[Samsung Galaxy Nexus] josteink:
Radio grabbing and trimming tools

Glad you asked! :p

Just to prove to myself that I can still do something in C when that is in fact the right tool for the job, I created a radio-trimmer.

The tool can be found on the following URL:

tgz: http://nexfiles.kjonigsen.net/tools/radiotrim.tgz

zip: http://nexfiles.kjonigsen.net/tools/radiotrim.zip

Also: Source now on Github.

(Both files contains the same. If in doubt, DL the ZIP.)

Source is included, so that you know what you are running. If you are one of the guys who cares about that kinda stuff. Which you should. Because running some random dude on the internet's code is pretty freaky.

Back to the stuff at hand: Current version is built for Linux 32-bit and Windows, but the C-file uses nothing non-standard and should easily build in any other friendly environment.

For Windows-users: The steps below assumes Linux. Adapt as required. It shouldn't be rocket-science.

Try to see if it works first. Unpack the files, and check that it works on your machine. Try running it in a console. Correct output should be a usage statement:

$ ./radiotrim
# lotsa text
usage: ./radiotrim input.img output.img
$ ./i9250radiograbber
# lotsa text
usage: ./i9250radiograbber output.img
$
# it works

If this is not the output, chances are you need to compile it from source. Don't worry. It's surprisingly easy. The following example assumes Debian-based distro and gcc as a compiler. Adapt as needed:

$ sudo apt-get install build-essential
# this will take some time
$ gcc radiotrim.c -o radiotrim
$ gcc i9250radiograbber.c -o i9250radiograbber
# quickly done
$

Try running it again like in the example above, and see if it works now. If it does, you are good to go.

(If you manage/bother to put up a platform-specific build not here (Mac, Arm, etc), please do submit it :) )

Next: If you want to grab a radio, not just trim a pre-existing one, ensure that you have adb working and ready, as the grabber depends on this. Adb needs to be in your path.

Connect you phone via USB and execute the following:

$ adb devices
List of devices attached
02343B0C11018018 device

$

Reported serial doesn't matter. What's important is that your phone shows up. If it doesn't google the internet to figure how to make adb work in your environment.

Now. With all that out of the way, you should be ready to rip your radio.

In a console window, enter the directory where you unpacked the stuff, and grab your radio. On my machine it looks like this:

Grabbing radio from phone and trimming it

$ ./i9250radiograbber radio.img

Samsung Galaxy Nexus I9250 radio-image grabber.
Grabbing started...
49153+0 records in
49153+0 records out
12583168 bytes transferred in 12.724 secs (988931 bytes/sec)
3042 KB/s (12583168 bytes in 4.038s)
Radio grabbed successfully.
Detected baseband name: SC04DOMLA1

$

The resulting file, radio.img, is your ripped and trimmed radio, in fastboot format. Voila!

Manually grabbing a image

If for some reason the util above doesn't work, you can manually grab an image and then trim it later. With the phone hooked up via USB, do the following:

$ adb shell
# == inside adb shell ==
$ su
# dd bs=256 count=49153 if=/dev/block/platform/omap/omap_hsmmc.0/by-name/radio of=/sdcard/radio.img
49153+0 records in
49153+0 records out
12583168 bytes transferred in 11.365 secs (1107185 bytes/sec)
# exit
$ exit
# == adb shell exited ==
$ adb pull /sdcard/radio.img .
# done

Note: This image has been extracted with its correct length. It doesn't need to be trimmed.

You can use the trimming to verify that it has been extracted correctly though, as this will output its recognized baseband name.

Trimming a preexisting radio-image

This is just as easy. In a console, just specify the source and the destination file and you are pretty much done.

$ ./radiotrim radio.img trimmed.img

Samsung Galaxy Nexus I9250 radio-image trimmer.
radio.img opened successfully.
Detected baseband name: SC04DOMLA1
Creating trimmed copy trimmed.img (12583168 bytes).

$

To package it in a CWM-zip, just take any of the CWM packages found here and replace the radio.img file contained with yours trimmed copy. It may show the wrong name when flashing, but it should work ;)