Jump to content

Samsung Nexus S (samsung-crespo): Difference between revisions

From postmarketOS Wiki
Romain (talk | contribs)
No edit summary
Changed the text to include the ButtonCombo template, .
 
(13 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{Infobox device
{{Infobox device
| manufacturer = Samsung (Google)
| manufacturer = Google (Samsung)
| name = Nexus S
| name = Nexus S
| codename = samsung-crespo
| codename = samsung-crespo
| image = File:CHANGE_ME_TO_DEVICE_CODENAME.jpg
| image = File:Nexus_S.png
| imagecaption = CHANGE_ME
| imagecaption = Samsung Nexus S
| releaseyear = 2010
| releaseyear = 2010
| originalsoftware = Android 2.3
| originalsoftware = Android
| chipset = Exynos 3 Single 3110
| originalversion = 2.3
| chipset = Samsung Exynos 3110
| cpu = 1.0 GHz Hummingbird
| cpu = 1.0 GHz Hummingbird
| gpu = PowerVR SGX540
| gpu = PowerVR SGX540
Line 14: Line 15:
| memory = 512 MB
| memory = 512 MB
| architecture = armv7
| architecture = armv7
| type = Handset
<!-- the following status_* questions should be answered with Y - yes, P - partial, N - no, or left blank (for untested or unknown) -->
<!-- the following status_* questions should be answered with Y - yes, P - partial, N - no, or left blank (for untested or unknown) -->
| status_usbnet = Y
| status_usbnet = Y
Line 25: Line 27:
| status_battery =  
| status_battery =  
| status_3d =  
| status_3d =  
| status_accel =  
| status_accel = Y
| status_audio = Y
| status_audio = Y
| status_bluetooth = N
| status_bluetooth = N
Line 33: Line 35:
| status_sms = N
| status_sms = N
| status_calls = N
| status_calls = N
| status = <!-- Text displayed in the "not booting" table on the Devices page , e.g "kernel compiles, doesn't boot" -->
| status =
| booting = yes
| booting = yes
| pmoskernel = 3.0.101
| pmoskernel = 3.0.101
Line 40: Line 42:
== Contributors ==
== Contributors ==
* joeblos
* joeblos
* Romain


== Maintainer(s) ==
<!-- Only if this device doesn't run on linux-postmarketos yet! -->
<!-- This person needs to be willing to answer questions from users of this device -->


== Users owning this device ==
== Users owning this device ==
{{Device owners}}
{{Device owners}}
<!-- autogenerated, use {{Owns device|devicepage|notes}} on your profile page -->
<!-- use _ instead of spaces in device page name, e.g. {{Owns device|HTC_Desire_(htc-bravo)|custom notes}}-->
<!-- you may need to purge page cache to see changes (more->purge cache)-->
<!-- you can use {{My devices}} on your profile page to show table with all your devices -->


== How to enter flash mode ==
== How to enter flash mode ==
Hold volup+power to power up in bootloader/fastboot mode.
Hold {{ButtonCombo|Volume Up|Power}} to power up in bootloader/fastboot mode.


== Installation ==
== Installation ==
Line 100: Line 96:
path/to/pmos-samsung-crespo.zip
path/to/pmos-samsung-crespo.zip
$ cp path/to/pmos-samsung-crespo.zip pmos-samsung-crespo.zip
$ cp path/to/pmos-samsung-crespo.zip pmos-samsung-crespo.zip
$ wget https://gitlab.com/joeblos/postmarketos-android-recovery-installer/-/commit/10c161770923649552f29348ea35ff1fa1fcf513.diff -O p1.path
$ wget https://gitlab.com/joeblos/postmarketos-android-recovery-installer/-/commit/10c161770923649552f29348ea35ff1fa1fcf513.diff -O p1.patch
$ unzip pmos-samsung-crespo.zip chroot/bin/pmos_install_functions
$ unzip pmos-samsung-crespo.zip chroot/bin/pmos_install_functions
$ patch pmos_install_functions p1.patch
$ patch chroot/bin/pmos_install_functions p1.patch
$ zip -r pmos-samsung-crespo.zip chroot/bin/pmos_install_functions
$ zip -r pmos-samsung-crespo.zip chroot/bin/pmos_install_functions
</syntaxhighlight>
</syntaxhighlight>
Line 129: Line 125:
<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
$ cat /proc/bus/input/devices
$ cat /proc/bus/input/devices
</syntaxhighlight>
yiels :
<pre>
I: Bus=0000 Vendor=0000 Product=0000 Version=0000
I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="mxt224_ts_input"
N: Name="mxt224_ts_input"
Line 145: Line 136:
                                                                                                                                                                  
                                                                                                                                                                  
[...]
[...]
</pre>
</syntaxhighlight>


The <code>Handlers</code> line indicates that the device file is <code>/dev/input/event0</code>.                                                                                                                           
The <code>Handlers</code> line indicates that the device file is <code>/dev/input/event0</code>.                                                                                                                           


=== Inittab method ===
=== Inittab method ===
Line 183: Line 172:
</pre>
</pre>


<!-- add more sections below as necessary, e.g. WiFi, photos, ... -->
== Sensors ==
=== Gyro ===
 
The gyro is available as an input device :
 
<syntaxhighlight lang="shell-session">
$ cat /proc/bus/input/devices
[...]
I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="gyro"
P: Phys=
S: Sysfs=/devices/virtual/input/input1
U: Uniq=
H: Handlers=event1
B: PROP=0
B: EV=5
B: REL=38
[...]
</syntaxhighlight>
 
Activate the output:
 
<syntaxhighlight lang="shell-session">
$ sudo sh -c "echo 1 > /sys/devices/virtual/input/input1/enable"
$ sudo sh -c "echo 1 > /sys/devices/virtual/input/input1/poll_delay"
</syntaxhighlight>
 
Read it with <code>evtest</code> (you need to install it before)
<syntaxhighlight lang="shell-session">
$ evtest /dev/input/event1
</syntaxhighlight>
 
=== Accelerometer ===
 
On Android the accelerometer data is accessed through a proprietary library. An open source implementation, libakm_free, has been developed (see [https://github.com/ralisi/hardware_libakm_free 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:
<syntaxhighlight lang="C">
/* printf() */
#include <stdio.h>
 
/* ioctl function */
#include <sys/ioctl.h>
 
/* open function */
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
 
/* close function */
#include <unistd.h>
 
/* errno */
#include <errno.h>
 
/* strerror function */
#include <string.h>
 
/* struct kr3dm_accel_data and ioctl parameter */
#include "kr3dm.h"
 
int main(void)
{
        char *name = "/dev/accelerometer";      // device file
        struct kr3dm_acceldata data;            // data structure variable
        int fd = -1;                            // file descriptor for accessing device
 
        /* open the device file */
        if ((fd = open(name, O_RDWR)) < 0)
        {
                printf("Error opening file %s\n", name);
                return 1;
        }
 
        while (1)
        {
                /* fill the data structure with ioctl */
                if (ioctl(fd, KR3DM_IOCTL_READ_ACCEL_XYZ, &data) < 0)
                {
                        printf("Error reading the data through ioctl: %s\n", strerror(errno));
                        close(fd);
                        return 1;
                }
 
                printf("X = %d, Y = %d, Z = %d\n", data.x, data.y, data.z);
                usleep(50000); /* wait 50ms = 50 000us */
        }
 
        close(fd);
        return 0;
}
</syntaxhighlight>
 
== GPS ==
 
The Nexus S uses [[Broadcom BCM4751 GPS]].


== See also ==
== See also ==
<!--
* [https://redmine.replicant.us/projects/replicant/wiki/NexusSGTI902x Replicant Device page]
Link to related GitLab issues or merge requests like the following (replace CHANGEME with the ID, e.g. 1234):
* {{Device package|samsung-crespo}}
* {{MR|CHANGEME|pmaports}} Initial merge request
* {{Kernel package|samsung-crespo}}
* {{issue|CHANGEME|pmaports}} Some related issue
You can also add normal web links:
* [https://redmine.replicant.us/projects/replicant/wiki/GalaxyS2I9100 Replicant wiki page]
-->
<!--
If you manage to get your device packages merged, uncomment links below and change DEVICE_CODENAME with the actual one.
* {{Device package|DEVICE_CODENAME}}
* {{Kernel package|DEVICE_CODENAME}}
-->

Latest revision as of 08:31, 13 April 2024

Google (Samsung) Nexus S
Samsung Nexus S
Samsung Nexus S
Manufacturer Google (Samsung)
Name Nexus S
Codename samsung-crespo
Released 2010
Type handset
Hardware
Chipset Samsung Exynos 3110
CPU 1.0 GHz Hummingbird
GPU PowerVR SGX540
Display 480x800 Super AMOLED
Storage 16 GB
Memory 512 MB
Architecture armv7
Software
Original software Android
Original version 2.3
postmarketOS
Category testing
Pre-built images no
Mainline no
postmarketOS kernel 3.0.101
Features
Flashing
Partial
USB Networking
Works
Internal storage
No data
SD card
No data
Battery
No data
Screen
Works
Touchscreen
Works
Multimedia
3D Acceleration
No data
Audio
Works
Camera
Broken
Camera Flash
No data
Connectivity
WiFi
Works
Bluetooth
Broken
GPS
Broken
NFC
No data
Modem
Calls
Broken
SMS
Broken
Mobile data
Broken
Miscellaneous
FDE
No data
USB OTG
No data
HDMI/DP
No data
Sensors
Accelerometer
Works
Magnetometer
No data
Ambient Light
No data
Proximity
No data
Hall Effect
No data
Haptics
No data
Barometer
No data


Contributors

  • joeblos
  • Romain


Users owning this device


How to enter flash mode

Hold Volume Up+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
$ pmbootstrap init
  1. Generate the initramfs
$ pmbootstrap initfs build
  1. Generate the recovery zip without boot partition
$ pmbootstrap install --android-recovery-zip --recovery-no-kernel
  1. Put the device in fastboot mode, by holding volume_up+power for a few seconds
  2. Flash the boot partition
$ pmbootstrap flasher flash_kernel
  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:
    1. Patch the recovery zip
$ find -name "pmos-samsung-crespo.zip"
path/to/pmos-samsung-crespo.zip
$ cp path/to/pmos-samsung-crespo.zip pmos-samsung-crespo.zip
$ wget https://gitlab.com/joeblos/postmarketos-android-recovery-installer/-/commit/10c161770923649552f29348ea35ff1fa1fcf513.diff -O p1.patch
$ unzip pmos-samsung-crespo.zip chroot/bin/pmos_install_functions
$ patch chroot/bin/pmos_install_functions p1.patch
$ zip -r pmos-samsung-crespo.zip chroot/bin/pmos_install_functions
    1. Manually sideload the edited recovery zip
$ adb sideload pmos-samsung-crespo.zip
  1. Done!

Audio

Install alsamixer and a music player:

$ apk add alsa-utils
$ apk add cmus # a console player, only to show music playback works

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 :

$ cat /proc/bus/input/devices
I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="mxt224_ts_input"
P: Phys=
S: Sysfs=/devices/virtual/input/input0
U: Uniq=                                                                                                                                                        
H: Handlers=event0                                                                                                                                              
B: PROP=0
B: EV=9                                                                                                                                                         
B: ABS=6610000 0                                                                                                                                                
                                                                                                                                                                
[...]

The Handlers line indicates that the device file is /dev/input/event0.

Inittab method

Add the following to /etc/inittab:

# fbkeyboard
tty1::respawn:/usr/bin/fbkeyboard -d /dev/input/event0

This spawns a fbkeyboard on tty1

Init script hack method

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

$ sudo vi /etc/init.d/fbkeyboard
[...]
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"
[...]

Sensors

Gyro

The gyro is available as an input device :

$ cat /proc/bus/input/devices
[...]
I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="gyro"
P: Phys=
S: Sysfs=/devices/virtual/input/input1
U: Uniq=
H: Handlers=event1 
B: PROP=0
B: EV=5
B: REL=38
[...]

Activate the output:

$ sudo sh -c "echo 1 > /sys/devices/virtual/input/input1/enable"
$ sudo sh -c "echo 1 > /sys/devices/virtual/input/input1/poll_delay"

Read it with evtest (you need to install it before)

$ evtest /dev/input/event1

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:

/* printf() */
#include <stdio.h>

/* ioctl function */
#include <sys/ioctl.h>

/* open function */
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

/* close function */
#include <unistd.h>

/* errno */
#include <errno.h>

/* strerror function */
#include <string.h>

/* struct kr3dm_accel_data and ioctl parameter */
#include "kr3dm.h"

int main(void)
{
        char *name = "/dev/accelerometer";      // device file
        struct kr3dm_acceldata data;            // data structure variable
        int fd = -1;                            // file descriptor for accessing device

        /* open the device file */
        if ((fd = open(name, O_RDWR)) < 0)
        {
                printf("Error opening file %s\n", name);
                return 1;
        }

        while (1)
        {
                /* fill the data structure with ioctl */
                if (ioctl(fd, KR3DM_IOCTL_READ_ACCEL_XYZ, &data) < 0)
                {
                        printf("Error reading the data through ioctl: %s\n", strerror(errno));
                        close(fd);
                        return 1;
                }

                printf("X = %d, Y = %d, Z = %d\n", data.x, data.y, data.z);
                usleep(50000); /* wait 50ms = 50 000us */
        }

        close(fd);
        return 0;
}

GPS

The Nexus S uses Broadcom BCM4751 GPS.

See also