Difference between revisions of "Samsung Galaxy S5 (samsung-klte)"

From postmarketOS
Jump to navigation Jump to search
(IRDA is present on this phone, but not supported yet)
 
(70 intermediate revisions by 4 users not shown)
Line 3: Line 3:
 
| name = Galaxy S5
 
| name = Galaxy S5
 
| codename = samsung-klte
 
| codename = samsung-klte
| image = File:Samsung-s5-weston.jpg
+
| image = File:Samsung-klte-phosh.jpg
 
| imagecaption = Samsung Galaxy S5
 
| imagecaption = Samsung Galaxy S5
 
| releaseyear = 2014
 
| releaseyear = 2014
 
| originalsoftware = Android 4.4.2 (KitKat)
 
| originalsoftware = Android 4.4.2 (KitKat)
 +
| pmoskernel = 5.14
 
| chipset = Qualcomm MSM8974PRO-AC Snapdragon 801
 
| chipset = Qualcomm MSM8974PRO-AC Snapdragon 801
 
| cpu = Quad-core 2.5 GHz Krait 400
 
| cpu = Quad-core 2.5 GHz Krait 400
Line 14: Line 15:
 
| memory = 2 GB
 
| memory = 2 GB
 
| architecture = armv7
 
| architecture = armv7
| status_usbnet = Y
+
| status_usbnet = P
 
| status_flashing = Y
 
| status_flashing = Y
 
| status_touch = Y
 
| status_touch = Y
Line 21: Line 22:
 
| status_xwayland = Y
 
| status_xwayland = Y
 
| status_fde =  
 
| status_fde =  
| status_mainline = P
+
| status_mainline = Y
| status_battery = Y
+
| status_battery = P
 
| status_3d = P
 
| status_3d = P
| status_accel = Y
+
| status_accel = N
| status_audio = Y
+
| status_audio = N
| status_bluetooth = N
+
| status_bluetooth = Y
| status_camera =
+
| status_camera = N
| status_gps = Y
+
| status_gps = N
| status_mobiledata =  
+
| status_mobiledata = Y
| status_sms =  
+
| status_sms = Y
| status_calls =  
+
| status_calls = N
| status_otg =
+
| status_otg = N
| pmoskernel = 3.4.113 / 5.6
+
| status_nfc = N
 +
| status_irtx = N
 
| whet_dhry = 884.3
 
| whet_dhry = 884.3
 
| booting = yes
 
| booting = yes
 
}}
 
}}
 +
{{Based on SoC|Qualcomm_Snapdragon_800/801_(MSM8974)|Snapdragon 801}}
 +
 +
__TOC__
  
 
== Contributors ==
 
== Contributors ==
Line 50: Line 55:
 
{{Device owners}}
 
{{Device owners}}
  
== What works ==
+
== Status table explanation ==
 +
This table explains more in detail why some features are marked as partial (P). Generally it's because feature works with some limitations, or is a "work-in-progress":
  
* Flash Kernel (<code>pmbootstrap flasher flash_kernel</code>)
+
{|class="wikitable feature-colors"
* Flash Rootfs (<code>pmbootstrap flasher flash_rootfs</code>)
+
|-
* Initramfs boot
+
! Component !! Status !! notes
* USB Network
+
|-
* Framebuffer graphics (Splash screens)
+
| USB Networking || P || Only first cable attach works, doesn't work after detaching (missing cable detection support)
* SSH Connectivity
+
|-
* Touchscreen
+
| 3D Accel (GPU) || P || GPU works for simple use cases, but can't render complex GUIs/shaders. If you run Phosh or Plasma Mobile, you'll "crash" the display. Phosh works more steadily though. The phone continues to work, so this shouldn't be too hard to figure out. This is most likely due to lack of GPU IOMMU support or bugs in mesa/freedreno.
* Wi-Fi
 
* Xwayland
 
* Weston on framebuffer [broken with latest weston]
 
* Plasma Mobile on framebuffer [untested with last update]
 
* X11 based UIs on framebuffer work fine
 
* Android container starts
 
* audio works with nonfree-userland (with Android container)
 
  
== What does not work ==
+
SXMO may be more wise UI choice for now.
 
+
|-
* Audio playback without nonfree-userland
+
| Battery || P || Percentage reporting works; no charging status reported, but it is charging fine
* Bluetooth adapter is visible in rfkill list, but does not work
+
|}
* Everything else
 
  
 
== How to enter flash mode ==
 
== How to enter flash mode ==
Line 87: Line 85:
 
<source lang="shell-session">
 
<source lang="shell-session">
 
$ pmbootstrap init
 
$ pmbootstrap init
...
+
Channel [edge]:
Vendor [samsung]: samsung <- enter this
+
Vendor [samsung]: samsung       <- enter this
 
Device codename [i9100]: klte  <- enter this
 
Device codename [i9100]: klte  <- enter this
Kernel [downstream]: downstream        <- you probably want downstream for now
+
Enable this package? (y/n) [y] <- you probably want non-free firmware
User interface [weston]:               <- choose any UI by your preference
+
User interface [sxmo]:         <- choose any UI by your preference. fbkeyboard and sxmo work well :)
 
