Samsung Galaxy SII (samsung-i9100)

From postmarketOS
Revision as of 21:07, 30 August 2020 by 10BitAdam (talk | contribs) (Fix some typos)
Jump to navigation Jump to search
Samsung Galaxy S II
First photo ever released of postmarketOS (from the original introduction post).
First photo ever released of postmarketOS (from the original introduction post).
Manufacturer Samsung
Name Galaxy S II
Codename samsung-i9100
Released 2011
Category testing
Original software Android 2.3.4
Hardware
Chipset Exynos 4210 Dual
CPU Dual-core 1.2 GHz Cortex-A9
GPU Mali-400 MP4
Display 480x800 AMOLED
Storage 16/32 GB
Memory 1 GB
Architecture armv7
Unixbench Whet/Dhry score 542.5
Features
USB Networking
Works
Flashing
Works
Touchscreen
Works
Display
Works
WiFi
Works
Xwayland
Works
FDE
Partial
Mainline
Partial
Battery
3D Acceleration
Accelerometer
Works
Audio
Bluetooth
Camera
GPS
Mobile data
SMS
Calls
USB OTG


Running XFCE

Contributors

  • ollieparanoid
  • veggie

Device Owners


Status

What works

  • Installation to device memory (pmbootstrap flasher flash_rootfs)
  • Installation to sdcard (pmbootstrap install --sdcard=/dev/mmcblk...)
  • Touchscreen
  • Weston (only on SD card)
  • XWayland
  • Xfce4
  • Wifi
  • Display brightness control
  • Accerelometer sensor
  • rtc

What does not work

  • Audio, bluetooth, modem, ...
  • MHL (Video-out)
  • See "Hardware specifications" for ideas how to get them working.
  • Auto resizing partitions during installation to device memory (probably)

Installation

You have the following options:

  • Install from the SD card (easiest)
  • Install using netcat
  • Install from the recovery zip installer

Install from the SD card (easiest)

  • Configure the image
 $ pmbootstrap init
Not all the configurations will work. For instance, Phosh does not work yet. See What works to confirm your choice.
  • Insert the SD card and find its path

One way is to run lsblk in a terminal and find the path to the SD card (e.g. /dev/sde). In the following steps, we will use /path/to/sdcard as a placeholder, which you should adapt to your system.

  • Prepare the installation
 $ pmbootstrap install --sdcard=/path/to/sdcard
  • Insert the SD card into your Galaxy S2 and reboot. The system should boot (JonesV tested it with xfce4 and weston on 2020-08-20).

