PieHead wrote:Code: Select all
# go to kernel source directory
cd /home/pi/src/linux - you will need to use the directory you store your source in.
My
/home/pi dir exists, but I do not appear to have
/src/linux inside here (searched for hidden types too)
I have run
find / -type d "src" and cannot locate this folder.
I setup my Pi from
http://downloads.raspberrypi.org/raspbian_latest image, image to microSD, and thats pretty much it.
Am I supposed to do some other step to get this /src/linux folder?
Regards
Hi PiHead,
The
src directory is a directory I configured to put the source data for the kernel and driver code I use.
As an example I will show you how I compile the driver module, including downloading and configuring all the necessary code.
First I am starting with a newly set up SD card with raspbian 3.12.28+ from the Raspberry Pi Download page and it is connected to the internet using a wired network cable connection.
The command
uname -a shows the following:-
Code: Select all
Linux raspberrypi 3.12.28+ #709 PREEMPT Mon Sep 8 15:28:00 BST 2014 armv6l GNU/Linux
After logging in which puts me in my home directory
/home/pi I generate the
src directory with the command
Now I enter the source directory and download the source code for the kernel, the kernel firmware and the rtl8188eu driver. The command
will put me in directory
/home/pi/src.
Now download the linux kernel source, the kernel firmware and the driver source from the various git repositories with the commands
Code: Select all
git clone --depth 100 https://github.com/raspberrypi/linux.git
git clone --depth 25 https://github.com/raspberrypi/firmware.git
git clone https://github.com/lwfinger/rtl8188eu
Note: the option
--depth xxx in the git clone commands above limits the amount of code downloaded otherwise it will literally take all day to download and most of the code will not be needed.
Now you will have three directories in the
/home/pi/src directory. These are
linux,
firmware and
rtl8188eu. Now we need to configure the linux and firmware directories to point to the right kernel version, 3.12.28+ #709, ready for compiling the driver. First enter the
firmware directory and set it up with the commands
Code: Select all
cd firmware
git checkout 53d1ae311226b5cd7ea1277832139b74b2bb0f90
Be patient as the checkout may take some time before it appears to do anything. Now enter the linux source directory and set that up using commands
Code: Select all
cd ../linux
git checkout 94a382fed1a5ec303eef9e1f3439df8f759ba60c
The long numbers in the
git checkout commands are the commit IDs and can be found looking at the firmware git repository for a particular kernel revision. For a particular kernel version look at the description of the commit to find the firmware commit ID and then browse the code and look at the value at
extra/git_hash and that is the kernel commit ID for the particular kernel version.
Now we can configure the kernel ready to compile the driver. First initialise the kernel code and set up the
.config file
Code: Select all
make mrproper
make bcmrpi_defconfig
The
make bcmrpi_defconfig command is a general command using data included in the source code that can be used to generate the
.config file even if you are compiling a kernel version that is different to the version currently running on the Pi. An alternative to this command if you are compiling for the kernel you are running on the Pi is
zcat /proc/config.gz > .config and this will copy the
.config used by the running kernel.
Now finish configuring the kernel ready to compile the driver with the following commands.
Code: Select all
make modules_prepare
cp ../firmware/extra/Module.symvers .
Note the period/full stop at the end of the
cp command. The kernel should now be ready for compiling the wifi driver.
One final thing before compiling the driver. You will need to set up a pair of symbolic links that the driver compile requires to reference the kernel source directory when the driver is compiled. Set up the symlinks with the commands
Code: Select all
sudo ln -s /home/pi/src/linux /lib/modules/$(uname -r)/build
sudo ln -s /home/pi/src/linux/arch/arm /home/pi/src/linux/arch/armv6l
Now enter the wifi driver source directory and compile it with the following commands
Code: Select all
cd ../rtl8188eu
make clean
make
sudo make install
You should now have a driver compiled and installed. Now to get the wifi working you will have to configure the wifi either by editing the file
/etc/network/interfaces and then rebooting or running the GUI and using the Wifi Config button.
As an alternative to using the lwfinger driver which requires a seperate firmware file you can use the driver I use. You can load both sets of source code as they use different directory names,
rtl8188eu for lwfinger's version and
rtl8188eus for the version I prefer. Load, compile and install the driver I use using the following commands. First enter the source directory and download the driver using one of the following sets of two commands
Code: Select all
cd /home/pi/src
wget http://lazyzhu.com/file/RTL8188EUS_RTL8189ES_linux_v4.1.8_9499.20131104.zip
or
Code: Select all
cd /home/pi/src
wget https://dl.dropboxusercontent.com/u/80256631/RTL8188EUS_RTL8189ES_linux_v4.1.8_9499.20131104.zip
Now unzip it and install the driver source.
Code: Select all
unzip -q RTL8188EUS_RTL8189ES_linux_v4.1.8_9499.20131104.zip
cp RTL8188EUS_RTL8189ES_linux_v4.1.8_9499.20131104/driver/rtl8188EUS_rtl8189ES_linux_v4.1.8_9499.20131104.tar.gz .
tar xzf rtl8188EUS_rtl8189ES_linux_v4.1.8_9499.20131104.tar.gz
rm rtl8188EUS_rtl8189ES_linux_v4.1.8_9499.20131104.tar.gz
rm -r RTL8188EUS_RTL8189ES_linux_v4.1.8_9499.20131104
mv rtl8188EUS_rtl8189ES_linux_v4.1.8_9499.20131104 rtl8188eus
Note the period/full stop at the end of the
cp command. The driver source is now in directory
/home/pi/src/rtl8188eus. The driver now needs a patch applying to make it work with the Pi. Download the patch, go to the driver source directory and apply the patch.
Code: Select all
wget https://dl.dropboxusercontent.com/u/80256631/rtl8188eus.patch
cd rtl8188eus
patch -p1 < ../rtl8188eus.patch
and now compile and install the driver
and don't forget to update
/etc/network/interfaces if necessary. And you can, if you want, install the source for both drivers and try compiling both drivers and see how each behave although only one or the other will be installed at any one time.
Once installed the driver file is at
/lib/modules/3.12.28+/kernel/drivers/net/wireless/8188eu.ko. The lwfinger version also includes a separate firmware file which is installed at
/lib/firmware/rtlwifi/rtl8188eufw.bin
Hopefully this is some help. There is also a lot on the internet about compiling modules for the Raspberry Pi which may be useful searching for and looking at.
MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra
Please post ALL technical questions on the forum. Please Do Not send private messages.