After a break of a few months I picked this up again.
The goal is to get fan control with the least effort possible.
Communication is done over the Intel Braswell SMBus device and the Intel Braswell HSUART controller bound to /dev/ttyS2
Debian Jessie (3.16+ kernel)
Out of the box, there is no support for the Braswell smbus/uart… the driver is unknown.
# apt install setserial
# setserial -g /dev/ttyS2
/dev/ttyS2, unknown Port: 0x0000 IRQ: 4
The PCI bus shows that no drivers are loaded.
$ lspci -k -s 00:1e
00:1e.0 DMA controller: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 DMA Controller (rev 35)
Subsystem: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 DMA Controller
00:1e.3 Communication controller: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 HSUART Controller #1 (rev 35)
Subsystem: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 HSUART Controller
00:1e.4 Communication controller: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 HSUART Controller #2 (rev 35)
Subsystem: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 HSUART Controller
$ lspci -k -s 00:1f
00:1f.3 SMBus: Intel Corporation Device 2292 (rev 35)
The smbus component is an I2C device, but there was no I2C devices detected on my Debian Jessie installation with kernel 3.16.
# ls /sys/bus/i2c/devices
Google for vendor 8086 and device id 2292 leads to this great site: Linux Kernel Driver DataBase: CONFIG_I2C_I801: Intel 82801 (ICH/PCH)
vendor: 8086 ("Intel Corporation"), device: 2292 ("Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx SMBus Controller")
...
lkddb pci 8086 2292 .... .... ...... : CONFIG_I2C_I801 : drivers/i2c/busses/i2c-i801.c # in 3.17–3.19, 4.0–4.16, 4.17-rc+HEAD
The i2c driver called i2c_i801
only supports the SMBus controller with ID 2292 as of kernel 3.17 or 4.0+.
Support in the kernel was added with this patch: [4/4] i2c: i801: Add PCI ID for Intel Braswell - Patchwork
I compiled and installed the 3.18 mainline kernel on my PR4100 (with Debian 8) with these steps:
$ mkdir -p ~/kbuild && cd ~/kbuild
$ wget https://cdn.kernel.org/pub/linux/kernel/v3.x/linux-3.18.106.tar.xz
$ tar xf linux-3.18.106.tar.xz
$ cd linux-3.18.106
Note that you could also just patch the 3.16 kernel source (but then you need to add the 8250 uart support too).
Copy the config of the kernel you’re currently using.
$ cp /boot/config-3.16.0* .config
Build the kernel config
$ make olddefconfig
Ensure that the serial port module is enabled by setting SERIO_SERPORT in .config to yes or by adding serport to /etc/modules
Build the kernel
$ make -j 4 KDEB_PKGVERSION=1.0.TFL deb-pkg
or use this
$ fakeroot make-kpkg --initrd --revision=1.0.TFL kernel_image kernel_headers -j 4
Install it and reboot
# dpkg -i ../linux-image-3.18.106_1.0.TFL_amd64.deb
# reboot
Verify new kernel
$ uname -r
Normally it is sufficient to do
# insmod i2c_designware_pci i2c_i801
# insmod serport
Then I used lm-sensors and sensors-detect and finally I had this:
lsmod | grep i2c
i2c_algo_bit 12744 1 i915
i2c_i801 16965 0
i2c_designware_pci 12611 0
i2c_hid 17403 0
hid 102264 1 i2c_hid
i2c_designware_platform 12645 0
i2c_designware_core 12813 2 i2c_designware_pci,i2c_designware_platform
i2c_core 50108 8 drm,i2c_designware_pci,i915,i2c_i801,i2c_hid,i2c_designware_platform,drm_kms_helper,i2c_algo_bit
Confirm that ttyS2 has a uart driver now
# setserial -g /dev/ttyS2
/dev/ttyS2, UART: 16550A, Port: 0x0000, IRQ: 19
Then the final test (I believe I had to run this command twice):
echo -ne 'FAN=25\r' | sudo tee /dev/ttyS2
echo -ne 'LN1=Cool Story Bro\r' | sudo tee /dev/ttyS2
echo -ne 'LN2=--------------\r' | sudo tee /dev/ttyS2
And finally the box fell silent.
Now setup the python2.7 branch of WD Hardware tools. Note that this is made for a DL2100, you’ll need some changes to make it work on a PRx100. Check the issues in the github repo.
Debian Stretch (4.9+ kernel)
Show the pci devices and the kernel modules they use.
lspci -k -s 00:1e
00:1e.0 DMA controller: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 DMA Controller (rev 35)
Subsystem: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 DMA Controller
00:1e.3 Communication controller: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 HSUART Controller #1 (rev 35)
Subsystem: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 HSUART Controller
00:1e.4 Communication controller: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 HSUART Controller #2 (rev 35)
Subsystem: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 HSUART Controller
lspci -k -s 00:1f
00:1f.0 ISA bridge: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series PCU (rev 35)
Subsystem: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series PCU
Kernel driver in use: lpc_ich
Kernel modules: lpc_ich
00:1f.3 SMBus: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx SMBus Controller (rev 35)
Subsystem: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx SMBus Controller
Kernel driver in use: i801_smbus
Kernel modules: i2c_i801
The SMBus device is detected and the i2c_i801 driver is loaded, but the UART device at 00:1e.3
does not have a driver yet.
A lookup of the vendor (8086) and device id (228a / 228c) leads to the 8250_lpss module. See Linux Kernel Driver DataBase: CONFIG_SERIAL_8250_LPSS: Support for serial ports on Intel LPSS platforms
They cleaned up the 8250 serial driver and the Intel Braswell code was moved out of the default serial module.
This driver is not included in the kernel, as can be seen in the kernel config at /boot/config-4.9.xxxx
# CONFIG_SERIAL_8250_LPSS is not set
Time to build our own kernel.
Get the 4.9 kernel (or get the current stable version, just drop the -4.9
).
sudo apt install linux-source-4.9 linux-headers-amd64
The source archive is now available in the /usr/src directory. Alternatively, you could’ve downloaded a source archive from http://www.kernel.org
Setup a working directory and unpack the source.
mkdir ~/kbuild && cd ~/kbuild
tar xf /usr/src/linux-source-4.9.tar.xz
cd linux-source-4.9
Use the current config as a basis.
make olddefconfig
Enable the CONFIG_SERIAL_8250_LPSS flag (and any other LPSS related flag) in the .config file.
editor .config
or use the menu based installer
Install ncurses and set it in Device Drivers - Character devices - Serial drivers.
make nconfig
Press F8 to search for LPSS, verify that it is enabled.
Now make the kernel debian package
make -j 4 KDEB_PKGVERSION=1.tflinux deb-pkg
This took 2 hours when building on the NAS. You may explore kernel-package to build faster.
Install the kernel (and the headers if you want to use virtualbox/zfs) and reboot
sudo dpkg -i ../linux-image-4.9.88_1.0.TFL_amd64.deb
sudo dpkg -i ../linux-headers-4.9.88_1.0.TFL_amd64.deb
sudo reboot
Check the kernel version
uname -a
Check support for the uart modules
lspci -k -s 00:1e
00:1e.0 DMA controller: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 DMA Controller (rev 35)
Subsystem: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 DMA Controller
Kernel driver in use: dw_dmac_pci
00:1e.3 Communication controller: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 HSUART Controller #1 (rev 35)
Subsystem: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 HSUART Controller
Kernel driver in use: 8250_lpss
00:1e.4 Communication controller: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 HSUART Controller #2 (rev 35)
Subsystem: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 HSUART Controller
Kernel driver in use: 8250_lpss
Confirm uart support
sudo setserial -g /dev/ttyS*
/dev/ttyS0, UART: 16550A, Port: 0x03f8, IRQ: 4
/dev/ttyS1, UART: 16550A, Port: 0x0000, IRQ: 18
/dev/ttyS2, UART: 16550A, Port: 0x0000, IRQ: 19
/dev/ttyS3, UART: unknown, Port: 0x02e8, IRQ: 3
However, the default baud rate is not correct yet…
I’m now using these commands, but this should be done with /etc/serial.conf
sudo stty -F /dev/ttyS2 0:0:0cbd:0:3:1c:7f:15:4:0:0:0:11:13:1a:0:12:f:17:16:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0
sudo setserial /dev/ttyS2 closing_wait 3000
sudo setserial /dev/ttyS2 baud_base 4608000
And finally
echo -ne 'STA\r' | sudo tee /dev/ttyS2
echo -ne 'FAN=25\r' | sudo tee /dev/ttyS2
echo -ne 'LN1=Cool Story Bro\r' | sudo tee /dev/ttyS2
echo -ne 'LN2=--------------\r' | sudo tee /dev/ttyS2
Almost done…
Now setup the python3 version of the WD Hardware tools. This is a fork of the original project by Michael Roland, I’ve added the required changes for a PR4100, as discussed in the following 10 posts.