[Solved] Samsung S8 Dex without Dex Station

SilentMobius

Senior Member
Apr 17, 2007
269
39
0
I posted the below in the other Dex related thread and I thought it might be a good idea to post it here for those that hadn't seen it:

Hi All, I just had a look through the S8 kernel source as I figured that anything in /sys/class would most likely have kernel code to support it, looks like the "Dex check" is as follows:

Code:
bool check_dex_support(struct displayport_device *displayport)
{
	if (displayport->ven_id == SAMSUNG_VENDOR_ID
			&& displayport->prod_id == DEXDOCK_PRODUCT_ID)
		return true;

#ifdef CONFIG_DISPLAYPORT_ENG 
	return true;
#else
	return false;
#endif
}
Which is pretty ****ty IMHO. CONFIG_DISPLAYPORT_ENG is a define that isn't set in the release kernel so, it looks like the only way to do this would be to spoof the vend/prod id's on the displayport adapter. I'm not sure id these ID's are displayport native data or USB ID's that then signal the electrical change of using the alt-mode pairs, though it's stored in the "dispayport" struct.

That is assuming that this check echo's out to /sys/class/dp_sec/dex and the dex_home checks it.

That said, for unlocked/rooted users if the samsung source compiles it should be a simple job to compile with CONFIG_DISPLAYPORT_ENG set

EDIT:
the prod/Ven ID's do come from the USB subsystem when a CCIC_NOTIFY_ATTACH is sent:

Code:
displayport->ven_id = usb_typec_info.sub2;
displayport->prod_id = usb_typec_info.sub3;

if(check_dex_support(displayport))
    displayport_info("Dex mode supported product connected\n");
Also, here are the numbers it's expecting:
Code:
/* Samsung Acc VID */
#define SAMSUNG_VENDOR_ID 0x04E8
#define SAMSUNG_MPA_VENDOR_ID 0x04B4
/* Samsung Acc PID */
#define DEXDOCK_PRODUCT_ID 0xA020
#define HDMI_PRODUCT_ID 0xA025
#define MPA_PRODUCT_ID 0x2122
 

bogdi1988

Senior Member
Mar 16, 2007
1,361
142
83
Seattle, WA
I know Samsung likes to take advantage of magnets for various features.
Example: flip case has a magnet in a specific location. Keyboard add-on has a couple magnets. That's how the device recognizes that the accessories are installed.
Curious if the DeX has a magnet in the base, and the cable plugged + magnet would enable the DeX feature.
 

Tricky901

New member
Jun 20, 2017
1
0
0
So i tried the magnet + hdmi and keyboard mouse combo.. It does not work, currently using the sentio app to have the closest thing to a desktop.
 

bogdi1988

Senior Member
Mar 16, 2007
1,361
142
83
Seattle, WA
So i tried the magnet + hdmi and keyboard mouse combo.. It does not work, currently using the sentio app to have the closest thing to a desktop.
So I kinda peeked inside my DeX unit. Couldn't open it all the way but it looked like it might be an NFC chip/antenna in the sliding base?

---------- Post added at 12:06 AM ---------- Previous post was at 12:05 AM ----------

So i tried the magnet + hdmi and keyboard mouse combo.. It does not work, currently using the sentio app to have the closest thing to a desktop.
Oh, and that Sentio app screams DeX in the design/UI part!
 

Meleor

Member
Dec 11, 2012
40
38
0
Sentio's app is so lame comparing to Dex, Continuum or Oxi OS.

QUESTION NOW IS : How to fake the Samsung ID on a random dock station ?
 

fonix232

Senior Member
Jun 20, 2009
1,054
553
143
London
I know Samsung likes to take advantage of magnets for various features.
Example: flip case has a magnet in a specific location. Keyboard add-on has a couple magnets. That's how the device recognizes that the accessories are installed.
Curious if the DeX has a magnet in the base, and the cable plugged + magnet would enable the DeX feature.
There's only a single magnet, used with a hall effect sensor to trigger phone sleep/wake when you close/open the flip case. Actual ID of the device connected is transferred via NFC.

