Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2015 Macbook testing #9

Open
theishshah opened this issue Jan 25, 2017 · 128 comments
Open

2015 Macbook testing #9

theishshah opened this issue Jan 25, 2017 · 128 comments

Comments

@theishshah
Copy link

It seems that the driver is primarily non-functional on the 2015model. The trackpad is essentially broken and (possibly random, need more testing) very few keystrokes are registering.

@cb22
Copy link
Owner

cb22 commented Jan 26, 2017

@theishshah interesting; so it was registering some keystrokes? Last I heard about the 2015 model the SPI driver wouldn't bind properly

@theishshah
Copy link
Author

Yeah I'm not sure it seems very sporadic. It is possible that it was interpreting input from an external usb device or something, i'm not sure

@Maximus-
Copy link

Under a stock linux kernel (4.11.0-rc6) with Intel LPSS modules disabled, the keyboard works again with this module on the 2015 model. However, there are a few issues. Typing is kind of slow/laggy, which could be due to systemd, but it seems unlikely. Also there are issues when typing too fast, which may be due to rollover previously mentioned. Also, trackpad doesn't work at all. It appears the data read related to trackpad is correct, but multitouch isn't properly enabled, as there's only one finger's worth of data.

@Maximus-
Copy link

Maximus- commented Apr 20, 2017

Update: the typing lag was due to the clock speed being set low. Bumped it up from 400kHz to the 8MHz and now typing is nice and smooth. Key-rollover issues still occur, of course. I've got the trackpad working with the rel_x and rel_y parameters passed from the device, however I'm getting no multitouch data.

@cb22
Copy link
Owner

cb22 commented Apr 20, 2017

@Maximus- interesting you say about bumping up the speed; the multitouch initialization might have to do with the issue mentioned by @roadrunner2 here.

Alternatively, the initialization packet might be difference on the 2015 model. That would need to be decoded from Windows and added to the driver.

@Maximus-
Copy link

I'm trying to find those packets in the OS X kexts, and I've checked AppleHSSPIHIDDriver, AppleHSSPISupport, AppleIntelLpssDmac, and AppleIntelLpssGspi; I can't find any trace of them, but they may just be stored a bit differently in the binaries. Downloading the windows drivers now.

Also some things I'm not entirely clear on:
What's the actual difference between the two machines (2015, and 2016 models)?
Why does this work when all Intel LPSS-related kernel modules are disabled?
Furthermore, should I care about having LPSS? Battery life seems fine under linux so far.

@roadrunner2
Copy link
Contributor

@Maximus- Try the following patch to see if that fixes your mt-initialization (I'll be pushing the full proper patches in a few days):
applespi-init.patch.txt
Also, can you show me your DSDT (aml or dsl, patched or not)? And I presume the model is MacBook8,1?

@Maximus-
Copy link

@roadrunner2 Those patches work. Multitouch is properly enabled. :-)

I have some patches to fix the key rollover issues I'll be posting soon. Good work!

Also attached is my DSDT.
dsdt.dsl.txt

(Had to add txt extension to make github happy.)

@roadrunner2
Copy link
Contributor

@Maximus- Thanks for the DSDT - looks like the relevant parts are the same as for the newer MacBook(Pro)'s, so that good.

@roadrunner2
Copy link
Contributor

@Maximus- If you have a moment, could you per chance try out #14? In particular to verify caps-lock led now works (and of course that initialization and speed still good)

@Maximus-
Copy link

@roadrunner2 Tested it out. Everything seems to be still be working on the 2015 12" Macbook. Caps lock key included :)

@roadrunner2
Copy link
Contributor

@Maximus- Thanks!

@john-morton
Copy link

john-morton commented May 8, 2017

