Updated Get Started (markdown)

Patrik Jakobsson
2020-12-16 12:10:27 +01:00
parent 80601afb5c
commit 05f19e89bc

@@ -1,14 +1,10 @@
# Get Started
You can contribute and test this module without touching your Mac's Hard Disk. You just need an USB 3.0 key to install Linux on, on top of your Linux installation Media. Best of both worlds, try Linux until you're ready to commit your internal drive. Please check [linux.com article](https://www.linux.com/learn/tutorials/718439-how-to-run-fedora-linux-on-the-macbook-air-without-touching-the-ssd)
General knowledge of WebCam support in linux: http://www.tldp.org/HOWTO/Webcam-HOWTO/hardware.html
Getting the driver working is two steps:
* [Firmware extraction](#firmware-extraction): Run the script to download and install the firmware from Apple.
Gentoo users using the [ebuild](#get-started-on-gentoo) skip this step.
[NixOS](http://nixos.org/) users can also skip this step.
* [Installation](#installation): Installing the driver itself.
* [Installation](https://github.com/patjak/bcwc_pcie/wiki/Installation): Installing the driver itself.
See [Additional Notes](#additional-notes) below in case you come across any issues.
@@ -42,354 +38,7 @@ Copying firmware into '/usr/lib/firmware/facetimehd'
To extract the sensor calibration files see: https://github.com/patjak/bcwc_pcie/wiki/Extracting-the-sensor-calibration-files
## Installation
Now continue with one of
* [Fedora](#get-started-on-fedora)
* [Debian](#get-started-on-debian)
* [Ubuntu](#get-started-on-ubuntu)
* [Arch](#get-started-on-arch)
* [Gentoo](#get-started-on-gentoo)
* [OpenSUSE](#get-started-on-opensuse)
* [NixOS](#get-started-on-nixos)
## Get Started on Fedora
DKMS RPMs are [available](https://copr.fedorainfracloud.org/coprs/frgt10/facetimehd-dkms/) for active Fedora versions ([packaging code](https://github.com/frgt10/facetimehd-dkms)).
Kmod RPMs are [available](https://ktdreyer.fedorapeople.org/macbook/) for Fedora 27-29 ([packaging code](https://github.com/ktdreyer/facetimehd-kmod-rpm)).
Tested on Fedora 32. - Extract firmware file as described in [Firmware extraction](#firmware-extraction)
- Become root `sudo su -`
- Install packages kernel-devel (if you installed the Wireless Card driver, you likely already have it): `dnf install kernel-devel`
- Clone the driver's code: `git clone https://github.com/patjak/bcwc_pcie.git`
- Change into directory: `cd bcwc_pcie`
- Build the kernel module: `make`
- Install the kernel module: `make install`
- Run `depmod`
- Load the module: `modprobe facetimehd`
- Check if all relevant modules are loaded: `lsmod | grep facetimehd`
Everything should load fine. Check with command dmesg, the main driver should have loaded and ignore the error about the missing .dat file in the firmware directory (these are the calibration files, we do not have them yet).
Time for testing: launch Cheese and enjoy your own smily face :-)
The driver now handles suspend / resume properly, you're all set.
## Setting up DKMS (auto-compile on kernal update)
This assumes you have already followed the Fedora steps. You will need to verify `dkms.conf` that the module name `facetimehd` and version number `0.1` are correct and either update the `dkms.conf` or adjust the instructions where `-m` and `-v` are used.
- Install needed packages: `# dnf install dkms`
- Make a directory to work from: `# mkdir /usr/src/facetimehd-0.1`
- Change into the git repo dir: `$ cd bcwc_pcie`
- Copy files over: `# cp -r * /usr/src/facetimehd-0.1/`
- Change into that dir: `# cd /usr/src/facetimehd-0.1/`
- Clear out previous compile: `# make clean`
- Register the new module with DKMS: `# dkms add -m facetimehd -v 0.1`
- Build the module: `# dkms build -m facetimehd -v 0.1`
- Install the module: `# dkms install -m facetimehd -v 0.1`
See [Additional Notes](#additional-notes) below in case you come across any issues.
## Get Started on Debian
(very similar to arch instructions, which I copied and altered a bit ;) because I am lazy / efficient)
**before you start, use `uname -r` to ensure that you are running Linux kernel 4.4 or later or the driver will not work!**
`#` indicates as root, you can use sudo if you prefer.
`$` indicates as normal user
- Extract and install the firmware file as described in [Firmware extraction](#firmware-extraction).
- Install the dependencies : `# apt-get install linux-headers git kmod libssl-dev checkinstall`
linux-headers may be slightly different e.g. linux-headers-4.3.0-1-amd64, you can check which kernel version you are running with `$ uname -r`
- Clone the driver's code: `$ git clone https://github.com/patjak/bcwc_pcie.git`
- Change into that dir: `$ cd bcwc_pcie`
- Build the kernel module: `$ make`
- Generate dkpg and install the kernel module, this is easy to uninstall later: `# checkinstall`
Alternatively if you are really lazy just: `# make install`
- Run depmod for the kernel to be able to find and load it: `# depmod`
- Load kernel module: `# modprobe facetimehd`
- try it out: `$ mplayer tv://`
See [Additional Notes](#additional-notes) below in case you come across any issues.
## Get Started on Ubuntu
All the steps are the same as Debian. (The only difference is that the firmware.bin is copied into `/lib/firmware/facetimehd/` instead of `/usr/lib/firmware/facetimehd/`, but the script does that for you.)
## Ubuntu installation script
This may be used as an alternative to the manual installation steps described above. Works on Ubuntu 16.04. To be placed outside the `bcwc_pcie` folder. Run with `bash script.sh`
#!/bin/bash
cd bcwc_pcie/firmware
printf "Compiling firmware\n";
make
printf "done\n\n";
printf "Installing firmware\n";
sudo make install
printf "done\n\n";
cd ..
printf "Compiling driver\n";
make
printf "done\n\n";
printf "Installing driver\n";
sudo make install
printf "done\n\n";
printf "Running depmod\n";
sudo depmod
printf "done\n\n";
printf "Running modprobe -r bdc_pci\n";
sudo modprobe -r bdc_pci
printf "done\n\n";
printf "Loading driver\n";
sudo modprobe facetimehd
printf "done\n\n";
If `sudo modprobe facetimehd` fails, run `dmesg`. If you get `facetimehd: version magic '4.13.0-37-generic SMP mod_unload ' should be '4.13.0-38-generic SMP mod_unload '`, or similar, you may manually edit the file via `sudo vim /lib/modules/4.13.0-38-generic/extra/facetimehd.ko` and replace `vermagic=4.13.0-37-generic SMP mod_unload` with `vermagic=4.13.0-38-generic SMP mod_unload`. Then you may be able to `sudo modprobe facetimehd` without any issues.
## Suspend on 16.04 and later (systemd)
As long as suspend is not working you can use the following approach to make the module unload on suspend:
[Systemd Module Unload Script](https://gist.github.com/mauron85/f764c88d2dc47af157487a7a318dd35b)
Just add facetimehd to /etc/suspend-modules.conf then.
Also: Don't forget to add a file /etc/modprobe.d/blacklist-facetimehd.conf with the line
`blacklist bdc_pci` to prevent bdc_pci from being auto-loaded.
## Setting up DKMS (auto-compile on kernal update)
This assumes you have already followed the Debian/Ubuntu deb package steps. You will need to verify `dkms.conf` that the module name `facetimehd` and version number `0.1` are correct and either update the `dkms.conf` or adjust the instructions where `-m` and `-v` are used.
- Install needed packages: `# apt install debhelper dkms`
- Remove old package if installed: `# dpkg -r bcwc-pcie `
- Make a directory to work from: `# mkdir /usr/src/facetimehd-0.1`
- Change into the git repo dir: `$ cd bcwc_pcie`
- Copy files over: `# cp -r * /usr/src/facetimehd-0.1/`
- Change into that dir: `# cd /usr/src/facetimehd-0.1/`
- Remove any previous debs and backups: `# rm backup-*tgz bcwc-pcie_*deb`
- Clear out previous compile: `# make clean`
- Register the new module with DKMS: `# dkms add -m facetimehd -v 0.1`
- Build the module: `# dkms build -m facetimehd -v 0.1`
- Build a Debian source package: `# dkms mkdsc -m facetimehd -v 0.1 --source-only`
- Build a Debian binary package: `# dkms mkdeb -m facetimehd -v 0.1 --source-only`
- Copy deb locally: `# cp /var/lib/dkms/facetimehd/0.1/deb/facetimehd-dkms_0.1_all.deb /root/`
- Get rid of the local build files: `# rm -r /var/lib/dkms/facetimehd/`
- Install the new deb package: `# dpkg -i /root/facetimehd-dkms_0.1_all.deb`
If you have any trouble, please read this guide on making a DKMS package:
http://www.xkyle.com/building-linux-packages-for-kernel-drivers/
## Get started on Arch
There is [AUR package](https://aur.archlinux.org/packages/bcwc-pcie-git/) available, and [another one](https://aur.archlinux.org/packages/bcwc-pcie-firmware/) for the firmware itself (the separation will make upgrades less painful, and don't force you to keep `firmware.bin` around forever).
If you want to install the kernel module manually, instead, you should:
- Extract firmware file as described in [Firmware extraction](#firmware-extraction).
- Install dependencies: `sudo pacman -S linux-headers git kmod`
- Clone driver's code: `git clone https://github.com/patjak/bcwc_pcie.git`
- Step into cloned dir: `cd bcwc_pcie`
- Build kernel module: `make`
- Install kernel module: `sudo make install`
- Run depmod for kernel to be able to find and load it: `sudo depmod`
- Load kernel module: `sudo modprobe facetimehd`
- Try it with the application of choice. mpv for example: `sudo pacman -S mpv && mpv tv://`
See [Additional Notes](#additional-notes) below in case you come across any issues.
## Get Started on Gentoo
On Gentoo it is no longer necessary to extract the firmware from a running OS X.
Simply use the `bcwc_pcie` ebuild from https://github.com/toaster/gentoo-overlay.git.
The following steps have to be performed as `root`.
### Adding the overlay using `layman`
First create a local overlay list:
```sh
echo '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE repositories SYSTEM "/dtd/repositories.dtd">
<repositories xmlns="" version="1.0">
<repo quality="experimental" status="unofficial">
<name>toaster</name>
<description>toasters own ebuilds</description>
<homepage>https://github.com/toaster/gentoo-overlay</homepage>
<owner type="project">
<email>tilo@pruetz.net</email>
<name>Tilo Prütz</name>
</owner>
<source type="git">https://github.com/toaster/gentoo-overlay.git</source>
<feed>https://github.com/feeds/toaster/commits/gentoo-overlay/master</feed>
</repo>
</repositories>' > /etc/layman/overlays/toaster.xml
```
Then make it known to layman and add it to your local overlays:
```sh
layman -L
layman -a toaster
```
### Install the driver
Note that you have to set the `~amd64` keyword for the driver package and for `media-video/apple_facetimehd_firmware`. How this is done in detail depends on how you manage your keywords.
```sh
emerge -av media-video/bcwc_pcie
```
The firmware ebuild will download a partial OS X 10.11 upgrade and extract the firmware from it. It is not necessary to boot OS X and extract it manually.
See [Additional Notes](#additional-notes) below in case you come across any issues.
## Get Started on openSUSE
Prebuilt packages are available for Leap 15.1, Leap 15.2 and Tumbleweed:
(https://software.opensuse.org/search?utf8=%E2%9C%93&baseproject=ALL&q=facetimehd)
You need to install the facetimehd-kmp-default and facetimehd-firmware package. The facetimehd-firmware package will download and install the firmware so an internet connection is required when installing. For older versions of openSUSE follow the instructions below.
- You need a least openSUSE Leap 42.1. If you are running openSUSE 13.2 upgrade to openSUSE Leap 42.1 (https://en.opensuse.org/SDB:System_upgrade) or install a kernel >= 3.19 (not tested)
- Extract firmware file as described in [Firmware extraction](#firmware-extraction)
- Become root `su -`
- Install packages kernel-devel and git: `zypper install kernel-devel git`
- Clone the driver's code: `git clone https://github.com/patjak/bcwc_pcie.git`
- Change into directory: `cd bcwc_pcie`
- Build the kernel module: `make`
- Install the kernel module: `make install`
- Run `depmod`
- Load the module: `modprobe facetimehd`
- Check if all relevant modules a loaded: `lsmod | grep facetimehd`
```
facetimehd 102400 0
videobuf2_dma_sg 20480 1 facetimehd
videobuf2_core 57344 1 facetimehd
videodev 176128 3 v4l2_common,facetimehd,videobuf2_core
```
- At the moment the kernel module is not loaded automatically. If you would like the kernel module to be loaded at system startup add the following line to `/etc/init.d/after.local` (Note that this is not yet recommended since the driver is not 100% stable)
```sh
modprobe facetimehd
```
- In order to get it working after suspend see [below](#make-driver-load-correctly-after-suspend)
- To test the camera install mplayer from Packman repo. If not yet done add Packman repo first
```sh
zypper addrepo -f http://packman.inode.at/suse/openSUSE_Leap_42.1/ packman
zypper install mplayer
```
- As user start mplayer: `mplayer tv://`
- By the way, the Packman repo provides a driver for the WiFi card (Broadcom):
`zypper install broadcom-wl`
- In order to update the driver later to the newest version, change to the folder where your have cloned the driver's code `cd bcwc_pcie` run `git pull` followed by `make clean; make; make install`.
See [Additional Notes](#additional-notes) below in case you come across any issues.
## Get Started on NixOS
[NixOS](http://nixos.org/) has built-in facetimehd support starting 16.03. Enabling the [NixOS module](https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/hardware/video/webcam/facetimehd.nix) will extract the firmware online, blacklist bdc_pci and add rmmod/modprobe hooks during suspend.
1. Make sure the following lines (or its equivalent) are in `/etc/nixos/configuration.nix`
```ini
hardware.facetimehd.enable = true;
nixpkgs.config.allowUnfree = true;
```
2. Execute `nixos-rebuild boot` to rebuild the configuration
3. Reboot
See [Additional Notes](#additional-notes) below in case you come across any issues.
# Additional Notes
## /dev/video not created
In some scenarios, you'll have to unload `bdc_pci` before inserting the kernel module, or `/dev/video` (or `/dev/video0`) won't be created. Do this with `modprobe -r bdc_pci`. If that doesn't help you can try `modprobe -r bdc_pci` and `modprobe -a v4l2-common videobuf2-dma-sg videobuf2-core videobuf2-v4l2`.
## Make driver load correctly after suspend
~~Putting the computer to suspend and trying to use the camera afterwards makes the computer freeze. Here is a fix for that.~~
Suspend/resume should now work without any additional fixes. Note that suspend/resume with the device opened is still not supported.
### Make driver load correctly on startup
If you want the driver to be enabled on startup, extra steps may be required. On Ubuntu, the following should work:
```sh
echo facetimehd >> /etc/modules
```
On most `systemd`-based systems (tested on OpenSUSE):
```sh
echo facetimehd | sudo tee /etc/modules-load.d/facetimehd.conf
```
### For Ubuntu 15.04 and higher (Should work on some other distros too):
Put this in terminal. Use `gedit` or your favorite text editor:
`sudo gedit /lib/systemd/system-sleep/99facetimehd`
or if /lib/systemd/system-sleep does not exist:
`sudo gedit /usr/lib/systemd/system-sleep/99facetimehd`
Paste this in the empty file:
```sh
#!/bin/sh
case $1/$2 in
pre/*)
echo "Going to $2..."
modprobe -r facetimehd
;;
post/*)
echo "Waking up from $2..."
modprobe -r bdc_pci
modprobe facetimehd
;;
esac
```
And save.
Make it executable:
`sudo chmod a+x /lib/systemd/system-sleep/99facetimehd`
or
`sudo chmod a+x /usr/lib/systemd/system-sleep/99facetimehd`
### For Ubuntu 14.10 and lower / Mint 17 (Should work on some other distros too):
Paste this in terminal: `sudo gedit /etc/pm/sleep.d/99_facetimehd`
And paste this in and save file:
```sh
#!/bin/sh
case $1 in
resume|thaw)
logger -t pm 'Loading facetimehd kernel module'
/sbin/rmmod bdc_pci
/sbin/modprobe facetimehd
;;
suspend|hibernate)
logger -t pm 'Removing facetimehd kernel module'
/sbin/rmmod facetimehd
exit 0
;;
esac
```
And make it executable: `sudo chmod a+x /etc/pm/sleep.d/99_facetimehd`
See the [Installation page](https://github.com/patjak/bcwc_pcie/wiki/Installation) for instructions
## If you cannot get mplayer to load after correctly creating /dev/vide0