...
 
...
 
</source>
 
</source>
Line 113: Line 111:
 
</source>
 
</source>
  
=== Nonfree-userland (halium) installation ===
+
== Installation with lk2nd ==
 +
You can use custom 2nd stage bootlaoder to install postmarketOS on Samsung Galaxy S5. Soon this will be the recommended way to perform the installation.
 +
 
 +
For now, you must have heimdall and fastboot installed locally.
 +
 
 +
1. Go to https://github.com/msm8916-mainline/lk2nd/releases and download the latest <code>lk2nd-msm8974.img</code> release.
  
[[File:Samsung-klte-android-running-inside-lxc-cut.png|400px|thumb|right|Android processes running inside lxc container]]
+
2. Boot your phone to download mode (hold {{button|Volume Down}} + {{button|Home}} while booting).
  
To make full use of nonfree-userland intallation, which involves running Android in lxc container to make all hardware work (read more at [[Hybris]] wiki page), you need to to '''manually'''  download and install custom device-specific Android/Halium system image. Building it manually takes a lot of time and free space on HDD, so I've prepared prebuilt image: https://androidfilehost.com/?fid=6006931924117913010
+
3. Flash lk2nd to boot parition: <code>heimdall flash --BOOT lk2nd-msm8974.img</code>
  
You need to download it, un-sparse and place in to root of userdata partition:
+
4. Boot your phone to fastboot mode: hold {{button|Volume Down}} (whithout "Home") while booting. You can still boot to stock Odin mode as before, by holding {{button|Volume Down}} + {{button|Home}}.
  
Un-sparse:
+
5. Now using pmbootstrap, do as usual
 
<source lang="shell-session">
 
<source lang="shell-session">
$ simg2img halium-klte-2019-07-09-system.img halium-klte-2019-07-09-system.img.raw
+
$ pmbootstrap init
 +
  select samsung-klte, your favorite UI
 +
$ pmbootstrap install --no-firewall
 
</source>
 
</source>
If it says "invalid sparse format or header magic" it means that the image is already unsparsed. Proceed to next step
 
  
Reboot phone to TWRP recovery and push image using ADB:
+
6. But then, instead of using <code>pmbootstrap flasher</code>, do flashing manually
 
<source lang="shell-session">
 
<source lang="shell-session">
$ adb push halium-klte-2019-07-09-system.img.raw /data/system.img
+
$ pmbootstrap export --no-install
 +
$ fastboot erase boot              # we don't need to flash boot partition with this method
 +
$ fastboot flash system /tmp/postmarketOS-export/samsung-klte.img
 +
$ fastboot reboot
 
</source>
 
</source>
  
Boot to a running postmarketOS system and login with SSH using [[USB_Network]]. Next commands are executed on the phone. Make sure that you have a <code>/data</code> mounted (check output of <code>mount</code> command). Ensure that Android is fully running inside an lxc container (on device, install <code>htop</code>, run it and switch into tree mode by pressing '''t''') (see the picture on the right). If it does not, check if <code>lxc-android</code> is running (see output of <code>rc-status</code> command). Run '''logcat''' and see if it is printing some error logs on the screen.
+
7. You are done! With this method you don't have to reflash phone to get kernel updates anymore. lk2nd is capable of booting from ext2 filesystem directly.
 +
 
 +
== Mainlining Notes ==
 +
 
 +
=== Power IC ===
 +
 
 +
The phone uses max77804k MFD (Multi Function Device), which is also a [[Micro-USB_Interface_Controller]] to handle charging, extcon (cable detect), vibrator, flash led. This device is not in mainline, but it is very similar (i.e the same) to max77693 in register layout. In the next paragraph I'll refer to max77804k code as downstream and max77693 code as upstream.
 +
 
 +
* '''Charging''' : downstream charging code is scary. Mainline code only reads info, and doesn't charge, so a brave soul might be able to figure out a minimal setup that does charge the phone.
 +
* '''Extcon''' : downstream extcon is not too bad, and it is trivial to follow the basic use cases and ensure they are ported correctly. Mainline code is different and writes different values for diffrent use cases, but following a similar structure it can be made to behave.
 +
* '''Flash Leds''' : these are pretty straight forward, the existing mainline code is a bit weird, but I wrote a port of downstream and it does work for the most part.
 +
* '''Vibrator''' : the mainline code is for a different kind of vibrator. It shouldn't be too hard to port the downstream code.
 +
 
 +
=== USB ===
 +
 
 +
At the moment usb-networking works only the first time it is plugged, and only
 +
if the (experimental) max77804k is not enabled.
 +
 
 +
There are 2 different blocks for USB on the klte. One has a good driver, and
 +
manages the somewhat working usb networking -- let's call it simple. But if the
 +
max77804k driver is enabled, it switches to the other IP block which does not
 +
have mainline drivers -- let's call it complex. Downstream only has code for
 +
the complex block.
 +
 
 +
Drivers for the complex block are present on newer SoCs from qualcomm, but at
 +