It's alive, it's ALIVE! I can't believe the 2015 12" 8,1 machine I'd put away in a closet for two years (awaiting all of your incredible recent efforts) is now functional. I press the letter 'A' on the keyboard and an 'A' appears on screen - insane! Likewise the track-pad, simply awesome! I'd nearly given up hope... I'm sincerely grateful and would be more than happy to assist any further 'polishing' efforts by submitting verbose logs etc (please just let me know). Further, if there's a way to buy you guys some beers over the Internet, I'm more than happy to. I haven't used this machine in angst yet but my only observation is a slight hover over the track-pad (without touching it) is being picked up and acted on. I'm not sure if this will present an annoyance in the future with the thumbs and hand-rests during typing or if it's mechanical and not a software issue etc. As others have suggested, if there's any way to avoid the DSDT modification and a means to keep up with kernel changes, that'd be the icing on the cake. Again, thank you sincerely to everyone who's contributed! John

@Maximus-
Copy link

Maximus- commented May 8, 2017

@john-morton the linux ACPI devs have proposed a fix to avoid the DSDT modification, which I've been working on (https://www.spinics.net/lists/linux-spi/msg06968.html).

@john-morton
Copy link

@Maximus- yeah, I've been following all of threads and aware of this (and looking forward to seeing what might potentially eventuate). Fingers crossed! ;)

@roadrunner2
Copy link
Contributor

roadrunner2 commented May 9, 2017

@Maximus- Interesting to hear you're working on something, because so am I 😃 Specifically, I am close to having something working in the applespi driver, where essentially I detect that there's no spi-device, call _DSM to get the info, and then explicitly create an spi-device from that info. While this isn't the better and more comprehensive solution in the core as discussed in the link, it would/will allow folks to use the driver right now until the core has support for this setup. I'd be curious to know what exactly you're doing, and if we should be coordinating or merging or something.

@roadrunner2
Copy link
Contributor

@john-morton, @Maximus- see #29 for a solution for now (pending the better solution in the core).

@sergioabril
Copy link

Not strictly a bug related comment, I know, and sorry for that, but I came here looking for a way to start using linux on my macbook 12" 2015 properly, and I'm not sure on how to proceed with this solution. Any quick link to a guide or step-by-step read for noobs on how to compile and load this drivers/modules on an already installed debian distro (dual boot)? I'm still learning, and using an external keyboard every day it's a bit frustrating

@choelzl
Copy link

choelzl commented Jun 10, 2017

@sergioabril
Add the modules "spi_pxa2xx_platform", "intel_lpss_pci" and "applespi" in the mkinitcpio.conf file.
Clone this git repo and inside the folder run the following commands :

sudo make all
sudo make install

then

reboot

after booting it should work if not try to run inside the cloned git repo

sudo make test

it should work without a reboot now (except if one of the commands gave you an error). If not there

@sergioabril
Copy link

sergioabril commented Jun 11, 2017

@choelzl
Thank you for the explanation! These are my first steps with Linux, and I really appreciate it.

