Please choose a “good” MAC address for your testing if you want to change it. In Linux 2.6.24.4, do not use “X1:XX:XX:XX:XX:XX” as your MAC address. It’s not allowed.
The following snippet code is copy from kernel. It explains everything
#include <stdio.h>
#include <stdlib.h>
/* Linux Kernel */
static inline int is_zero_ether_addr(const u_char *addr)
{
return !(addr[0] | addr[1] | addr[2] | addr[3] | addr[4] | addr[5]);
}
static inline int is_multicast_ether_addr(const u_char *addr)
{
return (0x01 & addr[0]);
}
static inline int is_valid_ether_addr(const u_char *addr)
{
return !is_multicast_ether_addr(addr) && !is_zero_ether_addr(addr);
}
int main (int argc, char **argv) {
int ret;
ret = is_valid_ether_addr("11:22:33:44:55:66");
printf("ret = %d\n", ret);; ret = 0, Not a valid MAC address
ret = is_valid_ether_addr("01:22:33:44:55:66");
printf("ret = %d\n", ret);; ret = 0, Not a valid MAC address
ret = is_valid_ether_addr("00:1B:21:11:22:33");
printf("ret = %d\n", ret);; ret = 1, This is a valid MAC address
return;
}
How to prevent to set up the invalud MAC address? Please call "is_valid_ether_addr" in network device driver.
Monday, June 30, 2008
Tuesday, June 24, 2008
Thursday, June 12, 2008
IPTV Week
I plan to study IPTV this week (Night Life)
- IPTV and Internet Video - Focal Press
- Understanding IPTV - Auerbach Publications
- Next Generation IPTV Services and Technologies - Wiley
Wednesday, June 11, 2008
802.1X Port-Based Authentication
Tuesday, June 10, 2008
How to build eCos 2.x toolchain for ARM platform
In Fedora Core 8, Fedora Core 9
* binutils-2.15
* gcc-3.4.3
* newlib-1.12.0
* insight-6.6
1. Pre-Configuration
BASE_DIR=`pwd`
TARGET=arm-elf
2. Download source code
[ ]# wget -P $BASE_DIR/src http://www.gnuarm.com/binutils-2.15.tar.bz2
[ ]# wget -P $BASE_DIR/src http://www.gnuarm.com/gcc-3.4.3.tar.bz2
[ ]# wget -P $BASE_DIR/src http://www.gnuarm.com/newlib-1.12.0.tar.gz
[ ]# wget -P $BASE_DIR/src ftp://sourceware.org/pub/insight/releases/insight-6.6.tar.bz2
3. Pre-Build
[ ]# mkdir -p /opt/gnutools
[ ]# bunzip2 < $BASE_DIR/src/binutils-2.15.tar.bz2 | tar xvf -
[ ]# bunzip2 < $BASE_DIR/src/gcc-3.4.3.tar.bz2 | tar xvf -
[ ]# gunzip < $BASE_DIR/src/newlib-1.12.0.tar.gz | tar xvf -
[ ]# bunzip2 < $BASE_DIR/src/insight-6.6.tar.bz2 | tar xvf -
[ ]# cp -rf newlib-1.12.0/newlib gcc-3.4.3/
[ ]# cp -rf newlib-1.12.0/libgloss gcc-3.4.3/
4. Binutils
[ ]# mkdir -p /tmp/build/binutils
[ ]# cd /tmp/build/binutils
[ ]# $BASE_DIR/binutils-2.15/configure --target=$TARGET --prefix=/opt/gnutools \
-v 2>&1 | tee configure.out
[ ]# make -w all install 2>&1 | tee make.out
5. GCC
[ ]# PATH=/opt/gnutools/bin:$PATH ; export PATH
[ ]# mkdir -p /tmp/build/gcc
[ ]# cd /tmp/build/gcc
[ ]# $BASE_DIR/gcc-3.4.3/configure --target=$TARGET --prefix=/opt/gnutools \
--enable-languages=c,c++ --with-gnu-as --with-gnu-ld --with-newlib \
--with-gxx-include-dir=/opt/gnutools/$TARGET/include \
-v 2>&1 | tee configure.out
[ ]# make -w all install 2>&1 | tee make.out
6. GDB
[ ]# mkdir -p /tmp/build/gdb
[ ]# cd /tmp/build/gdb
[ ]# $BASE_DIR/insight-6.6/configure --target=$TARGET --prefix=/opt/gnutools \
-v 2>&1 | tee configure.out
[ ]# make -w all install 2>&1 | tee make.out
7. Post-Build
* Clean
[ ]# rm -rf /tmp/build/
* Change PATH environment variable (Edit /root/.bash_profile file)
PATH=$PATH:$HOME/bin
# Toolchain for ARM-eCos platform
PATH=/opt/gnutools/bin:$PATH
export PATH
* Effect the change
That's all. Here is the script file. Enjoy!
You can also download the complete source tarball (84MB).
* binutils-2.15
* gcc-3.4.3
* newlib-1.12.0
* insight-6.6
1. Pre-Configuration
BASE_DIR=`pwd`
TARGET=arm-elf
2. Download source code
[ ]# wget -P $BASE_DIR/src http://www.gnuarm.com/binutils-2.15.tar.bz2
[ ]# wget -P $BASE_DIR/src http://www.gnuarm.com/gcc-3.4.3.tar.bz2
[ ]# wget -P $BASE_DIR/src http://www.gnuarm.com/newlib-1.12.0.tar.gz
[ ]# wget -P $BASE_DIR/src ftp://sourceware.org/pub/insight/releases/insight-6.6.tar.bz2
3. Pre-Build
[ ]# mkdir -p /opt/gnutools
[ ]# bunzip2 < $BASE_DIR/src/binutils-2.15.tar.bz2 | tar xvf -
[ ]# bunzip2 < $BASE_DIR/src/gcc-3.4.3.tar.bz2 | tar xvf -
[ ]# gunzip < $BASE_DIR/src/newlib-1.12.0.tar.gz | tar xvf -
[ ]# bunzip2 < $BASE_DIR/src/insight-6.6.tar.bz2 | tar xvf -
[ ]# cp -rf newlib-1.12.0/newlib gcc-3.4.3/
[ ]# cp -rf newlib-1.12.0/libgloss gcc-3.4.3/
4. Binutils
[ ]# mkdir -p /tmp/build/binutils
[ ]# cd /tmp/build/binutils
[ ]# $BASE_DIR/binutils-2.15/configure --target=$TARGET --prefix=/opt/gnutools \
-v 2>&1 | tee configure.out
[ ]# make -w all install 2>&1 | tee make.out
5. GCC
[ ]# PATH=/opt/gnutools/bin:$PATH ; export PATH
[ ]# mkdir -p /tmp/build/gcc
[ ]# cd /tmp/build/gcc
[ ]# $BASE_DIR/gcc-3.4.3/configure --target=$TARGET --prefix=/opt/gnutools \
--enable-languages=c,c++ --with-gnu-as --with-gnu-ld --with-newlib \
--with-gxx-include-dir=/opt/gnutools/$TARGET/include \
-v 2>&1 | tee configure.out
[ ]# make -w all install 2>&1 | tee make.out
6. GDB
[ ]# mkdir -p /tmp/build/gdb
[ ]# cd /tmp/build/gdb
[ ]# $BASE_DIR/insight-6.6/configure --target=$TARGET --prefix=/opt/gnutools \
-v 2>&1 | tee configure.out
[ ]# make -w all install 2>&1 | tee make.out
7. Post-Build
* Clean
[ ]# rm -rf /tmp/build/
* Change PATH environment variable (Edit /root/.bash_profile file)
PATH=$PATH:$HOME/bin
# Toolchain for ARM-eCos platform
PATH=/opt/gnutools/bin:$PATH
export PATH
* Effect the change
That's all. Here is the script file. Enjoy!
You can also download the complete source tarball (84MB).
Friday, June 6, 2008
eCos
eCos
Changelog
1998.11 - eCos 1.1, Cygnus Solutions
1999.05 - eCos 1.2
1999.11 - Cygnus Solutions was acquired by Red Hat
2000.03 - eCos 1.3, Red Hat
2003.05 - eCos 2.0, eCosCentric Original members of eCos team formed eCosCentric Limited in Cambridge.
2004 - I first met eCos
2008 - I second met eCos. Next assigned task is porting the eCos to a new ARM9 processor.
Changelog
1998.11 - eCos 1.1, Cygnus Solutions
1999.05 - eCos 1.2
1999.11 - Cygnus Solutions was acquired by Red Hat
2000.03 - eCos 1.3, Red Hat
2003.05 - eCos 2.0, eCosCentric Original members of eCos team formed eCosCentric Limited in Cambridge.
2004 - I first met eCos
2008 - I second met eCos. Next assigned task is porting the eCos to a new ARM9 processor.
Some useful tools for creating a bootable USB flash drive
Wednesday, June 4, 2008
Diff and Patch
發佈原始碼更新最常使用的工具是 patch 和 diff. 一開始建立兩個內容一樣的目錄“original directory”和“working directory”,然後在“working directory”中加上我們的修改。例如:
[]$ tar zxvf linux-2.6.24.tar.gz
[]$ mv linux linux-2.6.24-orig
[]$ tar zxvf linux-2.6.24.tar.gz
[]$ mv linux linux-2.6.24
在linux-2.6.24 目錄下修改。完成後利用下列指令來產生修補檔。
$ diff -Naur -X dontdiff linux-2.6.24-orig linux-2.6.24 > kernel.patch
Other instructions:
[]$ cd linux-2.6.24-orig
[]$ patch -p1 < ../2.6.25.patch
[]$ cd ..
[]$ mv linux-2.6.24-orig linux-2.6.25
[]$ cd linux-2.6.24
[]$ patch -p1 -R < ../kernel.patch
[]$ patch -p1 < ../2.6.25.patch
[]$ cd ..
[]$ mv linux-2.6.24 linux-2.6.25
[]$ cd linux-2.6.25
[]$ patch -p1 < ../kernel.patch
[]$ tar zxvf linux-2.6.24.tar.gz
[]$ mv linux linux-2.6.24-orig
[]$ tar zxvf linux-2.6.24.tar.gz
[]$ mv linux linux-2.6.24
在linux-2.6.24 目錄下修改。完成後利用下列指令來產生修補檔。
$ diff -Naur -X dontdiff linux-2.6.24-orig linux-2.6.24 > kernel.patch
Other instructions:
[]$ cd linux-2.6.24-orig
[]$ patch -p1 < ../2.6.25.patch
[]$ cd ..
[]$ mv linux-2.6.24-orig linux-2.6.25
[]$ cd linux-2.6.24
[]$ patch -p1 -R < ../kernel.patch
[]$ patch -p1 < ../2.6.25.patch
[]$ cd ..
[]$ mv linux-2.6.24 linux-2.6.25
[]$ cd linux-2.6.25
[]$ patch -p1 < ../kernel.patch
Tuesday, June 3, 2008
eCos books
1. Embedded Software Development with eCos
Download PDF
Download Source Code
2. Programming Embedded Systems: With C and GNU Development Tools, 2nd Edition
Monday, June 2, 2008
Build Linux Kernel/Module in Fedora Core 9
# Build Linux Kernel
[ ]# yum install yum-utils
[ ]# yumdownloader --source kernel
# Download Linux Kernel Source RPM
[ ]# yum install kernel-headers
# Install Linux Kernel source and patch files to "/usr/src/redhat/SOURCES/"
[ ]# rpm -ivh kernel-2.6.25.3-18.fc9.src.rpm
# Prepare to build Linux Kernel
[ ]# cd /usr/src/redhat/SPECS
[ ]# rpmbuild -bp --target=i686 kernel.spec
[ ]# cd ../BUILD/kernel-2.6.25/linux-2.6.25.i686/
[ ]# cp configs/kernel-2.6.25.3-i686.config .config
# Edit "EXTRAVERSION" in "/usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/Makefile" file
# (example)
-EXTRAVERSION = .3
+EXTRAVERSION = .3-18.fc9.i686
# Build Linux Kernel
[ ]# make
[ ]# make modules
[ ]# make modules_install
[ ]# make install
# Check "GRUB" configuration file "/etc/grub.conf"
# (example)
+title Fedora (2.6.25.3-18.fc9.i686)
+ root (hd0,1)
+ kernel /vmlinuz-2.6.25.3-18.fc9.i686 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
+ initrd /initrd-2.6.25.3-18.fc9.i686.img
# reboot.
# Check Linux Kernel Version
[ ]# uname -a
# Compile module - via-rhine NIC
(example)
1. via-rhine.c
2. Makefile
============================================================
ifneq ($(KERNELRELEASE),)
obj-m := via-rhine.o
else
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
rm -r -f .tmp_versions *.mod.c .*.cmd *.o *.symvers
endif
clean:
rm -rf via-rhine.ko
============================================================
3. [ ]# make
# Install module
4. [ ]# insmod via-rhine.ko
# Remove module
5. [ ]# rmmod via-rhine
Troubleshot
1Q:
[ ]# insmod via-rhine.ko
insmod: error inserting 'via-rhine.ko': -1 Unknown symbol in module
1A:
1A.1 - Check module dependence
[ ]# modinfo via-rhine.ko
filename: via-rhine.ko
license: GPL
description: VIA Rhine PCI Fast Ethernet driver
author: Donald Becker
srcversion: 8158094F4B64FDC36073DA7
alias: pci:v00001106d00003053sv*sd*bc*sc*i*
alias: pci:v00001106d00003106sv*sd*bc*sc*i*
alias: pci:v00001106d00003065sv*sd*bc*sc*i*
alias: pci:v00001106d00003043sv*sd*bc*sc*i*
depends: mii
vermagic: 2.6.25.3-18.fc9.i686 SMP mod_unload 686 4KSTACKS
parm: max_interrupt_work:VIA Rhine maximum events handled per interrupt (int)
parm: debug:VIA Rhine debug level (0-7) (int)
parm: rx_copybreak:VIA Rhine copy breakpoint for copy-only-tiny-frames (int)
parm: avoid_D3:Avoid power state D3 (work-around for broken BIOSes) (bool)
1A.2 - Check "depends" field for other modules
[ ]# insmod /lib/modules/2.6.25.3-18.fc9.i686/kernel/drivers/net/mii.ko
[ ]# insmod via-rhine.ko
Download Sample Code
Great site: http://www.mjmwired.net/resources/mjm-fedora-f8.html
[ ]# yum install yum-utils
[ ]# yumdownloader --source kernel
# Download Linux Kernel Source RPM
[ ]# yum install kernel-headers
# Install Linux Kernel source and patch files to "/usr/src/redhat/SOURCES/"
[ ]# rpm -ivh kernel-2.6.25.3-18.fc9.src.rpm
# Prepare to build Linux Kernel
[ ]# cd /usr/src/redhat/SPECS
[ ]# rpmbuild -bp --target=i686 kernel.spec
[ ]# cd ../BUILD/kernel-2.6.25/linux-2.6.25.i686/
[ ]# cp configs/kernel-2.6.25.3-i686.config .config
# Edit "EXTRAVERSION" in "/usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/Makefile" file
# (example)
-EXTRAVERSION = .3
+EXTRAVERSION = .3-18.fc9.i686
# Build Linux Kernel
[ ]# make
[ ]# make modules
[ ]# make modules_install
[ ]# make install
# Check "GRUB" configuration file "/etc/grub.conf"
# (example)
+title Fedora (2.6.25.3-18.fc9.i686)
+ root (hd0,1)
+ kernel /vmlinuz-2.6.25.3-18.fc9.i686 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
+ initrd /initrd-2.6.25.3-18.fc9.i686.img
# reboot.
# Check Linux Kernel Version
[ ]# uname -a
# Compile module - via-rhine NIC
(example)
1. via-rhine.c
2. Makefile
============================================================
ifneq ($(KERNELRELEASE),)
obj-m := via-rhine.o
else
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
rm -r -f .tmp_versions *.mod.c .*.cmd *.o *.symvers
endif
clean:
rm -rf via-rhine.ko
============================================================
3. [ ]# make
# Install module
4. [ ]# insmod via-rhine.ko
# Remove module
5. [ ]# rmmod via-rhine
Troubleshot
1Q:
[ ]# insmod via-rhine.ko
insmod: error inserting 'via-rhine.ko': -1 Unknown symbol in module
1A:
1A.1 - Check module dependence
[ ]# modinfo via-rhine.ko
filename: via-rhine.ko
license: GPL
description: VIA Rhine PCI Fast Ethernet driver
author: Donald Becker
srcversion: 8158094F4B64FDC36073DA7
alias: pci:v00001106d00003053sv*sd*bc*sc*i*
alias: pci:v00001106d00003106sv*sd*bc*sc*i*
alias: pci:v00001106d00003065sv*sd*bc*sc*i*
alias: pci:v00001106d00003043sv*sd*bc*sc*i*
depends: mii
vermagic: 2.6.25.3-18.fc9.i686 SMP mod_unload 686 4KSTACKS
parm: max_interrupt_work:VIA Rhine maximum events handled per interrupt (int)
parm: debug:VIA Rhine debug level (0-7) (int)
parm: rx_copybreak:VIA Rhine copy breakpoint for copy-only-tiny-frames (int)
parm: avoid_D3:Avoid power state D3 (work-around for broken BIOSes) (bool)
1A.2 - Check "depends" field for other modules
[ ]# insmod /lib/modules/2.6.25.3-18.fc9.i686/kernel/drivers/net/mii.ko
[ ]# insmod via-rhine.ko
Download Sample Code
Great site: http://www.mjmwired.net/resources/mjm-fedora-f8.html
Subscribe to:
Posts (Atom)