Monday, March 28, 2011

How to debug new Linux kernel (2.6.38) using Eclipse Helios and Qemu

(1) Make sure you have the latest QEMU from its official website and install SDL (Simple Directmedia Layer) and Eclipse Helios CDT package from Eclipse website.
(2) refer to the post
http://issaris.blogspot.com/2007/12/download-linux-kernel-sourcecode-from.html
for basic setup.


Below are specific to Eclipse Helios (different from the post above):
(3) ON the menu "Run -> Debug configurations", double-click "C/C++ Application", on the right panel, make sure you got a name for this configuration. Then on the "Main" tab, click "Search project" and select "vmlinux", then NOTE: under the "vmlinux" subcategory, select the one that is NOT compressed, i.e., select "root_project_directory/vmlinux" NOT "root_project_directory/arch/x86/boot/compressed/vmlinux".

(4) Note that at the bottom of the "Main" tab, just above the "apply" and "revert" bottons, there is "Using GDB(DSF) create process launcher-select other..". We want to use another launcher because this GDB(DSF) one doesn't come with TCP connectivity. So click on "select other..", then tick "Use configuration specific setting" enabling the selection list below, then select "Standard create process launcher", then click "OK" to dismiss the "Select Preferred Launcher" dialog.

(5) Back to "Debug Configurations" dialog, click the "Debugger" tab, underneath it you will find the desired "Debugger" drawdown list, go with the post above and select "gdbserver", then pick your "Stop on startup at" (start_kernel in the post), click the "Connection", fill in "TCP", "1234", etc..then "Apply", "Close" the dialog.
(NOTE that here you have to disable the autobuild feature before debug of Eclipse. Else the debugger will NOT successfully stop execution at start_kernel(). The reason is: you first start Qemu to let the execution hang at the start point, then you turn to Eclipse to start the debugger. If you enable "autobuild", then when you try to start debugger, it will rebuild everything and the bzImage that you used to start Qemu will be replaced. That I guess will mess up the debugger. I notice this when Qemu seems to reload the kernel and flash the screen when the debugger is started)
(6) The rest steps are the same as the post. Enjoy, I know I'm thrilled..

Sunday, March 27, 2011

How to create a Linux Debian File System

(1) dd if=/dev/zero of=output.img bs=1M count=4096 //create 4G empty file
(2) mkfs -t ext4 output.img
(3) mount -o loop output.img /mnt/mount_point
(4) debootstrap sid /mnt/mount_point http://ftp.us.debian.org/debian/
(5) chroot /mnt/mount_point
(6) passwd root
(7) umount /mnt/mount_point

Using kernel and file system in QEMU

If prefer to using kernel and file system separately in QEMU, get an disk img ready and use:

qemu -hda disk.img -kernel your_kernel -append "root=/dev/sda"

work with QEMU Linux-0.2.img and 2.6.38.1 kernel

Saturday, March 26, 2011

AT&T T-Mobile Merger

This merger just reminds me of the Chinese market where China Mobile and Unicom are the only two companies that offer wireless services (later China Telecom struggled to blend in). And all Chinese customers pay ridiculously high fee for every wireless service. Cannot believe this kind of thing will ever happen in the USA.

Wednesday, March 23, 2011

How to add google code as Maven remote repository

onejar-maven-plugin.googlecode.com

http://onejar-maven-plugin.googlecode.com/svn/mavenrepo

Tuesday, March 8, 2011

Set environment variable for sudo in Ubuntu

(1) edit /etc/environment
(2) edit /etc/bash.bashrc
(3) use sudo -E to use the user's variables