2009年12月8日 星期二
ubi filesystem on NAND
Volumes count: 0
Logical eraseblock size: 1032192 bytes, 1008.0 KiB
Total amount of logical eraseblocks: 16336 (16861888512 bytes, 15.7 GiB)
Amount of available logical eraseblocks: 16169 (16689512448 bytes, 15.5 GiB)
Maximum count of volumes 128
Count of bad physical eraseblocks: 18
Count of reserved physical eraseblocks: 163
Current maximum erase counter value: 2
Minimum input/output unit size: 8192 bytes
Character device major/minor: 253:0
#sudo ubimkvol /dev/ubi0 -S 16169 -N ROOTFS
#mkfs.ubifs /dev/ubi0_0
#mkdir /tmp/ubi
#mount -t ubifs ubi0_0 /tmp/ubi
#mkdir /tmp/mmc
#mount -t ext3 /dev/mmcblk0p1 /tmp/mmc
#cd mmc/
#(tar -cf - * | tar -C ../ubi/ -xf -) &
//Booting from UBI
Setting u-boot parameters
setenv bootargs_root root=ubi0:ROOTFS rootfstype=ubifs
setenv tftpbootcmd 'tftpboot 0x2000000 ${image_name}; setenv bootargs pm_disable ${console} ${bootargs_root} usb0Mode=${usb0Mode} usb1Mode=${usb1Mode} video=dovefb:lcd0:${lcd0_params},lcd1:${lcd1_params} clcd.lcd0_enable=${lcd0_enable} clcd.lcd1_enable=${lcd1_enable} mtdparts=spi0.0:512k(uboot)ro,128k(uboot_env),3072k(kernel) ubi.mtd=Root;bootm 0x2000000'
解deb 不用dpkg
看deb內部有哪些東西
#ar p xserver-xorg-video.deb data.tar.gz | tar -C / -ztvf -
使用dpkg
#dpkg --force-all -i xserver-xorg-video.deb
2009年11月11日 星期三
Integrate image
#dd if=u-boot of=ub bs=1M conv=sync
#vi ub
Then see the hex file by :%!xxd
verify it by see address
#ll
ex:477624
#dc
16o 477624
p
749B8
Integrate image: uboot and uImage
#cat ub uImage > image
-------------------------------
result:
#dd if=u-boot of=du bs=1M conv=sync
#cat ub uImage > image
----------------------------------------
;c code mkimage.c
;compile
#gcc -O2 -o mknandimg mknandimg.c
;make image
#./mknandimg u-boot.bin uImage image
#
2009年11月5日 星期四
link application to desktop
#echo 'firefox /*.swf ' > flashdemo.sh
#chmod +x flashdemo.sh
2009年10月29日 星期四
720p and 1080p 備忘
.pixclock = 0,
.refresh = 60,
.xres = 1280,
.yres = 720,
.hsync_len = 40,
.left_margin = 220,
.right_margin = 110,
.vsync_len = 5,
.upper_margin =20,
.lower_margin = 5,
.sync = 0,
},
[8] = { //1080p
.pixclock = 0,
.refresh = 60,
.xres = 1920,
.yres = 1080,
.hsync_len = 44,
.left_margin = 148,
.right_margin = 88,
.vsync_len = 5,
.upper_margin =36,
.lower_margin = 4,
.sync = 0,
},
2009年10月28日 星期三
2009年10月25日 星期日
nand testing
#tftpboot 0x2000000 uImage
#nand erase 0x400000 0x400000
#nand write 0x2000000 0x400000 0x400000
#nand read 0x2000000 0x400000 0x400000
#bootm 0x2000000
setenv bootcmd 'nand read 0x2000000 0x400000 0x400000;bootm 0x2000000'
setenv bootcmd 'nand read 0x2000000 0x400000 0x400000;setenv bootargs ${console} ${bootargs_root} nfsroot=${serverip}:${rootpath} ip=${ipaddr}:${serverip}${bootargs_end} usb0Mode=${usb0Mode} usb1Mode=${usb1Mode} video=dovefb:lcd0:${lcd0_params},lcd1:${lcd1_params} clcd.lcd0_enable=${lcd0_enable} clcd.lcd1_enable=${lcd1_enable}; bootm 0x2000000'
mtd utility:
dump nand device by nanddump
#nanddump -p -f /tmp/mtd1 /dev/mtd1
see mtd1 file
#less /tmp/mtd1
erase nand device
#flash_erase /dev/mtd1
see mtd1 full 0xff
#less /tmp/mtd1
//===========================================
MTD utility
# flash_erase /dev/mtd2
Erase Total 1 Units
Performing Flash Erase of length 524288 at offset 0x0 done
#dd if=/dev/zero of=/tmp/zero.img bs=1k count=4
4+0 records in
4+0 records out
# flashcp zero.img /dev/mtd2
#nanddump -p -f /work/mtd2 /dev/mtd2
//========================================
//jffs2
http://blog.chinson.idv.tw/2007/11/arm-jffs2-nand-flash.html
//===============================================
# ./mtd_debug read /dev/mtd0 0 100 gliethttp.bin
Copied 100 bytes from address 0x00000000 in flash to gliethttp.bin
# hexdump gliethttp.bin
0000000 03ff ea00 350c e59f 001c e583 410e e3a0
0000010 4004 e583 4a03 e3a0 4001 e254 fffd 1aff
0000020 4106 e3a0 4004 e583 420f e202 5000 e594
0000030 4001 e084 5000 e594 4001 e084 5000 e594
0000040 4001 e084 5000 e594 4010 e3a0 4008 e583
0000050 4050 e3a0 4001 e254 fffd 1aff 4e1e e3a0
0000060 4008 e583
0000064
#
# ./mtd_debug read /dev/mtd2 0 100 gliethttp.bin;hexdump gliethttp.bin -Cv
Copied 100 bytes from address 0x00000000 in flash to gliethttp.bin
00000000 1f 8b 08 00 ca 14 7d 4a 02 03 e4 5a 0f 70 93 e7 |......}J...Z.p..|
00000010 79 7f 3f 49 36 b2 31 41 80 a0 0e 38 cd 57 70 16 |y.?I6.1A...8.Wp.|
00000020 93 18 f3 19 3b 60 12 9a d9 60 08 09 4e 22 c0 a4 |....;`...`..N"..|
00000030 b4 81 ca 42 92 6d 0d 59 d2 49 72 02 2b 4d dd 60 |...B.m.Y.Ir.+M.`|
00000040 72 84 e1 86 03 a7 21 01 8a d2 b2 4b 2e f3 56 76 |r.....!....K..Vv|
00000050 63 b7 34 0b 1d cd b1 1d 6b b3 95 36 dc 95 db d1 |c.4.....k..6....|
00000060 8b 90 d1 ea |....|
00000064
[root@Dove /]# flash_eraseall /dev/mtd2
Erasing 512 Kibyte @ 13300000 -- 7 % complete.
Skipping bad block at 0x13380000
Erasing 512 Kibyte @ 35080000 -- 20 % complete.
Skipping bad block at 0x35100000
Erasing 512 Kibyte @ 53180000 -- 32 % complete.
Skipping bad block at 0x53200000
Erasing 512 Kibyte @ 73d00000 -- 45 % complete.
Skipping bad block at 0x73d80000
Erasing 512 Kibyte @ 77a00000 -- 46 % complete.
Skipping bad block at 0x77a80000
Erasing 512 Kibyte @ ff680000 -- 99 % complete.
Skipping bad block at 0xff700000
Skipping bad block at 0xff780000
Skipping bad block at 0xff800000
Skipping bad block at 0xff880000
Skipping bad block at 0xff900000
Skipping bad block at 0xff980000
Skipping bad block at 0xffa00000
Skipping bad block at 0xffa80000
Erasing 512 Kibyte @ ffb00000 -- 100 % complete.
spin down
Hdparm –S <> /dev/
For example : SATA HD mount at /dev/sda1 ,you want SATA HD into sleep after 1 min
You need type command “hdparm –S 12 /dev/sda
reference:
http://yenjinc.info/?p=60
http://www.gentoo.org/doc/zh_tw/power-management-guide.xml
2009年10月23日 星期五
mtd utility
http://nienfeng.blogspot.com/2008/08/mtd-partition-tools.html
2009年9月6日 星期日
* Audio: I2S and Linux sound system
------------ --------
| Embedded | ---->I2S | audio | <----MIC | controller | ---->I2C | codec | ----->AMP -->speaker
------------ --------
I2S: Inter-IC sound
1. SCLK(BCLK) : sclk frequency= (2) x (sample rate) x (sample bit)
2. LRCK(WS) : WS=0 for left channel, WS=1 for right channel
3. SDATA: data from MSB to LSB
4. MCLK : main clock
Right/Left Justified:左右校正
Linux sound system:
Kernel 2.6 : ALSA (advanced Linux Sound Architecture)
Kernel 2.4 : OSS (Open sound system)
Device node:
ALSA => /dev/snd/*
OSS => /dev/dsp, /dev/adsp, /dev/mixer, /dev/audio
Procfs and sysfs interface implementation via
/proc/asound
/sys/class/sound
Driver:
Audio codec --> audio codec interface -------> sound core
audio controller --> audio controller driver----> sound core
Driver support function:
1.playback
2. capture
3. mixer control
Reference:
http://tldp.org/HOWTO/Sound-HOWTO/
2009年9月4日 星期五
2009年9月3日 星期四
* busybox : mdev
建立dev node的方式除了mknod逐一建入之外,可以利用mdev的機制來建立device node
udev已經幾乎是每個os裡必備的機制了,但其佔用了相當的資源,包括開機時,更佔去了好一部份的開機時間。很明顯的,在資源較少的embedded system,不太可能使用這樣的一個東西。
替代品是busybox的mdev,意思是mini udev。mdev需要透過 kernel的hotplug event來完成device node的增減。通常以mdev -s來啟動,設定檔是mdev.conf。啟動時會去掃描/sys/block和/sys/class裡的 dev檔,並根據其指的的major/minor number建立device node,因此在啟動mdev前當需要先把/sys mount起來囉!
掛載 sys
echo "----------mount /sys as sysfs"
/bin/mount -t tmpfs mdev /dev
/bin/mount -t sysfs sysfs /sys
echo "----------Starting mdev......"
/bin/echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s
*mdev -s 主要是掃描 /sys/class and /sys/block
reference:
1. http://kezeodsnx.pixnet.net/blog/post/26153916
2. http://syncmaster795.info/?p=44
3. http://blogimg.chinaunix.net/blog/upfile2/080111091002.pdf
4. http://blog.chinaunix.net/u1/34474/showart.php?id=460882
2009年9月2日 星期三
* busybox : /bin/sh : app not found
後來發現需要copy tools chain /lib 和 /libc to embedded root file system 當中
* How to build busybox
#make menuconfig ARCH=arm CROSS_COMPILE=arm-none-linux-
Select
Location:
x -> Busybox Settings
x -> Build Options
x -> Build shared libbusybox (BUILD_LIBBUSYBOX [=y])
#make ARCH=arm CROSS_COMPILE=arm-none-linux-
#make install ARCH=arm CROSS_COMPILE=arm-none-linux-
Then, copy them into system rootfs
#sudo cp -dpR _install/* /work/nfs
*Create rootfs
#mkdir bin dev etc home lib mnt proc root sbin tmp usr var sys
#mkdir usr/bin usr/sbin
# mkdir mnt tmp var
# chmod 1777 tmp
# mkdir var/lib var/lock var/log var/run var/tmp
# chmod 1777 var/tmp
*make device node
./dev
#sudo mknod -m 600 dev/console c 5 1
#sudo mknod -m 666 dev/null c 1 3
* Create /etc/init.d/rcS
* Copy toolchain libc......xxx files into /lib in rootfs
ld-2.5.so libc.so.6 libgcc_s.so.1 libnss_dns-2.5.so
libnss_nisplus-2.5.so librt.so.1 ld-linux.so.3 libcidn-2.5.so
libm-2.5.so libnss_dns.so.2 libnss_nisplus.so.2 libthread_db-1.0.so libBrokenLocale-2.5.so libcidn.so.1 libm.so.6 libnss_files-2.5.so libpcprofile.so libthread_db.so.1 libBrokenLocale.so.1 libcrypt-2.5.so libmemusage.so libnss_files.so.2 libpthread-2.5.so libutil-2.5.so libSegFault.so libcrypt.so.1 libnsl-2.5.so libnss_hesiod-2.5.so libpthread.so.0 libutil.so.1 libanl-2.5.so libdl-2.5.so libnsl.so.1 libnss_hesiod.so.2 libresolv-2.5.so libanl.so.1 libdl.so.2 libnss_compat-2.5.so libnss_nis-2.5.so libresolv.so.2 libc-2.5.so libgcc_s.so libnss_compat.so.2 libnss_nis.so.2 librt-2.5.so
*Change busybox mode
#chmod 4755 ./bin/buxybox
之前遇到兩個問題
1. busybox : -/bin/sh :app not found
2. init= not found when using Build shared libbusybox configuration
結果都是需要 copy toolchain 相關的 ./libxxx.so.x 到 filesystem
弄了好幾天才搞定ㄟ
reference:
http://www.lupaworld.com/home/space-345712-do-blog-id-128444.html
http://blog.chinaunix.net/u2/70445/showart_1150301.html2009年8月28日 星期五
* ubuntu mplayer using fbdev
#mplayer -vo help
#mplayer -vo fbdev /media/sda7/else/lian.flv
#mplayer -vo fbdev -vf scale=1024:768 video_file.avi
-vo fbdev 是告诉mplayer用framebuffer作视频驱动.
-vf scale=1024:768 是全屏的方法,可按屏幕的具体情况作调整
用fbxine的话需要下载:
# apt-get install xine-console
picture
# apt-get install fbi
用这个软件包里的fbi可以浏览图片,fbgs可以观看pdf文件:
# fbi -a *jpg
# fbgs -c *pdf
2009年8月27日 星期四
* ubuntu command "mksquashfs"
#mksquashfs . /scratchbox.squashfs -b 65536
#mkdir scratchbox.base
//only for test,this is base layer and squashfs only support read mode
#mount -t squashfs -oloop scratchbox.squashfs scratchbox.base/
#mkdir scratchbox.changes
#mkdir scratchbox
#mount -t aufs -o dirs=scratchbox.changes/=rw:scratchbox.base/=rr aufs /scratchbox
//if you want to automount while bootup linux,then you need to edit /etc/fstab
------------------------------------------------------------------------------
mount squashfs
And, make sure you are root
#mount -t squashfs -o loop /scratchbox.squashfs /scratchbox.base/
#mount -t aufs -o dirs=/scratchbox.changes/=rw:/scratchbox.base/=rr aufs /scratchbox
*ubuntu command "7zip"
Tar file:
#sudo su
#tar -cvf - Adobe | 7za a -t7z -m0=lzma -mx=9 -mfb=64 -md=64m -ms=on -si Adobe.tar.7z
Untar file:
#7za x -so /opt/Adobe.tar.7z | tar -xf -
* ubuntu bash.bashrc setting
Added
----------------------------------------
----------------------------------------
bind 'C-b':backward-word
bind 'C-f':forward-word
bind 'C-w':backward-kill-word
bind '"\x1b\x5b\x41":history-search-backward'
bind '"\x1b\x5b\x42":history-search-forward'
export HISTFILESIZE=10000
export HISTSIZE=10000
---------------------------------------------
2009年8月26日 星期三
*audio driver on linux
1. Audio connection
cpu ===> audio codec ===> MIC or speaker
ex: audio codec : AC97. TI TPS65950
audio codec converts digitial audio to analog sound for playing through speakers
Then, audio codec has "mixer" functionality
2.Linuc sound subsystem
ALSA is the sound subsystem of choice in the 2.6 kernel
Device node : /dev/snd/*
/dev/snd/controlC0 is control node for volume gain
/dev/snd/pcmC0D0p is a playback device, p is playback
/dev/snd/pcmC0D0c is a recording device, c is capture
3. Accessing information via /proc/asound and /sys/class/sound
4. ALSA library : user space alsa library alsa-lib which provides the libasound.so
ALSA utility : alsa-utils, alsamixer, amixer, alsactl , aplay and areocrd
5. Audio driver is build out of three main function
* Playback
* Capture
* Mixer control functions
2009年8月24日 星期一
* ubuntu scp command
scp 來源 目的
將檔案從遠端傳到本機
遠端-->本機
scp username@tohostname:/remotefile /newlocalfile
將檔案從本機傳到遠端
本機 -->遠端
scp localfile username@tohostname:/newfilename
* [ D ] Ubuntu can't use console
Solution:
#cd /etc/event.d/
#cp tty1 ttyS0
Please make sure your console setting by bootargs=console=ttyS0,115200......
Then, edit /etc/event.d/ttyS0
----------------------------------------------------------------------------
#vi /etc/event.d/ttyS0
tart on stopped rc2
start on stopped rc3
start on stopped rc4
start on stopped rc5
stop on runlevel 0
stop on runlevel 1
stop on runlevel 6
console owner
respawn
exec /sbin/getty 115200 ttyS0
----------------------------------------------------------------------------
* ubuntu upstart
http://linux.com/archive/feature/125977
Upstart is an event-based replacement for the
/sbin/init
daemon which handles starting of tasks and services during boot, stopping them during shutdown and supervising them while the system is running.
*Linux ash prompt can't work about PS1='[\u\@\h \W]# '
Symbol: FEATURE_EDITING_FANCY_PROMPT
x Prompt: Fancy shell prompts
x Defined at libbb/Config.in:97
x Depends on: FEATURE_EDITING
x Location:
x -> Busybox Settings
x -> Busybox Library Tuning
x -> Command line editing (FEATURE_EDITING [=y])
Location: x
-> Busybox Settings x
-> Busybox Library Tuning x
-> Command line editing (FEATURE_EDITING [=y])
*build busybox and create rootfs for nfs
#make menuconfig CROSS_COMPILE=arm-none-linux-
#make CROSS_COMPILE=arm-none-linux
#make install CROSS_COMPILE=arm-none-linux
Then, get _intall directory
#cp -rdf _install/* /nfs
Step2: Create nfs rootfs
#mkdir bin dev etc lib proc sbin tmp usr var
#chmod 1777 tmp
#mkdir usr/bin usr/lib usr/sbin
#mkdir var/lib var/lock var/log var/run var/tmp
#chmod 1777 var/tmp
Step3: Create device node
#mknod -m 600 console c 5 1
or you can copy device nodes from your linux system
Step4: Create /etc/init.d/rcS
-------------------------------------------------------------------
Note: When you makemenuconfig,you must take care below:
Busybox Settings >
General Configuration >
[*] Support for devfs
Build Options >
[*] Build BusyBox as a static binary (no shared libs)
[*] Do you want to build BusyBox with a Cross Compiler? (/usr/local/arm/3.3.2/bin/armlinux) Cross Compiler prefix Init Utilities > [*] init [*] Support reading an inittab file Shells > Choose your default shell (ash) >
http://blog.sina.com.cn/s/blog_4570e33b0100dbp5.html~type=v5_one&label=rela_prevarticle
2009年8月21日 星期五
* beagle board format mmc card
#dmesg | tail
get mmcblk0
step2: umount mmc card
#umount /medisk/disk
step3: list mmc
#sudo su -
#fdisk -l /dev/mmcblk0
step4: format mmc card
#sudo ./mmc.sh
--------------------------------------------------------------------------------
#! /bin/sh
MMCDEV="/dev/mmcblk0"
DISKSIZE=`fdisk -l ${MMCDEV} | awk '/[^=] [0-9]+ bytes/{print $5}'`
CYLINDERS=`echo "${DISKSIZE} 255 63 512 **/f" | dc`
/bin/echo -e "p\nn\np\n1\n\n+64M\nn\np\n2\n\n\n\na\n1\nt\n1\nc\np\nw\nq\n" | fdisk -H 255 -S 63 -C ${CYLINDERS} ${MMCDEV}
------------------------------------------------------------------------------
#mkdosfs -F 32 /dev/mmcblk0p1
#mke2fs -j /dev/mmcblk0p2
----------------------------------------------------------------------------------
step5: insert mmc card
#mount
beagleboard format mmc card
#umount /media/disk
step2: list disk and delete disk format
#fdisk -l /dev/mmcblk0
#fdisk /dev/mmcblk0
step3: partition disk
step4: format disk
2009年8月20日 星期四
[ d ] booting from nfs
#setenv netmask 255.255.0.0
#setenv serverip 192.168.1.101
#setenv ipaddr 192.168.1.102
#setenv rootpath /work/nfs
#setenv bootcmd 'tftpboot 0x2000000 $(image_name);setenv bootargs console=ttyS0,115200 root=/dev/nfs nfsroot=$(serverip):$(rootpath) ip=$(ipaddr):$(serverip):::orion:eth0:none usb0Mode=host usb1Mode=host; bootm 0x2000000'
ubuntu 架設 nfs server
$ sudo vi /etc/exports
/work/MVP 192.168.*.*(rw,no_root_squash,nohide,insecure,no_subtree_check,async)
啟動nfs
$/etc/init.d/nfs-kernel-server restart
檢查
$showmount -e
掛載
$mount -t nfs 192.168.xxx.xxx:/work /mnt/nfs
2009年8月19日 星期三
ubuntu 架設 tftp server
安裝TFTP server
修改設定檔/etc/default/tftpd-hpa
RUN_DAEMON="yes"
OPTIONS="-l -c -s /tftpboot"
也修改/etc/inetd.conf
tftp dgram udp wait root /usr/sbin/in.tftpd /usr/sbin/in.tftpd -c -s /tftpboot
參數:
-c 讓client可以修改server內的檔案
-s 指定server的資料夾
重新啟動ttftp server
#sudo /etc/init.d/tftpd-hpa restart
安裝client
#sudo apt-get install tftp
連線到主機去 xxx.xxx.xxx.xxx is ip
tftp xxx.xxx.xxx.xxx
>get xxx
>quit
2009年8月18日 星期二
[w] 測試Webcam
卻無法動作
後來才發現是權限的問題
# ls /dev/video0 -al
crw-rw---- 1 root video 81, 0 Jan 1 00:00 /dev/video0
#sudo su -
# chmod o+rw /dev/video0
或是到 /etc/group 下面加入 yourname on video中
測試方式:
#mplayer -cache 128 -tv driver=v4l2:width=320:height=240:outfmt=i420 -vc rawyuy2 -vo x11 tv://
2009年8月17日 星期一
[w]linux audio 權限問題
根據之前/dev/video0的權限經驗
今天也把audio 權限修改之後就可以看到了
Solution:
vi /etc/group
audio:x:29:pulse,myname
myname是我登入的名稱
How to add user to audio group
#gpasswd -a username audio