FSO Resources

From Openmoko

(Difference between revisions)
Jump to: navigation, search
m (CPU)
(Viewing Resources: +link)
 
(26 intermediate revisions by 5 users not shown)
Line 7: Line 7:
 
FSO introduces the concept of resources. A resource is a high-level entity with a name and a state. The name is used to identify a resource (e.g. WiFi), the state is describing its condition (e.g. enabled). It is important to understand that a resource not necessarily correlates to a peripheral device. Although enabling a resource such as Bluetooth most likely has the consequence of powering up a device, there may as well be more to it, such as launching a low level device handling services or allocating related resources.
 
FSO introduces the concept of resources. A resource is a high-level entity with a name and a state. The name is used to identify a resource (e.g. WiFi), the state is describing its condition (e.g. enabled). It is important to understand that a resource not necessarily correlates to a peripheral device. Although enabling a resource such as Bluetooth most likely has the consequence of powering up a device, there may as well be more to it, such as launching a low level device handling services or allocating related resources.
  
== List of FSO resources ==
+
=== Resource Policies ===
=== WiFi ===
+
Unless this resource is enabled you've no eth0 and wifi module is completely unpowered.
+
  
=== Display ===
+
Once in a while, reference counted handling of resources gets in your way, for example when you are running legacy applications or want to configure or debug peripherals. In that case it may become necessary for a resource to be always enabled or always disabled. While not recommended, it is possible to switch from automatic resource control to manual control by calling SetResourcePolicy. Valid values are auto (which is the default on system startup), enabled, and disabled.
While this resource is kept the display won't be blanked.
+
  
=== TEST ===
+
== List of FSO resources ==
A test resource
+
List of possible FSO resources:
 +
* Accelerometer - Unless this resource is enabled, the module is unpowered.
 +
* Bluetooth - You need to have this resource requested, to have bluetooth module powered.
 +
* CPU - Default rules.yaml checks for this resource, to disable automatic suspend, when it's requested.
 +
* Display - While this resource is kept, the display won't be blanked.
 +
* GPS - Same idea as WiFi/Bluetooth
 +
* GSM - The same for GSM modem
 +
* TEST - A test resource - this resource is not listed with <tt>fsoraw -l</tt>
 +
* UsbHost - Unless this resource is enabled, you've no usb host.
 +
* WiFi - Unless this resource is enabled you've no eth0 and wifi module is completely unpowered.
  
=== Bluetooth ===
+
GTA02 [[Neo FreeRunner]] has:
You need to have this resource requested to have bluetooth module powered.
+
root@om-gta02 / $ fsoraw -l
 +
Resource List:
 +
CPU
 +
Display
 +
UsbHost
 +
WiFi
 +
Bluetooth
 +
GSM
 +
Accelerometer
 +
GPS
  
=== GSM ===
+
GTA01 [[Neo 1973]] has:
The same for GSM modem
+
*...
 
+
=== CPU ===
+
Default rules.yaml checks for this resource to disable automatic suspend when it's requested.
+
 
+
=== GPS ===
+
Same idea as WiFi/Bluetooth
+
  
 
== Resource management ==
 
== Resource management ==
 +
 
=== Manual way ===
 
=== Manual way ===
With the help of SHR Settings or an appropriate mdbus call (example: <code>mdbus -s org.freesmartphone.ousaged /org/freesmartphone/Usage org.freesmartphone.Usage.SetResourcePolicy Bluetooth enabled</code>) you set resource policy to "enabled". Do not forget that way you'll lose power since it will leave the corresponding device powered all the time.
+
By default, the policy for every resource is '''auto''', which means that it is enabled only when it has been requested by a currently running application.  However, it is possible to throw a "hard switch" to force the resource to be always '''enabled''' or '''disabled''', regardless of what applications request it.  This can be done with the help of the SHR Settings GUI or from the command line using an appropriate [[OpenmokoFramework/mdbus|mdbus]] call.  For example,
 +
 
 +
mdbus -s org.freesmartphone.ousaged /org/freesmartphone/Usage \
 +
org.freesmartphone.Usage.SetResourcePolicy Bluetooth enabled
 +
 
 +
Do not forget that forcing a resource to be enabled will drain more power since it will leave the corresponding device powered all the time.  And, of course, forcing a resource to be disabled will cause any applications that require it to fail.  Because of this, you are highly discouraged from changing the resource policy from '''auto''' unless you know exactly what you are doing.
  
 
=== Automatic way ===
 
