Building the kernel for the Nexus S is straightforward – the kernel is public as one would expect so it’s simply a matter of building it using the standard Linux build system (the machine is called herring in the code). There is one gotcha, though – the driver for the BCM4329 WiFi controller is a loadable kernel module rather than being built into the image. This means you need to copy it onto the device filesystem separately to flashing the kernel itself if you’re only updating the kernel. The procedure I use for this is below – it’s straightforward but I’m posting it here to make it a bit more discoverable.
First we make the system partition writable:
adb root adb remount
Then copy the BCM4329 driver over (the path to the driver here is running from the root of the kernel tree:
adb push drivers/net/wireless/bcm4329/bcm4329.ko /system/modules
Finally, reboot into the bootloader and flash the actual kernel:
adb reboot bootloader fastboot flash zimage arch/arm/boot/zImage fastboot reboot
Note that some of these commands may return before the operation they’ve started has completed so you may need to wait for the phone at various points.
As with updating the main system firmware the above requires an unlocked device which voids your warranty.