I see that you're trying to crack this from the bottom up, making the kernel recognize anything as a DeX device. How about the other way around, hacking the DeX app itself to run even on unsupported hardware, as a third party app (change package name, change checks for devices)?
 

kbarni

Senior Member
Nov 16, 2010
204
128
73
I still wonder if the CONFIG_DISPLAYPORT_ENG switch in the kernel could solve the problem...
I have a rooted S8 and a HDMI adapter, so I'm willing to test it, if anybody could compile a kernel for me. Unfortunately I couldn't recompile it myself, I think the NDK I'm using is too old (or I'm making something wrong).
 

karatekid430

Senior Member
May 28, 2017
84
39
0
Okay, I bought a Galaxy S8 SM-G950F for AUD $350. How so cheap? It is smashed and the screen doesn't work - it just displays random colours.

That does not matter with the Galaxy S8. I went there and used my multiport adapter to help the previous owner factory reset it with a mouse, keyboard and TV through HDMI. I got it home and it works on DeX. Thankfully neither of the cameras are smashed, and the fingerprint works.

Unfortunately it is Telstra, so my first step will be flashing carrierless XSA firmware. Then I will use Magisk root, and recompile and flash the kernel with the option set to allow DeX always. I will report back.
 

fonix232

Senior Member
Jun 20, 2009
1,054
553
143
London
Please gather anybody who might have an interest and get them to make accounts here. Later on I will be starting a petition. It will take a few days as I am going to make it elaborate with images and diagrams. Let's kick Samsung's A and get the right to choose third party hardware, which is what USB-C is all about.

Thanks for following.
You can use any Type-C accessory. But their feature, SAMSUNG'S OWN FEATURE, is hardware locked for a reason.
 

karatekid430

Senior Member
May 28, 2017
84
39
0
You can use any Type-C accessory. But their feature, SAMSUNG'S OWN FEATURE, is hardware locked for a reason.
Yes, but:
- a) I would be happy to pay to unlock it for any adapter
- b) You could argue that paying $1349 for a flagship would entitle us to use whatever we want, anyway

---------- Post added at 05:42 AM ---------- Previous post was at 05:36 AM ----------

Okay my Galaxy S8 with the smashed (and not working) screen is rooted and passes Safety Net. After playing with the /sys/class/dp_sec files, it looks like this is only part of the story. Even if these are modified to values that occur when the DeX is connected, there must be other things under the hood that are not right.

I have flashed the kernel I compiled (CONFIG_DISPLAYPORT_ENG=y), but it does not boot. I used Android Kitchen and just extracting the Samsung official boot.img and repacking results in a file 3MB less. I then tried on Windows and it created one of similar size, but still would not boot.

I flashed the stock boot.img back and now it works again. Does anybody know how to compile and pack a Samsung kernel? I use Ubuntu 17.04 and / or Windows 10.

I used the steps here, more or less: https://forum.xda-developers.com/an...erence-how-to-compile-android-kernel-t3627297

Thanks!
 

kbarni

Senior Member
Nov 16, 2010
204
128
73
Okay, I've got a (partially) working kernel with CONFIG_DISPLAYPORT_ENG enabled. (the touchscreen isn't working - probably something wrong with the configuration files -, I'll try to solve it; now I could test it with a mouse)

When it first booted, I got a Dex greeting message! YEAH! :laugh:

Unfortunately I can't try the HDMI output until monday (I don't have the adaptor at home). I hope DEX will work without further complications. Fingers crossed!
 
Last edited:

fonix232

Senior Member
Jun 20, 2009
1,054
553
143
London
Yes, but:
- a) I would be happy to pay to unlock it for any adapter
- b) You could argue that paying $1349 for a flagship would entitle us to use whatever we want, anyway


