macbook12-spi-driver icon indicating copy to clipboard operation
macbook12-spi-driver copied to clipboard

2015 Macbook testing

Open theishshah opened this issue 8 years ago • 128 comments

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.

theishshah avatar Jan 25 '17 18:01 theishshah

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

cb22 avatar Jan 26 '17 05:01 cb22

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

theishshah avatar Jan 27 '17 19:01 theishshah

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.

mxms0 avatar Apr 13 '17 20:04 mxms0

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.

mxms0 avatar Apr 20 '17 11:04 mxms0

@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.

cb22 avatar Apr 20 '17 11:04 cb22

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.

mxms0 avatar Apr 20 '17 13:04 mxms0

@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?

roadrunner2 avatar Apr 20 '17 21:04 roadrunner2

@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.)

mxms0 avatar Apr 20 '17 22:04 mxms0

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

roadrunner2 avatar Apr 23 '17 13:04 roadrunner2

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

roadrunner2 avatar Apr 24 '17 09:04 roadrunner2

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

mxms0 avatar Apr 24 '17 11:04 mxms0

@Maximus- Thanks!

roadrunner2 avatar Apr 25 '17 03:04 roadrunner2

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

john-morton avatar May 08 '17 20:05 john-morton

@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).

mxms0 avatar May 08 '17 20:05 mxms0

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

john-morton avatar May 08 '17 20:05 john-morton

@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 avatar May 09 '17 03:05 roadrunner2

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

roadrunner2 avatar May 28 '17 05:05 roadrunner2

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

sergioabril avatar Jun 10 '17 15:06 sergioabril

@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

choelzl avatar Jun 10 '17 17:06 choelzl

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

sergioabril avatar Jun 11 '17 00:06 sergioabril

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

choelzl avatar Jun 11 '17 02:06 choelzl

@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.

roadrunner2 avatar Jun 11 '17 07:06 roadrunner2

@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.

sergioabril avatar Jun 11 '17 16:06 sergioabril

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

choelzl avatar Jun 12 '17 00:06 choelzl

@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.

sergioabril avatar Jun 12 '17 08:06 sergioabril

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

tudorbarascu avatar Jun 12 '17 08:06 tudorbarascu

@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.

roadrunner2 avatar Jun 12 '17 09:06 roadrunner2

@roadrunner2 firstly, thank you. I've checked cat /proc/cmdline and noapic is not present. intremap=nosid it is.

Then I verified that APP00D:00 was present.

lastly, I rmmod both modules (pxa2xx and applespi), ran an apt update && upgrade, and downloaded again source + headers. Compiled again both spi_pxa2xx_platform and applespi, and again, even though both are loaded and appear on lsmod, only pxa2xx is showing relevant info on dmesg (applespi doesn't seem to attach).

Is there any specific log I could check to gather more info?

sergioabril avatar Jun 12 '17 21:06 sergioabril

@sergioabril Could you post the output here from the ls -l /sys/bus/acpi/devices/APP000D:00/ command? And you have the intel_lpss_pci module loaded too, right?

Then, can you also post the output here of the following commands:

lspci -nn | grep SPI
ls -l /sys/devices/pci0000:00/0000:00:1e.3/pxa2xx-spi.3/
ls -l /sys/devices/pci0000:00/0000:00:1e.3/pxa2xx-spi.3/spi_master/
ls -l /sys/devices/pci0000:00/0000:00:1e.3/pxa2xx-spi.3/spi_master/spi/

Those last three paths may not exist exactly like that: depending on the pci-id of your SPI controller (as shown by the first command) the 0000:00:1e.3 might be different (it's 0000:<pci-id>), and the pxa2xx-spi.3 might have a different number at the end.

roadrunner2 avatar Jun 12 '17 22:06 roadrunner2

@roadrunner2 sure, this is the output of the first command:

ls -l /sys/bus/acpi/devices/APP000D:00/
total 0
-r--r--r-- 1 root root 4096 Jun 13 01:09 adr
-r--r--r-- 1 root root 4096 Jun 13 01:09 hid
-r--r--r-- 1 root root 4096 Jun 13 01:09 modalias
-r--r--r-- 1 root root 4096 Jun 13 01:09 path
drwxr-xr-x 2 root root    0 Jun 13 01:09 power
-r--r--r-- 1 root root 4096 Jun 13 01:09 status
lrwxrwxrwx 1 root root    0 Jun 13 01:06 subsystem -> ../../../../../../bus/acpi
-rw-r--r-- 1 root root 4096 Jun 13 01:06 uevent
-r--r--r-- 1 root root 4096 Jun 13 01:09 uid

Regarding intel_lpss_pci, I added it to be loaded on boot, and it's showing on lsmod (should appear on any other log/place to make sure?)

lspci -nn | grep SPI
00:15.4 Serial bus controller [0c80]: Intel Corporation Wildcat Point-LP Serial IO GSPI Controller #1 [8086:9ce6] (rev 03)

Regarding the last three commands, If I got it right,the pc-id is 00:15.4, and the path to check should be here: /sys/devices/pci0000:00/0000:00:15.4

However, listing that path returns no pxa2xx-spi*, and no even if I try find command from parent folder, it doesn't get anything pxa* related anywhere. Can we conclude that pxa2xx_platform is not right then?

ls -l /sys/devices/pci0000:00/0000:00:15.4
total 0
-rw-r--r-- 1 root root 4096 Jun 13 01:27 broken_parity_status
-r--r--r-- 1 root root 4096 Jun 13 01:27 class
-rw-r--r-- 1 root root  256 Jun 13 01:27 config
-r--r--r-- 1 root root 4096 Jun 13 01:27 consistent_dma_mask_bits
-rw-r--r-- 1 root root 4096 Jun 13 01:27 d3cold_allowed
-r--r--r-- 1 root root 4096 Jun 13 01:27 device
-r--r--r-- 1 root root 4096 Jun 13 01:27 dma_mask_bits
-rw-r--r-- 1 root root 4096 Jun 13 01:27 driver_override
-rw-r--r-- 1 root root 4096 Jun 13 01:27 enable
lrwxrwxrwx 1 root root    0 Jun 13 01:27 firmware_node -> ../../LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/INT33C1:00
-r--r--r-- 1 root root 4096 Jun 13 01:27 irq
-r--r--r-- 1 root root 4096 Jun 13 01:27 local_cpulist
-r--r--r-- 1 root root 4096 Jun 13 01:27 local_cpus
-r--r--r-- 1 root root 4096 Jun 13 01:27 modalias
-rw-r--r-- 1 root root 4096 Jun 13 01:27 msi_bus
-rw-r--r-- 1 root root 4096 Jun 13 01:27 numa_node
drwxr-xr-x 2 root root    0 Jun 13 01:27 power
--w--w---- 1 root root 4096 Jun 13 01:27 remove
--w--w---- 1 root root 4096 Jun 13 01:27 rescan
-r--r--r-- 1 root root 4096 Jun 13 01:27 resource
-rw------- 1 root root 4096 Jun 13 01:27 resource0
lrwxrwxrwx 1 root root    0 Jun 13 01:27 subsystem -> ../../../bus/pci
-r--r--r-- 1 root root 4096 Jun 13 01:27 subsystem_device
-r--r--r-- 1 root root 4096 Jun 13 01:27 subsystem_vendor
-rw-r--r-- 1 root root 4096 Jun 13 01:27 uevent
-r--r--r-- 1 root root 4096 Jun 13 01:27 vendor

sergioabril avatar Jun 12 '17 23:06 sergioabril