Jump to content

Samsung Galaxy S5 (samsung-klte)

From Nura Wiki
Samsung Galaxy S5
Samsung Galaxy S5
Samsung Galaxy S5
Manufacturer Samsung
Name Galaxy S5
Codename samsung-klte
Released 2014
Type handset
Hardware
Chipset Qualcomm Snapdragon 801 (MSM8974PRO-AC)
CPU Quad-core 2.5 GHz Krait 400
GPU Adreno 330
Display 1080x1920 AMOLED
Storage 16/32 GB
Memory 2 GB
Architecture armv7
Software
Original software
The software and version the device was shipped with.
Android 4.4.2
Extended version
The most recent supported version from the manufacturer.
Android 6.0.1
Nura
Category archived
Mainline
Instead of a Linux kernel fork, it is possible to run (Close to) Mainline.
no
Nura kernel
The kernel version that runs on the device's port.
6.9.1
Unixbench score
Unixbench Whetstone/Dhrystone score. See Unixbench.
884.3
Device package device-samsung-klte
Kernel package linux-postmarketos-qcom-msm8974
Firmware package firmware-samsung-klte
Features
Flashing
Whether it is possible to flash the device with pmbootstrap flasher.
Works
USB Networking
After connecting the device with USB to your PC, you can connect to it via telnet (initramfs) or SSH (booted system).
Partial
Battery
Whether charging and battery level reporting work.
Partial
Screen
Whether the display works; ideally with sleep mode and brightness control.
Works
Touchscreen
Works
Multimedia
3D Acceleration
Partial
Audio
Audio playback, microphone, headset and buttons.
Broken
Camera
Broken
IR TX
Broken
Connectivity
Wi-Fi
Works
Bluetooth
Works
GPS
Broken
NFC
Near Field Communication
Broken
Modem
Calls
Broken
SMS
Works
Mobile data
Works
Miscellaneous
FDE
Full disk encryption and unlocking with unl0kr.
Untested
USB OTG
USB On-The-Go or USB-C Role switching.
Broken
Sensors
Accelerometer
Handles automatic screen rotation in many interfaces.
Broken

Contributors

Maintainer(s)

