phc_init.d

Get and discuss Scripts directly supported by the linux-phc team
the-fallen
Administrator
Posts: 346
Joined: Wed 9. Jul 2008, 19:57

phc_init.d

Post by the-fallen » Thu 19. Feb 2009, 17:36

PHC_INIT.D

phc_init.d is a bash-based init script compatible with init.d.

It is compatible to the linux-phc configuration file and therefore compatible with PHCTool2.

It comes with an easy-to-use installer to make the installation as easy as possible for users.


1. download the package
2. unpack it somewhere
3. edit the setting lines in phc_init.sh
4. start the installer (or install it manually if you like)


The setting lines look like this:

Code: Select all

### begin setup ###
CONFIGFILE="../phctool-ng/fakephc/phcconfig"
SYSFSPATH="../phctool-ng/fakephc"
#SYSFSPATH="/sys/devices/system/cpu"	
### end setup - below there is nothing to change ###
In this example you see paths to a fake-phc environment. Set your matching values there.

CONFIGFILE is the path to the linux-phc config file (that may also be used by PHCTool2).

SYSFSPATH is the path to where the kernel puts your cpu related sysfs files to. Default is /sys/devices/system/cpu. (Just comment the like pointing to fakephc and uncomment the line beneath)

That's all you have to to there.


Please report any bugs or suggestions.
  • phc_init.d-0.3.tar.gz
    (4.54 KiB) Downloaded 778 times
    0.3
    -Installer updated to 0.3:
    • - change file permission of phcconfig file from 666 to 644
      - display the correct default-location of the init.d script
      - installer now sets up the init-script file. Users do not longer need to edit the init-script
    -Script now uses LSB (Linux Standard Base) functions to log messages (log_start_msg, log_daemon_msg, etc) instead plain echo
    -renamed script from phc_init.sh to phc_init

    0.2
    added support for phc_available_vids (available with phc-k8): the script checks if given FIDs are available and removes pairs if not

User avatar
DavidG
Posts: 180
Joined: Fri 18. Jul 2008, 11:25
Contact:

Re: phc_init.d

Post by DavidG » Fri 12. Jun 2009, 17:10

My quick feedback, I know you probably know most:
  • I don't like the fact that phcconfig in /etc has permission 666, IMHO it should be 644, otherwise everybody can make my system crash by writing unsuitable values here. (security bug)
  • [bug] It doesn't display the default location of the init.d script.
  • [bug]It should work to some extend out-of-the-box, on "/etc/init.d/phc_start.sh start". I shouldn't have to edit the script itself, only the config.
    I now get:

    Code: Select all

    Could not find /home/fallen/Desktop/in_arbeit/phctool-ng/fakephc/phcconfig. Please set path to a configuration file.
    It should point to /etc/phcconfig or whatever used in the install.sh
  • I would like to see the script using LSB functions ("log_begin_msg"/"log_end_msg"/"log_warning_msg", etc), e.g. look at Ubuntu's "acpi-support" script for a bare minimal example.
  • (My own preferences) I would like the script to be named "phc_start" instead of "phc_start.sh" and since it is a start/stop script it doesn't need the "start", I'd call it "linux-phc"
A bank is a place where they lend you an umbrella in fair weather and ask for it back when it begins to rain -- R. Frost

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

Re: phc_init.d

Post by the-fallen » Sat 13. Jun 2009, 08:58

Thank you for the feedback. I will change the script ASAP.

Done. :)

dirtytofu
Posts: 7
Joined: Fri 16. Oct 2009, 19:18

Re: phc_init.d

Post by dirtytofu » Mon 28. Dec 2009, 00:20

I have a problem here with the phc_init script.

I installed a new kernel with acpi as a module into my laptop with Xubuntu 9.04, but now it seems that the phc_init script will not start everytime I restart my computer.

I run the install.sh script using the default settings and everything installs correctly as far I know.

This is what my phcconfig file looks like:

Code: Select all

#This is an example config file for PHC Init-Scripts
#Below are two example strings to set up FID:VID pairs for two CPUs/Cores
#If you use a linux-phc version that supports FID changing you can simply add or remove FIDs from your string.

controls[0]="16:19 14:12 12:8 10:4 8:1 6:1"

