Installation Guide

If you have trouble with PHC you can ask and hope for help here.
the-fallen
Administrator
Posts: 346
Joined: Wed 9. Jul 2008, 19:57

Installation Guide

Post by the-fallen » Sun 13. Jul 2008, 09:24

Here is a little guide how to install linux-phc.
Its not that hard and you don't need to recompile a whole kernel if you don't want to (but you can if you want :) )

Checklist:
  • You need the sources of your kernel
  • You need compiling tools (build-essential)
  • You need a linux-phc patch
  • You need little time
  • You may need a cup of coffee (because I love coffee)
Most distributions provide a kernel source package for their installed kernel and the neccessary tools.
For Debian/Ubuntu for example you just need to install linux-source and build-essential.
This downloads the source-package to /usr/src (for example /usr/src/linux-source-2.6.24-19.tar.gz)

You can also download a vanilla kernel from kernel.org. But then most times you need to compile the whole kernel.
Just copy the package to /usr/src.

At least now you need to be root:
~/ sudo -s

Switch to the /usr/src:
#/ cd /usr/src

Then unpack the kernel source:
#/ tar -xjf <filename>.tar.gz

Now it unpacked the sources to a new subdirectory. Most times it is like the filename of the package.
#/ cd <dirname>

Now you need to get the config file for your kernel.

For some people it may bet tricky here if their distribution does not provide the config file.
For those they need to create one by typing make menuconfig . If you don't want to compile the whole kernel you
do not need to change any of the things in the configuration program but one: make sure that in

Code: Select all

[*] Power Management Options-->
                [*] CPU Frequency Scaling -->
                                <M> ACPI Processor P-States driver
is checked (as module ( [M] ) ).
Quit and save.

Many distributions ship the config file. Debian/Ubuntu for example store them to /boot.
For example you can find a file named config-2.6.24-19-generic in /boot. Just copy it and name it .config
Example: #/ cp /boot/config-2.6.24-19-generic /usr/src/<dirname>/.config
The dot ( . ) as the first character is important.

Now we need to prepare the kernel. We still are in our kernel source directory. Three things to do:
#/ make oldconfig
#/ make prepare
#/ make scripts

Next step is patching the source with linux-phc. You have the matching patch saved somewhere? Now copy it into the kernel source directory.
#/ cp /path/to/the/patchfile/<filename>.patch ./

Now patch it:
#/ patch -p1 < <filename>.patch

Everything went okay? Fine! Lets make the module:
For Kernel < 2.6.24 (for 64bit Kernels the path is different!):
#/ make M=arch/i386/kernel/cpu/cpufreq

For Kernel 2.6.24 or newer ( 32 and 64bit the same):
#/ make M=arch/x86/kernel/cpu/cpufreq

If everything went fine you can test the module now before 'installing' it forever.
First, unload the existing acpi-cpufreq module:
#/ modprobe -r acpi_cpufreq
Then insert the patched module:
#/ insmod <path like above>/acpi-cpufreq.ko

Check output of #/ dmesg.
Nothing to read about acpi-cpufreq? Then it's okay... no news are good news ;)

You should have some files in /sys/devices/system/cpu/cpu0/cpufreq/ beginning with "phc_".
Lets take a look at the content of one of those files to see if it is working:
#/ cat /sys/devices/system/cpu/cpu0/cpufreq/phc_controls

If you can read some values now: Congratulations! Everything is perfect now. Let's replace the old module with the patched one.
We still are in our kernel source directory.
#/ cp arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.ko /lib/modules/<name of the target kernel>/kernel/arch/x86/kernel/cpu/cpufreq/
If you made the module for your running kernel you can do
#/ cp arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.ko /lib/modules/$(uname -r)/kernel/arch/x86/kernel/cpu/cpufreq/

That's it. Now every time you restart your linux the patched module should be loaded.
Unfortunately you need to do the whole procedure for every kernel update your distribution brings you. But it wasn't that hard, was it?
I hope not ;)


______________
Errors and their solutions from answears I will extract and post here:

1: You read the following Warning while compiling:

"WARNING: Symbol version dump /usr/src/linux-source-2.6.27/Module.symvers
is missing; modules will have no dependencies and modversions."


Maybe this will help you:

Code: Select all

cd /usr/src/linux-source-`uname -r`/
cp ../linux-headers-`uname -r`/Module.symvers .
make clean M=./arch/x86/kernel/cpu/cpufreq
make M=./arch/x86/kernel/cpu/cpufreq
After this just copy the compiled module as before and try again with modprobe or insmod.

Bob
Posts: 17
Joined: Mon 14. Jul 2008, 14:07

Re: Installation Guide

Post by Bob » Wed 16. Jul 2008, 13:35

Well, first I want to say thanks for this great installation guide.
As you said, it isn´t that hard ;)
But I get an error message!I´m not that experienced that I could handle it by myself.....

At the point where I have to patch the source, I get the following error:

Code: Select all

Hunk #2 FAILED at 56.
Hunk #3 succeeded at 96 (offset -6 lines).
Hunk #4 FAILED at 734.
Hunk #5 succeeded at 738 (offset -19 lines).
2 out of 5 hunks FAILED -- saving rejects to file arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c.rej
Proceeding with making the module (

Code: Select all

#/ make M=arch/x86/kernel/cpu/cpufreq
) leads to:

Code: Select all

 WARNING: Symbol version dump /usr/src/linux-source-2.6.24/Module.symvers
           is missing; modules will have no dependencies and modversions.

  CC [M]  arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.o
  Building modules, stage 2.
  MODPOST 13 modules
  LD [M]  arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.ko
And typing

Code: Select all

modprobe -r acpi_cpufreq
is answered this way:

Code: Select all

FATAL: Module acpi_cpufreq is in use.
Do YOU know the problem?

the-fallen
Administrator
Posts: 346
Joined: Wed 9. Jul 2008, 19:57

Re: Installation Guide

Post by the-fallen » Wed 16. Jul 2008, 20:49

Hey... :)

All your problems are aftermaths of the first one: a failed patching. Some lines where not written.
Sounds like either you use a patch that is not for your kernel version or your kernel (in detail: the acpu-cpufreq module) is already patched with other things by your distributor.

Please write us what kernel version you are using or wich to patch and what patch you are using.

Bob
Posts: 17
Joined: Mon 14. Jul 2008, 14:07

Re: Installation Guide

Post by Bob » Thu 17. Jul 2008, 08:18

Ok. I´m using kernel 2.6.24-19 and I tried to patch it with "linux-phc-0.3.2-kernel-vanilla-2.6.26", the latest one.

the-fallen
Administrator
Posts: 346
Joined: Wed 9. Jul 2008, 19:57

Re: Installation Guide

Post by the-fallen » Thu 17. Jul 2008, 19:55

Hey Bob,

the problem is that the patch you are trying to use is not made for the version of your Kernel.
Your kernel is version 2.6.24 but the patch is for 2.6.26. That's the problem.

On the other Hand, it is not a problem because I will upload the patch for 2.6.24 just after clicking the "send" button :)
The patch will be version 0.3.1 but 0.3.1 and 0.3.2 do not differ in functionality.
Just download the matching patch and try to patch again. To avoid troubles delete the source directory and unpack it again from the tar.gz - file so you have a clean source to start.

Good luck again ;)

Bob
Posts: 17
Joined: Mon 14. Jul 2008, 14:07

Re: Installation Guide

Post by Bob » Fri 18. Jul 2008, 11:50

You won´t believe it, but I have another problem :roll:
Everything worked fine with your new patch. Unfortunately it´s the next step that makes the problem.
When I try to make the module with "make M=arch/x86/kernel/cpu/cpufreq" this message is shown:

Code: Select all

WARNING: Symbol version dump /usr/src/linux-source-2.6.24/Module.symvers
           is missing; modules will have no dependencies and modversions.

  Building modules, stage 2.
  MODPOST 13 modules
Because I wasn´t shure, if this would be normal, I tried the next step: Typing "#/ modprobe -r acpi_cpufreq" leads to:

Code: Select all

FATAL: Module acpi_cpufreq is in use.
I´m sure you know what to do, don´t you? ;)

the-fallen
Administrator
Posts: 346
Joined: Wed 9. Jul 2008, 19:57

Re: Installation Guide

Post by the-fallen » Fri 18. Jul 2008, 12:55

Hey again, Bob :)

The first "problem" can be ignored. It just tells you that there are no informations about dependencies, etc. This is simply caused by the way you made the module. That is not a problem.

The second thing .. humm, yes. Maybe the governor is blocking the module from being unloaded or what ever.

A simple trick is to rename the original module file (to have a backup if the patched one does not work) and copy the patched one right in the place of the original one.

The path is:
/lib/modules/<your kernel version>/kernel/arch/x86/kernel/cpu/cpufreq/


Steps to do:

1. become root
sudo -s

2. change to this path
cd /lib/modules/<your kernel version>/kernel/arch/x86/kernel/cpu/cpufreq/

3. There you'll find the original module. Just rename it:
mv ./acpi-cpufreq.ko ./acpi-cpufreq.ko-original

4. then copy the patched one:
# cp /path/to/patched/module/acpi-cpufreq.ko ./

then reboot.

First thing to do then is to check if everything is okay. (check if sysfs files exist, if you can read values from it, etc)

Go on! :)

Bob
Posts: 17
Joined: Mon 14. Jul 2008, 14:07

Re: Installation Guide

Post by Bob » Fri 18. Jul 2008, 20:11

It works!!! Everything works!! I can´t believe it!!
Have many thanks, the-fallen, for your patience with me! :P
Now I just have to find out what I can do with this little program...... ;)

the-fallen
Administrator
Posts: 346
Joined: Wed 9. Jul 2008, 19:57

Re: Installation Guide

Post by the-fallen » Fri 18. Jul 2008, 21:33

Gratulations :)

With this little program you can save power and reduce heating of the CPU ;) (just a hint).

Have fun with it and you're welcome to post any power saving and temperatur dropping results and statistics if you like ;)

neverdie
Posts: 3
Joined: Fri 25. Jul 2008, 02:53

Re: Installation Guide

Post by neverdie » Fri 25. Jul 2008, 02:59

Another problem here....
I'm compiling kernel 2.6.26 and I have linux-phc-0.3.2-kernel-vanilla-2.6.26.
Patching looks successful, the module compiles without errors, I unload the current acpi_cpufreq module, but when I try to load the new one I get this:
root@xxxxxx:/usr/src/linux-2.6.26# insmod arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.ko
insmod: error inserting 'arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.ko': -1 Invalid module format
Any ideas?

Post Reply