Users owning this device

  • Alexeymin (Notes: Old phone in good shape with new battery. Hopefully I'll never touch it again)
  • Bac0n (Notes: SXMO has been implemented. Docomo version, model number SC-04F.)
  • Bastindo (Notes: 1x white, 1x black)
  • BenWolsieffer
  • CalcProgrammer1
  • Casept (Notes: x2)
  • Chipmunk (Notes: SM-G900A, LineageOS)
  • Chmod-rwx (Notes: Dead battery)
  • Devbrones
  • Drebrez (Notes: Power IC dead)
  • DTBTech (Notes: cracked screen)
  • EnderNightLord (Notes: great condition)
  • Ethical haquer (Notes: AT&T variant (G900A))
  • Flagship Polaris (Notes: Optus Locked EMMC_11 Unit)
  • Gavodavo (Notes: AT&T model :()
  • H3 (Notes: runs lineageOS 18.1 (Android 11))
  • Hisssy (Notes: kltechn (China))
  • Icenowy (Notes: kltechnduo)
  • Ichernev (Notes: Working on mainline kernel support)
  • Jdkjkjj (Notes: Runs lineageos android 13)
  • Loomhigh (Notes: Has old fashioned charger)
  • Maccraft123 (Notes: i also got a bunch of random parts)
  • Madhaxbro (Notes: SM-G900F, runs lk2nd + pmOS edge + TWRP. Ready for testing. Weak battery. Every browser crashes when loading a webpage. Bluetooth is cooked, nothing works. Not sure if mine is broken, firmware issue perhaps?)
  • Magic RB
  • Manty (Notes: Android development)
  • Minecrell (Notes: SM-G900F with fa2 panel)
  • Mossroy (Notes: unused, with a screen that has brightness issues)
  • Nobodywasishere
  • Nspire
  • OHA (Notes: 5.2026: runs pmOS with lxqt)
  • Oliver193 (Notes: SM-G900F Vodafone model unlocked)
  • Olofolleola4 (Notes: SM-G900F - postmarketOS edge)
  • Rongrong (Notes: kltechnduo (G9006W). WLAN vanished (nothing relevant in dmesg), SMS (w/ ofono. modemmanager is broken) works; SIM1 works, SIM2 was not tested. WARNING: DO NOT TRY TO FLASH lk2nd TO kltechnduo. IT CANNOT BOOT AT ALL!)
  • Selfisekai
  • SnappedAll (Notes: lineageos 18.1, daily driver)
  • TryzenAlpensky (Notes: working)
  • Unrznbl (Notes: 2022-09-21 heimdall fails to flash)
  • V6lhost (Notes: Was working fine until I decided to open it)
  • Vaulster
  • Werti (Notes: 6x (all have no screen; two are running PMOS and one is probably dead))
  • Wurzel3
  • Xtex (Notes: kltechnduo (G9008W))
  • Yifei (Notes: new battery)
  • Zvava (Notes: two of them; one with lineage os 18.1, and one with ubuntu touch but no screen)

Status table explanation

This table explains more in detail why some features are marked as partial (P). Generally it's because a feature works with some limitations, or is "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

Special boot modes

  • Download/Odin Mode: With the device powered off, hold Volume Down, Home and Power while connecting the device to a computer with a USB cable. A warning screen will appear: click Volume Up to enter Download Mode and run Heimdall commands.
    • Alternatively, with USB debugging enabled, run $ adb reboot download on a connected USB host.
  • Fastboot Mode (lk2nd): Power on the device, then immediately hold Volume Down.
  • Recovery Mode: With the device powered off, hold Volume Up, Home and Power while connecting the device to a computer with a USB cable.
    • Alternatively, with USB debugging enabled, run $ adb reboot recovery on a connected USB host.
    • If lk2nd is installed, it's also available by powering on the device and immediately holding Volume Up.

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

Boot the device in Download Mode, and run:

$ pmbootstrap flasher --method=heimdall-bootimg flash_rootfs

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

$ pmbootstrap flasher --method=heimdall-bootimg flash_kernel --no-install

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

Installation with lk2nd

Note Currently, lk2nd only officially supports the international variant (klte), unofficially, any other variants with a revision id of 14 should work partially. Otherwise, lk2nd would probably fail to boot. Refer to the #Links section to learn more about porting lk2nd to your variant.

The lk2nd bootloader is cable of booting directly from the ext2 filesystem and can be chainloaded to install Nura on the Galaxy S5. With this method kernel updates don't require reflashing the device. Soon this will be the required way to perform the installation, and booting Nura on samsung-klte without lk2nd will not be supported.

  1. Generate all images locally:
    $ pmbootstrap init
     select samsung-klte, your favorite UI (but only fbkeyboard is really stable now. If you want to select UI that is not shown because of GPU support limitation, do one of the below:
    $ pmbootstrap config ui phosh
     or, alternatively
    $ pmbootstrap config ui plasma-mobile
    <syntaxhighlight lang="shell-session">
    $ pmbootstrap install [--no-firewall] [--password=123456]
    
  2. Boot into Download Mode and flash lk2nd:
    $ pmbootstrap flasher --method=heimdall-bootimg flash_lk2nd
    
    • Do this step only once. If you want to reinstall Nura and already have lk2nd installed, there is no need to repeat this.
  3. When the phone automatically reboots, hold Volume Down without Home) to get into lk2nd/fastboot mode. In this mode, run:
    $ pmbootstrap flasher flash_kernel --no-install
    $ pmbootstrap flasher flash_rootfs [--partition userdata]  # install to userdata if you want more space in /, when using full UIs like phosh or plasma
    $ fastboot erase system # only if you have flashed rootfs to userdata partition in the previous command
    $ fastboot reboot
    

Status and hardware table

Component Codename Mainline Introduced Notes
Debug serial msm_serial /dev/ttyMSM0 Y v4.17-rc1
Volume & home buttons gpio-keys Y 5.8
Regulator nodes pma8084, Maxim max77826 Y 5.8
Internal storage sdhci-msm Y 5.8
SD card storage sdhci-msm Y 5.11-rc1
USB Networking DesignWare dwc3_qcom / ChipIdea ci_hdrc_msm Y 5.8 Only works the first time it is plugged, and only if the (experimental) max77804k is not enabled
Display subsystem MDSS MDP5 Y 3.14-rc1
LCD Panels Samsung S6E3FA2 / MagnaChip(?) EA8064G Y Both are AMOLED command mode panels. In Nura kernel fork
Touchscreen synaptics rmi4-i2c Y 5.11-rc1
Touchkeys Cypress tm2-touchkey Y 5.11-rc1 See Tm2-touchkey for instructions
Vibration motor Maxim max77804k-vibrator N
Notification LED Panasonic AN30259A Y 5.11-rc1
Wi-Fi/Bluetooth Broadcom BCM4354 + PCAL6416A GPIO expander Y 5.11-rc1 It can sometimes fail to list APs
USB OTG Maxim max77804k-extcon N
Battery charger Maxim max77804k-charger N May not stop charging, unlike Android kernels
Fuel gauge Maxim max17048 Y 5.11-rc1
GPU drm_msm Adreno 330.2 Y 5.12
HDMI out Silicon Image Sil8240 MHL N
Audio Codec Qualcomm WCD9320 (+ Audience eS704 voice) N
Modem QCOM_Q6V5_MSS Qualcomm integrated modem Y 5.14
Accelerometer, Gyroscope Invensense MP65M (mpu6500) Y Has mainline driver, CONFIG_INV_MPU6050_IIO
Magnetometer Asahi Kasei AK09911C Y Has mainline driver, CONFIG_AK09911
Ambient light / Proximity AMS TMG399X Optical Sensor N
Sensor HUB STM32 A5006V0 hub Seamless Sensor Platform (SSP) N
NFC NXP PN547 Y Has mainline driver, CONFIG_NFC_NXP_NCI
Cameras s5k2p2xx, s5k8b1yx N

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

Modem

Mobile data and SMS work and require APN credentials to use. Calling technically works but without audio, rendering it useless.

Modem usage instructions

First, install a SIM card into device (obviously). When using the device without a mobile UI:

  • Install ModemManager manually: $ sudo apk add modemmanager
  • Start the service: $ sudo rc-service ModemManager start (on OpenRC)
    • Optionally, add it to default runlevel: $ sudo rc-update add modemmanager default
  • Check if the SIM card is detected and is registered: $ mmcli -m any

Add network connection using the 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[dead link], including oFono instructions.

Mainlining notes

Note For any concerned reader, the bold bulleted list and em dashes were written by humans before LLMs. :)

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 paragraphs, max77804k code will be referred to 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 straightforward, 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.

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.

USB

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.

Parts Bin code

Running on pure mainline

The following patch is required to run mainline version 5.6: (this is still needed in 5.13-rc)

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/Carkit debug cable with a 619kΩ resistor (see also MUIC)

Read help for CONFIG_DEBUG_QCOM_UARTDM kernel config. 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.

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 cpufreq-info). The configured default is conservative (CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE), which may be less thermally demanding than others.

Troubleshooting

Bluetooth

If you see errors about "Reading local version info failed (-110)" in dmesg like this:

[   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)

Then try reloading the bluetooth-uart driver module:

$ sudo modprobe -r hci_uart
$ sudo modprobe hci_uart

Bluetooth should now be recognized in dmesg:

[ 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

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

Alternatively, for an exhaustive or annotated output, try systool (lm-sensors package):

$ systool -v -c thermal
$ systool -c thermal  -A temp

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

Gallery

External links