My experiences in switching to powerline ethernet and getting around non-free r8169 firmware

18 replies [Last post]
t3g
t3g
Offline
Joined: 05/15/2011

A little over a year ago, I built a new computer from scratch that has an ASUS M5A99FX PRO R2.0 motherboard. For getting online, I used the ThinkPenguin 802.11n wireless USB dongle instead of the Realtek 8111F Gigabit LAN port that by default tries to use the r8169 firmware. Unlike Ubuntu's kernel, the Linux Libre kernel deblobs the r8169 firmware which is considered non-free and since I never bothered with the ethernet until now, it wasn't an issue.

So why did I switch back to ethernet? I work from home and I have a detached garage that I use as my mancave/office and have been getting terrible wireless reception. Maybe it was the distance or since my house is old and solid, it could be that. Or it could be the Motorola cable modem/router combo didn't want to play nice with the dongle.

I started looking into powerline ethernet where you send the internet through the power in your house by using two outlet plugs. One is in an outlet near my router attached to the router with a CAT6 and the other is in my detached garage with another CAT6 running to my PC.

So to get to the point of this post is that if your motherboard has a Realtek ethernet that uses the r8169 firmware by default and is deblobbed in Trisquel, there's the r8168-dkms package that works the same.

This is what I did to get my ethernet running in Trisquel 7:

1.) If using Trisquel 7 with the 3.13 (default) kernel, download r8168-dkms from http://packages.trisquel.info/belenos/r8168-dkms. If using Trisquel 7 with the 3.19 (Vivid) kernel, download r8168 from http://packages.ubuntu.com/vivid/r8168-dkms. I know I am pointing to an Ubuntu package, but it should be free and in my experience, plays nicer with the 3.19 kernel since the 3.19 kernel is the default in Ubuntu 15.04/Vivid.

2.) Blacklist r8169 driver by adding r8169 to the bottom of /etc/modprobe.d/blacklist.conf as sudo/su and save.

3.) Make sure dkms is installed via "sudo apt-get install dkms" if not already installed.

4.) Install r8168-dkms_8.037.00-1_all.deb (3.13 kernel) or r8168-dkms_8.039.00-1_all.deb (3.19 kernel)

5.) Add r8168 to the bottom of /etc/modules as sudo/su and save.

6.) If there are issues, run "sudo dpkg-reconfigure r8168-dkms"

7.) May or may not have to reboot after blacklisting, installing DKMS package, or dpkg-reconfigure

I haven't tested this with the 4.x kernels offered at http://jxself.org/linux-libre/ but since the 3.13 and 3.19 kernels are offered in the Trisquel 7 repos and have the same naming conventions and versions as the Ubuntu ones, the r8168-dkms package should play nice with them.

t3g
t3g
Offline
Joined: 05/15/2011

I do have a correction since I cannot edit my original post. For #2, it should be "blacklist r8169" instead of just "r8169" but I assume most of you knew that. :-)

Legimet
Offline
Joined: 12/10/2013

Why is the package in non-free in Debian? Maybe there's a firmware blob in the source code.
https://packages.debian.org/sid/r8168-dkms

EDIT: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=648286
"License : GPL-2+ (contains binary blobs)"
So it is indeed nonfree and should be removed from Trisquel.
I filed a bug report: #14731: belenos contains nonfree (binary blob-containing) package r8168-dkms

t3g
t3g
Offline
Joined: 05/15/2011

Are you sure? It's in the universe repo of Ubuntu and not restricted or multiverse. If you go to http://www.realtek.com.tw/downloads/downloadsview.aspx?langid=1&pnid=13&pfid=5&level=5&conn=4&downtypeid=3&getdown=false#2 for r8168-8.040.00.tar.bz2 and take a look at the source code you will see:

################################################################################
#
# r8168 is the Linux device driver released for Realtek Gigabit Ethernet
# controllers with PCI-Express interface.
#
# Copyright(c) 2014 Realtek Semiconductor Corp. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see .
#
# Author:
# Realtek NIC software team <name at domain>
# No. 2, Innovation Road II, Hsinchu Science Park, Hsinchu 300, Taiwan
#
################################################################################

t3g
t3g
Offline
Joined: 05/15/2011

Download http://archive.trisquel.info/trisquel/pool/main/r/r8168/r8168_8.037.00.orig.tar.bz2, extract, and go into the /src/ folder. Open up any of the files and you will see the source and the GPL license header.

t3g
t3g
Offline
Joined: 05/15/2011

Oh and I re-downloaded http://us.archive.trisquel.info/trisquel/pool/main/r/r8168/r8168-dkms_8.037.00-1_all.deb and http://us.archive.ubuntu.com/ubuntu/pool/universe/r/r8168/r8168-dkms_8.039.00-1_all.deb and then extracted them and peeked around the files.

Where are these binary blobs? All I see are source files that are used and created on the fly for DKMS. Wouldn't it be better to ACTUALLY look at the files that you are condemning instead of just taking someone else's word for it?

Legimet
Offline
Joined: 12/10/2013

Look at this file: https://github.com/mtorromeo/r8168/blob/master/src/r8168_n.c. It's hidden in the source.
Basically, all the rtl8168_set_phy_mcu_* contain the blobs. So yes, I did "ACTUALLY look at the files."

