Thursday, February 22, 2007

How to test Null-modem serial cable

[machine A ]--------Null-Modem Serial Cable -------[ machine B ]


1. Set serial line in and out speed in both machine A and B
stty ispeed 115200 ospeed 115200 -F /dev/ttyS0

2. Send a sample file to machine B from machine A
cat testfile.txt > /dev/ttyS0

3. Receive the sample file in machine B from machine A
cat /dev/ttyS0

Wednesday, February 21, 2007

How to Setup KGDB

[Developemnt machine]--Null-Modem Serial Cable --[ target machine ]

1. connect target and development machine using Null-Modem Cable

2. kernel should be compiled for kgdb (kernel gdb) support. Either we can compile the kernel in the target machine itself or cross compile in the development system

3. If compiled in the target machine then copy the vmlinux and source code to development machine.

4. If compiled in the development machine then copy the bzImage to target system /boot directory and update the boot loader

5. Include the following kernel command line option "kgdbwait kgdb8250=0,115200" in the target kernel option

6. After booting, the target machine will wait for the host development machine to connect, by displaying the message :- Waiting for connection from remote gdb...

7. In the development machine,

root# gdb vmlinux

(gdb) shell echo -e "\003" > /dev/ttyS0
(gdb) set remotebaud 115200
(gdb) target remote /dev/ttyS0
Remote debugging using /dev/ttyS0
breakpoint () at kernel/kgdb.c:1212
1212 atomic_set(&kgdb_setting_breakpoint, 0);
warning: shared library handler failed to enable breakpoint
(gdb)

8. Give c "continue" (gdb) to boot the target machine.

9. If any crash in the target system then (gdb) in the development machine will break and using bt (back trace) you can get the exact kernel crash location

Redhat Kernel Compilation

1. Copy kernel source to your custom source
cp -R /usr/src/linux-2.4.x/ /usr/src/linux-2.4.xcustom/

2. Open /usr/src/linux-2.4.xcustom/Makefile and append "custom" to EXTRAVERSION

3. Remove already existing kernel compiled files
make mrproper

4. copy existing config file to /usr/src/linux-2.4.xcustom/
cp /boot/config-2.4.x /usr/src/linux-2.4.xcustom/.config

5. Do required changes in the existing configuration by menuconfig
make menuconfig

6. Do dependency compilation
make dep

7. Do kernel image compilation
make bzImage

8. Do kernel module compilation
make modules

9. Install kernel modules. This will install new modules in /lib/modules/2.3.xcustom
make modules_install

10. Install kernel images in to /boot directory and also update /etc/grup.conf
make install

new image is /boot/vmlinuz-2.4.xcustom
new initrd is /boot/initrd-2.4.xcustom.img