Thứ Ba, 10 tháng 5, 2011

Eigenvalue and EigenVector complete

http://www.miislita.com/information-retrieval-tutorial/matrix-tutorial-3-eigenvalues-eigenvectors.html

Thứ Hai, 11 tháng 4, 2011

USB complete

I. A USB peripheral need all of the following
1) Controller chip with usb interface
2) Firmware  in the peripheral to carry out the USB
3) Some hardware and firmware to carry out its other function (processing data, reading input, writing output)
4) Host that support USB
5) Device driver on host that carry out USB Communication

II. Inside USB transfer
We can divide USB transfer into 2 categories:
- Configuring and setting up the device communication
- Application communication

Managing data on the bus
- USB is different from RS232 which has TXT and RXT line separately for sending and receiving. USB has only one data path for transmit
- The host manage traffic by dividing time into chunks call frames or microframes at high speed
  + For low and full speed: frames are 1 milisecond
  + for High speed: each frame is divided into 125 microsecond microframes.

Device Endpoints
- All transmission to or from device endponts
- The Endpoint is buffer that store received data or waiting data to be sent
- Each endpoint has it own unique address which consist of an endpoint number and direction
  + endpoint number may range from 0 to 15
  + direction: IN, OUT (from host's perspective)

Pipes: Connecting Endpoint to the Host
- Before a transfer can occur, the host and device must establish a pipe
- A USB pipe is not a physical objet, it is just connection between device 's endpoint and host's software

Type of Transfers
There are four types of transfer in USB
- Control transfer: enable the host to read information about the device, set a device address... Control transfer may also send custom requests that send and receive data for any purpose. All USB device must support Control transfer
- Bulk Transfer: is intended for situations where the rate of transfer is not critical (not very important), such as sending a file to printer, receiving data from scaner...
- Interrupt Transfer is intended for situations where data transfer periodically. Mouse of keyboard are some example of this transfer typ. Device are not required to support Interrupt Transfer, but some class of device might require it
- Isochronous Transfer: have guaranteed deliver time but no error correcting

Initiating Transfer
- A device driver want to communicate with USB device, it has to establish transfer
- In window, the initialize Transfer process follow following steps:
  + Application using handle in calling an API function for request the transfer from device driver
  + OS then passes the request to the appropriate device driver
  + Device driver then passes this process to other system-level driver and on to host controller
  + The host controller then initiates the transfer on the bus

III. How the host learns Enumeration about the device
- Before applications can communicate with a device, the host need to learn about device and assign a device driver
- The process including:
  + Assigning an address to a device
  + Reading data structure from device
  + Assigning and loading device driver
  + Selecting a configuration from the option represented in the retrieved data

Enumeration steps
1) The user plugs a device into a USB port (powered stage)
2) The hub detects the device
3) The host learns of the new device
4) The hub detects whether a device is low speed or full speed
5) The hub resets the device
6) The host learns if a fall-speed device supports high speed
7) The hub establish a signal path between host and device
8) The host send Get_Descriptor request to learn the maximum packet size of the default pipe
9) The host assigns an address
10) The host learns about device ability
11) The host assigns and loads device driver
12) The host's device driver selects a configuration

Thứ Năm, 31 tháng 3, 2011

Build Linux kernel

Cách thức để build linux kernel cho FriendlyARM kit (chip S3C2440 của samsung, lõi ARM 9)

Phần I. Build Image
1) Down load các file cần thiết, hoặc copy từ trong đĩa cài đi kèm với kit
- Source code linux kernel: linux-2.6.32.2-mini2440-20100921.tar.gz
- Trình biên dịch chéo (tool chain): arm-linux-gcc-4.4.3.tar.gz
- Boot loader: vboot-src-20100727.tar.gz

2) Cài đặt trình biên dịch chéo
b1) Giải nén file: arm-linux-gcc-4.4.3.tar.gz
b2) Add thêm biến môi trường cho user hiện tại
Sửa file: ~/.bashrc thêm dòng sau vào cuối file
export PATH=/yourdir/opt/FriendlyARM/toolschain/4.4.3/bin:$PATH
Trong đó yourdir là đường dẫn đền thư mục chứa arm-linux-gcc

3) Giải nén file: linux-2.6.32.2-mini2440-20100921.tar.gz vào một thư mục nào đó
ví dụ: /home/hiephv/arm-kit
cd /home/hiephv/arm-kit


4) Chạy make menuconfig

Chú ý bước này thường sẽ đọc cấu hình từ file .config (trong thư mục linux-2.6.32.2, file này ban đầu sẽ chưa có gì do chưa chạy lần nào). Tuy nhiên thông thường các hãng sản xuất sẽ có recommend cấu hình cần chọn cho kit và để trong file cấu hình của hãng (ví dụ: config_mini2440_n35, config_mini2440_t35)
Do đó để tiết kiệm thời gian và chính xác: nên copy file cấu hình của hãng vào file .config trước khi chạy make menuconfig

Lưu ý rằng, chương trình ncurses để tạo giao diện cấu hình có thể làm thay đổi
file “.config”. Có thể test thử bằng cách load và save các file config có sẵn và kiểm tra size của file. Việc này có thể/hoặc không gây panic khi chạy kernel.

5)Build kernel image file
# make -j4 ARCH=arm CROSS_COMPILE=<arm_toolchain_folder>/bin/arm-none-
linux-gnueabi- uImage

6) Build kernel modile file
# make -j4 ARCH=arm CROSS_COMPILE=<arm_toolchain_folder>/bin/arm-none-
linux-gnueabi- modules

Phần II. Nạp Image xuống kit
1) Cài đặt môi trường phát triển trên linux cho Friendly ARM kit
- Chương trình debug console: minicom
apt-get install minicom
- Chương trình download dữ liệu xuống kit (usbpush)
Download file thực thi s3c2410_boot_usb từ internet (các file cần down xuống kit để cùng thư mục với file này)