t3g
t3g
Offline
Joined: 05/15/2011

Can you please clarify the line number(s) of the suspected invalid "binary code" contained within the text file?

Legimet
Offline
Joined: 12/10/2013

The first one is at line 7432. Scroll down and you'll see functions spanning thousands of lines, one for each chipset.

quidam

I am a member!

I am a translator!

Offline
Joined: 12/22/2004

Several sections after line 5853 do not qualify for "source code" as per the GPL requirements. I marked the package for removal.

Legimet
Offline
Joined: 12/10/2013

Yes, there too. That is obviously not human-readable source.

t3g
t3g
Offline
Joined: 05/15/2011

I sent a message on GitHub (https://github.com/mtorromeo/r8168/issues/3) asking for him/her to provide source for the binary code or remove entirely.

Well this sucks... I thought I had a free alternative to the r8169 firmware. :-(

Legimet
Offline
Joined: 12/10/2013

mtorromeo's repo is just an unofficial mirror of realtek's source code. You would have to ask realtek, but I doubt they would listen.

t3g
t3g
Offline
Joined: 05/15/2011

Yeah, I sent an email to name at domain with this text:

"On your http://www.realtek.com.tw/downloads/downloadsview.aspx?langid=1&pnid=13&pfid=5&level=5&conn=4&downtypeid=3&getdown=false#2 page you provide firmware for RTL8111 for UNIX (Linux) that are licensed under the GPL. This inclusion of non human readable binary code also affects earlier versions of your code like version 8.037 used by the r8168-dkms package in Ubuntu 14.04.

When looking at the source code for r8168-8.040.00.tar.bz2, the r8168_n.c file in /src/ contains binary code that is not readable and does not have appropriate documentation on the license of such code.

According to these sources, the firmware is not in full compliance with the GPL and is considered non-free:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=787634
https://devel.trisquel.info/trisquel/ubuntu-purge/merge_requests/17
https://trisquel.info/en/forum/my-experiences-switching-powerline-ethernet-and-getting-around-non-free-r8169-firmware

Please consider a revision to your drivers to provide source code or better documentation regarding the source of the binary code so it is in the full spirit of the GPL and doesn't get excluded from popular GNU/Linux distributions.

Thank you"

Legimet
Offline
Joined: 12/10/2013

If realtek does anything, it would be taking the blob, putting it in a separate file to be placed in /lib/firmware, and requesting it with request_firmware.

alonsogonzalez
Offline
Joined: 10/29/2014

I don't see why you're attempting to install Realtek's Ethernet drivers. My desktop has an RTL8111D(L) chip, and my notebook has an RTL8111 series chip which I could not identify it's revision. Both computers are running Trisquel GNU 7.0.

Desktop: lspci: 02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 03)
uname -r: 3.13.0-55-lowlatency (Stock kernel from Trisquel repositories, updated)

Notebook: lspci: 02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 10)
uname -r: 3.16.0-40-lowlatency (Filtered Ubuntu 14.10 backport kernel from Trisquel repositories)

As far as I'm aware, there isn't much of a difference with the different RTL8111 chips. Even though the r8169 driver attempts to load non-existent (removed) firmware on both of these computers, I still have a stable Internet connection without the firmware.

You said something about the r8169 kernel module being de-blobbed, however you never said anything about testing it. I would remove the Realtek Ethernet drivers and try the one that comes with Linux (by Linux, I mean the kernel), and see if it works.

Legimet
Offline
Joined: 12/10/2013

Not all of the r8169 ethernet chips require firmware, so you may be lucky.

alonsogonzalez
Offline
Joined: 10/29/2014

That could also be possible, maybe either the firmware is embedded inside the chip, or it has a separate firmware chip, and it's trying to update the firmware. Or maybe an update to the driver made firmware irrelevant for some Realtek Ethernet chips and it still wants to load the firmware anyways.

Even before I knew about Trisquel (and was just barely familiar with the GNU Project), when I was still running Debian in 2013, it used to be that firmware was still required for Realtek chips using the r8169 driver, however it appears to be that even though it attempts to load the firmware for this chip, it is no longer required, at least for the computers I've used.

I've used the following three computers that have an RTL8111 series chip:
Desktop: BioStar TP55 Motherboard (Since 2012, I still use it)
Notebook: Toshiba L505-ES5018 (From 2011 [when I used to still run Microsoft Windows] until 2014 [It had Debian GNU by the time I stopped using it])
Notebook: ASUS Q301LA-BSI5T17 (Since 2014, first ran Debian then switched to Trisquel)

t3g
t3g
Offline
Joined: 05/15/2011

I'll try it later without the r8168-dkms package and toggle the blacklisting of the r8169 firmware. By defaut, Ubuntu 14.04 will use the firmware and Trisquel has shown the r8169 as simply deblobbed when checking.

Or I could just run a live CD on a fresh 7 ISO and see what happens.

To be honest, I probably screwed myself for making this r8168-dkms experience public. Most people would keep it secret, but it benefits you all in the end I guess. I just hope this doesn't force me back to Ubuntu or to simply install r8168-dkms manually from now on.