sebanc / brunch

Boot ChromeOS on x86_64 PC - Supports Intel CPU/GPU from 8th gen or AMD Ryzen
GNU General Public License v3.0
3.71k stars 393 forks source link

Tablet mode issues #345

Open KonstantinosDetsis opened 4 years ago

KonstantinosDetsis commented 4 years ago

Hello, I've been using brunch for the past month on my Surface Pro (1st gen) and I really like it although I have an issue. De-attaching the keyboard does not automatically put the device to tablet mode. As you requested here is the output of "sudo udevadm monitor" and de-attaching and re-attaching the keyboard. I am currently using the latest version of brunch (Brunch r83 k4.19 testing 20200614) and latest version of ChromeOS (83). Also here is my grub config and output of "uname -a" just in case you need it.

..cros_debug enforce_hyperthreading=1 options=enable_sensors,acpi_power_button

Linux localhost 4.19.122-brunch-sebanc SMP PREEMPT Sun Jun 14 11:23:46 CEST 2020 x86_64 Intel(R) Core(TM) i5-3317U CPU @ 1.70GHz GenuineIntel GNU/Linux

Should I also be using the samus recovery?

sebanc commented 4 years ago

Hi,

Could you try tablet mode with the unstable release available below ? https://github.com/sebanc/brunch-testing/releases

Yes for Intel Gen 3 samus is the right recovery.

KonstantinosDetsis commented 4 years ago

Thanks! I installed it but it doesn't do anything. I installed it using chromeos-update. Do I need to install it from scratch? Also here you said that it takes long to boot. Do you mean the linux sort of boot or the chrome logo because my Surface takes a long time there?

sebanc commented 4 years ago

chromeos-update should be ok, could you attach a dmesg to this issue ? (run "dmesg > ~/Downloads/dmesg.txt" in crosh shell and attach dmesg.txt from you downloads folder).

The chromeos logo is displayed while kernel modules are being loaded, you can have the ui displayed earlier by using "options=no_ui_delay" (the modules will load in the background but it causes issues with android apps on some devices).

KonstantinosDetsis commented 4 years ago

Here is the dmesg. Also I didn't have the issue with long ChromeOS logo boot before I updated to ChromeOS 83. dmesg.txt

(Edit) Adding no_ui_delay decreases the boot time by a lot and doesn't seem to break android apps on my device.

KonstantinosDetsis commented 4 years ago

I think I may have installed the wrong brunch release because this one that I downloaded doesn't mention anything about tablet mode in the changelog. Screenshot

sebanc commented 4 years ago

Hi,

You used the right release, it's just that I don't mention device specific patches in release notes.

I tried to fix the issue with the previous build and uploaded a new one. Could you try it ?

sebanc commented 4 years ago

Also, r83 increased boot time (at chromeos logo) on purpose to improve android apps compatibility on some devices, it is normal that you need to use "options=no_ui_delay" to get the previous behavior.

KonstantinosDetsis commented 4 years ago

I just installed it and it also doesn't seem to do anything. Do I need to enable some sort of option in the grub config? Here is a dmesg... dmesg.txt

sebanc commented 4 years ago

I can see in the dmesg that the tablet mode module is correctly activated this time. Normally if you remove the type cover (not fold it), it should switch to tablet mode.

Also, I notice that you have a wireless mouse/keyboard connected which could prevent tablet mode from working:

[    2.519995] input: Compx 2.4G Receiver as /devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.0/0003:1D57:FA60.0001/input/input3
[    2.571663] hid-generic 0003:1D57:FA60.0001: input,hidraw0: USB HID v1.00 Keyboard [Compx 2.4G Receiver] on usb-0000:00:14.0-2/input0
[    2.573575] input: Compx 2.4G Receiver as /devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.1/0003:1D57:FA60.0002/input/input4
[    2.574230] hid-generic 0003:1D57:FA60.0002: input,hidraw1: USB HID v1.00 Mouse [Compx 2.4G Receiver] on usb-0000:00:14.0-2/input1
[    2.576040] input: Compx 2.4G Receiver System Control as /devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.2/0003:1D57:FA60.0003/input/input5
[    2.627610] input: Compx 2.4G Receiver Consumer Control as /devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.2/0003:1D57:FA60.0003/input/input6
[    2.628018] hid-generic 0003:1D57:FA60.0003: input,hidraw2: USB HID v1.00 Device [Compx 2.4G Receiver] on usb-0000:00:14.0-2/input2

If it still does not work after removing the wireless keyboard/mouse dongle, I will try another method.

KonstantinosDetsis commented 4 years ago

Sadly after disconnecting the mouse dongle and rebooting just in case, it still does not work.

sebanc commented 4 years ago

Ok, no worries, I will try something else

KonstantinosDetsis commented 4 years ago

Ok, thanks!

sebanc commented 4 years ago

Could you try the new build with "options=force_tablet_mode" added to the kernel command line (after cros_debug) ?

KonstantinosDetsis commented 4 years ago

