Samsung Nexus S (samsung-crespo)

Contributors

 * joeblos
 * Romain

How to enter flash mode
Hold volup+power to power up in bootloader/fastboot mode.

Installation
The Nexus S fastboot flasher mode cannot be used to flash the system (rootfs) image, for two reasons:
 * There is a size limit of ~340MB (RAM limitation I assume)
 * The system image generated is rejected by the bootloader (bad magic number error)

So we can use the recovery zip flashing method, except for the boot.img (kernel+initramfs) as the pmos install script fails to correctly find the boot partition.

Thus, we use fastboot to flash the boot.img, and use recovery zip to flash the rootfs.

Here are the instructions:


 * 1) Get a recent TWRP. v2.8.7.0 is known to work. (CyanogenRecovery does not work)


 * 1) Setup your pmos environment


 * 1) Generate the initramfs


 * 1) Generate the recovery zip without boot partition


 * 1) Put the device in fastboot mode, by holding volume_up+power for a few seconds
 * 2) Flash the boot partition


 * 1) Reboot the device in recovery (i.e: TWRP, see above) and enable "ADB Sideload"
 * 2) Until this commit is not merged, the following temp fix is required:
 * 3) Patch the recovery zip
 * 1) Manually sideload the edited recovery zip


 * 1) Done!

Audio
Install alsamixer and a music player:

Open alsamixer, navigate to "Playback Path", change it to `RCV` or `SPK` (`HP` for headphones). Open cmus, add your music, start playback (see cmus manual on how).

fbkeyboard
In order to have a functional fbkeyboard, we need to find the input device associated to the touchscreen :

The  line indicates that the device file is.

Inittab method
Add the following to :

tty1::respawn:/usr/bin/fbkeyboard -d /dev/input/event0
 * 1) fbkeyboard

This spawns a fbkeyboard on tty1

Init script hack method
The  init script doesn't read config parameters, so in order to associate it with the touchscreen, we need to modify it directly (as root) :

[...] command_args="-r $(cat /sys/class/graphics/fbcon/rotate)" [...]

Change this line to :

[...] command_args="-r $(cat /sys/class/graphics/fbcon/rotate) -d /dev/input/event0" [...]

Gyro
The gyro is available as an input device :

Activate the output:

Read it with  (you need to install it before)

Accelerometer
On Android the accelerometer data is accessed through a proprietary library. An open source implementation, libakm_free, has been developed (see this page on Github).

Here is a sample program showing how to access the accelerometer data through ioctl function call using the kr3dm.h header file from libakm_free, based on the code in sensors/kr3dm.c and manpages:

GPS
The Nexus S uses Broadcom BCM4751 GPS.