least to me, they look different than the downstream code (downstream doesn't
 +
have the notion of phy's, and this is a pretty big deal). So this could be
 +
a simple fix, but likely isn't.
 +
 
 +
Another possible approach will be to somehow let the simple block handle all
 +
the USB, but without documentation on max77804k/usb blocks this is pretty hard.
 +
 
 +
=== Graphics/Display ===
 +
 
 +
There is mainline support for the GPU with 3D Acceleration. kmscube works.
 +
 
 +
If you run Phosh or Plasma Mobile, you'll "crash" the display. Phosh works more steadily though. The phone continues to work, so this shouldn't be too hard to figure out. This is most likely due to lack of GPU IOMMU support or bugs in mesa/freedreno.
 +
 
 +
SXMO may be more wise UI choice for now.
  
Before (re)starting lxc-android, remember to remove file <code>/tmp/lxc-android-once</code> if it exists.
+
=== Parts Bin code ===
  
== Additional info ==
+
max77693 to max77804k port (incl some usb work): https://gitlab.com/ichernev/linux-postmarketos/-/tree/max77693-update
  
=== Useful helper scripts ===
+
max77804k with leds only: https://gitlab.com/ichernev/linux-postmarketos/-/tree/max77804k
Default installation includes a couple of useful scripts to be used from a terminal: <code>battery-status</code> and <code>set-brightness</code>. <code>battery-status</code> allows you to check for battery charge level, and <code>set-brightness</code> allows to view/set lcd backlight brightness in range 0-255.
+
 
 +
=== Running on pure mainline ===
 +
 
 +
At the moment (5.6) (this is still needed in 5.13-rc), if you want to use real mainline (from torvalds tree), you'd need this patch:
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="width: 620px; overflow: auto;">
 +
Patch:
 +
<div class="mw-collapsible-content">
 +
<pre class="patch">
 +
commit 765f55b248cd3b231af8431fe2f2aeca263b4e4b
 +
Author: Jonathan Marek <jonathan@marek.ca>
 +
Date:  Sat Oct 5 21:15:07 2019 -0400
 +
 
 +
    HACK: delay rpmcc init
 +
   
 +
    Delay RPMCC init. This is a hack that somehow fixes some problems.
 +
    Hopefully the need for this patches goes away once the IOMMU is
 +
    working.
 +
   
 +
    Signed-off-by: Jonathan Marek <jonathan@marek.ca>
 +
    Signed-off-by: Brian Masney <masneyb@onstation.org>
 +
 
 +
diff --git a/drivers/clk/qcom/clk-smd-rpm.c b/drivers/clk/qcom/clk-smd-rpm.c
 +
index 0bbfef9fa6dec..447ca887deb11 100644
 +
--- a/drivers/clk/qcom/clk-smd-rpm.c
 +
+++ b/drivers/clk/qcom/clk-smd-rpm.c
 +
@@ -15,6 +15,7 @@
 +
#include <linux/of_device.h>
 +
#include <linux/platform_device.h>
 +
#include <linux/soc/qcom/smd-rpm.h>
 +
+#include <linux/delay.h>
 +
 +
#include <dt-bindings/clock/qcom,rpmcc.h>
 +
#include <dt-bindings/mfd/qcom-rpm.h>
 +
@@ -770,6 +771,9 @@ static int rpm_smd_clk_probe(struct platform_device *pdev)
 +
        rcc->clks = rpm_smd_clks;
 +
        rcc->num_clks = num_clks;
 +
 +
+      /* delay rpm init, somehow this fixes some problems */
 +
+      usleep_range(100000, 110000);
 +
+
 +
        for (i = 0; i < num_clks; i++) {
 +
                if (!rpm_smd_clks[i])
 +
                        continue;</pre>
 +
</div>
 +
</div>
 +
 
 +
I won't be surprised if more issues pop up in the future, as nobody is really testing for regressions on phones.
 +
 
 +
=== Getting early kernel logs using UART ===
 +
Craft a cable using [[Serial_debugging:Cable_schematics#microUSB.2FCarkit_debug_cable]] with 619kΩ resistor (see also [[MUIC]])
 +
 
 +
Read help for [https://elixir.bootlin.com/linux/latest/K/ident/CONFIG_DEBUG_QCOM_UARTDM CONFIG_DEBUG_QCOM_UARTDM kernel konfig]. Enable <code>CONFIG_DEBUG_LL</code> + <code>CONFIG_DEBUG_QCOM_UARTDM</code> + correct addresses for <code>CONFIG_DEBUG_UART_PHYS</code> and <code>CONFIG_DEBUG_UART_VIRT</code>. The ones listed in a help for <code>CONFIG_DEBUG_QCOM_UARTDM</code> option for MSM8974 work fine:
 +
 
 +
CONFIG_DEBUG_LL=y
 +
CONFIG_DEBUG_QCOM_UARTDM=y
 +
CONFIG_DEBUG_UART_PHYS=0xf991e000
 +
CONFIG_DEBUG_UART_VIRT=0xfa71e000
 +
CONFIG_EARLY_PRINTK=y
 +
 
 +
And add <code>earlyprintk</code> to kernel command line. This allows to receive debug messages from such early stages so you can even debug kernel self-decompressor.
 +
 
 +
=== If the phone becomes too hot ===
 +
Use this to check temperatures:
 +
<syntaxhighlight lang="shell">
 +
$ for i in $(ls --color=never /sys/devices/virtual/thermal/); do cat /sys/devices/virtual/thermal/$i/type /sys/devices/virtual/thermal/$i/temp; done
 +
</syntaxhighlight>
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="width: 620px; overflow: auto;">
 +
Example output:
 +
<div class="mw-collapsible-content">
 
<pre>
 
<pre>
samsung-klte:~$ battery-status
+
cpu-thermal0
25
+
45000
samsung-klte:~$ set-brightness
+
cpu-thermal1
255
+
44000
samsung-klte:~$ sudo set-brightness 20
+
cpu-thermal2
20
+
44000
 +
cpu-thermal3
 +
43000
 +
q6-dsp-thermal
 +
44000
 +
modemtx-thermal
 +
43000
 +
video-thermal
 +
44000
 +
wlan-thermal
 +
44000
 +
gpu-thermal-top
 +
44000
 +
gpu-thermal-bottom
 +
43000
 
</pre>
 
</pre>
 +
</div></div>
 +
 +
=== Using modem ===
 +
First, install SIM card into device (obviously).
 +
When using device without mobile UI, you will need to install modemmanager manually (<code>sudo apk add modemmanager</code>), start the service (<code>sudo rc-service modemmanager start</code>) (optionally add it to defult runlevel: <code>sudo rc-update add modemmanager default</code>). Check out if SIM card is detected and is registered: <code>mmcli -m 0</code>.
 +
 +
Add newtork connection using cell network:
 +
<syntaxhighlight lang="shell">
 +
$ sudo nmcli c add con-name "modem" type "gsm" ifname "wwan0qmi0"
 +
</syntaxhighlight>
 +
 +
Check connection status using <code>nmcli d</code> and if <code>rmnet0</code> got the IP address using <code>ip a</code>.
 +
 +
More info here, including oFono instructions: https://gist.github.com/Minecrell/4cc2bfb9fcae18e294386b0a213907d1
  
 
=== Partition layout ===
 
=== Partition layout ===
Line 197: Line 340:
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
  ! Component !! Codename !! Mainline kernel !! Since when !! Downstream 3.4 kernel
+
  ! Component !! Codename !! Mainline kernel !! Since when
 
|-
 
|-
| Debug serial || msm_serial /dev/ttyMSM0 || Working || v4.17-rc1 || yes, /dev/ttyHSL0
+
| Debug serial || msm_serial /dev/ttyMSM0 || Working || v4.17-rc1
 
|-
 
|-
| Volume &amp; home buttons || gpio-keys || Working || 5.8 || yes
+
| Volume &amp; home buttons || gpio-keys || Working || 5.8
 
|-
 
|-
| Regulator nodes || pma8084, Maxim max77826 || Working || 5.8 || yes
+
| Regulator nodes || pma8084, Maxim max77826 || Working || 5.8
 
|-
 
|-
| Internal storage || sdhci-msm || Working || 5.8 || yes
+
| Internal storage || sdhci-msm || Working || 5.8
 
|-
 
|-
| SD card storage || sdhci-msm || Working || In pmOS kernel fork || yes
+
| SD card storage || sdhci-msm || Working || 5.11-rc1
 
|-
 
|-
| USB Networking || usb_dwc3_qcom || Working || 5.8 || yes
+
| USB Networking || DesignWare dwc3_qcom / ChipIdea ci_hdrc_msm || Working || 5.8
 
|-
 
|-
| Display || panel-simple || Working || In pmOS kernel fork || yes
+
| Display subsystem || MDSS MDP5 || Working || Since forever; mdp5 appeared in kernel in 3.14-rc1
 
|-
 
|-
| Touchscreen  || synaptics rmi4-i2c || Working || In pmOS kernel fork || yes
+
| LCD Panels || Samsung S6E3FA2 AMOLED cmd mode panel, MagnaChip(?) EA8064G AMOLED cmd mode panel || Working || In pmOS kernel fork
 
|-
 
|-
| Touchkeys || Cypress tm2-touchkey || Working || In pmOS kernel fork || yes
+
| Touchscreen || synaptics rmi4-i2c || Working || 5.11-rc1
 
|-
 
|-
| Vibration motor || || Not working || || yes
+
| Touchkeys || Cypress tm2-touchkey || Working || 5.11-rc1
 
|-
 
|-
| Notification LED || Panasonic AN30259A || Working || In pmOS kernel fork || yes
+
| Vibration motor || Maxim max77804k-vibrator || Not working ||
 
|-
 
|-
| WiFi || brcmfmac + PCAL6416A GPIO Expander || Working || In pmOS kernel fork || yes
+
| Notification LED || Panasonic AN30259A || Working || 5.11-rc1
 
|-
 
|-
| USB OTG || || Not working || || yes
+
| WiFi || Broadcom BCM4354 (brcmfmac) + PCAL6416A GPIO Expander || Working || 5.11-rc1
 
|-
 
|-
| Bluetooth || brcmfmac || Not working || || no
+
| Bluetooth || Broadcom BCM4354 (hci_uart_bcm), needs GPIO expander too || Working || 5.13
 
|-
 
|-
| Battery charger || Maxim max77804k || Not working || || yes
+
| USB OTG || Maxim max77804k-extcon || Not working ||
 
|-
 
|-
| Battery fuelgauge || Maxim max17048 || Working || In pmOS kernel fork || yes
+
| Battery charger || Maxim max77804k-charger || Not working ||
 
|-
 
|-
| GPU || drm_msm || Working || in pmOS kernel fork || works with libhybris (test_hwcomposer_7_1_caf)
+
| Battery fuelgauge || Maxim max17048 || Working || 5.11-rc1
 
|-
 
|-
| Audio || || Not working || || with libhybris (pulseaudio-modules-droid)
+
| GPU || drm_msm Adreno 330.2 || Working || 5.12
 
|-
 
|-
| Modem || qcom-q6v5-mss || Not working || || powers up with libhybris
+
| HDMI out || Silicon Image Sil8240 MHL || Not working ||
 
|-
 
|-
| Sensors || || Not working || || yes (libhybris's test_sensors)
+
| Audio || WCD9320 (+Audience eS704 voice) Audio Codecs || Not working ||
 +
|-
 +
| Modem || QCOM_Q6V5_MSS Qualcomm integrated modem || Working || 5.14
 +
|-
 +
| Accelerometer, Gyroscope || Invensense MP65M (mpu6500) 6-axis gyro/accel || Has mainline driver, CONFIG_INV_MPU6050_IIO ||
 +
|-
 +
| Magnetometer || Asahi Kasei Microdevices AK09911C 3-axis compass || Has mainline driver, CONFIG_AK09911 ||
 +
|-
 +
| Ambient light / Proximity || AMS TMG399X Optical Sensor || Not working ||
 +
|-
 +
| Sensor HUB || STM32 A5006V0 hub Seamless Sensor Platform (SSP) || Not working ||
 +
|-
 +
| NFC || NXP pn547 || Has mainline driver, CONFIG_NFC_NXP_NCI ||
 +
|-
 +
| Cameras || s5k2p2xx, s5k8b1yx || Not working ||
 
|}
 
|}
  
Line 244: Line 401:
 
* {{Device package|samsung-klte}}
 
* {{Device package|samsung-klte}}
 
* {{Kernel package|samsung-klte}}
 
* {{Kernel package|samsung-klte}}
* [https://gitlab.com/postmarketOS/pmaports/tree/master/firmware/firmware-samsung-klte Firmware package]
+
* {{Firmware package|samsung-klte}}
 
+
* [https://github.com/msm8916-mainline/lk2nd/pull/55 lk2nd support]
Mainline kernel patches:
 
* https://patchwork.kernel.org/patch/10150807/
 
 
 
Development branch:
 
* https://gitlab.com/postmarketOS/linux-postmarketos/tree/old-4.17.0-rc3/qcom , old 4.17 kernel, commits by ''drebrez''
 
* https://github.com/drebrez/linux/tree/samsung-klte (old repo)
 
  
 
Extra:
 
Extra:
Line 257: Line 408:
 
* [https://www.ifixit.com/Teardown/Samsung+Galaxy+S5+Teardown/24016 Samsung Galaxy S5 Teardown]
 
* [https://www.ifixit.com/Teardown/Samsung+Galaxy+S5+Teardown/24016 Samsung Galaxy S5 Teardown]
 
* [https://forum.xda-developers.com/galaxy-s7/how-to/guide-samsung-galaxy-s7-uart-t3743895 UART guide]
 
* [https://forum.xda-developers.com/galaxy-s7/how-to/guide-samsung-galaxy-s7-uart-t3743895 UART guide]
 +
* [http://www.deviceinfohw.ru/devices/item.php?item=72846 Deviceinfo HW page]
 
* [https://www.youtube.com/watch?v=v0iI0p6qKKw Demo of Samsung klte running Plasma Mobile]
 
* [https://www.youtube.com/watch?v=v0iI0p6qKKw Demo of Samsung klte running Plasma Mobile]
 
* [https://www.youtube.com/watch?v=1kXpkorNCik Plasma Mobile Kirigami Gallery demo on samsung-klte]
 
* [https://www.youtube.com/watch?v=1kXpkorNCik Plasma Mobile Kirigami Gallery demo on samsung-klte]
Line 262: Line 414:
 
== Photos ==
 
== Photos ==
 
<gallery>
 
<gallery>
File:Klte weston.jpg|thumb|left|Weston
+
File:Samsung-s5-weston.jpg|thumb|left|Weston
 
File:Klte xfce.jpg|thumb|left|Xfce4 UI
 
File:Klte xfce.jpg|thumb|left|Xfce4 UI
 
File:Samsung debug UART.png|thumb|left|UART debugging
 
File:Samsung debug UART.png|thumb|left|UART debugging
File:IMG_20190715_185026.jpg|thumb|left|Plasma Mobile homescreen
 
File:Klte_plamo_top_panel_wifi.jpg|thumb|left|Plasma Mobile top panel
 
File:Samsung_klte_PlaMo_Index_FM.jpg|thumb|left|Plasma Mobile Index file manager
 
 
File:Samsung-klte-x2.jpg|thumb|left|klte x2
 
File:Samsung-klte-x2.jpg|thumb|left|klte x2
File:Samsung-klte-android-running-inside-lxc-cut.png|thumb|left|Android processes running inside lxc container
+
File:Samsung-klte-phosh-about.jpg|thumb|left|phosh - about
 +
File:Samsung-klte-phosh-lockscreen.jpg|thumb|left|phosh lockscreen
 +
File:Samsung-klte-phosh-kgx-neofetch.jpg|thumb|left|phosh, neofetch
 +
File:Klte_phosh_screenshot.png|thumb|left|full size screenshot
 +
File:Samsung-klte-phosh-bt.jpg|thumb|left|Bluetooth working in phosh
 +
File:Samsung-klte-sxmo-01.jpg|thumb|left|Sxmo on klte 01
 +
File:Samsung-klte-sxmo-02.jpg|thumb|left|Sxmo on klte 02
 
</gallery>
 
</gallery>

Latest revision as of 15:39, 31 October 2021

Samsung Galaxy S5
Samsung Galaxy S5
Samsung Galaxy S5
Manufacturer Samsung
Name Galaxy S5
Codename samsung-klte
Released 2014
Category testing
Original software Android 4.4.2 (KitKat)
postmarketOS kernel 5.14
Hardware
Chipset Qualcomm MSM8974PRO-AC Snapdragon 801
CPU Quad-core 2.5 GHz Krait 400
GPU Adreno 330
Display 1080 x 1920 AMOLED
Storage 16/32 GB
Memory 2 GB
Architecture armv7
Unixbench Whet/Dhry score 884.3
Features
USB Networking
Partial
Flashing
Works
Touchscreen
Works
Display
Works
WiFi
Works
Xwayland
Works
FDE
Mainline
Works
Battery
Partial
3D Acceleration
Partial
Accelerometer
Broken
Audio
Broken
Bluetooth
Works
Camera
Broken
GPS
Broken
Mobile data
Works
SMS
Works
Calls
Broken
USB OTG
Broken
NFC
Broken
Ir TX
Broken



This device is based on Snapdragon 801.
See the SoC page for common tips, guides and troubleshooting steps

Contributors

Maintainer(s)

Users owning this device


Status table explanation

This table explains more in detail why some features are marked as partial (P). Generally it's because feature works with some limitations, or is a "work-in-progress":

Component Status notes
USB Networking P Only first cable attach works, doesn't work after detaching (missing cable detection support)
3D Accel (GPU) P GPU works for simple use cases, but can't render complex GUIs/shaders. If you run Phosh or Plasma Mobile, you'll "crash" the display. Phosh works more steadily though. The phone continues to work, so this shouldn't be too hard to figure out. This is most likely due to lack of GPU IOMMU support or bugs in mesa/freedreno.

SXMO may be more wise UI choice for now.

Battery P Percentage reporting works; no charging status reported, but it is charging fine

How to enter flash mode

Press and hold Volume Down + Home + Power simultaneously. Then click Volume Up to confirm.

How to enter recovery mode

Press and hold Volume Up + Home + Power simultaneously.

Installation

First, install pmbootstrap.

Setup device to be used:

$ pmbootstrap init
Channel [edge]:
Vendor [samsung]: samsung       <- enter this
Device codename [i9100]: klte   <- enter this
Enable this package? (y/n) [y]  <- you probably want non-free firmware
User interface [sxmo]:          <- choose any UI by your preference. fbkeyboard and sxmo work well :)
...

Build the rootfs image:

$ pmbootstrap install

Then in order to flash it put your device in download mode, and plug it in USB. Then do:

$ pmbootstrap flasher flash_rootfs

 Hold "Volume down" + "Home" buttons at the end of the process,
 so that when phone reboots put it in flashing mode again 

$ pmbootstrap flasher flash_kernel

 This time, don't hold any button, let it reboot to Linux!

Installation with lk2nd

You can use custom 2nd stage bootlaoder to install postmarketOS on Samsung Galaxy S5. Soon this will be the recommended way to perform the installation.

For now, you must have heimdall and fastboot installed locally.

1. Go to https://github.com/msm8916-mainline/lk2nd/releases and download the latest lk2nd-msm8974.img release.

2. Boot your phone to download mode (hold Volume Down + Home while booting).

3. Flash lk2nd to boot parition: heimdall flash --BOOT lk2nd-msm8974.img

4. Boot your phone to fastboot mode: hold Volume Down (whithout "Home") while booting. You can still boot to stock Odin mode as before, by holding Volume Down + Home.

5. Now using pmbootstrap, do as usual

$ pmbootstrap init
  select samsung-klte, your favorite UI
$ pmbootstrap install --no-firewall

6. But then, instead of using pmbootstrap flasher, do flashing manually

$ pmbootstrap export --no-install
$ fastboot erase boot              # we don't need to flash boot partition with this method
$ fastboot flash system /tmp/postmarketOS-export/samsung-klte.img
$ fastboot reboot

7. You are done! With this method you don't have to reflash phone to get kernel updates anymore. lk2nd is capable of booting from ext2 filesystem directly.

Mainlining Notes

Power IC

The phone uses max77804k MFD (Multi Function Device), which is also a Micro-USB_Interface_Controller to handle charging, extcon (cable detect), vibrator, flash led. This device is not in mainline, but it is very similar (i.e the same) to max77693 in register layout. In the next paragraph I'll refer to max77804k code as downstream and max77693 code as upstream.

  • Charging : downstream charging code is scary. Mainline code only reads info, and doesn't charge, so a brave soul might be able to figure out a minimal setup that does charge the phone.
  • Extcon : downstream extcon is not too bad, and it is trivial to follow the basic use cases and ensure they are ported correctly. Mainline code is different and writes different values for diffrent use cases, but following a similar structure it can be made to behave.
  • Flash Leds : these are pretty straight forward, the existing mainline code is a bit weird, but I wrote a port of downstream and it does work for the most part.
  • Vibrator : the mainline code is for a different kind of vibrator. It shouldn't be too hard to port the downstream code.

USB

At the moment usb-networking works only the first time it is plugged, and only if the (experimental) max77804k is not enabled.

There are 2 different blocks for USB on the klte. One has a good driver, and manages the somewhat working usb networking -- let's call it simple. But if the max77804k driver is enabled, it switches to the other IP block which does not have mainline drivers -- let's call it complex. Downstream only has code for the complex block.

Drivers for the complex block are present on newer SoCs from qualcomm, but at least to me, they look different than the downstream code (downstream doesn't have the notion of phy's, and this is a pretty big deal). So this could be a simple fix, but likely isn't.

Another possible approach will be to somehow let the simple block handle all the USB, but without documentation on max77804k/usb blocks this is pretty hard.

Graphics/Display

There is mainline support for the GPU with 3D Acceleration. kmscube works.

If you run Phosh or Plasma Mobile, you'll "crash" the display. Phosh works more steadily though. The phone continues to work, so this shouldn't be too hard to figure out. This is most likely due to lack of GPU IOMMU support or bugs in mesa/freedreno.

SXMO may be more wise UI choice for now.

Parts Bin code

max77693 to max77804k port (incl some usb work): https://gitlab.com/ichernev/linux-postmarketos/-/tree/max77693-update

max77804k with leds only: https://gitlab.com/ichernev/linux-postmarketos/-/tree/max77804k

Running on pure mainline

At the moment (5.6) (this is still needed in 5.13-rc), if you want to use real mainline (from torvalds tree), you'd need this patch:

Patch:

commit 765f55b248cd3b231af8431fe2f2aeca263b4e4b
Author: Jonathan Marek <jonathan@marek.ca>
Date:   Sat Oct 5 21:15:07 2019 -0400

    HACK: delay rpmcc init
    
    Delay RPMCC init. This is a hack that somehow fixes some problems.
    Hopefully the need for this patches goes away once the IOMMU is
    working.
    
    Signed-off-by: Jonathan Marek <jonathan@marek.ca>
    Signed-off-by: Brian Masney <masneyb@onstation.org>

diff --git a/drivers/clk/qcom/clk-smd-rpm.c b/drivers/clk/qcom/clk-smd-rpm.c
index 0bbfef9fa6dec..447ca887deb11 100644
--- a/drivers/clk/qcom/clk-smd-rpm.c
+++ b/drivers/clk/qcom/clk-smd-rpm.c
@@ -15,6 +15,7 @@
 #include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/soc/qcom/smd-rpm.h>
+#include <linux/delay.h>
 
 #include <dt-bindings/clock/qcom,rpmcc.h>
 #include <dt-bindings/mfd/qcom-rpm.h>
@@ -770,6 +771,9 @@ static int rpm_smd_clk_probe(struct platform_device *pdev)
        rcc->clks = rpm_smd_clks;
        rcc->num_clks = num_clks;
 
+       /* delay rpm init, somehow this fixes some problems */
+       usleep_range(100000, 110000);
+
        for (i = 0; i < num_clks; i++) {
                if (!rpm_smd_clks[i])
                        continue;

I won't be surprised if more issues pop up in the future, as nobody is really testing for regressions on phones.

Getting early kernel logs using UART

Craft a cable using Serial_debugging:Cable_schematics#microUSB.2FCarkit_debug_cable with 619kΩ resistor (see also MUIC)

Read help for CONFIG_DEBUG_QCOM_UARTDM kernel konfig. Enable CONFIG_DEBUG_LL + CONFIG_DEBUG_QCOM_UARTDM + correct addresses for CONFIG_DEBUG_UART_PHYS and CONFIG_DEBUG_UART_VIRT. The ones listed in a help for CONFIG_DEBUG_QCOM_UARTDM option for MSM8974 work fine:

CONFIG_DEBUG_LL=y
CONFIG_DEBUG_QCOM_UARTDM=y
CONFIG_DEBUG_UART_PHYS=0xf991e000
CONFIG_DEBUG_UART_VIRT=0xfa71e000
CONFIG_EARLY_PRINTK=y

And add earlyprintk to kernel command line. This allows to receive debug messages from such early stages so you can even debug kernel self-decompressor.

If the phone becomes too hot

Use this to check temperatures:

$ for i in $(ls --color=never /sys/devices/virtual/thermal/); do cat /sys/devices/virtual/thermal/$i/type /sys/devices/virtual/thermal/$i/temp; done

Example output:

cpu-thermal0
45000
cpu-thermal1
44000
cpu-thermal2
44000
cpu-thermal3
43000
q6-dsp-thermal
44000
modemtx-thermal
43000
video-thermal
44000
wlan-thermal
44000
gpu-thermal-top
44000
gpu-thermal-bottom
43000

Using modem

First, install SIM card into device (obviously). When using device without mobile UI, you will need to install modemmanager manually (sudo apk add modemmanager), start the service (sudo rc-service modemmanager start) (optionally add it to defult runlevel: sudo rc-update add modemmanager default). Check out if SIM card is detected and is registered: mmcli -m 0.

Add newtork connection using cell network:

$ sudo nmcli c add con-name "modem" type "gsm" ifname "wwan0qmi0"

Check connection status using nmcli d and if rmnet0 got the IP address using ip a.

More info here, including oFono instructions: https://gist.github.com/Minecrell/4cc2bfb9fcae18e294386b0a213907d1

Partition layout

Partition layout:

~ # fdisk -l /dev/block/mmcblk0
Found valid GPT with protective MBR; using GPT

Disk /dev/block/mmcblk0: 30777344 sectors, 2740M
Logical sector size: 512
Disk identifier (GUID): 98101b32-bbe2-4bf2-a06e-2bb33d000c20
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 30777310

Number  Start (sector)    End (sector)  Size       Code  Name
   1            8192           38911       15.0M   0700  apnhlos
   2           38912          156543       57.4M   0700  modem
   3          156544          157567        512K   0700  sbl1
   4          157568          157695       65536   0700  dbi
   5          157696          157759       32768   0700  ddr
   6          157760          161855       2048K   0700  aboot
   7          161856          162879        512K   0700  rpm
   8          162880          163903        512K   0700  tz
   9          163904          170047       3072K   0700  fsg
  10          170048          184319       7136K   0700  pad
  11          184320          204799       10.0M   0700  param
  12          204800          233471       14.0M   0700  efs
  13          233472          239615       3072K   0700  modemst1
  14          239616          245759       3072K   0700  modemst2
  15          245760          272383       13.0M   0700  boot
  16          272384          303103       15.0M   0700  recovery
  17          303104          329727       13.0M   0700  fota
  18          329728          344045       7159K   0700  backup
  19          344046          344047        1024   0700  fsc
  20          344048          344063        8192   0700  ssd
  21          344064          360447       8192K   0700  persist
  22          360448          378879       9216K   0700  persdata
  23          378880         5498879       2500M   0700  system
  24         5498880         5908479        200M   0700  cache
  25         5908480         6010879       50.0M   0700  hidden
  26         6010880        30777310       11.8G   0700  userdata

Component support table

Component Codename Mainline kernel Since when
Debug serial msm_serial /dev/ttyMSM0 Working v4.17-rc1
Volume & home buttons gpio-keys Working 5.8
Regulator nodes pma8084, Maxim max77826 Working 5.8
Internal storage sdhci-msm Working 5.8
SD card storage sdhci-msm Working 5.11-rc1
USB Networking DesignWare dwc3_qcom / ChipIdea ci_hdrc_msm Working 5.8
Display subsystem MDSS MDP5 Working Since forever; mdp5 appeared in kernel in 3.14-rc1
LCD Panels Samsung S6E3FA2 AMOLED cmd mode panel, MagnaChip(?) EA8064G AMOLED cmd mode panel Working In pmOS kernel fork
Touchscreen synaptics rmi4-i2c Working 5.11-rc1
Touchkeys Cypress tm2-touchkey Working 5.11-rc1
Vibration motor Maxim max77804k-vibrator Not working
Notification LED Panasonic AN30259A Working 5.11-rc1
WiFi Broadcom BCM4354 (brcmfmac) + PCAL6416A GPIO Expander Working 5.11-rc1
Bluetooth Broadcom BCM4354 (hci_uart_bcm), needs GPIO expander too Working 5.13
USB OTG Maxim max77804k-extcon Not working
Battery charger Maxim max77804k-charger Not working
Battery fuelgauge Maxim max17048 Working 5.11-rc1
GPU drm_msm Adreno 330.2 Working 5.12
HDMI out Silicon Image Sil8240 MHL Not working
Audio WCD9320 (+Audience eS704 voice) Audio Codecs Not working
Modem QCOM_Q6V5_MSS Qualcomm integrated modem Working 5.14
Accelerometer, Gyroscope Invensense MP65M (mpu6500) 6-axis gyro/accel Has mainline driver, CONFIG_INV_MPU6050_IIO
Magnetometer Asahi Kasei Microdevices AK09911C 3-axis compass Has mainline driver, CONFIG_AK09911
Ambient light / Proximity AMS TMG399X Optical Sensor Not working
Sensor HUB STM32 A5006V0 hub Seamless Sensor Platform (SSP) Not working
NFC NXP pn547 Has mainline driver, CONFIG_NFC_NXP_NCI
Cameras s5k2p2xx, s5k8b1yx Not working

Links

postmarketOS packages:

Extra:

Photos