Finally, it works, thank you very much! It even works with the mouse dongle connected. Now I want to ask a few more questions. If I insert an SD Card to my Surface using the built-in slot, the SD card appears as a USB in ChromeOS and I had to rename my SD Card to "SD Card". Is there any way to fix this? Finally, is there any possible way I can make chrome://flags work on samus (other than switching to dev channel) or change the flags any other way? Thanks!

sebanc commented 4 years ago

Nice to see that it eventually works :)

For the sdcard, unfortunately I don't think I have a way to change it as it is chromeos interpretation of your device.

Regarding chrome://flags, there are several solutions:

KonstantinosDetsis commented 4 years ago

Ok, I will update to dev channel. But what will happen when brunch r84 comes out? Will options=force_tablet_mode still work for me?

sebanc commented 4 years ago

Yes the Surface Pro tablet mode patch will be included in all future builds.

KonstantinosDetsis commented 4 years ago

Ok, thanks for your help!

KonstantinosDetsis commented 4 years ago

I decided to open this issue again because I discovered another problem with tablet mode. Auto-rotation doesn't work. "dmesg | grep ish-hid" doesn't report anything. I remember when I was using brunch r80 with options=enable_sensors and was in tablet mode it worked perfectly. After I updated to brunch r83 it stopped working. Any ideas why?

sebanc commented 4 years ago

enable_sensors option has been removed, they are enabled by default. Could you try to remove no_ui_delay and see if rotation works ?

Also, could you post the output of "lsmod" ?

KonstantinosDetsis commented 4 years ago

Removing no_ui_delay doesn't seem to work. I have also made sure I have auto-rotation turned on in ChromeOS. Here is the output of lsmod: lsmod.txt What apps do you know that support auto-rotation in ChromeOS?

sebanc commented 4 years ago

It's the interface that rotates in chromeos so from the moment you are in tablet mode, if you rotate the device, the interface should match the device orientation (though some apps/games are designed specifically for portrait / landscape and can block rotation)

The accelerometer driver seems correctly loaded, could you try removing options=force_tablet_mode and to reboot ?

Then go to tablet mode with CTRL+ALT+SHIFT+T and check if rotation is working ?

KonstantinosDetsis commented 4 years ago

It still doesn't work after removing both no_ui_delay and force_tablet_mode from "options=". Something which I noticed which could be related is that when the device is in tablet the and type cover is removed the virtual keyboard still doesn't appear on the screen and has to manually be enabled from settings every time the device exits tablet mode. Also since I have AIDA64 installed here is what it shows. Screenshot 2020-07-01 at 7 00 22 PM

sebanc commented 4 years ago

It still doesn't work after removing both no_ui_delay and force_tablet_mode from "options=". Something which I noticed which could be related is that when the device is in tablet the and type cover is removed the virtual keyboard still doesn't appear on the screen and has to manually be enabled from settings every time the device exits tablet mode.

This is most likely because of your wireless keyboard adapter being plugged in.

Also since I have AIDA64 installed here is what it shows.

Screenshot 2020-07-01 at 7 00 22 PM

The AIDA64 output is correct as for the loaded modules, I really don't understand why it does not work, could you verify that rotation is not locked in the settings area ?

KonstantinosDetsis commented 4 years ago

After removing the mouse dongle the virtual keyboard appears fine so thanks for that. Auto-rotation is turned on. IMG_0024 IMG_0025

sebanc commented 4 years ago

I changed something in the new unstable build that could have an impact on this. Could you update to it ? (it also has the tablet mode patch included) https://github.com/sebanc/brunch-testing/releases

KonstantinosDetsis commented 4 years ago

I've updated to the latest brunch-testing release and it still doesn't work. Also with the latest brunch-testing boot speeds are much faster (it's basically as fast as no_ui_delay) so that's nice. Okay I just found something strange. After the device boots up with the keyboard connected if you enable tablet mode with CTRL + ALT + SHIFT + T and NOT remove the keyboard rotation works. If I remove the keyboard rotation just stops working. Attaching it again doesn't make rotation work either. A full reboot is needed.

sebanc commented 4 years ago

Could you replace the content of /lib/udev/rules.d/99-tablet-mode.rules with the below lines, reboot and see if there is a difference ?

ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="045e", ATTRS{idProduct}=="07a9", RUN+="/bin/bash -c 'echo 0 > /sys/bus/platform/devices/tablet_mode_switch.0/tablet_mode'"
ACTION=="remove", SUBSYSTEMS=="usb", ATTRS{idVendor}=="045e", ATTRS{idProduct}=="07a9", RUN+="/bin/bash -c 'echo 1 > /sys/bus/platform/devices/tablet_mode_switch.0/tablet_mode'"
KonstantinosDetsis commented 4 years ago

The 99-tablet-mode.rules file doesn't exist so I created but it still didn't work. If I manually run "echo 1 > /sys/bus/platform/devices/tablet_mode_switch.0/tablet_mode" it says that the file doesn't exist.

sebanc commented 4 years ago

Sorry forgot to mention that this method is to be used with "options=force_tablet_mode", I thought you still had it enabled

KonstantinosDetsis commented 4 years ago

Well I added it and it just broke everything. On the login screen my wallpaper was flashing, the icons on the bottom (power off, guest mode, etc) were bouncing up and down. After entering my password it took like 2 minutes to login. After that I was clearly able to see that the device kept switching from desktop to tablet mode every half a second. De-attaching the keyboard stopped it. Had to force reboot (because everything was very laggy) and remove force_tablet_mode from grub config, boot the device and reboot again.

sebanc commented 4 years ago

Ok, could you boot again with "options=force_tablet_mode", then run "sudo rm /lib/udev/rules.d/99-tablet-mode.rules" in crosh shell, reboot and confirm if rotation works or not ?

KonstantinosDetsis commented 4 years ago

The only difference is that the device now boots in tablet mode and that when I remove the type cover it doesn't go to tablet mode. If I rotate the device while it is in tablet mode and I haven't removed the type cover since I booted the device, rotation works. If I remove the type cover, rotation just stops working.

sebanc commented 4 years ago

It does not really make sense to me right now, the only thing that I can think of which could explain it would be that the accelerometer is actually in the type cover.

Could use a live usb linux distro and confirm if the rotation works both with type cover plugged and type cover removed ?

KonstantinosDetsis commented 4 years ago

I tried in Linux Mint but it didn't work (probably because Linux Mint isn't meant to be used on tablet devices). I will now download and try to see if Android x86 will work with auto-rotation.