a, It's not about paying. They make the accessory, you use that. But above that, Samsung cannot guarantee the same quality of service with a third party docking system (especially since most of them are incapable of QC2.0, which is a key requirement for this to work properly).
 

karatekid430

Senior Member
May 28, 2017
84
39
0
a, It's not about paying. They make the accessory, you use that. But above that, Samsung cannot guarantee the same quality of service with a third party docking system (especially since most of them are incapable of QC2.0, which is a key requirement for this to work properly).
The phone supports (afaik) all three of the QC, Samsung AFC, and USB PD. I cannot verify the QC, but I have used both AFC and USB PD, with the phone alone, and with the DeX Station.

In fact, the USB PD could supply enough power to run the DeX and simultaneously fast charge the phone. The Samsung EP-TA20 can only power the DeX and standard charge the phone. Samsung told me the 12V 2.1A 25W TabPro S AFC could do fast charging through the DeX, but since this is discontinued, I cannot verify that.

Technically the charging is not a key requirement - although it would be a major inconvenience if you could not charge it at all.

The reasons I want to use a different product:
- DeX is bulky and cannot go in a laptop bag. A USB-C multi-port adapter is a fraction of the size. You can get these that can even support USB PD for fast charging through them.
- DeX is not hitting the limits of the USB-C connector. USB-C allows for 2-lane DP and a USB SS channel, or 4-lane DP alone. This means that the port should be able to support both 3840x2160p30 and 5Gbps USB for Gigabit Ethernet and fast USB ports, or 3840x2160p60 and a USB 2.0 signal. Since the phone can support 3840x2160p60 DisplayPort, and USB 10Gbps (not simultaneously), it means the dock is, for lack of a better word, half-arsed. My biggest peeve is not having 1GBASE-T (which I can verify works without the DeX, attached directly to the phone - RTL8153, iperf 900Mbps). Even my wireless is legitimately faster than 100MBASE-T.
- They went out of their way to convert DP signal to inferior HDMI, adding cost, complexity, and reducing the versatility of the dock. It is very difficult to convert HDMI back to DisplayPort, and even then, AdaptiveSync would be lost. Really they should have just left the video output as a USB-C so that we can adapt it to whatever takes our fancy.

---------- Post added at 10:29 AM ---------- Previous post was at 10:24 AM ----------

Okay, I've got a (partially) working kernel with CONFIG_DISPLAYPORT_ENG enabled. (the touchscreen isn't working - probably something wrong with the configuration files -, I'll try to solve it; now I could test it with a mouse)

When it first booted, I got a Dex greeting message! YEAH! :laugh:

Unfortunately I can't try the HDMI output until monday (I don't have the adaptor at home). I hope DEX will work without further complications. Fingers crossed!
That is amazing news! With the touch screen, do you mean the screen on the phone, or do you mean an external touchscreen monitor? I have an external touchscreen, Dell S2340T, and its touch works with DeX.

Could you please tell me how to pack the boot.img with the new kernel? I compiled successfully, but when flashed with the packed boot.img, it just hangs on the "SAMSUNG GALAXY S8" bootloader screen. I used the compiler toolchain from Google, using arm64 arch and cross compile environment variables. I tried both in Windows 10 Bash running Ubuntu 17.04 and also actual Ubuntu 17.04 on a laptop.

Thanks!
 

russ18uk

Senior Member
Aug 1, 2011
472
80
0
Would save on cost too due to royalties.

Anyway, the Switch and DeX docks have been reproduced by the Chinese with the CF001. Luckily for us S8 users is that it seems Nintendo went with the same method of whitelist/lockout.

Only a matter of time now before they will be much easier to find. There is a crowdfunded one which is a rebrand of the CF001.
 

kbarni

Senior Member
Nov 16, 2010
204
128
73
That is amazing news! With the touch screen, do you mean the screen on the phone, or do you mean an external touchscreen monitor? I have an external touchscreen, Dell S2340T, and its touch works with DeX.