=== Automatic way ===
Use the <code>fsoraw</code> utility. With it you can automatically request the necessary resource before starting a command and release it when it's finished. Especially recommended for WiFi since due to the bugs in the firmware and the driver full power-cycle of the module is often advantageous.
+
Use the <code>fsoraw</code> (created per Joerg's request [http://trac.freesmartphone.org/ticket/393]) utility. With it you can automatically request the necessary resource before starting a command and release it when it's finished (<em>this will happen even if it was killed with SIGKILL</em>).
 +
 
 +
Typical basic use:
 +
fsoraw -r CPU,Display mokomaze
 +
Start a game (or any other app) and avoid auto-suspend and display-blank
 +
 
 +
Especially recommended for WiFi since due to the bugs in the firmware and the driver full power-cycle of the module is often advantageous.
  
 
Example command (works for open, WEP and WPA/WPA2 networks, automatically determining the network it can connect to, just add all the networks you use to the config):
 
Example command (works for open, WEP and WPA/WPA2 networks, automatically determining the network it can connect to, just add all the networks you use to the config):
 
  fsoraw -r WiFi -- wpa_supplicant -ieth0 -Dwext -c/etc/wpa_supplicant/wpa_supplicant.conf
 
  fsoraw -r WiFi -- wpa_supplicant -ieth0 -Dwext -c/etc/wpa_supplicant/wpa_supplicant.conf
 +
To keep wifi useable, due to bug still present currently (2009-08-18) you need to also do (''fixed with the latest SHR kernel, 2009-09-01'', this command is no longer needed):
 +
rmmod ar6000 && modprobe ar6000
  
 
Bluetooth scan for nearby devices example:
 
Bluetooth scan for nearby devices example:
  fsoraw-armel -r Bluetooth -- bash -c "sleep 1; hcitool scan"
+
  fsoraw -r Bluetooth -- bash -c "sleep 1; hcitool scan"
 +
 
 +
=== Viewing Resources ===
 +
 
 +
It would be nice to have a command to list the current state of all
 +
resources. (See [http://trac.freesmartphone.org/ticket/461].) Unfortunately, such a utility is yet to be written. However, a first take on implementing the desired functionality can already be downloaded from [http://trac.freesmartphone.org/raw-attachment/ticket/461/lsfsor.py].
 +
 
 +
To examine the state of a resource manually, there are three <code>org.freesmartphone.Usage</code> methods which are particularly useful.
 +
 
 +
* '''GetResourcePolicy''' ( s ) → s
 +
: Get the current resource policy for a given resource.
 +
* '''GetResourceState''' ( s ) → b
 +
: Get the current resource state. True if the resource is currently enabled.
 +
* '''GetResourceUsers''' ( s ) → as
 +
: Get the users (an array of bus names) which currently use a given resource.
 +
 
 +
For example,
 +
mdbus -s org.freesmartphone.ousaged /org/freesmartphone/Usage \
 +
org.freesmartphone.Usage.GetResourceState WiFi
 +
 
 +
==External links==
 +
*http://www.freesmartphone.org/
 +
 
 +
[[Category:FSO]]

Latest revision as of 16:32, 12 December 2009

Contents

[edit] Resource management conception

Here goes some introductory text shamelessly borrowed from FSO specs.

One of the most important aspects of middleware for mobile devices is saving energy. To do this, the system needs to make sure that peripherals are only powered when they are actually in use by at least one application. In order to support multiple concurrent applications, it is not possible to leave peripheral control up to individual applications — otherwise one application could shut down e.g. a GPS receiver, while another application still wants to access it.

FSO introduces the concept of resources. A resource is a high-level entity with a name and a state. The name is used to identify a resource (e.g. WiFi), the state is describing its condition (e.g. enabled). It is important to understand that a resource not necessarily correlates to a peripheral device. Although enabling a resource such as Bluetooth most likely has the consequence of powering up a device, there may as well be more to it, such as launching a low level device handling services or allocating related resources.

[edit] Resource Policies

Once in a while, reference counted handling of resources gets in your way, for example when you are running legacy applications or want to configure or debug peripherals. In that case it may become necessary for a resource to be always enabled or always disabled. While not recommended, it is possible to switch from automatic resource control to manual control by calling SetResourcePolicy. Valid values are auto (which is the default on system startup), enabled, and disabled.

[edit] List of FSO resources

List of possible FSO resources:

  • Accelerometer - Unless this resource is enabled, the module is unpowered.
  • Bluetooth - You need to have this resource requested, to have bluetooth module powered.
  • CPU - Default rules.yaml checks for this resource, to disable automatic suspend, when it's requested.
  • Display - While this resource is kept, the display won't be blanked.
  • GPS - Same idea as WiFi/Bluetooth
  • GSM - The same for GSM modem
  • TEST - A test resource - this resource is not listed with fsoraw -l
  • UsbHost - Unless this resource is enabled, you've no usb host.
  • WiFi - Unless this resource is enabled you've no eth0 and wifi module is completely unpowered.

GTA02 Neo FreeRunner has:

root@om-gta02 / $ fsoraw -l
Resource List:
CPU
Display
UsbHost
WiFi
Bluetooth
GSM
Accelerometer
GPS

GTA01 Neo 1973 has:

  • ...

[edit] Resource management

[edit] Manual way

By default, the policy for every resource is auto, which means that it is enabled only when it has been requested by a currently running application. However, it is possible to throw a "hard switch" to force the resource to be always enabled or disabled, regardless of what applications request it. This can be done with the help of the SHR Settings GUI or from the command line using an appropriate mdbus call. For example,

mdbus -s org.freesmartphone.ousaged /org/freesmartphone/Usage \
org.freesmartphone.Usage.SetResourcePolicy Bluetooth enabled

Do not forget that forcing a resource to be enabled will drain more power since it will leave the corresponding device powered all the time. And, of course, forcing a resource to be disabled will cause any applications that require it to fail. Because of this, you are highly discouraged from changing the resource policy from auto unless you know exactly what you are doing.

[edit] Automatic way

Use the fsoraw (created per Joerg's request [1]) utility. With it you can automatically request the necessary resource before starting a command and release it when it's finished (this will happen even if it was killed with SIGKILL).

Typical basic use:

fsoraw -r CPU,Display mokomaze

Start a game (or any other app) and avoid auto-suspend and display-blank

Especially recommended for WiFi since due to the bugs in the firmware and the driver full power-cycle of the module is often advantageous.

Example command (works for open, WEP and WPA/WPA2 networks, automatically determining the network it can connect to, just add all the networks you use to the config):

fsoraw -r WiFi -- wpa_supplicant -ieth0 -Dwext -c/etc/wpa_supplicant/wpa_supplicant.conf

To keep wifi useable, due to bug still present currently (2009-08-18) you need to also do (fixed with the latest SHR kernel, 2009-09-01, this command is no longer needed):

rmmod ar6000 && modprobe ar6000

Bluetooth scan for nearby devices example:

fsoraw -r Bluetooth -- bash -c "sleep 1; hcitool scan"

[edit] Viewing Resources

It would be nice to have a command to list the current state of all resources. (See [2].) Unfortunately, such a utility is yet to be written. However, a first take on implementing the desired functionality can already be downloaded from [3].

To examine the state of a resource manually, there are three org.freesmartphone.Usage methods which are particularly useful.

  • GetResourcePolicy ( s ) → s
Get the current resource policy for a given resource.
  • GetResourceState ( s ) → b
Get the current resource state. True if the resource is currently enabled.
  • GetResourceUsers ( s ) → as
Get the users (an array of bus names) which currently use a given resource.

For example,

mdbus -s org.freesmartphone.ousaged /org/freesmartphone/Usage \
org.freesmartphone.Usage.GetResourceState WiFi

[edit] External links

Personal tools

Resource management conception

Here goes some introductory text shamelessly borrowed from FSO specs.

One of the most important aspects of middleware for mobile devices is saving energy. To do this, the system needs to make sure that peripherals are only powered when they are actually in use by at least one application. In order to support multiple concurrent applications, it is not possible to leave peripheral control up to individual applications — otherwise one application could shut down e.g. a GPS receiver, while another application still wants to access it.

FSO introduces the concept of resources. A resource is a high-level entity with a name and a state. The name is used to identify a resource (e.g. WiFi), the state is describing its condition (e.g. enabled). It is important to understand that a resource not necessarily correlates to a peripheral device. Although enabling a resource such as Bluetooth most likely has the consequence of powering up a device, there may as well be more to it, such as launching a low level device handling services or allocating related resources.

List of FSO resources

WiFi

Unless this resource is enabled you've no eth0 and wifi module is completely unpowered.

Display

While this resource is kept the display won't be blanked.

TEST

A test resource

Bluetooth

You need to have this resource requested to have bluetooth module powered.

GSM

The same for GSM modem

CPU

Default rules.yaml checks for this resource to disable automatic suspend when it's requested.

GPS

Same idea as WiFi/Bluetooth

Resource management

Manual way

With the help of SHR Settings or an appropriate mdbus call (example: mdbus -s org.freesmartphone.ousaged /org/freesmartphone/Usage org.freesmartphone.Usage.SetResourcePolicy Bluetooth enabled) you set resource policy to "enabled". Do not forget that way you'll lose power since it will leave the corresponding device powered all the time.

Automatic way

Use the fsoraw utility. With it you can automatically request the necessary resource before starting a command and release it when it's finished. Especially recommended for WiFi since due to the bugs in the firmware and the driver full power-cycle of the module is often advantageous.

Example command (works for open, WEP and WPA/WPA2 networks, automatically determining the network it can connect to, just add all the networks you use to the config):

fsoraw -r WiFi -- wpa_supplicant -ieth0 -Dwext -c/etc/wpa_supplicant/wpa_supplicant.conf

Bluetooth scan for nearby devices example:

fsoraw-armel -r Bluetooth -- bash -c "sleep 1; hcitool scan"