English is not my native language so please be patient.

I'm using a Rasp and the Ethernet port is already taken, so we bought a USB2.0 to Fast Ethernet Adapter, like this one: https://www.jacobsparts.com/items/USB-LAN-04

The RasPi detect the QingHeng Electronics device as is show in the following screenshot. The Chipset is suposed to be the CH9200.

enter image description here

Installing the drivers in a laptop with Ubuntu 14.04 was easy, but same steps for the Rasp didn't work. Aparently the issue is the Kernel, the CD with the drivers bring a "readme", which claims:

sudo Note:

  1. Please run as root

  2. Supported linux kernel range from 2.6.x to 3.8.x

  3. CH9x00 module depends on mii and usbnet modules
  4. If you want complied this module in kernel, refer to followed

    a. # cp ch9x00.c ~/2.6.25/driver/net/usb/

    b. # cd> ~/2.6.25/driver/net/usb/

    c. modified Makefile and Kconfig for ch9x00.c

Install: # make # make load

Uninstall: # make unload

So i verify the kernel version of the rasp using uname -a, gives the following:

Linux raspberrypi 4.1.7-v7+ #817 SMP PREEMPT Sat Sep 19 15:32:00 BST 2015 armv7l GNU/Linux

I copy the files from the CD driver to home/pi/linux, the command sudo make returns the following:

make -C /lib/modules/4.1.7-v7+/build M=/home/pi/linux
make[1]: *** /lib/modules/4.1.7-v7+/build: No existe el fichero o el directorio.  Alto.
Makefile:13: recipe for target 'modules' failed
make: *** [modules] Error 2

the output of ls -l acording to Diederik comment. This is before I used the linux-headers method.

ls -l acording to Diederik comment

In the Raspberry forums there is a posible solution in the seventh post that lead to install the "linux-headers-3.10-3-rpi" and then link the modules:

sudo ln -s /lib/modules/3.10-3-rpi/build /lib/modules/ 4.1.7-v7+/build

This let me compile the files, once there I tried to run sudo make load, but this time the answer was:

modprobe mii
modprobe usbnet
insmod ch9x00.ko
Error: could not insert module ch9x00.ko: Invalid module format
Makefile:16: recipe for target 'load' failed
make: *** [load] Error 1

Also tried with "linux-headers-3.18.0-trunk-rpi2" because those are made for the RasPi2, but that didn't work either.

Thanks to Diederik de Haas for his response and the updates, i just followed his detailed steps, in the Step 1 choosed the "Commit" published on Nov 18th with the "2a329e0", using the Module7.symvers and the git_hash from that date.

Step 2 and 3 went just ok, compilation too, but when the time for waking up the module come, got the following result:

Almost there

Also tried with --force, finally post the dmesg | tail for clues.

Update Dic 16

When I start this question already have a working web server in the RasPi (raspbian wheezy) using tomcat7, which was quite difficult to setup, so i made an RasPi_14_12_16.img for safety, in this image i have the following setup that can differs from a standard ".img"

1 - Got network with static ip runing on a wifi usb module.

2 - Change some rules (rules.d - udev) to auto-mount usb with full permissions.

3 - Internationalisation Options was changed to es_CO. UTF-8 UTF-8 and SPI Interface was disabled.

Just uploaded the ".img" once again and the detailed info for the procedure acording to my kernel,is the next:

1 - uname -a got the following Linux raspberrypi 4.1.7-v7+ #817 SMP PREEMPT Sat Sep 19 15:32:00 BST 2015 armv7l GNU/Linux

2 - Installed gcc (i have previously removed) sudo apt-get install gcc (works fine install other packages along)

3 - sudo apt-get update && sudo apt-get upgrade, Then uname -r ---> still 4.1.7-v7+

4 - Then I get the git_hash from my Pi : zgrep '* firmware as of' /usr/share/doc/raspberrypi-bootloader/changelog.Debian.gz | head -1

* firmware as of 960832a6c2590635216c296b6ee0bebf67b2****

5 - Like the Step 1 on Diederik's answer: download (raw --> right click --> save link as...) the Module7.symvers from https://github.com/raspberrypi/firmware/tree/2a329e0c7d8ea19c085bac5633aa4fccee0f21be/extra

6 - Like the Step 2 on Diederik's answer: Got the kernel sources and put them into the rpf-linux-kernel folder: ~ $ git clone https://github.com/raspberrypi/linux rpf-linux-kernel


git checkout -b rpi-bootloader-4.1.7 960832a6c2590635216c296b6ee0bebf67b2**** make mrproper make bcm2709_defconfig make modules_prepare

7 - Like the Step 3 on Diederik's answer: I made the virtual links using: sudo ln -s /home/pi/rpf-linux-kernel/ /lib/modules/$(uname -r)/build