Could you please tell me how to pack the boot.img with the new kernel? I compiled successfully, but when flashed with the packed boot.img, it just hangs on the "SAMSUNG GALAXY S8" bootloader screen. I used the compiler toolchain from Google, using arm64 arch and cross compile environment variables. I tried both in Windows 10 Bash running Ubuntu 17.04 and also actual Ubuntu 17.04 on a laptop.

Thanks!
I agree that this is a great news!

Here's what I did: I was using Jesse's kernel sources, compiled with the UberTC 7.1 or 8.1 toolchain (from the thread you linked): ./build_kernel dreamlte Then, I obtained the original boot.img from the Jesse's flashable kernel zip, unpacked with Android Image Kitchen (again, from the tutorial: ./unpackimg boot.img), replaced the boot.img-zImage with the Image file from the kernel_out folder, then repackaged the boot image (./repackimg). Finally flashed this the image-new.img from TWRP (as image file).

Other toolchains either couldn't build the kernel, or it was even worse. I might try other kernels to see if I can get better results. Unfortunately, the unresponsive touchscreen (of the phone) seems like a driver problem, as it persists if I build the kernel without the CONFIG_DISPLAYPORT_ENG switch.

I post the kernel I built, but USE IT WITH PRECAUTION! As i said, touchscreen isn't working! Have a backup of your system (later you can restore only the boot partition) and a mouse connected to your phone. If you need to reboot the phone in TWRP, hold VolumeDown+Power key for 6 seconds, then (before it vibrates) VolumeUp+Bixby+Power until TWRP starts.

I AM NOT RESPONSIBLE FOR ANY DAMAGE DONE TO YOUR DEVICE IF YOU DECIDE TO USE THIS KERNEL! Here's the link for the kernel image to test.
 

karatekid430

Senior Member
May 28, 2017
84
39
0
I agree that this is a great news!

Here's what I did: I was using Jesse's kernel sources, compiled with the UberTC 7.1 or 8.1 toolchain (from the thread you linked): ./build_kernel dreamlte Then, I obtained the original boot.img from the Jesse's flashable kernel zip, unpacked with Android Image Kitchen (again, from the tutorial: ./unpackimg boot.img), replaced the boot.img-zImage with the Image file from the kernel_out folder, then repackaged the boot image (./repackimg). Finally flashed this the image-new.img from TWRP (as image file).

Other toolchains either couldn't build the kernel, or it was even worse. I might try other kernels to see if I can get better results. Unfortunately, the unresponsive touchscreen (of the phone) seems like a driver problem, as it persists if I build the kernel without the CONFIG_DISPLAYPORT_ENG switch.

I post the kernel I built, but USE IT WITH PRECAUTION! As i said, touchscreen isn't working! Have a backup of your system (later you can restore only the boot partition) and a mouse connected to your phone. If you need to reboot the phone in TWRP, hold VolumeDown+Power key for 6 seconds, then (before it vibrates) VolumeUp+Bixby+Power until TWRP starts.

I AM NOT RESPONSIBLE FOR ANY DAMAGE DONE TO YOUR DEVICE IF YOU DECIDE TO USE THIS KERNEL! Here's the link for the kernel image to test.
No doubt the screen not working is because it is some random person's kernel. I am trying to build the exact same stock kernel and boot image except for the one config change. I could probably just take the normal one and modify a DWORD or something using a hex editor to change the return value, but I am really not good enough at assembly to find the location.

