Downloading the Nexus S kernel source
As of today, the above isn't going to get you the Nexus S kernel source. That's easy to fix:
Code:
$ cd ~/mydroid
$ git clone git://android.git.kernel.org/kernel/samsung.git
Now you can go into that directory in your Android source tree:
Now the building. Copy and paste these lines into your terminal. BE SURE TO EDIT YOUR EXPORT COMMAND WITH THE CORRECT PATH!
Code:
export PATH=$PATH:/home/[B][COLOR="Red"]<your username>[/COLOR][/B]/mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/
make ARCH=arm clean
make ARCH=arm herring_defconfig
make -j4 ARCH=arm CROSS_COMPILE=arm-eabi-
This builds the kernel, as well as the wireless module. It takes a few minutes, depending on your computer. If it hasn't stopped and spit out an error, it's not done

You find your kernel at:
~/mydroid/samsung/arch/arm/boot/zImage
The wlan module is at:
~/mydroid/samsung/drivers/net/wireless/bcm4329/bcm4329.ko
Next you need to package it up to test. I can't get a zImage to boot via fastboot on the NS, so you'll have to pack up a boot image. Download the attached file, and extract it. Put fastboot in your SDK/tools folder (if you don't have it) and place the unpack-bootimg.pl script and the mkbootimg binary into a folder in your home called NS-bootwork. Copy your zImage in there, too.
Now pull the boot image from your phone, either via adb or from a terminal app:
Code:
cat /dev/mtd/mtd2 > /sdcard/boot.img
Copy the boot.img from your Nexus S to your NS-bootwork folder, then it's time for more term c/p
Code:
cd ~/NS-bootwork
./unpack-bootimg.pl boot.img
cd boot.img-ramdisk/
find . | cpio -o -H newc | gzip > /home/[B][COLOR="Red"]<your username>[/COLOR][/B]/NS-bootwork/boot.img-ramdisk/ramdisk-repack.cpio.gz
cd ..
./mkbootimg --kernel zImage --ramdisk /home/[B][COLOR="Red"]<your username>[/COLOR][/B]/NS-bootwork/boot.img-ramdisk/ramdisk-repack.cpio.gz --base 0x30000000 --pagesize 4096 -o newtestboot.img
thanks to whoever originally created the unpack Perl script. If it was you, or you know who did, for the love of God let me know so I can thank them.
Now to test it

Take the newtestboot.img you just made, and put it in your SDK/tools folder. Shut your phone off, connect it to your computer, then hold volume up + power to enter fastboot. From the terminal (told you i love it)
Code:
cd ~/android-sdk-linux_86/tools
sudo fastboot boot newtestboot.img
<password>
If it boots, you won't have Wifi because we haven't pushed the kernel module over yet. But take the time to open settings>about phone and admire your own kernel showing there. Smoke a cig, have a beer, whatever you need to do to celebrate. If it doesn't boot, just pull the battery and reboot. We only told the phone to boot this one time from your new image, and the next boot will have you back where you started.
If it works well and you want to keep it, you need to put the bcm4329.ko (the kernel module) into /system/modules/. This will break wifi for any kernel except the one you have built, so only do it when you're ready to get final.
Then just like before, we're going to use fastboot to copy it over, except this time we flash it permanently.
Code:
sudo fastboot flash boot newtestboot.img
<password>
If you wanna play around with the boot image, and don;t feel like building your own kernel, there's one right here:
NS-kernel_build.tar.bz2
Good luck!
Putting this here so i don't lose it (courtesy of Swetland -- a mighty Googler)
baseaddr 0x30000000
pagesize 4096