#Shall the init script restore default values on onload? Yes=1, No=0
#unloadrestore=1
Also, I get this warning when I start the phc-intel module through the command prompt.

Code: Select all

sudo modprobe phc-intel

WARNING: All config files need .conf: /etc/modprobe.d/oss-compat, it will be ignored in a future release.
If anyone can help me diagnose this issue I would greatly appreciate it.

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

Re: phc_init.d

Post by the-fallen » Mon 28. Dec 2009, 18:36

The Warning can be ignored. It just tells us that we need to change something soon for future kernels. For now it should work.

Can you manually set VIDs?

Does the init script work / does display messages if you manually start it?

( sudo /etc/init.d/phc_init restart ) (assuming you used the default paths)

dirtytofu
Posts: 7
Joined: Fri 16. Oct 2009, 19:18

Re: phc_init.d

Post by dirtytofu » Sat 2. Jan 2010, 22:43

On initial boot:

Code: Select all

sudo /etc/init.d/phc_init restart

/etc/init.d/phc_init: line 107: [: ==: unary operator expected
  * Leaving controls unrestored
  * PHC Configuration file found.
  * Could not find Interface-File to write to.
This error occurs because the phc-intel module didn't load properly on boot, so the cpufreq folder isn't created.

If I run this first:

Code: Select all

sudo modprobe phc-intel
WARNING: All config files need .conf: /etc/modprobe.d/oss-compat, it will be ignored in a future release.
Then I re-enter this:

Code: Select all

sudo /etc/init.d/phc_init restart
/etc/init.d/phc_init: line 107: [: ==: unary operator expected
 * Leaving controls unrestored
 * PHC Configuration file found.
 * Writing "16:19 14:12 12:8 10:4 8:1 6:1" to phc_controls of CPU0  
Then everything seems to run fine.

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

Re: phc_init.d

Post by the-fallen » Sun 3. Jan 2010, 10:06

Are you sure that the cpufreq / phc-intel module is set to be automatically loaded at boot?

You may need to install cpufreq-utils to have it that way or you need to add phc-intel to /etc/modules

dirtytofu
Posts: 7
Joined: Fri 16. Oct 2009, 19:18

Re: phc_init.d

Post by dirtytofu » Sun 3. Jan 2010, 19:01

Ah thanks for the /etc/modules tip.

I didn't know I had to add phc-intel in there.

Linux noob here learning as I go along...

But thanks to this problem I learned a lot of run levels and how scripts are started on boot! :D

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

Re: phc_init.d

Post by the-fallen » Mon 4. Jan 2010, 17:04

Hehe, you're welcome.

The latest phc kernel from the ppa (if you are using ubuntu) should suggest installing cpufreq-utils, too. If you install them THEY care about loading the driver. But writing it to /etc/modules works fine, too.

I hope you are able tu undervolt you CPU :)

sinter
Posts: 6
Joined: Sat 13. Feb 2010, 09:52

Re: phc_init.d

Post by sinter » Sat 13. Feb 2010, 10:13

Hi.

Linux noob here. I got the script working however when I try to run the 'stop' or 'restart' options I get an error:

Code: Select all

 * Restoring default controls                                                            
./phc_init: line 111: /sys/devices/system/cpu/cpu0/cpufreq/phc_controls.: No such file or directory
./phc_init: line 111: /sys/devices/system/cpu/cpu1/cpufreq/phc_controls.: No such file or directory
I noticed there is a '.' after phc_controls on line 111:

Code: Select all

cat $SYSFSPATH"/cpu$i/cpufreq/phc_default_controls" > $SYSFSPATH"/cpu$i/cpufreq/phc_controls." #restore 
Is that correct?

I removed the '.' and ran the scrip again, now the error I get is:

Code: Select all

 * Restoring default controls                                                            
cat: write error: Invalid argument
cat: write error: Invalid argument
my phcconfig file looks like this:

Code: Select all

controls[0]="9:30 8:15 6:15 136:15"
controls[1]="9:30 8:15 6:15 136:15"
unloadrestore=1
It's not a big deal for me because the controls from my phcconfig file are written into the phc_controls file, only the phc_default_controls aren't written back.

Post Reply