I managed to make and load "applespi" after some hours learning a bit more of linux kernel and modules, and then added the "intel_lpss_pci" module aswell (note: I used modprobe, and also added them to /etc/modules just in case, since I've nothing like 'mkinitcpio.conf' anywhere).

However, I have no clue of what to do with "spi_pxa2xx_platform"; it doesn't exist as a module anywhere, and can't load it using modprobe. (I guess I should find the source, maybe on my linux-source folder, and compile it somehow?)

I guess all this is way over my linux knowledge for now... I'll keep on investigating.

But thank you again for trying 👍 (P.S. No, didn't get my keyboard working)

@choelzl
Copy link

choelzl commented Jun 11, 2017

@sergioabril what kernel and distro do you run ? mkinitcpio is used for arch, in some cases you might look for initramfs in your kernel (/etc/initramfs/initramfs.conf would be the file for example where you add the modules in that case).
PS : the "spi_pxaa2xx_platform" module is present in the kernel since kernel 2.6.17 (http://cateee.net/lkddb/web-lkddb/SPI_PXA2XX.html)

@roadrunner2
Copy link
Contributor

@sergioabril The spi_pxa2xx_platform module may be built in, or not build at all - run this to see:

grep PXA2XX /boot/config-`uname -r`

If you see CONFIG_SPI_PXA2XX=y then it's compiled in and you don't need to load it at all; if you get # CONFIG_SPI_PXA2XX is not set then it isn't built at all, and you'll need to either reconfigure and rebuild your kernel or just this module.

Regarding where to add the modules for the ramdisk: assuming Debian uses initramfs-tools/mkinitramfs like Ubuntu does, then you'll need to add the modules to /etc/initramfs-tools/modules.

@sergioabril
Copy link

sergioabril commented Jun 11, 2017

@choelzl I'm using kernel 4.9.0-Kali4-amd64 (Debian 4.9.25-1kali1)

I tried what @roadrunner2 said and the message I got was "CONFIG_SPI_PXA2XX is not set", so I decided to build just the module (after trying to rebuild the hole kernel, I thought it twice).

Apparently, now I have the three modules built and loaded, and all of them appear when I type lsmod. I also added them to the /etc/initramfs-tools/modules and called update-initramfs -u However, keyboard and trackpad are not working yet.

The only message the dmesg throws related to these three modules, is spi_pxa2xx_platform: loading out-of-tree module taints kernel

Where should I be looking for errors or possible problems?

P.S: I also tried adding intremap=nosid to grub, but nothing happened, so I removed it again.

@choelzl
Copy link

choelzl commented Jun 12, 2017

@sergioabril Does the applespi driver attach it self to the device ? Does your dmesg give any hint about what applespi is doing ? ("dmesg | grep applespi")
You should get a message that the module applespi is out of tree module and also taints the kernel...
Try rebuilding the driver.
Also try a "sudo depmod".

I run on ArchLinux 4.11.4 without any trouble installing, just adding the modules to mkinitcpio.conf and installing applespi and it worked pretty much (the only problem is after every kernel update I have to manualy reinstall the driver)

@sergioabril
Copy link

sergioabril commented Jun 12, 2017

@choelzl no, it's not there; for some reason, dmesg | grep applespi doesn't show anything. I'll try to build it again to see if that changes. Should I add any special boot parameter so it attaches to the device? (e.g. intremap=nosid, etc)

Lucky you with ArchLinux! (Although I might have the same problems on ArchLinux too; I'm probably building it the wrong way). Thanks anyway.

@tudorbarascu
Copy link

@sergioabril I'm using debian (kali linux is based on debian) and it works just fine.

@roadrunner2
Copy link
Contributor

@sergioabril The intremap=nosid boot param is definitely needed, in case you don't have that; also, make sure you do not have noapic in your boot params - double check this with cat /proc/cmdline after booting.

Next, verify that the ACPI device exists: what does

ls -l /sys/bus/acpi/devices/APP000D:00/

show? (that directory should exist, and the driver in there should point to appleacpi)

The fact that you see absolutely no messages from applespi indicates that somehow the applespi driver is not being attached to the APP000D device. You can also try (re)loading the module with extra debugging turned on:

sudo rmmod applespi ; sudo modprobe applespi dyndbg=+p

but it's unlikely to show anything either.

@Maximus-
Copy link

Maximus- commented Jul 23, 2017

I never ended up getting to the bottom of this, but I noticed that when I cloned a stock kernel from github.com/torvalds/linux (and only enabled USB-related drivers), this driver worked entirely fine. The moment I enabled any Intel-Lpss related options, the reads would be all zeros. Even disabling the Intel-Lpss options, and doing a make clean && make, it still wouldn't work, so perhaps one of the lpss dependencies was causing these issues.

The only time any of this worked was when I compiled a fresh kernel with only the few things I needed, and it never seemed to work from blacklisting modules while in archlinux.

I haven't tested this lately, as some of apple's newest apfs stuff seems to have messed with refind and my dual booting.

@denverslair
Copy link

WOOOOOT!!!
@roadrunner2 great job! The new applespi-fixes branch works! It seems to need irqpoll set in the linux boot line, otherwise it grumbles about irq 21 and fails. Is this what you expect?

applespi_working_debug.txt
applespi_working_tree.txt

I've included the debug details incase they are of interest. If you need me to test anything else, please ask.

I suggest you claim the bounty that has grown at the link below, because I certainly think you've earned it!
https://www.bountysource.com/issues/35422234-macbook8-1-12-inch-early-2015-keyboard-and-trackpad-don-t-work

Well done & thanks :D

@roadrunner2
Copy link
Contributor

@Maximus- Thanks for the response. So that makes sense: it turns out that building the kernel with CONFIG_X86_INTEL_LPSS=n disables the registering of the problematic acpi handler. And since that's not a module, no amount of blacklisting will help. Not sure why rebuilding after a make clean doesn't work, but I have to assume that the above config got (re)enabled again somehow.

@roadrunner2
Copy link
Contributor

@denverslair This is the first I'm hearing about irqpoll being needed, so no, I didn't expect that. Your logs and tree look fine.

As to the bounty, thanks, but I think that would belong to @cb22.

@denverslair
Copy link

@roadrunner2

If I don't include irqpoll in the kernel boot params then the keyboard and touchpad doesn't work and I get the attached error in dmesg:
noirqpoll.txt
I think the mac also doesn't shutdown properly (this could be an unrelated issue).

By including the irqpoll option I then get a load of errors in dmesg along the lines of:
[ 12.030104] hpet1: lost 3 rtc interrupts
..which seems to be a known issue of the option.

@roadrunner2
Copy link
Contributor

A quick update/summary for MacBook8,1 (2015). The patch to fix the missing spi master device has been accepted, so I expect it to be in kernel 14.4. Until then you need to configure and compile your kernel with CONFIG_X86_INTEL_LPSS=n.

Note: none of this applies to MacBook's after 2015 or MacBookPro's.

@roadrunner2
Copy link
Contributor

@denverslair Hmm, I don't know what's going on there - not too familiar with the whole irq management stuff.

Does anybody else have this issue on MacBook8,1?

@baumhoto
Copy link

@roadrunner2 yes, just installed it on my MacBook8,1 using the Archlinux Macbook Kernel . Compling it with LPSS disabled alone did not work. but after i added irqpoll to kernel boot it worked

@justgerd
Copy link

justgerd commented Sep 11, 2017

I am aware that using a third-party compiled kernel is highly insecure, but can any contributor of this repo provide a compiled kernel with that CONFIG_X86_INTEL_LPSS=n option?

Especially because I have no idea how to compile the Linux kernel on Mac.

I would need the .deb files, alternatively, an explanation would work as well.

Well, fifth edit. Hope that edits don't cause emails to followers.

@roadrunner2
Copy link
Contributor

@gerd2002 What distro are you using? Since you mention debian package, it sounds like Debian or Ubuntu? In any case you want to boot Linux with an external usb keyboard attached, install the distro, and then build and install the kernel. Assuming you're using Ubuntu, these instructions explain how to build your own kernel.

But if you at least specify what distro you're using, maybe somebody has some built kernel packages for it.

@justgerd
Copy link

I am actually using Ubuntu, and I got it working using the latest mainline kernel that can be found here (and the irqpoll flag): http://kernel.ubuntu.com/~kernel-ppa/mainline/daily/current/

@rfc6919
Copy link

rfc6919 commented Sep 14, 2017

What's the summary of the last 112 comments wrt kernel config requirements? CONFIG_SPI_PXA2XX is required, and CONFIG_X86_INTEL_LPSS=y breaks MacBook8,1?

@roadrunner2
Copy link
Contributor

@gerd2002 Excellent! I didn't realize Ubuntu was providing kernels built from the very latest code. But be warned: since this isn't even rc1 yet (the merge window for 4.14 is still open), let alone a stable release, there could well be issues.

@rfc6919 For MacBook8,1 (2015) the requirements are:

  • CONFIG_SPI_PXA2XX=y or CONFIG_SPI_PXA2XX=m on all kernels (I think all distros have this by default)
  • If you have kernel 4.13 or earlier then CONFIG_X86_INTEL_LPSS must not be set; for 4.14 or later it doesn't matter whether this is set or not (which is why gerd2002 is having success above with the very latest kernel)

In short: when distros start providing 4.14 kernels then you should be able to use those kernels without any changes (still need to build/load this applespi driver, of course). Until then you'll need to build your own kernel with CONFIG_X86_INTEL_LPSS disabled.

@rfc6919
Copy link

rfc6919 commented Sep 14, 2017

Cool, thanks. Debian currently sets CONFIG_SPI_PXA2XX=n but https://bugs.debian.org/872004 should fix that shortly.

@justgerd
Copy link

@roadrunner2 indeed, i am getting a lot of "Report system error" messages on startup, and the facetime camera driver refuses to work at all, but it was more comfortable than to rebuild the kernel.

@justgerd
Copy link

justgerd commented Oct 17, 2017

So today I installed 4.14-rc5 today, and it still works like a charm. My only problem is that suspend doesn't work at all. Any ideas?

I needed to disable suspend, because otherwise my computer freezes when waking up/suspending (don't know which of both)

@rquast
Copy link
Contributor

rquast commented Oct 19, 2017

I installed Ubuntu 17.04 on my Macbook 12 Retina 8,1 (2015) yesterday and managed to get applespi working. To do this, I recompiled the current kernel's source with CONFIG_X86_INTEL_LPSS=n and added this to /etc/default/grub:

GRUB_CMDLINE_LINUX_DEFAULT='nosplash irqpoll intremap=nosid'

However, I've got two problems:

1. It doesn't work when I boot up, so I can't enter the LUKS full disk encryption password without an external keyboard.

I notice that the applespi module tries to load but it says it's tainted:

[    2.710177] applespi: loading out-of-tree module taints kernel.
[    2.713510] applespi: module verification failed: signature and/or required key missing - tainting kernel
[    2.717250] applespi: No spi-master device found for device APP000D - waiting for it to be registered
[    2.717250] applespi: acpi-device probe done: APP000D

But loads later on after entering in the password:

[   52.219378] applespi: Got spi-master device for device APP000D
[   52.221652] dw_dmac_pci 0000:00:15.0: DesignWare DMA Controller, 8 channels
[   52.238929] ACPI: SBS HC: EC = 0xffff8a8a24f0a700, offset = 0x20, query_bit = 0x10
[   52.248506] shpchp: Standard Hot Plug PCI Controller Driver version: 0.4
[   52.285058] input: Apple SPI Keyboard as /devices/pci0000:00/0000:00:15.4/pxa2xx-spi.0/spi_master/spi0/spi-APP000D:00/input/input7
[   52.289068] input: Apple SPI Touchpad as /devices/pci0000:00/0000:00:15.4/pxa2xx-spi.0/spi_master/spi0/spi-APP000D:00/input/input8
[   52.289221] applespi: spi-device probe done: spi-APP000D:00
[   52.289227] applespi: Added spi device spi-APP000D:00
[   52.294512] applespi: modeswitch done.

2. I can suspend and resume, but when I resume applespi no longer works.

I think there is already an issue for this. Is this a work in progress?

My full dmesg output can be found here: https://gist.github.com/rquast/998f8f32e01f07945caf43454d7fcc1c

This is a great project. Thanks for all the hard work!

@roadrunner2
Copy link
Contributor

@rquast:

  • keyboard at boot: make sure the modules are included in your initrd - see these instructions (Ubuntu uses mkinitramfs, so use the instructions for that) - these instructions have been recently updated to reflect the current dkms setup, but for your system basically it consists of
    echo 'add_drivers+="applespi spi_pxa2xx_platform"' | sudo tee -a /etc/initramfs-tools/modules
    sudo dkms install applespi/0.1
  • I don't think intremap=nosid is necessary on your setup (Ubuntu 17.04 has kernel 4.10)
  • the "tainted" warning is normal
  • resume is known to be problematic - see for example https://github.com/Dunedan/mbp-2016-linux#suspend--hibernation (though this topic has cropped up in other places too)

@rquast
Copy link
Contributor

rquast commented Oct 19, 2017

@roadrunner2 thanks for the tips.

I dropped the intremap=nosid.

I've configured it correctly the first time with the modules for both initramfs's modules and /etc/modules which is why I get the applespi output:

[ 2.717250] applespi: No spi-master device found for device APP000D - waiting for it to be registered
[ 2.717250] applespi: acpi-device probe done: APP000D

I dropped to an initramfs shell during boot, did an rmmod/modprobe on both the applespi and spi_pxa2xx_platform but keep getting the message "No spi-master device...".

Strangely, I don't have a problem once it gets out of initramfs.

With regard to the resume, to clarify, I meant that the resume works, but applespi stops working on resume.

@rquast
Copy link
Contributor

rquast commented Oct 19, 2017

Looking at someone else's dmesg, I notice that they have the serial port register in initramfs where mine doesn't. Theirs: https://github.com/Dunedan/mbp-2016-linux/blob/master/MacBookPro14%2C1/dmesg - mine https://gist.github.com/rquast/998f8f32e01f07945caf43454d7fcc1c

Their output in initramfs shows this:
[ 2.472631] dw-apb-uart.2: ttyS0 at MMIO 0x9282b000 (irq = 20, base_baud = 3000000) is a 16550A
[ 2.489048] intel-lpss 0000:00:1e.3: enabling device (0000 -> 0002)
[ 2.489341] applespi: Got spi-master device for bus-number 2

Mine registers later on after initramfs:

[ 52.199749] 0000:00:15.5: ttyS4 at MMIO 0xc1819000 (irq = 21, base_baud = 2764800) is a 16550A
[ 52.219378] applespi: Got spi-master device for device APP000D

It also turns out that irqpoll makes no difference if it is enabled or not on my system, so I have removed it also for now.

@justgerd
Copy link

justgerd commented Nov 2, 2017

Is there any way of compiling the kernel on macOS and then installing it on Linux?

@tudorbarascu
Copy link

@gerd2002 You can build the kernel inside a Linux VM (Virtual machine).

@justgerd
Copy link

justgerd commented Nov 2, 2017

@tudorbarascu I guess that is what I am going to do then.

@chroi
Copy link

chroi commented Mar 1, 2018

I'm struggling with the driver on a MacBook8,1 (12" early 2015).

I've recompiled my kernel :
gilles@unicorn:~$ grep LPSS /boot/config-4.13.0-32-generic

CONFIG_X86_INTEL_LPSS is not set

and

gilles@unicorn:$ uname -a
Linux unicorn 4.13.0-32-generic #35
16.04.1 SMP Tue Feb 13 13:14:19 CET 2018 x86_64 x86_64 x86_64 GNU/Linux

here's the output on dmesg :

[ 2.325105] applespi: loading out-of-tree module taints kernel.
[ 2.325129] applespi: module verification failed: signature and/or required key missing - tainting kernel
[ 2.325337] applespi: No spi-master device found for device APP000D - waiting for it to be registered
[ 2.325338] applespi: acpi-device probe done: APP000D
[ 2.333316] applespi: Got spi-master device for device APP000D
[ 2.333583] applespi: Unexpected data returned from SPI _DSM method: type=1

neither the keyboard nor the trackpad are recognized or responsive...

Any idea what I can try?

@roadrunner2
Copy link
Contributor

@chroi Thanks for the dmesg output. Well, that error is certainly odd: the _DSM on your system is returning an integer instead of a struct. Did you modify your dsdt in any way? Can you provide your dsdt please?

@chroi
Copy link

chroi commented Mar 2, 2018

Thanks for the quick reply !

I didn't know what DSDT was... but apparently ElementaryOS is messing with it in its default config. I had a "acpi_osi=" kernel option in my boot loader config. I don't know why they did that.

Removing it fixed the problem. I have a working touchpad and keyboard. Thank you very much!

@roadrunner2
Copy link
Contributor

Ah, forgot about acpi_osi - now the error makes complete sense. Yes, this must be left unset or set to "Darwin" on Apple machines. Sounds like a bug in ElementaryOS' setup then. Thanks for the update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests