2012年11月5日 星期一
2012年10月16日 星期二
Driver: update firmware metho
http://www.makelinux.net/ldd3/chp-14-sect-8
http://www.mjmwired.net/kernel/Documentation/firmware_class/
/sys/class/firmware
http://www.mjmwired.net/kernel/Documentation/firmware_class/
/sys/class/firmware
#includeint request_firmware(const struct firmware **fw, char *name, struct device *device);
struct firmware { size_t size; u8 *data; };
void release_firmware(struct firmware *fw);
2012年10月15日 星期一
2012年10月10日 星期三
trick : vi and cscope
vi
cscope
- CTRL-] : 檢索游標所在位置的函式(或變數),跳到函式本體或變數定義的地方
- CTRL-O : 跳回前一個游標的位置 (Go to older cursor position in jump list)
- CTRL-I : 跳到下一個游標的位置 (Go to newer cursor position in jump list)
-
CTRL-N-P : 在 Insert mode 下按住 CTRL,連續輸入 n,p,會出現如下畫面的選單讓我們挑選函式(或變數)
cscope
Ctrl+[ s "s表Symbol,列出所有參考到游標所在字串的地方,包含定義和呼叫。
ctrl+[ g "g表Global,與ctags的Ctrl+]相同。
ctrl+[ c "c表Call,列出所有以游標所在字串當函數名的地方。
ctrl+[ t "t表Text,列出專案中所有出現游標所在字串的地方。
ctrl+[ f "f表File,以游標所在字串當檔名,開啟之。
ctrl+[ i "i表Include,以游標所在字串當檔名,列出所有include此檔的檔案。
ctrl+[ d "d表calleD,以游標所在字串當函式名,列出所有此函式呼叫的函式。
2012年10月9日 星期二
2012年9月27日 星期四
ubuntu :setup 中文輸入 gcin
1. system -> Admin -> package manager -> gcin
2. Terminal
$im-switch -s gcin
3. reboot
2. Terminal
$im-switch -s gcin
3. reboot
2012年9月12日 星期三
ubuntu 11.10: change gcc for build android
$sudo apt-get install gcc-4.4 g++-4.4 gcc-4.4-multilib g++-4.4-multilib
$sudo update-alternatives --install \
/usr/bin/gcc gcc /usr/bin/gcc-4.6 60 \
--slave /usr/bin/g++ g++ /usr/bin/g++-4.6
$sudo update-alternatives --install \
/usr/bin/gcc gcc /usr/bin/gcc-4.4 40 \
--slave /usr/bin/g++ g++ /usr/bin/g++-4.4
$sudo update-alternatives --config gcc
$gcc -v
$g++ -v
$sudo update-alternatives --install \
/usr/bin/gcc gcc /usr/bin/gcc-4.6 60 \
--slave /usr/bin/g++ g++ /usr/bin/g++-4.6
$sudo update-alternatives --install \
/usr/bin/gcc gcc /usr/bin/gcc-4.4 40 \
--slave /usr/bin/g++ g++ /usr/bin/g++-4.4
$sudo update-alternatives --config gcc
$gcc -v
$g++ -v
2012年8月19日 星期日
2012年8月12日 星期日
repo:Change branch in existed repo directory
Get code with a manifest in branch ABC:
#cd .repo/manifests
#git pull
#git checkout -b ABC origin/ABC
#cd ../..
#repo sync -d
#repo start NEW_BRANCH --all
2012年7月25日 星期三
android: how to see LOGV message
In your code add
#define LOG_NDEBUG 0
The reason is log.h at system/core/include/cutils/log.h
Ex:
In you want to see LOGV in audio_hw.c
You must add
#define LOG_TAG "audio_hw_primary"
#define LOG_NDEBUG 0
#define LOG_NDEBUG_FUNCTION
#ifndef LOG_NDEBUG_FUNCTION
#define LOGFUNC(...) ((void)0)
#else
#define LOGFUNC(...) (LOGV(__VA_ARGS__))
#endif
android: Filter logcat to get only you want message
adb -d logcat your_package_name:log_level *:S
ex: adb -d logcat com.example.example:I *:S
reference:
http://stackoverflow.com/questions/6854127/filter-logcat-to-get-only-the-messages-from-my-application-in-android
2012年7月24日 星期二
audio: concept
@Fetures Overview
The features supported by ALSA SoC Audio driver are:
-Supports audio codec in ALSA SoC framework.
-Multiple sample rates support (8 KHz, 16 KHz, 22.05 KHz, 32 KHz, 44.1 KHz, 48 KHz etc) for both capture and playback.
-Supports audio in stereo mode.
-Supports simultaneous playback and record (full-duplex mode).
-Start, stop, pause and resume feature.
-Supports mixer interface for audio codecs.
@Tool:
tinyalsa are used for audio playback, capture and configuration.
@ALSA HAL:
mydroid/device/xx/common-open/audio/audio_hw.c
The compiled HAL is named audio.primary.xxxx.so at /system/lib/hw
@ALSA Soc Architecture
- ASOC (ALSA System On Chip)
ASoC) layer is to provide better ALSA support for embedded system on chip processors and portable audio codecs
- Desgin:
1.Codec independence:
Allows reuse of codec drivers on other platforms and machines.
2.Easy I2S/PCM audio interface setup between codec and SoC.
Each SoC interface and codec registers it's audio interface capabilities with the
core and are subsequently matched and configured when the application hw params are known.
3.Dynamic Audio Power Management (DAPM):
DAPM automatically sets the codec to it's minimum power state at all times.
This includes powering up/down internal power blocks depending on the internal codec audio routing
and any active streams.
4.Pop and click reduction:
Pops and clicks can be reduced by powering the codec up/down in the correct sequence
(including using digital mute). ASoC signals the codec when to change power states.
-SoC basically splits an embedded audio system into three components:
1.Codec driver:
The codec driver is platform independent and contains audio controls,
audio interface capabilities, codec dapm definition and codec IO functions.
2.Platform driver:
The platform driver contains the audio dma engine and audio interface drivers (e.g. I2S, AC97, PCM)
for that platform.
3.Machine driver:
The machine driver handles any machine specific controls and audio events
i.e. turning on an amp at start of playback
@ Device Interface : /dev/snd/
- PCM devices for recording and play
- CTL devices that allow manipulating the internal mixer and routing of the card
1./dev/snd/controlC0: Control devices (i.e. mixer, etc)
2./dev/snd/pcmC0D0c : PCM Card 0 Device 0 Capture device
3./dev/snd/pcmC0D0p : PCM Card 0 Device 0 Playback device
@ Proc FS Interface: /proc/asound
The /proc/asound kernel interface is used as a status and configuration interface.
A lot of useful information about the sound system can be found in the
/proc/asound subdirectory.
1.cards : List of registered cards
2.version : Version and date the driver was built on
3.devices : List of registered ALSA devices
4.pcm : The list of allocated PCM streams
5.cardX : (X = 0-7) The card specific directory
6.cardX/pcm0p : The directory of the given PCM playback stream
7.cardX/pcm0c : The directory of the given PCM capture stream
@ Sys FS Interface:
- /sys/devices/platform/soc-audio/ : Information on the codec device
- /sys/devices/platform/xxx-pcm-audio : Interface for platfrom pcm (ALSA) device
- /sys/devices/platfrom/xxx-mcbsp-dai.x : Interface for McBSP device
@ Commonly Used API for ALSA:
snd_pcm_open:
Opens a PCM stream
snd_pcm_close:
Closes a previously opened PCM stream
snd_pcm_hw_params_any:
Fill params with a full configuration space for a PCM
snd_pcm_hw_params_test_ <
Test the availability of important parameters like number of channels,
sample rate etc.
For e.g. snd_pcm_hw_params_test_format, snd_pcm_hw_params_test_rate etc.
snd_pcm_hw_params_set_ <
For e.g. snd_pcm_hw_params_set_format, snd_pcm_hw_params_set_rate etc.
snd_pcm_hw_params:
Install one PCM hardware configuration chosen from a configuration space
snd_pcm_writei:
Write interleaved frames to a PCM
snd_pcm_readi:
Read interleaved frames from a PCM
snd_pcm_prepare:
Prepare PCM for use
snd_pcm_drop:
Stop a PCM dropping pending frames
snd_pcm_drain:
Stop a PCM preserving pending frames
reference:
http://processors.wiki.ti.com/index.php/UserGuideAudioDriver_PSP_04.02.00.07
2012年7月19日 星期四
Enabling dev_dbg in the kernel
Enabling dev_dbg in the kernel
To enable dev_dbg messages in a specific kernel file:
Reference: https://lkml.org/lkml/2007/6/29/323
To enable dev_dbg messages in a specific kernel file:
#define DEBUG
before including
Reference: https://lkml.org/lkml/2007/6/29/323
2012年7月11日 星期三
android: lcd backlight
1. packages/apps/Settings/src/com/Android/settings/BrightnessPreference.java
2.frameworks/base/core/java/Android/os/IPowerManager.aidl.java
--> // sets the brightness of the backlights (screen, keyboard, button) 0-255
void setBacklightBrightness(int brightness)
3.frameworks/base/core/java/Android/os/PowerManager.java
public void setBacklightBrightness(int brightness)
{
try {
mService.setBacklightBrightness(brightness);
} catch (RemoteException e) {
}
}
4.frameworks/base/services/java/com/Android/server/PowerManagerService.java
-- >public void setBacklightBrightness(int brightness) {
5.frameworks/base/services/java/com/android/server/LightsService.java
public void setBrightness(int brightness) {
setBrightness(brightness, BRIGHTNESS_MODE_USER);
}
public void setBrightness(int brightness, int brightnessMode) {
synchronized (this) {
int color = brightness & 0x000000ff;
color = 0xff000000 | (color << 16) | (color << 8) | color;
setLightLocked(color, LIGHT_FLASH_NONE, 0, 0, brightnessMode);
}
}
6./frameworks/base/services/jni/com_android_server_LightsService.cpp
static void setLight_native(JNIEnv *env, jobject clazz, int ptr,
int light, int colorARGB, int flashMode, int onMS, int offMS, int brightnessMode)
{
Devices* devices = (Devices*)ptr;
light_state_t state;
if (light < 0 || light >= LIGHT_COUNT || devices->lights[light] == NULL) {
return ;
}
memset(&state, 0, sizeof(light_state_t));
state.color = colorARGB;
state.flashMode = flashMode;
state.flashOnMS = onMS;
state.flashOffMS = offMS;
state.brightnessMode = brightnessMode;
devices->lights[light]->set_light(devices->lights[light], &state);
}
7. devices/vendor/board/liblights.c
set_light_backlight(struct light_device_t* dev,
struct light_state_t const* state)
{
int err = 0;
int brightness = rgb_to_brightness(state);
int fd;
char buf[1]={0};
pthread_mutex_lock(&g_lock);
fd = open(LCD_FILE, O_RDONLY);
err=read(fd, &buf, 1);
close(fd);
if(buf[0] == '0' && brightness)
usleep(200000);
err = write_int(LCD_FILE, brightness);
pthread_mutex_unlock(&g_lock);
return err;
}
char const*const LCD_FILE
= "/sys/class/leds/lcd-backlight/brightness";
8. kernel/driver/leds
ex: kernel/driver/leds/xxxx-pwm.c
2012年7月2日 星期一
vim: marked word
- 使用 vim 來註解一整段文字 -----------------------------------------------
‧執行 apt-get install vim-addon-manager vim-scripts
‧執行 vim-addons install enhanced-commentify
‧執行 vim 某個 文字檔,進入vim:
1. 先按 Esc 離開 insert mode
2. 再按 ctrl+v 將要註解的這幾行選取(使用上下左右鍵 or + shift )
3. 再按大寫的 I (指的是進入Insert mode)
4. 再輸入 #
5. 最後按 Esc 就會看到選取的這幾行都被 # 註解掉了
‧執行 apt-get install vim-addon-manager vim-scripts
‧執行 vim-addons install enhanced-commentify
‧執行 vim 某個 文字檔,進入vim:
1. 先按 Esc 離開 insert mode
2. 再按 ctrl+v 將要註解的這幾行選取(使用上下左右鍵 or + shift )
3. 再按大寫的 I (指的是進入Insert mode)
4. 再輸入 #
5. 最後按 Esc 就會看到選取的這幾行都被 # 註解掉了
linux screen: command list
Key | Action | Notes |
---|---|---|
Ctrl+a c | new window | |
Ctrl+a n | next window | |
Ctrl+a p | previous window | |
Ctrl+a “ | select window from list | |
Ctrl+a Ctrl+a | previous window viewed | |
Ctrl+a S | split terminal horizontally into regions | Ctrl+a c to create new window there |
Ctrl+a | | split terminal vertically into regions | Requires debian/ubuntu patched screen 4.0 |
Ctrl+a :resize | resize region | |
Ctrl+a :fit | fit screen size to new terminal size | Ctrl+a F is the same. Do after resizing xterm |
Ctrl+a :remove | remove region | Ctrl+a X is the same |
Ctrl+a tab | Move to next region | |
Ctrl+a d | detach screen from terminal | Start screen with -r option to reattach |
Ctrl+a A | set window title | |
Ctrl+a x | lock session | Enter user password to unlock |
Ctrl+a [ | enter scrollback/copy mode | Enter to start and end copy region. Ctrl+a ] to leave this mod |
Ctrl+a ] | paste buffer | Supports pasting between windows |
Ctrl+a > | write paste buffer to file | useful for copying between screens |
Ctrl+a < | read paste buffer from file | useful for pasting between screens |
Ctrl+a ? | show key bindings/command names | Note unbound commands only in man page |
Ctrl+a : | goto screen command prompt | up shows last command entered |
refer: http://deep.tw/others/screen/split-vertical.html
git & vimdiff setting
ref:http://stackoverflow.com/questions/3713765/viewing-all-git-diffs-with-vimdiff
#git config --global diff.tool vimdiff
#git config --global difftool.prompt false
#git config --global alias.d difftool
You type #git d
exit #wq:
2012年7月1日 星期日
git log
http://gitready.com/advanced/2009/01/20/bend-logs-to-your-will.html
#git log -n
show all content
#git log -p
show one line
#git log -pretty=oneline
show graph
#git log --graph
2012年6月27日 星期三
linux : debugfs
We can find out /sys/kernel/debug folder and we can create folder to debug our driver
Below is example code to create new folder and file in /sys/kernel/debug path
#include "linux/platform_device.h"
#include "linux/debugfs.h"
#include "linux/seq_file.h"
#include "linux/fs.h"
#include "linux/stat.h"
#define DEBUGFS 1
void foo_debug_dump_version(struct seq_file *s)
{
int tmp=1.0;
seq_printf(s, "==============\n %s \n", "foo_debug_dump_version");
seq_printf(s,"version: %d \n",tmp);
}
static int foo_debugfs_show(struct seq_file *s, void *data)
{
printk("%s \n", __func__);
void (*func)(struct seq_file *) = s->private;
func(s);
//seq_printf(s,"version: %s \n","1.0");
return 0;
}
static int foo_debugfs_open(struct inode *inode, struct file *file)
{
printk("%s \n", __func__);
return single_open(file, foo_debugfs_show, inode->i_private);
}
static const struct file_operations foo_debugfs_fops = {
.open = foo_debugfs_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_ release,
};
//step 1
struct dentry *foo_debugfs_dir;
static int foo_probe(struct platform_device *pdev)
{
printk("%s", __func__);
//debugfs
foo_debugfs_dir = debugfs_create_dir("foo_debug",NULL);
if (IS_ERR(foo_debugfs_dir)) {
goto err_node;
}
debugfs_create_file("foo_version", ( S_IRUGO | S_IWUSR ), foo_debugfs_dir,
&foo_debug_dump_version, &foo_debugfs_fops);
pr_info(" debugfs entries created ");
return 0;
//~debugfs
err_node:
debugfs_remove_recursive(foo_debugfs_dir);
foo_debugfs_dir = NULL;
pr_err(" debugfs entries creation failed ");
return -EIO;
}
static int foo_remove(struct platform_device *pdev)
{
printk("%s", __func__);
debugfs_remove_recursive(foo_debugfs_dir);
return 0;
}
static struct platform_driver foo_driver = {
.probe = foo_probe,
.remove = foo_remove,
.driver = {
.name = "foo_device",
.owner = THIS_MODULE,
},
};
static int __init foo_init(void)
{
return platform_driver_register(&foo_driver);
}
static void __exit foo_exit(void)
{
return platform_driver_unregister(&foo_driver);
}
module_init(foo_init);
module_exit(foo_exit);
MODULE_DESCRIPTION("foo driver ");
Below is example code to create new folder and file in /sys/kernel/debug path
#include "linux/platform_device.h"
#include "linux/debugfs.h"
#include "linux/seq_file.h"
#include "linux/fs.h"
#include "linux/stat.h"
#define DEBUGFS 1
void foo_debug_dump_version(struct seq_file *s)
{
int tmp=1.0;
seq_printf(s, "==============\n %s \n", "foo_debug_dump_version");
seq_printf(s,"version: %d \n",tmp);
}
static int foo_debugfs_show(struct seq_file *s, void *data)
{
printk("%s \n", __func__);
void (*func)(struct seq_file *) = s->private;
func(s);
//seq_printf(s,"version: %s \n","1.0");
return 0;
}
static int foo_debugfs_open(struct inode *inode, struct file *file)
{
printk("%s \n", __func__);
return single_open(file, foo_debugfs_show, inode->i_private);
}
static const struct file_operations foo_debugfs_fops = {
.open = foo_debugfs_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_ release,
};
//step 1
struct dentry *foo_debugfs_dir;
static int foo_probe(struct platform_device *pdev)
{
printk("%s", __func__);
//debugfs
foo_debugfs_dir = debugfs_create_dir("foo_debug",NULL);
if (IS_ERR(foo_debugfs_dir)) {
goto err_node;
}
debugfs_create_file("foo_version", ( S_IRUGO | S_IWUSR ), foo_debugfs_dir,
&foo_debug_dump_version, &foo_debugfs_fops);
pr_info(" debugfs entries created ");
return 0;
//~debugfs
err_node:
debugfs_remove_recursive(foo_debugfs_dir);
foo_debugfs_dir = NULL;
pr_err(" debugfs entries creation failed ");
return -EIO;
}
static int foo_remove(struct platform_device *pdev)
{
printk("%s", __func__);
debugfs_remove_recursive(foo_debugfs_dir);
return 0;
}
static struct platform_driver foo_driver = {
.probe = foo_probe,
.remove = foo_remove,
.driver = {
.name = "foo_device",
.owner = THIS_MODULE,
},
};
static int __init foo_init(void)
{
return platform_driver_register(&foo_driver);
}
static void __exit foo_exit(void)
{
return platform_driver_unregister(&foo_driver);
}
module_init(foo_init);
module_exit(foo_exit);
MODULE_DESCRIPTION("foo driver ");
2012年6月26日 星期二
Linux driver :platform devices and driver
find out at /sys/bus/platform/devices and /sys/bus/platform/drivers
ex:
./arch/arm/board-file.c
+static struct platform_device foo_device = {
+ .name = "foo_device",
+ .id = -1,
+ .dev = {
+ .platform_data = NULL,
+ },
+};
This will create foo_device at /sys/devices/platform/
ex:
./driver/misc/foo.c
static struct platform_driver foo_driver = {
.probe = foo_probe,
.driver = {
.name = "foo_device",
.owner = THIS_MODULE,
},
};
static int __init foo_init(void)
{
return platform_driver_register(&foo_driver);
}
static void __exit foo_exit(void)
{
return platform_driver_unregister(&foo_driver);
}
This will find the foo_device folder at /sys/bus/platform/drivers
/sys/bus/platform/drivers/foo_device # ls
bind foo_device uevent unbind
/sys/bus/platform/drivers/foo_device # ls foo_device/
driver modalias power subsystem uevent
ex:
./arch/arm/board-file.c
+static struct platform_device foo_device = {
+ .name = "foo_device",
+ .id = -1,
+ .dev = {
+ .platform_data = NULL,
+ },
+};
This will create foo_device at /sys/devices/platform/
ex:
./driver/misc/foo.c
static struct platform_driver foo_driver = {
.probe = foo_probe,
.driver = {
.name = "foo_device",
.owner = THIS_MODULE,
},
};
static int __init foo_init(void)
{
return platform_driver_register(&foo_driver);
}
static void __exit foo_exit(void)
{
return platform_driver_unregister(&foo_driver);
}
This will find the foo_device folder at /sys/bus/platform/drivers
/sys/bus/platform/drivers/foo_device # ls
bind foo_device uevent unbind
/sys/bus/platform/drivers/foo_device # ls foo_device/
driver modalias power subsystem uevent
2012年6月1日 星期五
android reboot process
- frameworks/base/core/java/android/os/Power.java android_os_Power_reboot()
- frameworks/base/core/jni/android_os_Power.cpp
reboot() - bionic/libc/unistd/reboot.c
reboot(__reboot) - bionic/libc/arch-arm/syscalls/__reboot.S
- kernel/arch/sh/kernel/reboot.c
struct machine_ops machine_ops = {
.power_off = native_machine_power_off,
.shutdown = native_machine_shutdown,
.restart = native_machine_restart,
.halt = native_machine_halt,
} - bionic/libc/include/sys/linux-syscalls.h
#define __NR_reboot (__NR_SYSCALL_BASE + 88) - ./arch/arm/kernel/calls.S
__NR_reboot 就是系统函数sys_reboot - ./kernel/sys.c
kernel_restart
{
kernel_restart_prepare(cmd);
if (!cmd)
printk(KERN_EMERG "Restarting system.\n");
else
printk(KERN_EMERG "Restarting system with command '%s'.\n", cmd);
kmsg_dump(KMSG_DUMP_RESTART);
machine_restart(cmd);
}
void kernel_restart_prepare(char *cmd)
{
blocking_notifier_call_chain(&reboot_notifier_list, SYS_RESTART, cmd);
system_state = SYSTEM_RESTART;
usermodehelper_disable();
device_shutdown();
syscore_shutdown();
}
void kernel_power_off(void)
{
kernel_shutdown_prepare(SYSTEM_POWER_OFF);
if (pm_power_off_prepare)
pm_power_off_prepare();
disable_nonboot_cpus();
syscore_shutdown();
printk(KERN_EMERG "Power down.\n");
kmsg_dump(KMSG_DUMP_POWEROFF);
machine_power_off();
} - kernel/arch/arm/kernel/process.c
void machine_shutdown(void)
{
#ifdef CONFIG_SMP
smp_send_stop();
#endif
}
void machine_halt(void)
{
machine_shutdown();
while (1);
}
void machine_power_off(void)
{
machine_shutdown();
if (pm_power_off)
pm_power_off();
}
void machine_restart(char *cmd)
{
machine_shutdown();
arm_pm_restart(reboot_mode, cmd);
} - If you would like to trace power_off
kernel/driver/mfd/xxxx_poweroff.c
You will see:
pm_power_off=xxxx_poweroff
2012年5月30日 星期三
android command : getevent and sendevent
reference :
http://topic.csdn.net/u/20100326/17/1f0fc5a1-3bd2-4294-aa35-1bcb73357aa3.html
getevent
getevent
add device 1: /dev/input/event0
name: "qwerty2"
/dev/input/event0: 0001 001e 00000001
/dev/input/event0: 0001 001e 00000000
其中/dev/input/event0是device的名字 0001是type, 001e是键码, 最后一个根据type不同而不同
比如上面的倒数第二条就是按下a键的keydown,最后一个是按下a的keyup
具体的type,code,value的定义可以在源码/frameworks/base/core/java/android/view/KeyEvent.java中找到
sendevent发送时间,格式和上面的一样,需要注意的是在get中code显示的是十六进制,而send中需要用十进制,例如
# sendevent /dev/input/event0 1 5 1
这个命令就是发送数字4的keydown消息,所以在屏幕上就会一直打印出很多个4(因为没有发送keyup)
http://topic.csdn.net/u/20100326/17/1f0fc5a1-3bd2-4294-aa35-1bcb73357aa3.html
getevent
getevent
add device 1: /dev/input/event0
name: "qwerty2"
/dev/input/event0: 0001 001e 00000001
/dev/input/event0: 0001 001e 00000000
其中/dev/input/event0是device的名字 0001是type, 001e是键码, 最后一个根据type不同而不同
比如上面的倒数第二条就是按下a键的keydown,最后一个是按下a的keyup
具体的type,code,value的定义可以在源码/frameworks/base/core/java/android/view/KeyEvent.java中找到
sendevent发送时间,格式和上面的一样,需要注意的是在get中code显示的是十六进制,而send中需要用十进制,例如
# sendevent /dev/input/event0 1 5 1
这个命令就是发送数字4的keydown消息,所以在屏幕上就会一直打印出很多个4(因为没有发送keyup)
Using iw command to link AP
# enable wifi
# iw dev wlan0 scan | grep SSID
# iw wlan0 connect "SSID"
# iw dev wlan0 link
# netcfg wlan0 dhcp
Turn off power save mode
#iw dev wlan0 set power_save off
# iw dev wlan0 scan | grep SSID
# iw wlan0 connect "SSID"
# iw dev wlan0 link
# netcfg wlan0 dhcp
Turn off power save mode
#iw dev wlan0 set power_save off
wifi basic diagram on Linux
reference http://acx100.erley.org/stable.html
Should be self explanitory... handles sending/receiving wireless packets
Linux Kernel:
The linux kernel contains the driver for the wireless card, the mac80211 subsystem which handles packet generation and scheduling, and the nl80211 subsystem, which handles configuring the wireless interfaces for userspace
libnl:
libnl is the transport layer used to communicate with the kernel via netlink
udev:
udev is the facility the kernel uses to pass events/calls to crda
iw:
iw is a userspace utility that we can use to test that libnl is working correctly, as well as create additional virtual wireless interfaces on the wireless card
crda:
crda is a userspace program that the kernel queries (through udev) to find what channels/frequencies are usable, and at what powers. This moves the information out of static tables maintained in kernel to userspace, which allows them to be updated without reloading drivers/rebooting
Wireless Regulatory Database: database of allowable frequencies and transmit power levels used by crda
hostapd:
This is the daemon that handles generation of beacons and other wireless packets, as wel as wpa-psk, wpa2, etc encryptions.
Basic Diagram of Component Interaction
[Wireless Card] | [Linux Kernel ] | | [udev][libnl]-[iw] | / \ [crda] \ | \ [ Wireless ] | [Regulatory] | [ Database ] | | | [ hostapd ]
Understanding what each part does
Wireless Card:Should be self explanitory... handles sending/receiving wireless packets
Linux Kernel:
The linux kernel contains the driver for the wireless card, the mac80211 subsystem which handles packet generation and scheduling, and the nl80211 subsystem, which handles configuring the wireless interfaces for userspace
libnl:
libnl is the transport layer used to communicate with the kernel via netlink
udev:
udev is the facility the kernel uses to pass events/calls to crda
iw:
iw is a userspace utility that we can use to test that libnl is working correctly, as well as create additional virtual wireless interfaces on the wireless card
crda:
crda is a userspace program that the kernel queries (through udev) to find what channels/frequencies are usable, and at what powers. This moves the information out of static tables maintained in kernel to userspace, which allows them to be updated without reloading drivers/rebooting
Wireless Regulatory Database: database of allowable frequencies and transmit power levels used by crda
hostapd:
This is the daemon that handles generation of beacons and other wireless packets, as wel as wpa-psk, wpa2, etc encryptions.
2012年5月29日 星期二
wifi reference web site
http://processors.wiki.ti.com/index.php/OMAP_Wireless_Connectivity_NLCP_WLAN_Station_WPA_Supplicant_Configuration_file
http://processors.wiki.ti.com/index.php/OMAP_Wireless_Connectivity_NLCP_WLAN_IW_commands
http://processors.wiki.ti.com/index.php/OMAP_Wireless_Connectivity_NLCP_WiFi_Direct_Configuration_Scripts
http://processors.wiki.ti.com/index.php/OMAP_Wireless_Connectivity_NLCP_WLAN_Station_Configuration_Scripts
http://omappedia.org/wiki/Mac80211_based_open_source_architecture
http://processors.wiki.ti.com/index.php/OMAP_Wireless_Connectivity_NLCP_WLAN_IW_commands
http://processors.wiki.ti.com/index.php/OMAP_Wireless_Connectivity_NLCP_WiFi_Direct_Configuration_Scripts
http://processors.wiki.ti.com/index.php/OMAP_Wireless_Connectivity_NLCP_WLAN_Station_Configuration_Scripts
http://omappedia.org/wiki/Mac80211_based_open_source_architecture
android: getevent
getevent : it is android tool in device. it show device capabilities.
#getevent -p
#getevent
#getevnet -i
reference:
http://source.android.com/tech/input/getevent.html
The
The
#getevent -p
#getevent
#getevnet -i
reference:
http://source.android.com/tech/input/getevent.html
The
-i
option shows even more information than -p
, including HID mapping tables
and debugging information.The
-l
option uses textual labels for all event codes, which is handy.2012年5月28日 星期一
android: dumpsys
dumpsys is tool in android device. You can use this tool to dump system information.
The parameters may have below:
SurfaceFlinger, accessibility, account, activity, alarm, appwidget, audio, backup, battery, batteryinfo, bluetooth, bluetooth_a2dp, clipboard, connectivity, content, cpuinfo, device_policy, devicestoragemonitor, diskstats, dropbox, entropy, hardware, hdmi, input_method, iphonesubinfo, isms, location, media.audio_flinger, media.audio_policy, media.camera, media.player, meminfo, mount, netstat, network_management, notification, package, permission, phone, power, search, sensor, simphonebook, statusbar, telephony.registry, throttle, uimode, usagestats, vibrator, wallpaper, wifi, window
- dumpsys meminfo displays memory usage
- dumpsys cpuinfo displays processor usage
- dumpsys account displays information on all accounts
- dumpsys activity displays information about activities
- dumpsys window displays information about keyboards, windows and their z order
- dumpsys wifi shows information about available access points and current connection
The parameters may have below:
SurfaceFlinger, accessibility, account, activity, alarm, appwidget, audio, backup, battery, batteryinfo, bluetooth, bluetooth_a2dp, clipboard, connectivity, content, cpuinfo, device_policy, devicestoragemonitor, diskstats, dropbox, entropy, hardware, hdmi, input_method, iphonesubinfo, isms, location, media.audio_flinger, media.audio_policy, media.camera, media.player, meminfo, mount, netstat, network_management, notification, package, permission, phone, power, search, sensor, simphonebook, statusbar, telephony.registry, throttle, uimode, usagestats, vibrator, wallpaper, wifi, window
git-blame
http://schacon.github.com/git/git-blame.html
http://gitbook.liuhui998.com/5_5.html
#git blame file.c
#git blame -L start_line,end_line file.c
ex:
#git blame -L 160,+20 file.c
http://gitbook.liuhui998.com/5_5.html
#git blame file.c
#git blame -L start_line,end_line file.c
ex:
#git blame -L 160,+20 file.c
wifi calibrator for Tx/RX testing
*********************************************
*Tx
*********************************************
1. Make sure you turn off wifi on UI
2. #insmod /system/lib/modules/wl12xx_sdio.ko
3. #ifconfig wlan0 down
4. #calibrator wlan0 plt power_mode on
5. #calibrator wlan0 plt tx_stop
5. #calibrator wlan0 plt tune_channel
6. #calibrator wlan0 plt tx_cont
7. #calibrator wlan0 plt tx_stop
8. #calibrator wlan0 plt power_mode off
**********************************************
*Rx
**********************************************
1. Make sure you turn off wifi on UI
2. #insmod /system/lib/modules/wl12xx_sdio.ko
3. #ifconfig wlan0 down
4. #calibrator wlan0 plt power_mode on
5. #calibrator wlan0 plt tune_channel
6. #calibrator wlan0 plt stop_rx_statcs
7. #calibrator wlan0 plt reset_rx_statcs
8. #calibrator wlan0 plt start_rx_statcs
9. #calibrator wlan0 plt stop_rx_statcs
10.#calibrator wlan0 plt get_rx_statcs
11.#calibrator wlan0 plt power_mode off
~
*Tx
*********************************************
1. Make sure you turn off wifi on UI
2. #insmod /system/lib/modules/wl12xx_sdio.ko
3. #ifconfig wlan0 down
4. #calibrator wlan0 plt power_mode on
5. #calibrator wlan0 plt tx_stop
5. #calibrator wlan0 plt tune_channel
6. #calibrator wlan0 plt tx_cont
7. #calibrator wlan0 plt tx_stop
8. #calibrator wlan0 plt power_mode off
**********************************************
*Rx
**********************************************
1. Make sure you turn off wifi on UI
2. #insmod /system/lib/modules/wl12xx_sdio.ko
3. #ifconfig wlan0 down
4. #calibrator wlan0 plt power_mode on
5. #calibrator wlan0 plt tune_channel
6. #calibrator wlan0 plt stop_rx_statcs
7. #calibrator wlan0 plt reset_rx_statcs
8. #calibrator wlan0 plt start_rx_statcs
9. #calibrator wlan0 plt stop_rx_statcs
10.#calibrator wlan0 plt get_rx_statcs
11.#calibrator wlan0 plt power_mode off
~
2012年5月23日 星期三
訂閱:
文章 (Atom)