2009年9月6日 星期日

* Audio: I2S and Linux sound system

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月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

* mount usbfs

#mount -t usbfs usbfs /proc/bus/usb/
#cat /proc/bus/usb/devices

2009年9月2日 星期三

* busybox : /bin/sh : app not found

建立好的Busybox,我build 其他的application(alsa-utils) 出現 -/bin/sh : aplay 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.html

* Linux From Scratch, uclibc

Linux From scratch
http://www.linuxfromscratch.org/

uclibc
http://www.uclibc.org/FAQ.html