KonstantinosDetsis commented 4 years ago

The exact same thing that is happening with ChromeOS is happening with Android x86. On Windows auto-rotation without the keyboard works fine.

sebanc commented 4 years ago

Could you try adding "button.lid_init_state=open" on the kernel command line ?

KonstantinosDetsis commented 4 years ago

It didn't work so I removed it. This is my current grub config: ...cros_debug quiet enforce_hyperthreading=1 options=acpi_power_button,force_tablet_mode

sebanc commented 4 years ago

It looks like it is a bios / kernel issue as android x86 suffers from the same bug but I cannot find any information on how to solve that online. What's weird is that I cannot even find any discussion on this issue. Was your SP1 updated to the latest bios ?

KonstantinosDetsis commented 4 years ago

I really don't know. This is how my bios looks: Screenshot 2020-07-05 at 8 32 23 PM (picture taken from youtube video) At some point around the start of 2020, I remember Windows Update was installing Surface Pro Bios or something like that. As far as I know the Surface Pro 5 bios looks completely different. Something like this: sp5bios Any ideas how to update my bios?

sebanc commented 4 years ago

If you had an update in windows in 2020, you are on the latest bios. I am sorry but I am out of ideas on this one...

If you can reproduce this issue on a linux distro like ubuntu, you can try to see if someone on linux-surface (https://github.com/linux-surface/linux-surface) has any idea about it. (they don't support brunch or androidx86, so you need to be able to reproduce this issue on linux)

KonstantinosDetsis commented 4 years ago

Ok I will see if it happens with ubuntu too. Now I will ask something unrelated to this issue. If I have Secure Boot disabled in my bios and boot the device, it does this before it goes to grub: Screenshot 2020-07-05 at 9 00 28 PM If I enable secure boot and reboot the same thing happens. If I enable secure boot and select install default secure boot keys it boots like that but without the red which is what I want but then after a few seconds it shows this: Screenshot 2020-07-05 at 8 58 09 PM There is no option to enroll key from disk.

sebanc commented 4 years ago

I guess the red background when secure boot is disabled is normal. On my SP5 there is an unlock sign which is probably equivalent.

It is however very weird that with secure boot enabled it succeeds to boot grub without the brunch key being enrolled... You might want to enroll the key while you are in ubuntu by downloading it in the master branch of brunch repo and running "sudo mokutil --import brunch.der"

KonstantinosDetsis commented 4 years ago

Any way to run mokutil from ChromeOS or crouton because I don't have an ubuntu usb available to me right now?

sebanc commented 4 years ago

It should work from crouton i guess

KonstantinosDetsis commented 4 years ago

Ok I did run mokutil --import brunch.der from crouton and it said "input password: ". I typed a password and then the device froze for around 10 seconds. I then rebooted and I was taken to I think it was called MOK Manager. There was the option to enroll key from disk. I selected it hit EFI-SYSTEM and brunch.der. I then hit Enroll MOK and it asked for a password. I typed the password which I set earlier and rebooted. It worked but it still showed a red screen which is what I want to get rid of.

KonstantinosDetsis commented 4 years ago

Here is what I was talking about. Screenshot 2020-07-05 at 10 11 02 PM

sebanc commented 4 years ago

That's exactly it but I have no idea why SP1 considers brunch certificate as invalid, it works perfectly on my SP5...

KonstantinosDetsis commented 4 years ago

Ok I just tried live-booting Ubuntu on my Surface and auto-rotation works perfectly with and without the type-cover.

sebanc commented 4 years ago

Ok so this issue is definetly within the kernel, however it may have its origin anywhere in the kernel (ACPI, hid, sensors...) so it would be very difficult to identify the correct fix for it.

Could you try the below build ? (after accepting the github invite) https://github.com/sebanc/brunch-next/releases