Difference between revisions of "Category:How to - Low Power"
m (→PM Features: Removed kernel verisons specifiers and added note for non PM kernels instead.) |
(→PM Kernel) |
||
Line 22: | Line 22: | ||
===Compile PM Kernel=== | ===Compile PM Kernel=== | ||
− | '''NOTE:''' The linux-omap-pm bitbake recipe is setup to use the 2.6.29 PM kernel. Even though this kernel is significantly older than the mainstream 2.6.36 linux-omap kernel, it is necessary to use a PM kernel to get all PM features such as DVFS. In fact, the most savings will be seen with the most recent PM kernel. See the alternate | + | '''NOTE:''' The linux-omap-pm bitbake recipe is setup to use the 2.6.29 PM kernel. Even though this kernel is significantly older than the mainstream 2.6.36 linux-omap kernel, it is necessary to use a PM kernel to get all PM features such as DVFS. In fact, the most savings will be seen with the most recent PM kernel. See the two alternate methods below for instructions on how to use the latest PM kernel. |
'''TODO:''' Update bitbake recipe for latest PM branch. | '''TODO:''' Update bitbake recipe for latest PM branch. | ||
Line 38: | Line 38: | ||
Once you have the PM kernel built, follow the instructions for copying the new image and filesystem to your microSD card. | Once you have the PM kernel built, follow the instructions for copying the new image and filesystem to your microSD card. | ||
− | ===PM Kernel Alternate Method=== | + | ===PM Kernel Alternate OpenEmbedded Method=== |
− | + | If you already have an open embedded build system setup, then follow the directions in this section for the easiest and quickest build. | |
+ | |||
+ | First git the sources for the pm kernel branch | ||
+ | $ git clone git://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-omap-pm.git?branch=pm | ||
+ | and cd into the resulting "linux-omap-pm" directory. | ||
+ | |||
+ | '''NOTE:''' This will pull the latest development code from the pm kernel branch. Since this code is in constant development, things can change quickly. | ||
+ | |||
+ | '''TODO:''' Change to have git pull a known working revision. | ||
+ | |||
+ | Add the openembedded cross compile tools to your path. | ||
+ | $ PATH=<path to oe tmp>/sysroots/i686-linux/usr/armv7a/bin/:<path to oe tmp>/sysroots/i686-linux/usr/bin:$PATH | ||
+ | Next, activate the default config for omap2 and higher devices. | ||
+ | $ make CROSS_COMPILE=arm-angstrom-linux-gnueabi- ARCH=arm omap2plus_defconfig | ||
+ | By default, this config does not have the cpu frequency scaling enabled. In order to enable it you need to edit the config. | ||
+ | $ make menuconfig | ||
+ | Navigate to CPU Power Management and enable "CPU Frequency Scaling". Exit the config and select yes to save it. | ||
+ | |||
+ | Finally, build the kernel image. | ||
+ | $ make CROSS_COMPILE=arm-angstrom-linux-gnueabi- ARCH=arm uImage | ||
+ | |||
+ | Copy the resulting image to the FAT partition of your microSD card. The image can be found at | ||
+ | ./arch/arm/boot/uImage | ||
+ | |||
+ | You can now follow steps 4 through 6 in the CodeSourcery method below or continue here. | ||
+ | |||
+ | The new kernel uses ttyO2 as the serial port instead of ttyS2. So you need to make changes in your ext3 file system. cd to the os partition on your micro sd card (from your development system) and do the following. | ||
+ | * Edit <path to mcirosd rootfs>/etc/inittab and change ttyS2 to ttyO2 | ||
+ | * Make a "node" in dev for ttyO2 | ||
+ | $ mknod -m 660 <path to mcirosd rootfs>/dev/ttyO2 c 4 66 | ||
+ | * On bootup, execute these commands from the uboot command line (assumes your uboot and xload are setup previously) | ||
+ | mmc init | ||
+ | setenv console ttyO2,115200n8 | ||
+ | run loaduImage | ||
+ | run mmcboot | ||
+ | |||
+ | You should now boot into your new kernel. Follow the instructions in the sections below to use PM features. | ||
+ | |||
+ | '''NOTE:''' Some things have changed in the sections below for the new kernel such as the path to set the serial timeout. Its now | ||
+ | /sys/devices/platform/omap/omap_uart.#/sleep_timeout | ||
+ | |||
+ | ===PM Kernel Alternate CodeSourcery Method=== | ||
+ | If you do not already have an openembedded build setup, then follow these step taken from Peter Lawrence on the Gumstix mailing list. | ||
'''NOTE:''' As per the comments below, this method disables nand and microSD access. | '''NOTE:''' As per the comments below, this method disables nand and microSD access. | ||
Line 76: | Line 118: | ||
"git" the latest code: | "git" the latest code: | ||
− | git clone git://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-omap-pm.git | + | git clone git://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-omap-pm.git?branch=pm |
The result will be in the subdirectory "linux-omap-pm". | The result will be in the subdirectory "linux-omap-pm". | ||
Line 87: | Line 129: | ||
export ARCH=arm | export ARCH=arm | ||
make omap3_pm_defconfig | make omap3_pm_defconfig | ||
+ | </pre> | ||
+ | '''Update:''' The omap3_pm_defconfig is no longer available. Use omap2plus_defconfig instead. | ||
+ | <pre> | ||
This creates a .config file suitable for Linux OMAP3 PM. | This creates a .config file suitable for Linux OMAP3 PM. | ||
Line 122: | Line 167: | ||
mmc init | mmc init | ||
fatload mmc 1:1 0x80300000 uImage.pm | fatload mmc 1:1 0x80300000 uImage.pm | ||
− | fatload mmc 1:1 0x81600000 rd-ext2.bin | + | fatload mmc 1:1 0x81600000 rd-ext2-8M.bin |
− | setenv bootargs console= | + | setenv bootargs console=ttyO2,115200n8 ramdisk_size=8192 root=/dev/ram0 rw rootfstype=ext2 initrd=0x81600000,8M |
− | root=/dev/ram0 rw rootfstype=ext2 initrd=0x81600000,8M | + | |
bootm 0x80300000 | bootm 0x80300000 | ||
Revision as of 13:02, 10 March 2011
Contents
Status
This page is a work in progress. Many users are running Gumstix COMs in power sensitive applications and need to reduce power consumption as much as possible. This page is being developed by the Gumstix community as the steps are learned for reducing power.
Relevant Community Mailing List Threads
sample numbers for Overo Earth COM power consumption
Building a linux omap3 pm for Overo
Background
The default omap3 openembedded build does not provide an optimal setup for power reduction on Gumstix Overo COMS. In order to achieve the lowest power possible for your application, you have to perform a combination of the following:
- Use the latest OMAP Power Management (pm) kernel branch
- Enable power saving features such as sleep when idle, off mode, and dvfs
- Disable internal OMAP devices
- Hold unused external chips such as USB, Wifi, Bluetooth, etc. in reset
- Turn off unused LEDs
PM Kernel
The PM kernel is a development branch of the linux-omap kernel focused on developing the power management features of OMAP. By default, openembedded does not use the PM kernel, but instead uses the mainstream linux-omap kernel. Some of the changes of the PM branch have been merged to the mainstream linux-omap branch. However, not all changes have been merged so you must manually configure openembedded to use the PM kernel to get the most power savings possible.
Compile PM Kernel
NOTE: The linux-omap-pm bitbake recipe is setup to use the 2.6.29 PM kernel. Even though this kernel is significantly older than the mainstream 2.6.36 linux-omap kernel, it is necessary to use a PM kernel to get all PM features such as DVFS. In fact, the most savings will be seen with the most recent PM kernel. See the two alternate methods below for instructions on how to use the latest PM kernel.
TODO: Update bitbake recipe for latest PM branch.
To enable the PM kernel edit the file
org.openembedded.dev/conf/machine/overo.conf
and change the line
PREFERRED_PROVIDER_virtual/kernel = "linux-omap3"
to
PREFERRED_PROVIDER_virtual/kernel = "linux-omap-pm"
Save the changes and then run bitbake as usual e.g.
$ bitbake omap3-console-image
The pm branch will be downloaded and compiled.
Once you have the PM kernel built, follow the instructions for copying the new image and filesystem to your microSD card.
PM Kernel Alternate OpenEmbedded Method
If you already have an open embedded build system setup, then follow the directions in this section for the easiest and quickest build.
First git the sources for the pm kernel branch
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-omap-pm.git?branch=pm
and cd into the resulting "linux-omap-pm" directory.
NOTE: This will pull the latest development code from the pm kernel branch. Since this code is in constant development, things can change quickly.
TODO: Change to have git pull a known working revision.
Add the openembedded cross compile tools to your path.
$ PATH=<path to oe tmp>/sysroots/i686-linux/usr/armv7a/bin/:<path to oe tmp>/sysroots/i686-linux/usr/bin:$PATH
Next, activate the default config for omap2 and higher devices.
$ make CROSS_COMPILE=arm-angstrom-linux-gnueabi- ARCH=arm omap2plus_defconfig
By default, this config does not have the cpu frequency scaling enabled. In order to enable it you need to edit the config.
$ make menuconfig
Navigate to CPU Power Management and enable "CPU Frequency Scaling". Exit the config and select yes to save it.
Finally, build the kernel image.
$ make CROSS_COMPILE=arm-angstrom-linux-gnueabi- ARCH=arm uImage
Copy the resulting image to the FAT partition of your microSD card. The image can be found at
./arch/arm/boot/uImage
You can now follow steps 4 through 6 in the CodeSourcery method below or continue here.
The new kernel uses ttyO2 as the serial port instead of ttyS2. So you need to make changes in your ext3 file system. cd to the os partition on your micro sd card (from your development system) and do the following.
- Edit <path to mcirosd rootfs>/etc/inittab and change ttyS2 to ttyO2
- Make a "node" in dev for ttyO2
$ mknod -m 660 <path to mcirosd rootfs>/dev/ttyO2 c 4 66
- On bootup, execute these commands from the uboot command line (assumes your uboot and xload are setup previously)
mmc init setenv console ttyO2,115200n8 run loaduImage run mmcboot
You should now boot into your new kernel. Follow the instructions in the sections below to use PM features.
NOTE: Some things have changed in the sections below for the new kernel such as the path to set the serial timeout. Its now
/sys/devices/platform/omap/omap_uart.#/sleep_timeout
PM Kernel Alternate CodeSourcery Method
If you do not already have an openembedded build setup, then follow these step taken from Peter Lawrence on the Gumstix mailing list.
NOTE: As per the comments below, this method disables nand and microSD access.
TODO: See how to get nand and microSD working with the latest PM kernel.
Here are steps to build the kernel "the traditional way". 1) Download and install cross-compiler tools: The easiest solution is to download the CodeSourcery binaries: http://www.codesourcery.com/sgpp/lite/arm CodeSourcery provides an install program. (You'll have to set the executable bit on the file to run it.) Note that the CodeSourcery install modifies .bash_profile to add the path, but this file does not run automatically in Ubuntu. To fix this, refer to: http://www.linuxquestions.org/questions/linux-general-1/do-i-put-path-in-bash_profile-or-bashrc-or-both-540288/ which says: "You can change the second by opening a gnome-terminal window and going to Edit / Profiles - select the Default profile and click the Edit button. On the Title and Command tab, click the check box for Run command as a login shell. Your .bash_profile file should be sourced the next time you open a gnome-terminal." 2) Get latest Linux OMAP PM code "git" the latest code: git clone git://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-omap-pm.git?branch=pm The result will be in the subdirectory "linux-omap-pm". 3) Build the OMAP3_PM Linux Kernel Extract the download Linux kernel code and cd to that directory. The command sequence is: export ARCH=arm make omap3_pm_defconfig
Update: The omap3_pm_defconfig is no longer available. Use omap2plus_defconfig instead.
This creates a .config file suitable for Linux OMAP3 PM. TBD: patch the .config file for JFFS2 and SD card export CROSS_COMPILE=arm-none-eabi- make uImage [this takes a very long while] The resultant kernel file will be in: ./arch/arm/boot/uImage 4) Download the initramfs filesystem Obtain "rd-ext2-8M.bin" from: http://code.google.com/p/beagleboard/downloads/list 5) Create a bootable MicroSD card Follow the [http://www.gumstix.net/Setup-and-Programming/view/Overo-Setup-and-Programming/Creating-a-bootable-microSD-card/111.html instructions here]. However, one can omit the "MLO" and the "u-boot.bin" files. One should, however, copy over the "uImage" file created in step #3, and the "rd-ext2-8M.bin" (as "rd-ext2.bin") created in step #4. 6) Boot the Overo Use the "Press any key" prompt at boot to operate the U-Boot app. Enter the following commands: (these commands must be done individually, as U-Boot does not have a large enough buffer for the entire quantity to be pasted at once) mmc init fatload mmc 1:1 0x80300000 uImage.pm fatload mmc 1:1 0x81600000 rd-ext2-8M.bin setenv bootargs console=ttyO2,115200n8 ramdisk_size=8192 root=/dev/ram0 rw rootfstype=ext2 initrd=0x81600000,8M bootm 0x80300000 TBD: change u-boot parameters to perform this automatically Linux should boot to a BusyBox console prompt.
PM Features
For a full list of PM features see OMAP Power Management. The features listed here are the most common needed to reduce power.
Setup Debug FS
If you are using a non PM kernel, then before you can enable PM features, you need to setup the debug file system for manipulating pm configuration.
mkdir /debug mount -t debugfs debugfs /debug
Everywhere below you see "/sys/power/" replace with "/debug/pm_debug/".
Sleep While Idle
Next, enable "sleep while idle". This will allow the processor to attempt deeper sleep states when idle. You must also enable sleep timeouts for the serial ports, otherwise this will result in increased power consumption.
# echo 5 > /sys/devices/platform/serial8250.0/sleep_timeout # echo 5 > /sys/devices/platform/serial8250.1/sleep_timeout # echo 5 > /sys/devices/platform/serial8250.2/sleep_timeout # echo 1 > /sys/power/sleep_while_idle
You can also enable "off mode" after enabling "sleep while idle".
# echo 1 > /sys/power/enable_off_mode
NOTE: Enabling sleep when idle will cause the device to "miss" the first character or two from the serial console (and most likely all UARTS). Since the UART is asleep, a character must be sent to wake it up. This character will be missed as well as subsequent characters until the UART is fully awake.
DVFS
Dynamic frequency and voltage scaling dynamically reduces clock frequency and voltage for further power savings. You must be running the PM kernel for DVFS functionality.
The cpufreq utils and daemon are needed to enable and configure DVFS. Use bitbake to manually build cpufreqd and cpufrequtils.
$ bitbake cpufreqd $ bitbake cpufrequtils
You can also place these dependencies in your user config recipie....TODO
Once the cpufreqd and cpufrequtils are built, you can build your image as normal, or you can simply copy the ipk files to your SD card and install them.
$ cp tmp/deploy/glibc/ipk/armv7a/cpufreqd_* tmp/deploy/glib/ipk/armv7a/cpufrequtils_* /media/SD_CARD/home/root/
To install, run the following command from your Overo COM:
# opkg install /home/root/cpufreq*.ipk
You may see some errors about a "hicolor-icon-theme" which can be ignored.
Now that you have cpufreq tools setup, run cpufreq-info and you will see output describing the cpu frequency modes for your cpu.
root@overo:~#cpufreq-info cpufrequtils 006: cpufreq-info (C) Dominik Brodowski 2004-2009 Report errors and bugs to cpufreq@vger.kernel.org, please. analyzing CPU 0: driver: omap CPUs which run at the same hardware frequency: 0 CPUs which need to have their frequency coordinated by software: 0 maximum transition latency: 0.00 ms. hardware limits: 125 MHz - 600 MHz available frequency steps: 600 MHz, 550 MHz, 500 MHz, 250 MHz, 125 MHz available cpufreq governors: conservative, ondemand, userspace, powersave, performance current policy: frequency should be within 125 MHz and 600 MHz. The governor "performance" may decide which speed to use within this range. current CPU frequency is 600 MHz (asserted by call to hardware). cpufreq stats: 600 MHz:100.00%, 550 MHz:0.00%, 500 MHz:0.00%, 250 MHz:0.00%, 125 MHz:0.00% (1)
As you can see from the cpufreq stats line, we have run at full speed 600 MHz for 100% of the time. In order to reduce cpu frequency automatically, we have to change to a different "governor". For example, switching to the powersave governor will limit cpu frequency to between 0% and 33% of max speed.
root@overo:~# cpufreq-set -g powersave root@overo:~# cpufreq-info cpufrequtils 006: cpufreq-info (C) Dominik Brodowski 2004-2009 Report errors and bugs to cpufreq@vger.kernel.org, please. analyzing CPU 0: driver: omap CPUs which run at the same hardware frequency: 0 CPUs which need to have their frequency coordinated by software: 0 maximum transition latency: 0.00 ms. hardware limits: 125 MHz - 600 MHz available frequency steps: 600 MHz, 550 MHz, 500 MHz, 250 MHz, 125 MHz available cpufreq governors: conservative, ondemand, userspace, powersave, performance current policy: frequency should be within 125 MHz and 600 MHz. The governor "powersave" may decide which speed to use within this range. current CPU frequency is 125 MHz (asserted by call to hardware). cpufreq stats: 600 MHz:86.17%, 550 MHz:0.00%, 500 MHz:0.00%, 250 MHz:0.00%, 125 MHz:13.83% (2)
The cpufreq daemon automatically switches governors based on rules defined in
/etc/cpufreqd.conf
TODO: Examine how to use cpufreqd to manage the active governor.
Disable Internal Devices
The internal peripherals and devices such as the DSP and GPU consume power if not being used. All unused peripherals, DSP, and GPU should be turned off.
Turn Off Peripherals
TBD
Turn Off DSP
This section applies only to the OMAP3530-based Overo COMs, as the OMAP3530 has both a DSP and Graphics engine.
TBD
Turn Off GPU
This section applies only to the OMAP3530-based Overo COMs, as the OMAP3530 has both a DSP and Graphics engine.
TBD
Disable External Chipsets
Several external chipsets on the Gumstix COM consume power even if not being used. Their power consumption can be reduced (although not completely eliminated) by holding the chips in reset.
USB
You can hold the USB chip in reset with the following commands:
$ echo 183 > /sys/class/gpio/export $ echo out > /sys/class/gpio/gpio183/direction $ echo 0 > /sys/class/gpio/gpio183/value
These commands will export GPIO 183 for access through the sys interface, set the GPIO to output, and drive "0" to the reset line on the USB chip.
You can also turn off power to the USB chip.
If someone wanted to try the same nasty kernel hack, I added this two lines: twl_i2c_write_u8(TWL4030_MODULE_USB, 0x08 /* value */, 0xBB /* register (CARKIT_ANA_CTRL) */); twl_i2c_write_u8(TWL4030_MODULE_USB, 0x01 /* value */, 0xFD /*register (PHY_PWR_CTRL) */); in the function "twl_probe" in /drivers/mfd/twl-core.c just prior to the comment "load power event scripts".
Wifi/Bluetooth
If not using the combined Wifi/Bluetooth module, you can hold it in reset. You can also hold it in reset and only enable as needed for periodic connectivity.
TBD
Disable LEDs
The on-board blue LED can be disabled with the following commands.
$ echo 211 > /sys/class/gpio/export $ echo out > /sys/class/gpio/gpio211/direction $ echo 1 > /sys/class/gpio/gpio211/value
This category currently contains no pages or media.