If you are having the issue with the touch screen, I suggest using the same method you are already using, except download the source from the Samsung website (http://opensource.samsung.com/reception/receptionSub.do?method=sub&sub=F&searchValue=sm-g950f for SM-G950F) and compile with that. If that does not work then we have to start questioning our understanding of logic, or at the very least the compiler toolchain. Can you attach to an external touch screen and see if that is affected?

I would love to try that kernel straight away, but I am a fan of keeping things stock. I really wish Samsung would ship with a su binary for developers to enable for purposes other than running custom ROMs. All I want is a stock Samsung ROM with Magisk for now. AOSP is just horrid in my experience, Samsung really makes Android for me.

But thanks for that, I will see if I can apply that method to the Samsung stock source code. I will let you know.
 

fonix232

Senior Member
Jun 20, 2009
1,054
553
143
London
The phone supports (afaik) all three of the QC, Samsung AFC, and USB PD. I cannot verify the QC, but I have used both AFC and USB PD, with the phone alone, and with the DeX Station.

In fact, the USB PD could supply enough power to run the DeX and simultaneously fast charge the phone. The Samsung EP-TA20 can only power the DeX and standard charge the phone. Samsung told me the 12V 2.1A 25W TabPro S AFC could do fast charging through the DeX, but since this is discontinued, I cannot verify that.

Technically the charging is not a key requirement - although it would be a major inconvenience if you could not charge it at all.

The reasons I want to use a different product:
- DeX is bulky and cannot go in a laptop bag. A USB-C multi-port adapter is a fraction of the size. You can get these that can even support USB PD for fast charging through them.
- DeX is not hitting the limits of the USB-C connector. USB-C allows for 2-lane DP and a USB SS channel, or 4-lane DP alone. This means that the port should be able to support both 3840x2160p30 and 5Gbps USB for Gigabit Ethernet and fast USB ports, or 3840x2160p60 and a USB 2.0 signal. Since the phone can support 3840x2160p60 DisplayPort, and USB 10Gbps (not simultaneously), it means the dock is, for lack of a better word, half-arsed. My biggest peeve is not having 1GBASE-T (which I can verify works without the DeX, attached directly to the phone - RTL8153, iperf 900Mbps). Even my wireless is legitimately faster than 100MBASE-T.
- They went out of their way to convert DP signal to inferior HDMI, adding cost, complexity, and reducing the versatility of the dock. It is very difficult to convert HDMI back to DisplayPort, and even then, AdaptiveSync would be lost. Really they should have just left the video output as a USB-C so that we can adapt it to whatever takes our fancy.
Samsung AFC is just Qualcomm's actual QC with a few more restrictions (that's why my QC3.0 charger with the proper cable shows up as fast charging). USB-PD in my experience does not work, though I have the international 950F model, might be a limitation of the Exynos model itself.

Samsung tied it to the dock because it was designed to cool the device while pushing it to the limits. Any other solution means a security risk, and if they allowed it, there would be people killing their devices by not using adequate cooling, et cetera.

Sure, it's bulky. It would be nice if it could be folded into something flat. But Samsung didn't design it like that. Maybe they will release a next revision. And sure it is limited. I for one would prefer a lapdock style thing, with a battery pack, built-in storage, screen, etc. It would be awesome.

And I don't think they are converting DP to HDMI, they are using MLP over Type-C for HDMI output, just switch the source of the stream from the actual display buffer to the secondary (desktop) view.
 

kbarni

Senior Member
Nov 16, 2010
204
128
73
@karatekid430 I've been using Jesse's kernel with Renovate Ice rom for two months (since I got my S8) and I'm very pleased with it's performances; that's why I chose to modify it.
I tried to build the stock kernel with Google's 4.9 toolchain. I got the same problem as you, my S8 got stuck at the boot logo (despite trying several methods to build and package it). That said, you can still test my kernel and then restore the stock kernel.
Tomorrow I'll have my HDMI adaptor, so I'll be able to test if Dex shows up on an external screen.

@fonix232 I'm still pretty sure Samsung locked Dex to the dock mainly to be able to sell a 150$ accessory (a bit like iPhone that misses the jack connector to be able to sell the earbuds).
If screen mirroring works with Wifi and UsbC->HDMI adaptor, I son't see why Dex wouldn't work. That said, it's sure that the Dex dock is a good peripheral offering qood connectivity and cooling, but I'm sure they could solve this if they wanted.
 
Last edited: