Samsung Galaxy S5 (samsung-klte): Difference between revisions
Line 195: | Line 195: | ||
max77804k with leds only: https://gitlab.com/ichernev/linux-postmarketos/-/tree/max77804k | max77804k with leds only: https://gitlab.com/ichernev/linux-postmarketos/-/tree/max77804k | ||
==== Running on pure mainline ==== | |||
At the moment (5.6), 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 rpm init | |||
Delay RPM 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. | |||
=== Partition layout === | === Partition layout === |
Revision as of 10:16, 10 June 2020
![]() Samsung Galaxy S5 | |
Manufacturer | Samsung |
---|---|
Name | Galaxy S5 |
Codename | samsung-klte |
Released | 2014 |
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 |
Software | |
Original software | Android 4.4.2 (KitKat) |
postmarketOS | |
Category | testing |
Pre-built images | no |
Mainline | partial |
postmarketOS kernel | 3.4.113 / 5.6 |
Unixbench Whet/Dhry score | 884.3 |
Flashing |
Works |
---|---|
USB Networking |
Works |
Internal storage |
No data |
SD card |
No data |
Battery |
Works |
Screen |
Works |
Touchscreen |
Works |
Multimedia | |
3D Acceleration |
Partial |
Audio |
Works |
Camera |
No data |
Camera Flash |
No data |
Connectivity | |
WiFi |
Works |
Bluetooth |
Broken |
GPS |
Works |
NFC |
No data |
Modem | |
Calls |
No data |
SMS |
No data |
Mobile data |
No data |
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
Maintainer(s)
Users owning this device
- Alexeymin (Notes: Test subject #last. Old phone in good shape with new battery)
- Bastindo (Notes: 1x white, 1x black)
- BenWolsieffer
- CalcProgrammer1
- Casept (Notes: x2)
- Chmod-rwx (Notes: Dead battery)
- Drebrez (Notes: Power IC dead)
- EnderNightLord (Notes: great condition)
- Ethical haquer (Notes: AT&T variant (G900A))
- Hisssy (Notes: kltechn (China))
- Icenowy (Notes: kltechnduo)
- Ichernev (Notes: Working on mainline kernel support)
- Maccraft123 (Notes: i also got a bunch of random parts)
- Madhaxbro
- 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
- Oliver193 (Notes: SM-G900F Vodafone model unlocked)
- Rongrong (Notes:
kltechnduo
(G9006W
). WLAN vanished (nothing relevant indmesg
), SMS (w/ofono
.modemmanager
is broken) works; SIM1 works, SIM2 was not tested. WARNING: DO NOT TRY TO FLASHlk2nd
TOkltechnduo
. IT CANNOT BOOT AT ALL!) - Segfault
- Selfisekai
- SnappedAll (Notes: lineageos 18.1, daily driver)
- TPJS (Notes: 6x (all have no screen; two are running PMOS and one is probably dead))
- TryzenAlpensky (Notes: working)
- Unrznbl (Notes: 2022-09-21 heimdall fails to flash)
- V6lhost (Notes: Works fine until I disassembled it)
- Vaulster
- Wurzel3
- Xtex (Notes:
kltechnduo
(G9008W
)) - Yifei (Notes: new battery)
What works
- Flash Kernel (
pmbootstrap flasher flash_kernel
) - Flash Rootfs (
pmbootstrap flasher flash_rootfs
) - Initramfs boot
- USB Network
- Framebuffer graphics (Splash screens)
- SSH Connectivity
- Touchscreen
- 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
- Audio playback without nonfree-userland
- Bluetooth adapter is visible in rfkill list, but does not work
- Everything else
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:
$ pmbootstrap init
...
Vendor [samsung]: samsung <- enter this
Device codename [i9100]: klte <- enter this
Kernel [downstream]: downstream <- you probably want downstream for now
User interface [weston]: <- choose any UI by your preference
...
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!
Nonfree-userland (halium) installation

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
You need to download it, un-sparse and place in to root of userdata partition:
Un-sparse:
$ simg2img halium-klte-2019-07-09-system.img halium-klte-2019-07-09-system.img.raw
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:
$ adb push halium-klte-2019-07-09-system.img.raw /data/system.img
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 /data
mounted (check output of mount
command). Ensure that Android is fully running inside an lxc container (on device, install htop
, run it and switch into tree mode by pressing t) (see the picture on the right). If it does not, check if lxc-android
is running (see output of rc-status
command). Run logcat and see if it is printing some error logs on the screen.
Before (re)starting lxc-android, remember to remove file /tmp/lxc-android-once
if it exists.
Additional info
Useful helper scripts
Default installation includes a couple of useful scripts to be used from a terminal: battery-status
and set-brightness
. battery-status
allows you to check for battery charge level, and set-brightness
allows to view/set lcd backlight brightness in range 0-255.
samsung-klte:~$ battery-status 25 samsung-klte:~$ set-brightness 255 samsung-klte:~$ sudo set-brightness 20 20
Mainlining Notes
Power IC
The phone uses max77804k MFD (Multi Function Device) IC 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 plamo, you'll "crash" the display. The phone continues to work, so this shouldn't be too hard to figure out. Check this issue: https://gitlab.com/postmarketOS/pmaports/-/issues/424
If you just let the phone sit, even with no ui (terminal cursor blinking) the whole phone hard freezes, including usb networking, wifi networking, uart console. And there is no warning in dmesg.
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), 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 rpm init Delay RPM 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.
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 | Downstream 3.4 kernel |
---|---|---|---|---|
Debug serial | msm_serial /dev/ttyMSM0 | Working | v4.17-rc1 | yes, /dev/ttyHSL0 |
Volume & home buttons | gpio-keys | Working | 5.8 | yes |
Regulator nodes | pma8084, Maxim max77826 | Working | 5.8 | yes |
Internal storage | sdhci-msm | Working | 5.8 | yes |
SD card storage | sdhci-msm | Working | In pmOS kernel fork | yes |
USB Networking | usb_dwc3_qcom | Working | 5.8 | yes |
Display | panel-simple | Working | In pmOS kernel fork | yes |
Touchscreen | synaptics rmi4-i2c | Working | In pmOS kernel fork | yes |
Touchkeys | Cypress tm2-touchkey | Working | In pmOS kernel fork | yes |
Vibration motor | Not working | yes | ||
Notification LED | Panasonic AN30259A | Working | In pmOS kernel fork | yes |
WiFi | brcmfmac + PCAL6416A GPIO Expander | Working | In pmOS kernel fork | yes |
USB OTG | Not working | yes | ||
Bluetooth | brcmfmac | Not working | no | |
Battery charger | Maxim max77804k | Not working | yes | |
Battery fuelgauge | Maxim max17048 | Working | In pmOS kernel fork | yes |
GPU | drm_msm | Working | in pmOS kernel fork | works with libhybris (test_hwcomposer_7_1_caf) |
Audio | Not working | with libhybris (pulseaudio-modules-droid) | ||
Modem | qcom-q6v5-mss | Not working | powers up with libhybris | |
Sensors | Not working | yes (libhybris's test_sensors) |
Links
postmarketOS packages:
Mainline kernel patches:
- initial dts https://patchwork.kernel.org/patch/10150807/
- usb-net, storage, hwkeys dts https://lore.kernel.org/patchwork/project/lkml/list/?series=438265
- max77826 driver https://lore.kernel.org/patchwork/project/lkml/list/?series=438450
- max17048 fuelgauge driver https://lore.kernel.org/patchwork/project/lkml/list/?series=447534
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:
- Full phone specifications
- Samsung Galaxy S5 Teardown
- UART guide
- Demo of Samsung klte running Plasma Mobile
- Plasma Mobile Kirigami Gallery demo on samsung-klte
Photos
-
Weston
-
Xfce4 UI
-
UART debugging
-
Plasma Mobile homescreen
-
Plasma Mobile top panel
-
Plasma Mobile Index file manager
-
klte x2
-
Android processes running inside lxc container