Install using netcat (#456)

JonesV tested it with weston on 2020-08-24 but did not succeed: after a successful netcat transfer and running pmos_continue_boot from the debug shell, the phone would end up on the "boot partition not found" error.
If you get a "no space left on device" error, see #928.
  • Configure the image
 $ pmbootstrap init
Not all the configurations will work. For instance, Phosh does not work yet. See What works to confirm your choice.
  • Prepare the installation
 $ pmbootstrap install
  • Setup the image to start on a debug shell
 $ pmbootstrap initfs hook_add debug-shell
  • Set phone to ODIN (/flash) mode
  1. Turn off phone
  2. Connect USB cable
  3. Hold VOLUME_DOWN + HOME + POWER until you get the "Warning!!" screen
  4. Push VOLUME_UP to continue to ODIN mode, as per the instructions appearing on the screen
  • Flash Kernel and Recovery (phone will reboot to screen "debug-shell is active")
 $ pmbootstrap flasher flash_kernel
  • Check USB network connection to phone
 ping 172.16.42.1
If it does not ping, try replugging usb cable few times. Depending on your system, you may need to setup the USB network connection manually.
  • Connect to phone with telnet
 $ telnet 172.16.42.1
  • Start netcat to listen for image (on the phone)
/dev/mmcblk0p9 should be the FACTORYFS partition. Check by running fdisk -l /dev/mmcblk0
 / # nc -v -l -p 60000 > /dev/mmcblk0p9
  • Switch to pmboostrap chroot (on the computer in another terminal)
 $ pmbootstrap chroot --suffix native
  • Install pv in the chroot
 / # apk add pv
  • Send image from computer to netcat (via the chroot)
 / # pv /home/pmos/rootfs/samsung-i9100.img | nc 172.16.42.1 60000
  • Close both nc with CTRL+C when transfer the finishes, then reboot the phone with the POWER button (or from telnet with reboot -f).

Install from the recovery zip installer

  • Install a recovery like TWRP on your device
  • Configure the image
 $ pmbootstrap init
Not all the configurations will work. For instance, Phosh does not work yet. See What works to confirm your choice.
  • Prepare the installation
 $ pmbootstrap install --android-recovery-zip
  • Set phone to ODIN (/flash) mode
  1. Turn off phone
  2. Connect USB cable
  3. Hold VOLUME_DOWN + HOME + POWER until you get the "Warning!!" screen
  4. Push VOLUME_UP to continue to ODIN mode, as per the instructions appearing on the screen
  • Flash the image on the phone
 $ pmbootstrap flasher --method=adb sideload

Boot process

We're using the heimdall-isorec flash method, see deviceinfo_flash_methods for more information.

Mainline kernel

There is already a device tree file in mainline kernel for this phone. The postmarketOS kernel hasn't been updated yet. The following notes could be considered legacy, but I'll leave them here for documentation purpose.

The user Sekilsgs2 on Github created a mainline kernel port, based on the older kernel version 4.2. Using ArchLinux, I was still able to compile and flash the kernel using following commands:

 $ git clone https://github.com/Sekilsgs2/i9100_kernel_mainline_port.git
 $ cd i9100_kernel_mainline_port
 $ export ARCH=arm
 $ export CROSS_COMPILE=arm-none-eabi-
 $ make i9100_defconfig
 $ make -j6
 $ cat arch/arm/boot/zImage arch/arm/boot/dts/exynos4210-i9100.dtb > zimage
 $ mkimage -A arm -O linux -T kernel -C none -a 0x40008000 -e 0x40008000 -n Linux-android-sucks -d zimage boot.img
 $ make modules_install INSTALL_MOD_PATH=../
 $ heimdall flash --RECOVERY boot.img

It is also possible to use a more recent mainline kernel version. Therefore we will have to checkout the latest sources and download the device tree file:

 $ git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
 $ cd linux-stable
 $ git checkout tags/5.4.5
 $ wget "https://raw.githubusercontent.com/Sekilsgs2/i9100_kernel_mainline_port/6c02dad36b8a76a6f50d26ff1b9abb0d30aacbc9/arch/arm/configs/i9100_defconfig" -O arch/arm/configs/i9100_defconfig
 $ wget "https://raw.githubusercontent.com/Sekilsgs2/i9100_kernel_mainline_port/master/arch/arm/boot/dts/exynos4210-i9100.dts" -O arch/arm/boot/dts/exynos4210-i9100.dts
 $ wget "https://raw.githubusercontent.com/Sekilsgs2/i9100_kernel_mainline_port/master/arch/arm/boot/dts/exynos4210.dtsi" -O arch/arm/boot/dts/exynos4210.dtsi
 # patch file arch/arm/boot/dts/Makefile
 $ export ARCH=arm
 $ export CROSS_COMPILE=arm-none-eabi-
 $ make i9100_defconfig
 $ make -j6
 $ make dtbs
 $ cat arch/arm/boot/zImage arch/arm/boot/dts/exynos4210-i9100.dtb > zimage
 $ mkimage -A arm -O linux -T kernel -C none -a 0x40008000 -e 0x40008000 -n Linux-android-sucks -d zimage boot.img
 $ make modules_install INSTALL_MOD_PATH=../
 $ heimdall flash --KERNEL boot.img

Unfortunately some things doesn't work here any more. Using a keyboard with USB-OTG fails and also the screen output is up-side-down. I haven't yet found the fixes made to the custom 4.2 port which I have to reapply :(

Firmware files

Proprietary firmware files are needed to get Wifi and Bluetooth working with the mainline kernel. In the following commands, I download them to the ArchLinuxARM root filesystem before booting the device. This should also work for postmarketOS:

 $ wget "https://raw.githubusercontent.com/TheMuppets/proprietary_vendor_samsung/cm-14.1/i9100/proprietary/system/etc/wifi/nvram_net.txt" -O /usr/lib/firmware/brcm/brcmfmac4330-sdio.samsung,i9100.txt
 $ wget "https://github.com/TheMuppets/proprietary_vendor_samsung/raw/lineage-17.0/i9100/proprietary/system/etc/wifi/bcmdhd_sta.bin" -O /usr/lib/firmware/brcm/brcmfmac4330-sdio.bin # for wifi
 $ wget "https://github.com/respeaker/rkbin/raw/master/firmware/bluetooth/BCM4330B1.hcd" -O /usr/lib/firmware/brcm/BCM4330B1.hcd # for bluetooth

U-Boot bootloader (legacy)

Sekilsgs2 on Github created a u-boot bootloader port, based on the work done by the user astarasikov at this repository. On Arch Linux I was able to compile the older U-Boot version using following commands:

 $ pacman -U dtc-1.4.1-1-x86_64.pkg.tar.xz # downgrade to older version
 $ pacman -S gcc-arm-none-eabi-bin-49 # older gcc version
 $ git clone https://github.com/Sekilsgs2/i9100-uboot.git
 $ cd i9100-uboot
 $ export PATH="/usr/local/arm/gcc-arm-none-eabi-4_9-2015q3/bin:$PATH"
 $ export ARCH=arm
 $ export CROSS_COMPILE=arm-none-eabi-
 $ make galaxys2_config
 $ make galaxys2
 $ heimdall flash --KERNEL u-boot.bin

After that, u-boot is booting, showing a nice bootloader menu which can be controlled by using the arrow keys. Configuring the boot options is done by editing the file include/configs/galaxys2.h. The critical part for me was to change boot parameters in the section "boot_android" to something like this:

 root=/dev/mmcblk1p1 rw rootfstype=ext4 rootwait init=/sbin/init ;

Where /dev/mmcblk1p1 was the ext4 partition with the root filesystem on the sd-card.

User:Onny is interested in porting the i9100 u-boot patches to newer versions of u-boot but currently u-boot fails with the newer s5p_sdhci driver introduced in newer versions, see Github issue here.

Sekilsgs2 is also working on (March 2020) supporting the Galaxy S2 in the latest u-boot version.

TALUAtGitHub has a recent commit (March 2020) git commit that might be helpful [1]

Usage

Wifi

- Create conf for wpa_supplicant

 $ wpa_passphrase "SSID" "password" > wifi

Note : If you are connecting to a hidden wireless network, make sure to add line "scan_ssid=1" after the ssid line in your generated conf file

- Connect to wifi AP

 $ sudo wpa_supplicant -i wlan0 -c wifi &

- Get ip address from dhcp server (in another terminal)

 $ sudo udhcpc -i wlan0

To set wifi connection to start automatically on boot, please refer here wifi

Modem

Using Ofono: Best way seems to get Samsung IPC modem support from the patchset https://lists.ofono.org/pipermail/ofono/2012-September/013766.html (but it was not accepted) and does not build https://github.com/tssk/pmbootstrap/commits/device-samsung-i9100_modem . I would appreciate help from someone that understands C.

Second idea was to build Andoird RIL + Samsung RIL and get ofono working with ofono-ril support - https://redmine.replicant.us/projects/replicant/wiki/Samsung-RIL .

GPS

https://univers-libre.net/posts/galaxy-s2-gps-on-replicant.html

https://redmine.replicant.us/projects/replicant/wiki/GSD4t

https://github.com/mnalis/gsd4t_parser

https://redmine.replicant.us/boards/21/topics/897

Setting the hardware clock

If you have already setup chrony and if your hardware clock doesn't have the time set you can set it with,

localhost:~# hwclock -w  # Write the current system time to the hardware clock

Setting the display brightness

To adjust display brightness write a value between 0-255 to file given below,

localhost:~# echo 0 > /sys/class/backlight/panel/brightness #set the display to its lowest brightness

localhost:~# echo 255 > /sys/class/backlight/panel/brightness #set the display to maximum brightness

Reading Accelerometer sensor

Accelerometer sensor data can read from following file

localhost:~$ cat /sys/class/accelerometer/accelerometer/acc_file

Hardware specifications

This device is supported by Replicant. With some more research we should be able to get most stuff running with their free software userland drivers.

SoC

Samsung Exynos 4 Dual 45 nm (GT-I9100, SHW-M250S/K/L) source

CPU

1.2 GHz dual-core ARM Cortex-A9 (GT-I9100, GT-I9105, GT-I9100G, SHW-M250S/K/L) source

GPU

ARM Mali-400 MP4 (GT-I9100, SHW-M250S/K/L) source

WiFi / Bluetooth / FM radio

Broadcom BCM4330 (SWB-B42) Bluetooth 4.0 Dual Band WLAN FM source source

Driver? - https://wireless.wiki.kernel.org/en/users/drivers/brcm80211

Firmware - https://android.googlesource.com/platform/hardware/broadcom/wlan/+/master/bcmdhd/firmware/bcm4330/

Memory

1 GB RAM [2]

Storage

16 GB or 32 GB flash memory [3]

Removable storage

microSD (up to 128 GB SDXC) [4]

Modem

  • XMM6260 [5]
  • aka "X-GOLD 626", and it's also used in Nexus 7 [6]
  • it seems to be supported by the mainline kernel (big questionmark here) [7]

Audio

  • Yamaha MC1N2
  • The Android kernel exposes the alsa API.
  • But when you play with the volume sliders in alsamixer, nothing happens
  • /dev/snd/hwC0D0 implements hardware-specific controls (via ioctl) [8] (check the link for a free software Android userspace driver)
  • We could write a daemon, that watches the alsa sound levels, and unmutes channels (speaker, headphones etc.) via hwC0D0 as necessary. (This will only work with the downstream kernel, the sound is probably not implemented in the upstream kernel at all?)
  • Maybe all this is overkill and the strategy from Audio works as well.

Light / proximity sensor

the CM3663 sensor is being use and there is no driver in mainline. A downstream driver is available here.

MHL

  • Fairchild FSA3200UMX switch [9]
  • Maxim MAX8997 PMIC [10]
  • Silicon Image 9244 transmitter [11]
  • Should be all supported to a certain extent in mainline 4.15 kernel (of course the device is still stuck to 3.0 for the time being)

Serial / UART

It is not exactly clear yet where to find UART / serial on the device. For possible location see second image below (red rectangle). Nevertheless a good instruction on hardware teardown is available here. Follow this guide until step 5, than proceed with removing the black cover from the circuit board (see first image below).

Photos

See also