Samsung Galaxy S5 (samsung-klte)

Contributors

 * drebrez
 * Alexey Min
 * Iskren Chernev

Maintainer(s)

 * Alexey Min
 * Iskren Chernev

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":

How to enter flash mode
Press and hold +  +  simultaneously. Then click to confirm.

How to enter recovery mode
Press and hold +  +  simultaneously.

Installation
First, install pmbootstrap.

Setup device to be used:

Build the rootfs image:

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

Installation with lk2nd
You can use custom 2nd stage bootloader to install postmarketOS on Samsung Galaxy S5. Soon this will be the required way to perform the installation, and booting postmarketOS on samsung-klte without lk2nd will not be supported. It requires that you have pmbootstrap >= 1.42.3.

1. Generate all images locally

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

3. Flash lk2nd Do this step only once. If you want to reinstall postmarketOS and already have lk2nd installed, no need to repeat this.

After executing that command phone will automatically reboot. Hold (whithout ) while booting to get into lk2nd/fastboot mode.

4. Now in lk2nd/fastboot mode, do as usual

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.

Bluetooth
If you see errorrs about "Reading local version info failed (-110)" in dmesg, like this: $ dmesg | grep Bluetooth [  20.451424] Bluetooth: Core ver 2.22 ... [  23.035059] Bluetooth: hci0: command 0x1001 tx timeout ... [  31.195124] Bluetooth: hci0: BCM: Reading local version info failed (-110)

the try to reload bluetooth-uart driver module

$ sudo modprobe -r hci_uart $ sudo modprobe hci_uart

The you should see in dmesg that bluletooth is recognized (example):

[ 1945.562907] Bluetooth: hci0: BCM: chip id 92 [ 1945.566860] Bluetooth: hci0: BCM: features 0x2f [ 1945.591717] Bluetooth: hci0: BCM4350C0 [ 1945.591731] Bluetooth: hci0: BCM4354 (003.001.012) build 0000 [ 1945.593732] Bluetooth: hci0: BCM4354 'brcm/BCM4354.hcd' Patch [ 1954.428045] Bluetooth: hci0: BCM4354 37.4MHz SEMCO-B80 K-LTE-0395 [ 1954.428065] Bluetooth: hci0: BCM4354 (003.001.012) build 0797

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  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  Signed-off-by: Brian Masney 

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  @@ -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;
 * 1) include 
 * 2) include 
 * 3) include 
 * 1) include 
 * 2) include 

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 with 619kΩ resistor (see also MUIC)

Read help for CONFIG_DEBUG_QCOM_UARTDM kernel konfig. Enable  +   + correct addresses for   and. The ones listed in a help for  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  to kernel command line. This allows to receive debug messages from such early stages so you can even debug kernel self-decompressor.

CPU tuning
At present the WIP kernel (linux-postmarketos-qcom-msm8974) does not configure frequency scaling (CONFIG_PM_DEVFREQ), so no choice in governors is available (try ). The configured default is conservative (CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE), which may be less thermally demanding (see next item) than others.

If the phone becomes too hot
Use this to check temperatures:

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

Alternatively, for an exhaustive or annotated output, try  (lm-sensors package), e.g.,

For a dynamic graphical (ncurses) display of temperatures, try  (linux-tools-tmon package).

Using modem
First, install SIM card into device (obviously). When using device without mobile UI, you will need to install modemmanager manually, start the service (optionally add it to defult runlevel:  ). Check out if SIM card is detected and is registered:.

Add network connection using cell network:

Check connection status using  and if   got the IP address using.

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

Links
postmarketOS packages:
 * (obsolete)
 * (close to mainline)
 * Mainline kernel source
 * lk2nd support (klte)
 * lk2nd support (kltechn/kltechnduo)
 * lk2nd support (klte)
 * lk2nd support (kltechn/kltechnduo)

Extra:
 * Full phone specifications
 * Samsung Galaxy S5 Teardown
 * UART guide
 * Deviceinfo HW page
 * Demo of Samsung klte running Plasma Mobile
 * Plasma Mobile Kirigami Gallery demo on samsung-klte