2009年12月31日星期四

使用iwconfig 配置无线网卡

操作步骤如下:
1. 启动无线网卡
 ifconfig wlan0 on
2.  扫描无线接入点
iwlist wlan0 scanning
3. 连接接入点
iwconfig wlan0 essid   YOUR-SERVICE-NAME
4. 配置网络
例如
ifconfig wlan0 192.168.xxx.xxx netmask 255.255.255.0  up

5. 测试
例如
ping 192.168.1.1

2009年12月14日星期一

使用bootchart-lite监视linux启动和运行状态

使用bootchart可以方便监视linux的启动和运行时的状态,并能将这些状态信息以图形方式表示,以图像方式输出。
但鉴于bootchart的特殊实现方式,它不太适合嵌入式系统。
在嵌入式系统中,可以使用精简化的bootchart--bootchart-lite,替代bootchart。

1. bootchart-lite 源码下载
http://code.google.com/p/bootchart-lite/

2. 编译
CC=arm-linux-gcc ./configure
make
在src目录下面会生成bootchart-lite可执行文件

bootchart-lite 默认配置是把log文件存放在/etc/bootchart-lite/目录下,
使用之前要先建立这个目录。
3. 配置启动参数,让linux启动后,先启动bootchart-lite
init=bootchart-lite

4. 启动linux

5. 收集log文件,渲染图像
bootchart-lite会生成如下3个log文件:
proc_diskstats.log 
proc_ps.log
proc_stat.log

把这3个文件取出后,在pc上运行如下命令:
tar czf bootchart.tgz *.log
bootchart -f png bootchart.tgz

在log所在目录下,会生成一个bootchart.png文件,打开看看你的系统状态吧。。。。

当然,pc上别忘记装bootchart工具。


2009年12月8日星期二

Linux Framebuffer编程简介

linux下,framebuffer设备文件名通常是/dev/fb0,1,2等。
控制framebuffer设备的一般步骤如下:
1) 打开设备,映射framebuffer
2)依照硬件要求,准备好数据
3)把数据复制到framebuffer

例子程序如下:

1)打开设备,映射framebuffer
static void *fbbuf;
int openfb(char *devname)
{
    int fd;
    fd = open(devname, O_RDWR);
    if (ioctl(fd, FBIOGET_VSCREENINFO, &fbvar) < 0)
        return -1;
    bpp = fbvar.bits_per_pixel;
    screen_size = fbvar.xres * fbvar.yres * bpp / 8;
    fbbuf = mmap(0, screen_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
    return fd;
}

2)数据准备,假设lcd控制器被初始化为565,16bit格式的
static inline int  make_pixel(unsigned int a, unsigned int r, unsigned int g, unsigned int b)
{
    return (unsigned int)(((r>>3)<<11)|((g>>2)<<5|(b>>3)));
}

3) 把想要显示的数据复制到framebuffer,假设把framebuffer填充成一种颜色
static void fill_pixel(unsigned int pixel, int x0, int y0, int w, int h)
{
    int i, j;
    unsigned short *pbuf = (unsigned short *)fbbuf;
    for (i = y0; i < h; i ++) {
        for (j = x0; j < w; j ++) {
            pbuf[i * screen_width + j] = pixel;
        }
    }
}