@DiederikdeHaas Upload the ch9200.ko (https://drive.google.com/file/d/0BxmrihUj-8tSa2YxUDAzY1NyNkU/view?usp=sharing) and detailed the following steps to install the module:

1 - To install it, do: sudo install -p -m 644 ch9200.ko /lib/modules/4.1.7-v7+/kernel/drivers/net/usb 2 - Then: sudo /sbin/depmod -a 4.1.7-v7+ 3 - After that you can load the module with: sudo modprobe ch9200

  • Please do not post duplicate questions. I am going to delete the other one. – Steve Robillard Dec 14 '15 at 17:36
  • Thanks @SteveRobillard i was unable to delete the other because the user change, sorry for the trouble. – Elber CM Dec 14 '15 at 17:44
  • @DiederikdeHaas Updated the Question and erased serveral comments in Question and Answer, can't remove yours. Also upload the ch9200.ko to my personal google drive and updated the link, that's ok with you? – Elber CM Dec 16 '15 at 22:03
  • @ElberCM Yeah, that's fine. Ideally it shouldn't be needed anymore, but better safe then sorry ;-) I'll remove some more of my comments. – Diederik de Haas Dec 16 '15 at 22:05
  • 1
    Because the exact version is crucial and instructions for another kernel version is very likely to cause confusion. Given the back and forth we had, we understand it, but for others it would be incomprehensible. Now others should be able to follow and apply it to their own situation ... hopefully :-P – Diederik de Haas Dec 16 '15 at 22:27

Important: Follow these instructions meticulously

Note: The OP is using Wheezy and the latest kernel version from raspberrypi-bootloader then is 4.1.7-v7+, while on jessie that version is 4.1.13-v7+ and that's a critical difference!
If you're going to apply these steps to your own situation, adjust the values accordingly.

Step 1: Get the git_hash from the firmware
Get the firmware-commit-id: zgrep '* firmware as of' /usr/share/doc/raspberrypi-bootloader/changelog.Debian.gz | head -1 which returns 960832a6c2590635216c296b6ee0bebf67b21d50 or 960832a for short.
On https://github.com/raspberrypi/firmware/commits/master you look for that firmware-commit-id (960832a on 23 Sep 2015 (the date is only as extra helper, the only relevant thing is the firmware-commit-id)) and click on Browse the repository at this point in the history and switch to the extra directory. When you're there, download Module7.symvers and save it in your home directory (for the Pi 1, you'd download Module.symvers).
In the extra directory you'll also find a file git_hash which you should open and write down the id (59e76bb7e2936acd74938bb385f0884e34b91d72) you see there. This is the kernel-commit-id.

Step 2: Prepare the kernel for module compilation
Get the kernel sources and put them into the rpf-linux-kernel folder:
git clone https://github.com/raspberrypi/linux rpf-linux-kernel
This will download more then 1GB of data and then process it, which will take a while.

To prepare the sources for kernel module compilation there are some other steps to do.
First you need to checkout the kernel code at the exact kernel-commit-id you found earlier. I always do my 'work' in a separate branch instead of in 'master' as that makes it easier to start over in case things go wrong and it is considered best practice. Then you clean everything up (mrproper), load the default configuration for the Pi 2 (bcm2709_defconfig) and prepare the sources for module compilation (modules_prepare):

cd rpf-linux-kernel
git checkout -b rpi-bootloader-4.1.7 59e76bb7e2936acd74938bb385f0884e34b91d72
make mrproper
make bcm2709_defconfig
make modules_prepare

For the Pi 1 you should replace bcm2709_defconfig with bcmrpi_defconfig.

Now copy the Module7.symvers file you downloaded earlier into the kernel tree and rename it to Module.symvers: cp ../Module7.symvers Module.symvers
(for the Pi 1, just copy the Module.symvers into the kernel tree).

Step 3: Set up your system for kernel module compilation
When you're compiling a kernel module, the build system looks in the /lib/modules/<kernel-version>/build directory for the kernel headers/sources. So make the link from that build directory to our current directory:
sudo ln -s /home/pi/rpf-linux-kernel/ /lib/modules/$(uname -r)/build

When you now do ls -l /lib/modules/4.1.7-v7+/build you should get the following:
lrwxrwxrwx 1 root root 32 dec 15 21:38 /lib/modules/4.1.7-v7+/build -> /home/pi/rpf-linux-kernel/

And now you're ready to compile a kernel module.

Step 4: Compiling the kernel module
You're lucky as someone has posted the source file and a Makefile to compile the module.
To compile it, go back to your home directory, clone the git repository and make/install the driver:

cd ~
git clone https://github.com/xor-function/usb-ethernet-adapter
cd usb-ethernet-adapter
sudo make install

And then to load it, do sudo modprobe ch9200.
As the USB ID is part of the driver code, when you plug the device in it should detect it automatically and load the driver.

  • Wouldn't it be easier if I upload the ch9200.ko file (the kernel module itself)? – Diederik de Haas Dec 16 '15 at 16:23
  • the one you consider will be more helpfull. Please could you give me the steps for insmod the "ch9200.ko" correctly. Thanks again. – Elber CM Dec 16 '15 at 16:31
  • 1
    "Internet is Forever" that's why I'm going to say this: Thanks a lot @DiederikdeHaas , owe you three rounds of beers. One for your help, other for your dexterity and the last and more important for your patience. Thanks again. – Elber CM Dec 16 '15 at 20:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.