<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;CEYEQHs_fSp7ImA9WhRRFEk.&quot;"><id>tag:blogger.com,1999:blog-22080276</id><updated>2011-11-28T06:31:41.545+05:30</updated><category term="make" /><category term="Internet" /><category term="Camera" /><category term="C" /><category term="Shopping" /><category term="kernel" /><category term="Friends" /><category term="Tools" /><category term="Embedded Arm LPC1768 JTAG" /><category term="Ace" /><category term="Router NAS Linux" /><category term="Tips" /><category term="Windows" /><category term="Softwares" /><category term="Programming" /><title>Sam's Web Log</title><subtitle type="html">Here I log some of the technical things that I come across.</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://samueldotj.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://samueldotj.blogspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Samuel</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://3.bp.blogspot.com/_fvvvrkKNkOQ/S3Uq3uF53jI/AAAAAAAAAiw/kEyMmo3OI_c/S220/sam.JPG" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>49</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/blogspot/BCiPY" /><feedburner:info uri="blogspot/bcipy" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;DUQGQXs9cCp7ImA9WhZVFkU.&quot;"><id>tag:blogger.com,1999:blog-22080276.post-288083102394070600</id><published>2011-05-22T18:34:00.002+05:30</published><updated>2011-05-29T22:12:00.568+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-05-29T22:12:00.568+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Embedded Arm LPC1768 JTAG" /><title>OpenOCD and NGX USB ARM JTAG</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-_6DeH7Ilc-w/TdkGI01_Q_I/AAAAAAAAAoA/oE0lsFdiW_0/s1600/usb_jtag.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="240" src="http://1.bp.blogspot.com/-_6DeH7Ilc-w/TdkGI01_Q_I/AAAAAAAAAoA/oE0lsFdiW_0/s320/usb_jtag.jpg" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;This post describes the steps needed to make &lt;a href="http://shop.ngxtechnologies.com/product_info.php?cPath=26&amp;amp;products_id=30"&gt;NGX’s USB ARM JTAG&lt;/a&gt; to work with &lt;a href="http://openocd.berlios.de/web/"&gt;OpenOCD &lt;/a&gt;in windows 7. This &lt;a href="http://en.wikipedia.org/wiki/Joint_Test_Action_Group"&gt;JTAG &lt;/a&gt;is compatible with &lt;a href="http://www.coocox.org/Colink.htm"&gt;colink &lt;/a&gt;JTAG and works with&lt;a href="http://www.iar.com/"&gt; IAR Workbench&lt;/a&gt; and &lt;a href="http://www.keil.com/uvision/"&gt;Keil uVision&lt;/a&gt;. To use with these IDEs there is a well defined methods/plug-ins available in the product page and in internet. However to use this JTAG with OpenOCD there is scarce resource in the internet.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;OpenOCD can be used to low level debugging, source level debugging (through GDB) and can be used for flashing. OpenOCD exposes a command line interface which can be accessed through telnet. It also provides remote GDB server which also can be reached through TCP connection.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;Steps needed for Windows:&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: .5in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-indent: -.25in;"&gt;1)&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Plug-In the JTAG to a available USB connector&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: .5in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-indent: -.25in;"&gt;2)&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Download libusb-win32 from &lt;a href="http://sourceforge.net/projects/libusb-win32/files/"&gt;http://sourceforge.net/projects/libusb-win32/files/&lt;/a&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: .5in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-indent: -.25in;"&gt;3)&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Extract libusb-win32 to a folder and run “inf-wizard.exe”&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: .5in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-indent: -.25in;"&gt;4)&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Select “USB Serial Converter A” and install driver&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: .5in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-indent: -.25in;"&gt;5)&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Download and install openocd from &lt;a href="http://www.freddiechopin.info/index.php/en/download/category/4-openocd"&gt;http://www.freddiechopin.info/index.php/en/download/category/4-openocd&lt;/a&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: .5in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-indent: -.25in;"&gt;6)&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Attach the JTAG probe to your target ARM board and poweron the target board&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: .5in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-indent: -.25in;"&gt;7)&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Create a openocd configurations file (see at the end)&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: .5in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-indent: -.25in;"&gt;8)&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Run openocd.exe –f &lt;file&gt; &lt;/file&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="margin-left: .5in; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-indent: -.25in;"&gt;9)&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Run putty or telnet and connect to port localhost:4444&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;o:p&gt;&lt;br /&gt;
&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;o:p&gt;After this the target board will respond to JTAG commands which can be issued through the telnet session.&lt;/o:p&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;o:p&gt;For GDB debugging, you need a cross compiled GDB which can be downloaded from&amp;nbsp;&lt;/o:p&gt;&lt;a href="http://www.codesourcery.com/sgpp/lite/arm/portal/subscription?@template=lite"&gt;http://www.codesourcery.com/sgpp/lite/arm/portal/subscription?@template=lite&lt;/a&gt;.&lt;/div&gt;&lt;div class="MsoNormal"&gt;After launching&amp;nbsp;arm-none-eabi-gdb.exe run "target remote localhost:3333" to start remote debugging. You can execute low level JTAG commands from GDB by using "monitor &lt;jtag command=""&gt;" command.&lt;/jtag&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class="MsoNormal"&gt;Flashing can be done using the following commands:&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;div class="mycode"&gt;reset&lt;br /&gt;
halt&lt;br /&gt;
sleep 200&lt;br /&gt;
wait_halt&lt;br /&gt;
flash probe 0&lt;br /&gt;
flash info 0&lt;br /&gt;
flash write_image erase unlock &lt;br /&gt;
sleep 200&lt;br /&gt;
reset run&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Open OCD configuration file: &lt;br /&gt;
&lt;br /&gt;
&lt;div class="mycode"&gt;# openocd configurations&lt;br /&gt;
telnet_port 4444&lt;br /&gt;
&lt;br /&gt;
# gdb configuration&lt;br /&gt;
gdb_port 3333&lt;br /&gt;
&lt;br /&gt;
# cpu configuration&lt;br /&gt;
source [find target/lpc1768.cfg]&lt;br /&gt;
&lt;br /&gt;
# interface configuration&lt;br /&gt;
interface ft2232&lt;br /&gt;
ft2232_vid_pid 0x0403 0x6010&lt;br /&gt;
ft2232_device_desc "NGX JTAG"&lt;br /&gt;
ft2232_layout "oocdlink"&lt;br /&gt;
ft2232_latency 2&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/22080276-288083102394070600?l=samueldotj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/XKcE0ymw97CxXpFDBdjMTLr0OCg/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/XKcE0ymw97CxXpFDBdjMTLr0OCg/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/XKcE0ymw97CxXpFDBdjMTLr0OCg/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/XKcE0ymw97CxXpFDBdjMTLr0OCg/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/BCiPY/~4/wtbC3zkU7ho" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://samueldotj.blogspot.com/feeds/288083102394070600/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=22080276&amp;postID=288083102394070600" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/288083102394070600?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/288083102394070600?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/BCiPY/~3/wtbC3zkU7ho/openocd-and-ngx-usb-arm-jtag.html" title="OpenOCD and NGX USB ARM JTAG" /><author><name>Samuel</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://3.bp.blogspot.com/_fvvvrkKNkOQ/S3Uq3uF53jI/AAAAAAAAAiw/kEyMmo3OI_c/S220/sam.JPG" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-_6DeH7Ilc-w/TdkGI01_Q_I/AAAAAAAAAoA/oE0lsFdiW_0/s72-c/usb_jtag.jpg" height="72" width="72" /><thr:total>1</thr:total><feedburner:origLink>http://samueldotj.blogspot.com/2011/05/openocd-and-ngx-usb-arm-jtag.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A04HRH84eyp7ImA9WhZUFkQ.&quot;"><id>tag:blogger.com,1999:blog-22080276.post-1303793687576670374</id><published>2011-03-12T21:13:00.004+05:30</published><updated>2011-06-10T15:28:55.133+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-06-10T15:28:55.133+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Softwares" /><category scheme="http://www.blogger.com/atom/ns#" term="Router NAS Linux" /><title>Wirless Router, Network Storage and Media Server: Software Pieces</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
This is the followup post of &lt;a href="http://samueldotj.blogspot.com/2011/02/how-to-create-your-own-wireless-router.html"&gt;Router/Network Storage Server&lt;/a&gt;. Here I document about the different software used to make my RCN. Here is the different pieces needed.&lt;br /&gt;
&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;&lt;li&gt;Operating System&lt;/li&gt;
&lt;li&gt;Router&lt;/li&gt;
&lt;li&gt;Storage&lt;/li&gt;
&lt;li&gt;Media Server&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Operating System&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
There are two open source choices &lt;a href="http://www.freebsd.org/"&gt;BSD &lt;/a&gt;(FreeBSD) or &lt;a href="http://www.ubuntu.com/"&gt;Linux&lt;/a&gt;(ubuntu). After few days of analysis I decided to go with Linux - because in my work I use FreeBSD. In either case I didnt want to use &lt;a href="http://freenas.org/"&gt;FreeNAS &lt;/a&gt;or &lt;a href="http://www.openfiler.com/"&gt;OpenFiler &lt;/a&gt;or anyother ready made distro. Since I am familiar with Ubuntu - I decided to use it - the &lt;a href="http://www.ubuntu.com/business/server/overview"&gt;Ubuntu server&lt;/a&gt; version.&lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;b&gt;File System&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
Wanted to use &lt;a href="http://en.wikipedia.org/wiki/ZFS"&gt;ZFS &lt;/a&gt;on my main storage disk but it is not available on Linux yet, so decided to go with &lt;a href="http://en.wikipedia.org/wiki/XFS"&gt;XFS&lt;/a&gt;.  EXT3/4 on the boot disk because it is natively supported and no extra package needed. The boot media is 8GB flash disk.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Installation&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
Since there is no optical disk, installation should be through network or USB. Since most of the Linux distributions supports that I decided to use USB.&lt;br /&gt;
&lt;br /&gt;
&lt;ol style="text-align: left;"&gt;&lt;li&gt;&lt;a href="http://www.ubuntu.com/business/get-ubuntu/download"&gt;Download ubuntu 10.10 server&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.pendrivelinux.com/universal-usb-installer-easy-as-1-2-3/"&gt;Download universal USB installer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Create bootable install media using the installer&lt;/li&gt;
&lt;li&gt;Boot the system with boot media - My dual port monitor and wireless keyboards came handy in this situation because I could switch between Windows and Linux installation.&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
&lt;b&gt;Partitions&lt;/b&gt;&lt;br /&gt;
Although no data is going to be stored in the boot media, it would be good to have separate partitions to store the config files and home directory. Otherwise re-installation would wipe out all the data.&lt;br /&gt;
&lt;br /&gt;
I chose to create 5 partitions &lt;br /&gt;
&lt;br /&gt;
&lt;div class="mycode"&gt;/     - EXT4 - 2GB&lt;br /&gt;
/usr  - EXT4 - 2GB &lt;br /&gt;
/var  - EXT4 - 2GB&lt;br /&gt;
/home - EXT4 - 1GB&lt;br /&gt;
swap  -      - 1GB&lt;/div&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Administration&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Since this device will run without any Monitor and Keyboard only way to communicate with the system is through network interface. Having SSH access is good but still having a web interface for common administration access is better. Few Linux applications are available for that my choice is &lt;a href="http://www.webmin.com/"&gt;Webmin&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://www.webmin.com/deb.html"&gt;How to install webmin on Ubuntu&lt;/a&gt;&lt;br /&gt;
&lt;div class="mycode"&gt;sudo vi /etc/apt/sources.list &lt;br /&gt;
wget http://www.webmin.com/jcameron-key.asc &lt;br /&gt;
sudo apt-key add jcameron-key.asc &lt;br /&gt;
sudo apt-get update &lt;br /&gt;
sudo apt-get install webmin &lt;/div&gt;&lt;br /&gt;
After this the machine can be controlled from local network - https://hostname:10000/&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Shutdown&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Shutting down the system should be easy. Since the storage is connected to the system it cant be power off directly. The file system data should be syncd first. Using command line or web interface is not realistic. So programming the ATX power switch is the only way - acpid does that.&lt;br /&gt;
&lt;div class="mycode"&gt;sudo apt-get install acpid&lt;/div&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Storage&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The goal was to create file based storage which is accessible from my home network. The &lt;a href="http://en.wikipedia.org/wiki/Network-attached_storage"&gt;NAS server&lt;/a&gt; should be big enough for atleast next 2 years. It should be fast enough to view videos from it without flickering. It should have hardware fault tolerance. It should have a back up facility.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Space&lt;/b&gt;: 1TB is big enough for me.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Speed&lt;/b&gt;: Each disk has 64MB cache on board which is sufficient to buffer the read/write operations. RAID 1 can fasten read operations by queuing it on different disks(write it cant.Yet to check how Linux implements this.)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Backup&lt;/b&gt;: cron job to write create compressed tars on external disks? Need to explore other better software availability.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Fault Tollernce&lt;/b&gt;: &lt;a href="http://en.wikipedia.org/wiki/RAID"&gt;RAID &lt;/a&gt;(Redundant arrays of inexpensive disks)&lt;br /&gt;
&lt;br /&gt;
Although few of my desktop boards had RAID option in the BIOS menu, I never used it and never explored it.I thought RAID chipsets in a motherboard is equivalent to RAID controllers/adapters. It was one of the decideding factor I favoured for Gigabyte(GA-D425TUD) motherboard with JMicron RAID chipset over Intel(D525MO) motherboard.&lt;br /&gt;
&lt;br /&gt;
After configuring RAID in the BIOS and starting Linux I realized it is not true raid. Because Linux recognized as fakeraid. In simple terms fakeraid is a firmware based RAID. That is all the work is still to be done in software yielding no performance benefit. Advantage of fakeraid is multiple OS which runs on same box can utiltize the same RAID. Since my setup wont have multiboot option, I dont want the fakeraid so decided to go with pure software RAID 0.&lt;br /&gt;
&lt;br /&gt;
&lt;ol style="text-align: left;"&gt;&lt;li&gt;Create software raid using multiple devices(md) interface.&lt;br /&gt;
&lt;b&gt;mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sda /dev/sdb&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;The above command will take some time (around 6 hours) because it needs to sync the contents of both disks. While it is doing that the status can be checked by using the following command&lt;br /&gt;
&lt;b&gt;cat /proc/mdstat&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;Then create a XFS file system on the md device&lt;br /&gt;
&lt;b&gt;mkfs.xfs /dev/md0&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;Store the configuration&lt;br /&gt;
&lt;b&gt;mdadm --detail --scan &amp;gt; /etc/mdadm/mdadm.conf&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;Create mount point and add the mount information in the /etc/fstab&lt;br /&gt;
&lt;b&gt;mkdir /mnt/raid&lt;br /&gt;
echo "/dev/md0        /mnt/raid       xfs     defaults            1       2" &amp;gt;&amp;gt; /etc/fstab&lt;/b&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
After this /mnt/raid can be made accessible to remote machines through either NFS or through Windows File Sharing.&amp;nbsp;For Windows File Sharing&amp;nbsp;&lt;a href="http://www.samba.org/"&gt;samba &lt;/a&gt;service needed to installed&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;sudo apt-get install samba&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Use webmin to configure samba “Servers”-&amp;gt;”Samba File sharing”. Add the storage mount point here.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Router&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The routing functionality is very simple - handle all 3 interfaces with some limitations.&lt;br /&gt;
&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;&lt;li&gt;First interface eth0 is a Gigabit ethernet interface which is directly connected to the a desktop computer.&lt;/li&gt;
&lt;li&gt;Second interface eth1 is a Fast ethernet interface which is directly connected to internet(connected to a ADSL modem).&lt;/li&gt;
&lt;li&gt;Third interface is 802.11n wireless network.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Network and IP&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
All interfaces are in different networks. All interface should get static interface while booting up. This router should provide dynamic IP to the other machines.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href="https://lh5.googleusercontent.com/-HE1OJg_uvlA/TXwcs9Ttn8I/AAAAAAAAAng/SMB6dKi_KYw/s1600/Network.png"&gt;&lt;img border="0" src="https://lh5.googleusercontent.com/-HE1OJg_uvlA/TXwcs9Ttn8I/AAAAAAAAAng/SMB6dKi_KYw/s400/Network.png" /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Modify &lt;b&gt;/etc/network/interface&lt;/b&gt;&lt;br /&gt;
&lt;div class="mycode"&gt;# This file describes the network interfaces available on your system&lt;br /&gt;
# and how to activate them. For more information, see interfaces(5).&lt;br /&gt;
&lt;br /&gt;
# The loopback network interface&lt;br /&gt;
auto lo&lt;br /&gt;
iface lo inet loopback&lt;br /&gt;
&lt;br /&gt;
# The primary network interface&lt;br /&gt;
auto eth0&lt;br /&gt;
iface eth0 inet static&lt;br /&gt;
address 192.168.1.2&lt;br /&gt;
netmask 255.255.255.0&lt;br /&gt;
gateway 192.168.100.2&lt;br /&gt;
post-up iptables-restore &amp;lt; /etc/iptables.up.rules&lt;br /&gt;
up /etc/init.d/dhcp3-server start&lt;br /&gt;
&lt;br /&gt;
#wireless network&lt;br /&gt;
auto wlan0&lt;br /&gt;
iface wlan0 inet static&lt;br /&gt;
address 192.168.2.1&lt;br /&gt;
netmask 255.255.255.0&lt;br /&gt;
gateway 192.168.100.2&lt;br /&gt;
up /etc/init.d/dhcp3-server start&lt;br /&gt;
&lt;br /&gt;
#wan interface&lt;br /&gt;
auto eth1&lt;br /&gt;
iface eth1 inet static&lt;br /&gt;
address 192.168.100.2&lt;br /&gt;
netmask 255.255.255.0&lt;br /&gt;
gateway 192.168.100.1&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Modify&lt;b&gt; /etc/dhcp3/dhcpd.conf&lt;/b&gt;&lt;br /&gt;
&lt;div class="mycode"&gt;subnet 192.168.1.0 netmask 255.255.255.0 {&lt;br /&gt;
range 192.168.1.100 192.168.1.200;&lt;br /&gt;
option domain-name-servers 208.67.222.222, 208.67.220.220;&lt;br /&gt;
option routers 192.168.1.2;&lt;br /&gt;
option broadcast-address 192.168.1.255;&lt;br /&gt;
default-lease-time 600;&lt;br /&gt;
max-lease-time 7200;&lt;br /&gt;
}&lt;br /&gt;
subnet 192.168.2.0 netmask 255.255.255.0 {&lt;br /&gt;
range 192.168.2.100 192.168.2.200;&lt;br /&gt;
option domain-name-servers 208.67.222.222, 208.67.220.220;&lt;br /&gt;
option routers 192.168.2.1;&lt;br /&gt;
option broadcast-address 192.168.2.255;&lt;br /&gt;
default-lease-time 600;&lt;br /&gt;
max-lease-time 7200;&lt;br /&gt;
}&lt;/div&gt;&lt;br /&gt;
Finally enable forwarding in Linux kernel by setting the system tunable "/proc/sys/net/ipv4/ip_forward" to 1&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
To set it during boot set it in &lt;b&gt;/etc/sysctl.conf&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Still few work is pending to make the desktop to connect to network - &lt;b&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;NAT and Firewall.&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://en.wikipedia.org/wiki/Network_address_translation"&gt;NAT - Network Address Translation&lt;/a&gt;&lt;br /&gt;
NAT is required on eth1 to translate addresses on any outgoing packets and incoming packets. &lt;br /&gt;
&lt;div class="mycode"&gt;INTIF="eth0"&lt;br /&gt;
EXTIF="eth1"&lt;br /&gt;
&lt;br /&gt;
#set default polices and flush&lt;br /&gt;
iptables -P INPUT ACCEPT&lt;br /&gt;
iptables -F INPUT&lt;br /&gt;
iptables -P OUTPUT ACCEPT&lt;br /&gt;
iptables -F OUTPUT&lt;br /&gt;
iptables -P FORWARD DROP&lt;br /&gt;
iptables -F FORWARD&lt;br /&gt;
#setup NAT&lt;br /&gt;
iptables -t nat -F&lt;br /&gt;
iptables -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE&lt;br /&gt;
&lt;br /&gt;
iptables -A FORWARD -i $EXTIF -o $INTIF -m state --state ESTABLISHED,RELATED -j ACCEPT&lt;br /&gt;
iptables -A FORWARD -i $INTIF -o $EXTIF -j ACCEPT&lt;br /&gt;
&lt;br /&gt;
INTIF1="wlan0"&lt;br /&gt;
iptables -A FORWARD -i $EXTIF -o $INTIF1 -m state --state ESTABLISHED,RELATED -j ACCEPT&lt;br /&gt;
iptables -A FORWARD -i $INTIF1 -o $EXTIF -j ACCEPT&lt;br /&gt;
&lt;br /&gt;
iptables -A FORWARD -i $INTIF -o $INTIF1 -j ACCEPT&lt;br /&gt;
iptables -A FORWARD -i $INTIF1 -o $INTIF -j ACCEPT&lt;br /&gt;
&lt;br /&gt;
#unblock certain services&lt;br /&gt;
#webmin&lt;br /&gt;
iptables -A INPUT -p tcp -m tcp --dport 10000 -j ACCEPT&lt;/div&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Wireless&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
Now it is time to setup the wireless interface. Assuming the wireless are drivers are present in the kernel. The other tool requied is &lt;b&gt;hostapd&lt;/b&gt;. hostapd&amp;nbsp;implements IEEE 802.11 access point management.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="mycode"&gt;interface=wlan0&lt;br /&gt;
driver=nl80211&lt;br /&gt;
&lt;br /&gt;
ctrl_interface=/var/run/hostapd&lt;br /&gt;
ctrl_interface_group=0&lt;br /&gt;
&lt;br /&gt;
ssid=rcnap&lt;br /&gt;
hw_mode=g&lt;br /&gt;
channel=11&lt;br /&gt;
&lt;br /&gt;
ieee80211n=1&lt;br /&gt;
#ht_capab=[HT40-][SHORT-GI-40]&lt;br /&gt;
&lt;br /&gt;
wpa_pairwise=TKIP CCMP&lt;br /&gt;
wpa=1&lt;/div&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Media Servers&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
Yet to be filled&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Download  Manager&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;span class="Apple-style-span" style="font-size: small; font-weight: normal;"&gt;Yet to be filled&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/22080276-1303793687576670374?l=samueldotj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/7TtrWo2yhIsFAh7O9CM1hAdRtKo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/7TtrWo2yhIsFAh7O9CM1hAdRtKo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/7TtrWo2yhIsFAh7O9CM1hAdRtKo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/7TtrWo2yhIsFAh7O9CM1hAdRtKo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/BCiPY/~4/jVfA4xuWFpg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://samueldotj.blogspot.com/feeds/1303793687576670374/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=22080276&amp;postID=1303793687576670374" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/1303793687576670374?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/1303793687576670374?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/BCiPY/~3/jVfA4xuWFpg/rcn-software-pieces.html" title="Wirless Router, Network Storage and Media Server: Software Pieces" /><author><name>Samuel</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://3.bp.blogspot.com/_fvvvrkKNkOQ/S3Uq3uF53jI/AAAAAAAAAiw/kEyMmo3OI_c/S220/sam.JPG" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://lh5.googleusercontent.com/-HE1OJg_uvlA/TXwcs9Ttn8I/AAAAAAAAAng/SMB6dKi_KYw/s72-c/Network.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://samueldotj.blogspot.com/2011/03/rcn-software-pieces.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DE8BRnY4eCp7ImA9Wx9UFkQ.&quot;"><id>tag:blogger.com,1999:blog-22080276.post-3552151826736795052</id><published>2011-02-14T20:50:00.000+05:30</published><updated>2011-02-14T20:50:57.830+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-02-14T20:50:57.830+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Router NAS Linux" /><title>How to create your own wireless router, network storage server and media server</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;I have replaced my Buffalo WRT-G54 wireless router with my own custom built router. This blog explains how I did that. I call this device as RCN (Router cum NAS). &lt;br /&gt;
&lt;br /&gt;
To create your own RCN, you need:&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;&lt;li&gt;Hardware&lt;/li&gt;
&lt;li&gt;Software&lt;/li&gt;
&lt;li&gt;Motivation&lt;/li&gt;
&lt;/ul&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;b&gt;  Motivation &lt;/b&gt;&lt;/span&gt;for me was &lt;br /&gt;
&lt;ul style="text-align: left;"&gt;&lt;li&gt;&lt;b&gt;Storage&lt;/b&gt; - I was afraid of storing all my family photos/videos in a single drive. I wanted to have RAID 1 setup.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Power Saving&lt;/b&gt; - I hate running my i5 24x7 to download stuffs.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Media server&lt;/b&gt; – I want to get rid of copying photos/videos/movies on my Play Station 3 before watching it – it spoils the mood.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Exploration&lt;/b&gt; - Fun building new thing.&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;The above list is in reverted priority order. &lt;br /&gt;
&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;b&gt;Hardware&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
I began my hardware hunt 45 days back – it was difficult because of my requirements and availability in Indian Market. &lt;br /&gt;
&lt;br /&gt;
Here is the initial requirement list (strikethrough indicates I gave up that requirement because the items are too costly or not available in India): &lt;br /&gt;
&lt;ul style="text-align: left;"&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;Total board TDP should be less than 40watts&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;&lt;s&gt;Passively cooled&lt;/s&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;Mini-ITX form factor&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;Onboard RAID is preferred&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;DDR3 support is preferred&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;s&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;Dual core&lt;/span&gt;&lt;/s&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;Hardware should be available in India&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;s&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;Should be less than Rs.10K&amp;nbsp;&lt;/span&gt;&lt;/s&gt;&lt;/li&gt;
&lt;/ul&gt;Here is the final products I purchased:&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="color: #351c75;"&gt;&lt;a href="http://www.gigabyte.com/products/product-page.aspx?pid=3550#ov"&gt;Gigabyte GA-D425TUD&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class="Apple-style-span" style="color: #351c75;"&gt;&lt;a href="http://iball.co.in/Product.aspx?c=5"&gt;iBall Baby 306&lt;/a&gt; Cabinet&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class="Apple-style-span" style="color: #351c75;"&gt;DDR-3 2GB RAM&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class="Apple-style-span" style="color: #351c75;"&gt;2 x 1TB Western Digital &lt;a href="http://www.wdc.com/en/products/products.aspx?id=120"&gt;WD10EARS&lt;/a&gt; SATA&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class="Apple-style-span" style="color: #351c75;"&gt;USB to Ethernet&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class="Apple-style-span" style="color: #351c75;"&gt;USB Flash Drive&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class="Apple-style-span" style="color: #351c75;"&gt;PCI Wifi Adapter &lt;a href="http://www.dlink.com/products/?pid=531"&gt;DLink 552 Xtreme N&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;Here is some pictures of my RCN (Ignore the fancy cabling)&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-cDOgnjxRDjs/TVlEFHeduGI/AAAAAAAAAm8/dRd3w3qDHNw/s1600/RCN+006.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="212" src="http://3.bp.blogspot.com/-cDOgnjxRDjs/TVlEFHeduGI/AAAAAAAAAm8/dRd3w3qDHNw/s320/RCN+006.JPG" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Mini-ITX board - I didnt expect this board to be so small - Compare it with the building set block&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-M6M5yp_SUU4/TVlEHY9KkaI/AAAAAAAAAnA/asIPV44mMSY/s1600/RCN+007.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="213" src="http://4.bp.blogspot.com/-M6M5yp_SUU4/TVlEHY9KkaI/AAAAAAAAAnA/asIPV44mMSY/s320/RCN+007.JPG" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;I got two noisy fans with this cabinet - I yet to shutdown and close the holes&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-L_9YX5n9lRg/TVlELODaULI/AAAAAAAAAnI/WbnaHFDuZOo/s1600/RCN+010.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="213" src="http://3.bp.blogspot.com/-L_9YX5n9lRg/TVlELODaULI/AAAAAAAAAnI/WbnaHFDuZOo/s320/RCN+010.JPG" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-kvVU9HX8bIQ/TVlEM8VfvAI/AAAAAAAAAnM/5v7zrSktN5M/s1600/RCN+012.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="213" src="http://4.bp.blogspot.com/-kvVU9HX8bIQ/TVlEM8VfvAI/AAAAAAAAAnM/5v7zrSktN5M/s320/RCN+012.JPG" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;After Attaching the Wireless PCI card&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-dDgwoVbxCGU/TVlEPZrzumI/AAAAAAAAAnQ/hPUvuht31O4/s1600/RCN+013.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="213" src="http://1.bp.blogspot.com/-dDgwoVbxCGU/TVlEPZrzumI/AAAAAAAAAnQ/hPUvuht31O4/s320/RCN+013.JPG" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Interesting fact about&amp;nbsp;&lt;a href="http://www.wdc.com/en/products/products.aspx?id=120"&gt;WD10EARS&lt;/a&gt;&amp;nbsp;is it use 4KB sectors instead of the conventional 512byte sectors. Since this is a breakthrough software support is not much there. Looks like these drives perform poor if not partitioned properly - Since my requirement demands creating single partition, I purchased this drive and it performs well.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Will post the software things needed in the next post...&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/22080276-3552151826736795052?l=samueldotj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Yd5ArvtLWHrPRPnRYcAdwWVUklM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Yd5ArvtLWHrPRPnRYcAdwWVUklM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Yd5ArvtLWHrPRPnRYcAdwWVUklM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Yd5ArvtLWHrPRPnRYcAdwWVUklM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/BCiPY/~4/GWJVVnLCAXs" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://samueldotj.blogspot.com/feeds/3552151826736795052/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=22080276&amp;postID=3552151826736795052" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/3552151826736795052?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/3552151826736795052?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/BCiPY/~3/GWJVVnLCAXs/how-to-create-your-own-wireless-router.html" title="How to create your own wireless router, network storage server and media server" /><author><name>Samuel</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://3.bp.blogspot.com/_fvvvrkKNkOQ/S3Uq3uF53jI/AAAAAAAAAiw/kEyMmo3OI_c/S220/sam.JPG" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-cDOgnjxRDjs/TVlEFHeduGI/AAAAAAAAAm8/dRd3w3qDHNw/s72-c/RCN+006.JPG" height="72" width="72" /><thr:total>1</thr:total><feedburner:origLink>http://samueldotj.blogspot.com/2011/02/how-to-create-your-own-wireless-router.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DU4CRnw_fCp7ImA9Wx9UEkk.&quot;"><id>tag:blogger.com,1999:blog-22080276.post-8610478141056044629</id><published>2011-02-09T15:52:00.002+05:30</published><updated>2011-02-09T16:09:27.244+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-02-09T16:09:27.244+05:30</app:edited><title>USB image creation using dd command</title><content type="html">Wrote this post while waiting for a "dd" command to finish USB image creation. So this post is mainly for dd tips.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1) How to create a USB drive clone?&lt;/div&gt;&lt;div&gt;&lt;b&gt;sudo dd of=/dev/xxx if=clone.img&lt;/b&gt;&lt;/div&gt;&lt;div&gt;The output image will be in clone.img. If you want to restore to the original disk or another usb drive use &lt;b&gt;sudo dd if=/dev/xxx of=clone.img&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;2) How to find where my usb drive is attached?&lt;/div&gt;&lt;div&gt;&lt;b&gt;dmesg | less&lt;/b&gt;&lt;/div&gt;&lt;div&gt;This will tell which device name is attached to the usb drive.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;3) How long will it take for a 4GB drive?&lt;/div&gt;&lt;div&gt;Depends on your usb drive transfer rate.&lt;/div&gt;&lt;div&gt;But also depends on the buffer size used by dd, I use &lt;/div&gt;&lt;div&gt;&lt;b&gt;sudo dd of=/dev/xxx if=clone.img bs=10M&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-weight: normal; "&gt;&lt;b&gt;sudo dd if=/dev/xxx of=clone.img bs=10M&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;iostat &lt;/b&gt;will give you the transfer rate of your devices&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;4) Dont know whether dd is dead or not?&lt;/div&gt;&lt;div&gt;If you send USR1 signal to dd it will print the status.&lt;br /&gt;&lt;b&gt;sudo kill -USR1 `pidof dd`&lt;/b&gt;&lt;/div&gt;&lt;div&gt;If you want auto update every 10 sec, try&lt;/div&gt;&lt;div&gt;&lt;b&gt;watch -n 10 sudo kill -USR1 `pidof dd`&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/22080276-8610478141056044629?l=samueldotj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/z4SirfL8guQfq3QMHlmMUpXy_TU/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/z4SirfL8guQfq3QMHlmMUpXy_TU/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/z4SirfL8guQfq3QMHlmMUpXy_TU/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/z4SirfL8guQfq3QMHlmMUpXy_TU/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/BCiPY/~4/dijC6AIBB0M" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://samueldotj.blogspot.com/feeds/8610478141056044629/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=22080276&amp;postID=8610478141056044629" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/8610478141056044629?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/8610478141056044629?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/BCiPY/~3/dijC6AIBB0M/usb-image-creation-using-dd-command.html" title="USB image creation using dd command" /><author><name>Samuel</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://3.bp.blogspot.com/_fvvvrkKNkOQ/S3Uq3uF53jI/AAAAAAAAAiw/kEyMmo3OI_c/S220/sam.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://samueldotj.blogspot.com/2011/02/usb-image-creation-using-dd-command.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUMESX85fSp7ImA9Wx9UE00.&quot;"><id>tag:blogger.com,1999:blog-22080276.post-4745382766646656931</id><published>2010-12-21T20:50:00.005+05:30</published><updated>2011-02-10T08:40:08.125+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-02-10T08:40:08.125+05:30</app:edited><title>PS3 File Conversion(mkv to vob)</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div&gt;PlayStation 3 supports lot of &lt;a href="http://manuals.playstation.net/document/en/ps3/current/video/filetypes.html"&gt;file formats&lt;/a&gt;. However PS3 doesnt play most famous HD files container &lt;a href="http://www.matroska.org/"&gt;mkv&lt;/a&gt;. Another limitation of PS3 is it doesn't support any file system except FAT32. And FAT32 has limitation of &lt;a href="http://www.ntfs.com/ntfs_vs_fat.htm"&gt;4GB&lt;/a&gt; file size. And most of the HD files will easily cross 4GB limit.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;I used to watch HD movies on my PS3 since it is connected to TV and HT; and other movies(which doesnt require special video/audio effects) on my desktop computer. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;So to watch movie in mkv format on PS3, it should be converted to PS3 compatible format(&lt;a href="http://en.wikipedia.org/wiki/VOB"&gt;VOB&lt;/a&gt;) and the output file(s) size should be less than 4GB. For this I have been using &lt;a href="http://www.mkv2vob.com/"&gt;mkv2vob&lt;/a&gt;, this tool transcodes DTS to AC3(if necessary) otherwise just copies video/audio streams to output file which in vob format. It also does good job by splitting the files so that a single file is always &amp;lt;&amp;gt;&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Recently this tool was not able to convert a mkv file, so I have to try different tools. The first tool I tried was&lt;a href="http://www.mediacoderhq.com/"&gt; media coder&lt;/a&gt;; after few trial and errors I was able to convert mkv to vob. However it doesnt have provision for splitting the file. So I went through few forums to find &lt;a href="http://www.videohelp.com/tools/GOTSent"&gt;GOTSent&lt;/a&gt;. It did the job but took lot of time(~15-20min) than mkv2vob.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;After all this, I started watching that movie and realized that particular doesn't have any special effects(audio/video) but needs subtitles; instead of transcoding it again - I just watched it in my computer. Either I should lay cable between my router and PS3 so that&lt;a href="http://ps3mediaserver.blogspot.com/"&gt; PS3 Media Server&lt;/a&gt; or I should develop a wireless router which can communicate at 1G speed. I feel the later more interesting :)&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/22080276-4745382766646656931?l=samueldotj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/4omqgdVY31fBxvPl4C-WoXupbQI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/4omqgdVY31fBxvPl4C-WoXupbQI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/4omqgdVY31fBxvPl4C-WoXupbQI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/4omqgdVY31fBxvPl4C-WoXupbQI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/BCiPY/~4/9Wbi4vfoh-k" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://samueldotj.blogspot.com/feeds/4745382766646656931/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=22080276&amp;postID=4745382766646656931" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/4745382766646656931?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/4745382766646656931?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/BCiPY/~3/9Wbi4vfoh-k/ps3-file-conversionmkv-to-vob.html" title="PS3 File Conversion(mkv to vob)" /><author><name>Samuel</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://3.bp.blogspot.com/_fvvvrkKNkOQ/S3Uq3uF53jI/AAAAAAAAAiw/kEyMmo3OI_c/S220/sam.JPG" /></author><thr:total>1</thr:total><feedburner:origLink>http://samueldotj.blogspot.com/2010/12/ps3-file-conversionmkv-to-vob.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DE4MQ3Y4fip7ImA9Wx9REE0.&quot;"><id>tag:blogger.com,1999:blog-22080276.post-1813697094568603665</id><published>2010-12-10T23:33:00.002+05:30</published><updated>2010-12-11T00:19:42.836+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-12-11T00:19:42.836+05:30</app:edited><title>mount: Invalid Argument</title><content type="html">This post regarding a simple problem which took almost 10 hours to realize my mistake.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I am working on PowerPC FreeBSD system where no harddisk is attached instead USB flash drive is used as storage. I needed to edit file system layout and content extensively. So I took the USB flash drive from the that machine and came back to my desk. Time 3PM.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1) Inserted into my Linux desktop and did "&lt;b&gt;dmesg&lt;/b&gt;" - the kernel was able to detect the usb drive and print the partitions inside it. But when I tried &lt;b&gt;mount &lt;/b&gt;it failed. After some googling I found that UFS file system can be mounted in Linux only in RO mode. So I tried mount -r but still it failed.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;2) So I tried &lt;b&gt;Windows &lt;/b&gt;next, by googling UFS driver/utility for windows. The free one I could find which has write access it ffsdrv. I avoid posting its link because it is not helpful and I &lt;b&gt;wont recommend&lt;/b&gt; that utility to anyone. Since it has file system driver it can easily crash the windows. It showed me &lt;b&gt;BSOD &lt;/b&gt;three times to me. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;3) Then I decided to try mounting the USB on a FreeBSD machine. I couldnt find one, so I decided to use &lt;b&gt;VirtualBox&lt;/b&gt;. Since I already had virtual box installed and FreeBSD vm in it, it was easier to "start". I started the FreeBSD vm  but it couldnt detect the host USB device. So searched and found that when I installed I should have omitted the VirtualBox usb driver which is causing the issue, so downloaded the latest version of VirtualBox. After installing VirtualBox also it couldnt detect the USB drive. Few googling revealed there is a bug in VirtualBox implementation of USB EHCI controller 2, so I unselected it and VirtualBox is able to detect my drive. But when I tried to mount the drive, FreeBSD failed with "Invalid Argument".&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;4) At this time I lost hope with VirtualBox, so I installed Vmware and started FreeBSD on it. There were no glitches, the drive got detected immediately and FreeBSD was able to detect it too. However when it came to mount, again same problem. Ahhh&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;5) Ok - this is time to blame emulators - I thought both VirtualBox's and VMware's  USB simulation is bad :), so I decided to try with real hardware. Since it was late around 8PM, I went to home -  I booted my machine with a FreeBSD Live CD and tried to mount - same problem.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;6) Now I started suspecting the drive/data. I ran &lt;b&gt;fsck &lt;/b&gt;- it complaint it couldnt find super block and alternative super block. &lt;b&gt;newfs -N&lt;/b&gt; said the alternative should be at 32. So I tried &lt;b&gt;fsck_ffs -b 32&lt;/b&gt; and no luck.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;7) Time 11.xxPM, bulb:&gt; "you are using i386(Little Endian) machine to  read file system which was created by powerpc(Big Endian). &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/22080276-1813697094568603665?l=samueldotj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/BAK65MqH-Xr1bnckPvWQMC1xfkM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/BAK65MqH-Xr1bnckPvWQMC1xfkM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/BAK65MqH-Xr1bnckPvWQMC1xfkM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/BAK65MqH-Xr1bnckPvWQMC1xfkM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/BCiPY/~4/Eu_kVlhPnv4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://samueldotj.blogspot.com/feeds/1813697094568603665/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=22080276&amp;postID=1813697094568603665" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/1813697094568603665?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/1813697094568603665?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/BCiPY/~3/Eu_kVlhPnv4/mount-invalid-argument.html" title="mount: Invalid Argument" /><author><name>Samuel</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://3.bp.blogspot.com/_fvvvrkKNkOQ/S3Uq3uF53jI/AAAAAAAAAiw/kEyMmo3OI_c/S220/sam.JPG" /></author><thr:total>3</thr:total><feedburner:origLink>http://samueldotj.blogspot.com/2010/12/mount-invalid-argument.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ck4GQ3kycCp7ImA9Wx5TFUo.&quot;"><id>tag:blogger.com,1999:blog-22080276.post-7074186070446363731</id><published>2010-07-31T15:25:00.002+05:30</published><updated>2010-07-31T15:38:42.798+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-07-31T15:38:42.798+05:30</app:edited><title>Eva</title><content type="html">&lt;div&gt;I have created a small utility which can evaluate "C" expressions and print it in Hex/Binary formats. The name of the project is Eva.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The core part - Parser is created using &lt;a href="http://antlr.org/"&gt;ANTLR&lt;/a&gt;. Actually the parser part contains 3 modules - Lexer, Parser and Tree walker. The GUI part is developed using &lt;a href="www.wxwidgets.org/"&gt;WxWidgets&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Since it is a small project, I decided to post it in google code hosting rather than sourceforge. Here is the link to the project - &lt;a href="http://code.google.com/p/eva-c/"&gt;http://code.google.com/p/eva-c/&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/22080276-7074186070446363731?l=samueldotj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/iaJmBpQfI5oEgCV_d97i-ZF_Hwc/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/iaJmBpQfI5oEgCV_d97i-ZF_Hwc/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/iaJmBpQfI5oEgCV_d97i-ZF_Hwc/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/iaJmBpQfI5oEgCV_d97i-ZF_Hwc/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/BCiPY/~4/PDTeZqvqFLc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://samueldotj.blogspot.com/feeds/7074186070446363731/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=22080276&amp;postID=7074186070446363731" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/7074186070446363731?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/7074186070446363731?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/BCiPY/~3/PDTeZqvqFLc/eva.html" title="Eva" /><author><name>Samuel</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://3.bp.blogspot.com/_fvvvrkKNkOQ/S3Uq3uF53jI/AAAAAAAAAiw/kEyMmo3OI_c/S220/sam.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://samueldotj.blogspot.com/2010/07/eva.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ck4CRno7eCp7ImA9WxBWGE0.&quot;"><id>tag:blogger.com,1999:blog-22080276.post-2112093992227553473</id><published>2010-02-10T16:47:00.002+05:30</published><updated>2010-02-10T16:52:47.400+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-02-10T16:52:47.400+05:30</app:edited><title>Kernel(FreeBSD) Concurrency</title><content type="html">&lt;div&gt;Today, I had to revisit how FreeBSD system call path was synchronized. And here it is:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Kernel data structures are tradionally protected by the following synchronization methods.&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Interrupt disabling&lt;/li&gt;&lt;li&gt;Spinlock&lt;/li&gt;&lt;li&gt;System priority level&lt;/li&gt;&lt;li&gt;Mutex&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;Disabling interrupts is the easiest method because only one code path can be executed with in a interrupt disbale/enable boundary.  However exceptions are there which dont honour interrupts disabled attribute.&lt;/div&gt;&lt;div&gt;Eg:&lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;Exceptions&lt;/li&gt;&lt;li&gt;Faults&lt;/li&gt;&lt;li&gt;NMI&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div&gt;Disabling interrupts wont work on SMP because interrupts can be disabled/enabled only on current CPU. Disabling interrupts is problematic if the code path takes longer time to complete. Because the kernel would have lost interrupts from devices.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Spinlocks is a datastructure residing on memory and acceissible from all the processors on the system.  Before entering a critical code path spinlock is taken and all other access to that code path is prohibted and the other cpus will be in a loop trying to get the lock and enter. There are certain rules while creating a spinlock to avoid dead locks and gain performance from SMP.&lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;Locking order heierarchy should be maintained to avoid dead locks.&lt;/li&gt;&lt;li&gt;Fine grained locks instead of single big lock to gain performance on SMP.&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div&gt;Spinlock alone would cause a dead lock in a preemptive kernel. Avoiding this in easy way is disabling interrupt because scheduler wont run. However it again would introduce a problem of losing interrupts. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;system priority level or SPL is the prefered method to use with spinlock to avoid lock issues and also get interrupts from devices. SPL rules:&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;And all spinlocks are at greater SPL than scheduler.&lt;/li&gt;&lt;li&gt;All spinlocks should have a associated SPL and at that or greater SPL level only the spinlock should be taken.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;Note: &lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;In simpler term spl is equivalent to masking interrupts.&lt;/li&gt;&lt;li&gt;SPL is per processor, so the spinlock should have locking order hierarchy, otherwise deadlock for sure.&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div&gt;Mutexes used because even with fine grained spinlock there is performance penalty when other CPUs are waiting(looping) for a spinlock. Mutex solves this problem by scheduling out the looping threads in the other CPUs and selecting other threads to run.&lt;/div&gt;&lt;div&gt;Note:&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Mutex cant be used in certain situations eg: a interrupt handler which runs without context cant take mutex because it might be put into sleep.&lt;/li&gt;&lt;li&gt;Combining mutex and spinlock requires only one condition - after a spinlock is taken no mutex acquire should be attempted.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;FreeBSD 6.x&lt;/b&gt; uses mutex and spinlock - MUTEX_DEF and MUTEX_SPIN.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;MUTEX_DEF - Is a mutex which result in going to sleep.&lt;/div&gt;&lt;div&gt;MUTEX_SPIN - Is a spinlock which never puts the caller into sleep but spins and also disables interrupts.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;When FreeBSD was optimized for SMP, spinlocks were removed and mutex was introduced.&lt;/div&gt;&lt;div&gt;It also introduced context full interrupt handlers; now interrupt handlers can sleep, so can use mutex. Since most of the system calls was not ported to SMP, they were protected using a big mutex called Giant.&lt;/div&gt;&lt;div&gt;&lt;b&gt;Giant &lt;/b&gt;- Gaint is a MUTEX_DEF which protects the code path of most system calls.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/22080276-2112093992227553473?l=samueldotj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/VHNXhBtBVL0mx5C1xljx97Jvo6s/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/VHNXhBtBVL0mx5C1xljx97Jvo6s/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/VHNXhBtBVL0mx5C1xljx97Jvo6s/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/VHNXhBtBVL0mx5C1xljx97Jvo6s/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/BCiPY/~4/aRePlPsQKKU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://samueldotj.blogspot.com/feeds/2112093992227553473/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=22080276&amp;postID=2112093992227553473" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/2112093992227553473?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/2112093992227553473?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/BCiPY/~3/aRePlPsQKKU/kernelfreebsd-concurrency.html" title="Kernel(FreeBSD) Concurrency" /><author><name>Samuel</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://3.bp.blogspot.com/_fvvvrkKNkOQ/S3Uq3uF53jI/AAAAAAAAAiw/kEyMmo3OI_c/S220/sam.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://samueldotj.blogspot.com/2010/02/kernelfreebsd-concurrency.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkEAQn87fSp7ImA9WxNbFk8.&quot;"><id>tag:blogger.com,1999:blog-22080276.post-8387717447086831970</id><published>2009-11-19T16:28:00.003+05:30</published><updated>2009-11-19T16:34:03.105+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-11-19T16:34:03.105+05:30</app:edited><title>Size of all structures in your program</title><content type="html">There are some cases when you want to find size of all structures in your program/project. For a given program it is easy because we can manually calculate or put a printf sizeof() to calculate a few structures.  But for a project with few hundred files it is difficult. There is noway AFAIK in gcc to dump all the structure sizes while it compiles.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here is a way todo it using dwarf debugging info if you are using gnu compiler tools. Compile your project output file with &lt;b&gt;-g&lt;/b&gt; option, this will generate debugging information in your program. Then run &lt;b&gt;objdump&lt;/b&gt; to dump the debug info. This debugging information contains all the information about your program, filter the output for "&lt;span class="Apple-style-span" style="font-family: Calibri, sans-serif; font-size: 15px; "&gt;DW_TAG_structure_type&lt;span class="Apple-style-span" style="font-family: Georgia, serif; font-size: 16px; "&gt;" and you will get only structure information.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Calibri, sans-serif; font-size: 15px; "&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, serif; font-size: 16px; "&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Here is how I did it:&lt;/div&gt;&lt;div&gt;&lt;p class="MsoPlainText"&gt;&lt;/p&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;p class="MsoPlainText"&gt;&lt;b&gt;objdump -W kernel.debug.reloc &gt; debug.info&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoPlainText"&gt;&lt;b&gt;grep -e "DW_TAG_structure_type" debug.info --after-context=5 --mmap &gt; structs.txt           &lt;/b&gt;&lt;/p&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/22080276-8387717447086831970?l=samueldotj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/8fROWjGmHCBQeIDzmQhg5ACOfIg/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/8fROWjGmHCBQeIDzmQhg5ACOfIg/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/8fROWjGmHCBQeIDzmQhg5ACOfIg/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/8fROWjGmHCBQeIDzmQhg5ACOfIg/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/BCiPY/~4/0LZneUXHP6s" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://samueldotj.blogspot.com/feeds/8387717447086831970/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=22080276&amp;postID=8387717447086831970" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/8387717447086831970?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/8387717447086831970?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/BCiPY/~3/0LZneUXHP6s/size-of-all-structures-in-your-program.html" title="Size of all structures in your program" /><author><name>Samuel</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://3.bp.blogspot.com/_fvvvrkKNkOQ/S3Uq3uF53jI/AAAAAAAAAiw/kEyMmo3OI_c/S220/sam.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://samueldotj.blogspot.com/2009/11/size-of-all-structures-in-your-program.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0cHRn45fCp7ImA9WxNVGE4.&quot;"><id>tag:blogger.com,1999:blog-22080276.post-1931084898756173009</id><published>2009-10-29T21:51:00.005+05:30</published><updated>2009-10-29T22:20:37.024+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-10-29T22:20:37.024+05:30</app:edited><title>SLOC</title><content type="html">&lt;span&gt;&lt;span&gt;Recently I was browsing some open source project's(as usual I forgot the name) web site and the author has put &lt;a href="http://en.wikipedia.org/wiki/Source_lines_of_code"&gt;SLOC &lt;/a&gt;report for his project. It was pretty cool. I wanted to try it on some of my projects and tried sloccount(&lt;a href="http://www.dwheeler.com/sloccount/"&gt;http://www.dwheeler.com/sloccount/&lt;/a&gt;) in my office but since my office PC doesnt have my personal project sources I was not able to get SLOC report for my projects.&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;br /&gt;Today I suddenly, I remembered about SLOC and tried it on my Ace project. And here is the output&lt;/span&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;Sam@samxp /cygdrive/e/Projects&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;$ sloccount ace_test/src&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;Creating filelist for app&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;Creating filelist for drivers&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;Creating filelist for include&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;Creating filelist for kernel&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;Creating filelist for lib&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;Have a non-directory at the top, so creating directory top_dir&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;Adding /cygdrive/e/Projects/ace_test/src/wscript to top_dir&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;Categorizing files.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;Finding a working MD5 command....&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;Found a working MD5 command.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;Computing results.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;SLOC    Directory       SLOC-by-Language (Sorted)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;13716   include         ansic=13699,sh=17&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;9045    kernel          ansic=8810,asm=221,python=14&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;3712    lib             ansic=3691,sh=11,python=10&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;1062    drivers         ansic=1051,python=11&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;41      top_dir         python=41&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;10      app             ansic=6,python=4&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;Totals grouped by language (dominant language first):&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;ansic:        27257 (98.81%)&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;asm:            221 (0.80%)&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;python:          80 (0.29%)&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;sh:              28 (0.10%)&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;Total Physical Source Lines of Code (SLOC)                = 27,586&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;Development Effort Estimate, Person-Years (Person-Months) = 6.51 (78.15)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt; (Basic COCOMO model, Person-Months = 2.4 * (KSLOC**1.05))&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;Schedule Estimate, Years (Months)                         = &lt;/span&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;1.09 (13.10)&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt; (Basic COCOMO model, Months = 2.5 * (person-months**0.38))&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;Estimated Average Number of Developers (Effort/Schedule)  = &lt;/span&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;5.97&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;Total Estimated Cost to Develop                           = &lt;/span&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;$ 879,761&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt; (average salary = $56,286/year, overhead = 2.40).&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;SLOCCount, Copyright (C) 2001-2004 David A. Wheeler&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;SLOCCount is Open Source Software/Free Software, licensed under the GNU GPL.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;SLOCCount comes with ABSOLUTELY NO WARRANTY, and you are welcome to&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;redistribute it under certain conditions as specified by the GNU GPL license;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;see the documentation for details.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#6600CC;"&gt;Please credit this data as "generated using David A. Wheeler's 'SLOCCount'."&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;Pretty cool isnt it? &lt;b&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;:)&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/22080276-1931084898756173009?l=samueldotj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/IX7ujMIPB--aL0UrmScNJLaKE3U/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/IX7ujMIPB--aL0UrmScNJLaKE3U/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/IX7ujMIPB--aL0UrmScNJLaKE3U/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/IX7ujMIPB--aL0UrmScNJLaKE3U/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/BCiPY/~4/wbrOrIOf2WU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://samueldotj.blogspot.com/feeds/1931084898756173009/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=22080276&amp;postID=1931084898756173009" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/1931084898756173009?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/1931084898756173009?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/BCiPY/~3/wbrOrIOf2WU/sloc.html" title="SLOC" /><author><name>Samuel</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://3.bp.blogspot.com/_fvvvrkKNkOQ/S3Uq3uF53jI/AAAAAAAAAiw/kEyMmo3OI_c/S220/sam.JPG" /></author><thr:total>2</thr:total><feedburner:origLink>http://samueldotj.blogspot.com/2009/10/sloc.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0QNQH44cCp7ImA9WxNVFk4.&quot;"><id>tag:blogger.com,1999:blog-22080276.post-4285563194187640503</id><published>2009-10-27T14:31:00.002+05:30</published><updated>2009-10-27T15:59:51.038+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-10-27T15:59:51.038+05:30</app:edited><title>Funny numbers</title><content type="html">&lt;div&gt;Freebsd kernel source files count vs Makefile count. Just from the numbers it looks like for every 4 source files there is an Makefile. I ran these commands when I thought of converting FreeBSD build system(make) to use waf(&lt;a href="http://code.google.com/p/waf/"&gt;http://code.google.com/p/waf/&lt;/a&gt;) or scons(&lt;a href="http://www.scons.org/"&gt;http://www.scons.org/&lt;/a&gt;). &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;root@freebsd-sam:/sys#find . -name "*.c" | wc -l&lt;/div&gt;&lt;div&gt;    3171&lt;/div&gt;&lt;div&gt;root@freebsd-sam:/sys#find . -name "*.h" | wc -l&lt;/div&gt;&lt;div&gt;    3004&lt;/div&gt;&lt;div&gt;root@freebsd-sam:/sys#find . -name "*.s" | wc -l&lt;/div&gt;&lt;div&gt;      44&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;b&gt;root@freebsd-sam:/sys#find . -name "Makefile*"  | wc -l&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;     746&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;And yes, after seeing this number I let me thought to stay inside for sometime.&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/22080276-4285563194187640503?l=samueldotj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/sWQ3HHGIB-lfLzKR68A_F3IIPgg/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/sWQ3HHGIB-lfLzKR68A_F3IIPgg/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/sWQ3HHGIB-lfLzKR68A_F3IIPgg/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/sWQ3HHGIB-lfLzKR68A_F3IIPgg/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/BCiPY/~4/MFMFvlxqLAE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://samueldotj.blogspot.com/feeds/4285563194187640503/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=22080276&amp;postID=4285563194187640503" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/4285563194187640503?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/4285563194187640503?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/BCiPY/~3/MFMFvlxqLAE/funny-numbers.html" title="Funny numbers" /><author><name>Samuel</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://3.bp.blogspot.com/_fvvvrkKNkOQ/S3Uq3uF53jI/AAAAAAAAAiw/kEyMmo3OI_c/S220/sam.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://samueldotj.blogspot.com/2009/10/funny-numbers.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0EMQ3g5cCp7ImA9Wx9UE00.&quot;"><id>tag:blogger.com,1999:blog-22080276.post-3005459215998423887</id><published>2009-10-04T01:34:00.005+05:30</published><updated>2011-02-10T09:18:02.628+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-02-10T09:18:02.628+05:30</app:edited><title>Call Trace without modifying the source</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px;"&gt;&lt;/span&gt;&lt;br /&gt;
While investigating about gcc flag "-fprofile-arcs", I came to know about a new(to me) gcc flag and this blog entry is about it. For any large C project it is hard to learn/find call graph through code walk. From C prospective unless otherwise you put a printf in each function entry/exit it is hard to find the call trace.&amp;nbsp;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;GCC and ICC has a wonderful option "-finstrument-functions" to solve this. This option instructs the compiler to emit instructions to call a external function on each function's entry/exit. Defining these two functions like the following and adding the above option -finstrument-function to your makefile will do the magic.&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;void noinstrument&amp;nbsp;__cyg_profile_func_enter(void *this_fn, void *call_site)&lt;br /&gt;
{&lt;br /&gt;
printf("%p called from %p\n", this_fn, call_site);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void noinstrument&amp;nbsp;__cyg_profile_func_exit(void *this_fn, void *call_site)&lt;br /&gt;
{&lt;br /&gt;
printf("%p returns\n", this_fn);&lt;br /&gt;
}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Of course, you can do anything in these functions, for simplicity sake I just defined them as printfs.&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/22080276-3005459215998423887?l=samueldotj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/emfbSWt5IfhX5DCZKRZhQiCVHGs/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/emfbSWt5IfhX5DCZKRZhQiCVHGs/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/emfbSWt5IfhX5DCZKRZhQiCVHGs/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/emfbSWt5IfhX5DCZKRZhQiCVHGs/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/BCiPY/~4/jmpI6BiDx3M" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://samueldotj.blogspot.com/feeds/3005459215998423887/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=22080276&amp;postID=3005459215998423887" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/3005459215998423887?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/3005459215998423887?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/BCiPY/~3/jmpI6BiDx3M/call-trace-without-modifying-source.html" title="Call Trace without modifying the source" /><author><name>Samuel</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://3.bp.blogspot.com/_fvvvrkKNkOQ/S3Uq3uF53jI/AAAAAAAAAiw/kEyMmo3OI_c/S220/sam.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://samueldotj.blogspot.com/2009/10/call-trace-without-modifying-source.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CU4DQ3k4eSp7ImA9WxNREEk.&quot;"><id>tag:blogger.com,1999:blog-22080276.post-4699571412938984862</id><published>2009-09-04T11:00:00.002+05:30</published><updated>2009-09-04T11:29:32.731+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-09-04T11:29:32.731+05:30</app:edited><title>Tracing ld</title><content type="html">&lt;blockquote&gt;&lt;/blockquote&gt;I was trying to do something with customized FreeBSD kernel which required constructors(.ctors) and destructor(.dtors) sections to be included in the final binary. So I used the normal gnu practice of including the following code into my linker script(&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;b&gt;/sys/conf/ldscript.i386&lt;/b&gt;&lt;/span&gt;).&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;   .&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;data.gcov :&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;   {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;     &lt;/span&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;__CTOR_LIST__ = .;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;    LONG((__CTOR_END__ - __CTOR_LIST__) /&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;        (__CTOR_LIST2__ - __CTOR_LIST__) - 2 )&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;    __CTOR_LIST2__ = .;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;    KEEP(*(.ctors))&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;    LONG(0)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;    __CTOR_END__ = .;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;    __DTOR_LIST__ = .;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;    LONG(( __DTOR_END__ - __DTOR_LIST__ )/&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;        (__CTOR_LIST2__ - __CTOR_LIST__) - 2)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;    KEEP(*(.dtors))&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;    LONG(0)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;    __DTOR_END__ = .;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;   }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;But when I tried to see the contents of of the linked kernel there were no constructors. Because &lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-size:medium;"&gt;__CTOR_LIST__ and __CTOR_END__ are placed next to each other, from the linker script you can see the .ctors comes in between them.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;$objdump -t kernel | grep __CTOR&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#CC0000;"&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;c049cb8c &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;g       .data.gcov     00000000 __CTOR_LIST__&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#CC0000;"&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;c049cb94 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;g       .data.gcov     00000000 __CTOR_END__&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;c049cb90 g       .data.gcov     00000000 __CTOR_LIST2__&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;$objdump -s -j .data.gcov kernel | head&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;kernel:     file format elf32-i386-freebsd&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;Contents of section .data.gcov:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt; c049cb8c &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#990000;"&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;00000000 00000000 00000000 00000000&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;  ................&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt; c049cb9c 5f090000 e7124ac0 e7124ac0 1b4a4ac0  _.....J...J..JJ.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt; c049cbac 1b4a4ac0 085c4ac0 085c4ac0 06234bc0  .JJ..\J..\J..#K.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt; c049cbbc 06234bc0 1f374bc0 1f374bc0 d43b4bc0  .#K..7K..7K..;K.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt; c049cbcc d43b4bc0 b1414bc0 b1414bc0 b2494bc0  .;K..AK..AK..IK.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt; c049cbdc b2494bc0 d77b4bc0 d77b4bc0 0e894bc0  .IK..{K..{K...K.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;I tried to find what ld is doing by enabling &lt;b&gt;--verbose&lt;/b&gt; option in &lt;b&gt;SYSTEM_LD&lt;/b&gt; (&lt;b&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;/sys/conf/kern.pre.mk&lt;/span&gt;&lt;/b&gt;) but it did not help. Then I tried -Map option to ask ld to generate map file and it helped me. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In my environment the kernel is generated in step. First all system objects are partially linked(&lt;b&gt;&lt;span class="Apple-style-span"  style="color:#000066;"&gt;-r/-Ur &lt;/span&gt;&lt;/b&gt;option) to generate relocatable kernel. Then this relocatable kernel is linked with some other static modules to create the kernel. From the map files I could see the constructors are present in the relocatable kernel and dropped while creating the proper kernel. I guess it is a bug with ld. So I merged the two step process into one and it worked.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;$&lt;b&gt;objdump -t kernel | grep __CTOR&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="color:#006600;"&gt;c049cf50 &lt;/span&gt;g       .data.gcov     00000000 __CTOR_LIST__&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;span class="Apple-style-span"  style="color:#006600;"&gt;c049f4e4 &lt;/span&gt;g       .data.gcov     00000000 __CTOR_END__&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;c049cf54 g       .data.gcov     00000000 __CTOR_LIST2__&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;$&lt;b&gt;objdump -s -j .data.gcov kernel | head&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;kernel:     file format elf32-i386-freebsd&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Contents of section .data.gcov:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; c049cf50 &lt;span class="Apple-style-span"  style="color:#006600;"&gt;63090000 a7164ac0 a7164ac0 db4d4ac0&lt;/span&gt;  c.....J...J..MJ.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; c049cf60 db4d4ac0 c85f4ac0 c85f4ac0 c6264bc0  .MJ.._J.._J..&amp;amp;K.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; c049cf70 c6264bc0 df3a4bc0 df3a4bc0 943f4bc0  .&amp;amp;K..:K..:K..?K.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; c049cf80 943f4bc0 71454bc0 71454bc0 724d4bc0  .?K.qEK.qEK.rMK.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; c049cf90 724d4bc0 977f4bc0 977f4bc0 ce8c4bc0  rMK...K...K...K.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt; c049cfa0 ce8c4bc0 bbf74bc0 bbf74bc0 bb0a4cc0  ..K...K...K...L.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/22080276-4699571412938984862?l=samueldotj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/P68yuhXn1-IY4V-5pcul-BLDKnw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/P68yuhXn1-IY4V-5pcul-BLDKnw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/P68yuhXn1-IY4V-5pcul-BLDKnw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/P68yuhXn1-IY4V-5pcul-BLDKnw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/BCiPY/~4/t-qbxYF8Cko" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://samueldotj.blogspot.com/feeds/4699571412938984862/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=22080276&amp;postID=4699571412938984862" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/4699571412938984862?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/4699571412938984862?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/BCiPY/~3/t-qbxYF8Cko/tracing-ld.html" title="Tracing ld" /><author><name>Samuel</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://3.bp.blogspot.com/_fvvvrkKNkOQ/S3Uq3uF53jI/AAAAAAAAAiw/kEyMmo3OI_c/S220/sam.JPG" /></author><thr:total>1</thr:total><feedburner:origLink>http://samueldotj.blogspot.com/2009/09/tracing-ld.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEcHRXk9fSp7ImA9WxNREEk.&quot;"><id>tag:blogger.com,1999:blog-22080276.post-8877293892210461888</id><published>2009-08-28T14:53:00.004+05:30</published><updated>2009-09-04T10:57:14.765+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-09-04T10:57:14.765+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C" /><category scheme="http://www.blogger.com/atom/ns#" term="Programming" /><category scheme="http://www.blogger.com/atom/ns#" term="kernel" /><category scheme="http://www.blogger.com/atom/ns#" term="make" /><title>Debugging gcc behavior</title><content type="html">&lt;div&gt;While compiling a FreeBSD kernel I encountered the following error message from GNU assembler&lt;/div&gt;&lt;div&gt;Error: suffix or operands invalid for `mov'&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I was not sure whether the error is because of my changes are not. But still I have to debug the problem and solve it, so I decided to find what is wrong with the mov instruction. But since gcc created a temporary file and invoked as to assemble it, I couldn’t find the temp file anymore.&lt;/div&gt;&lt;div&gt;Googled and find the following gcc options to find what gcc does.&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;gcc –v is verbose mode, which prints all the action/scripts gcc is doing.&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;gcc -### similar to –v but wont execute any commands.&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;gcc –save-temps saves all the temporary files generated by the gcc. Useful if you want to see the assembly output passed to gnu assembler.&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;gcc –E Just preprocess the c file&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;gcc –S generate assembly file.&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;With gcc –v –save-temps, I got the temporary assembler file used by assembler. Since reading machine generated assembly file is difficult, I tried to find the C source code corresponding to the error. From nearest .file &lt;a href="http://sourceware.org/binutils/docs-2.19/as/Pseudo-Ops.html#Pseudo-Ops"&gt;assembler directive&lt;/a&gt; I found the C file name and from the .loc directive I found the line number. And the following was the inline assembly in the C file.&lt;/div&gt;&lt;div&gt;__asm __volatile("&lt;b&gt;movl &lt;/b&gt;%%ss,%0" : "=rm" (sel));&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Was surprised what is wrong with this and why my assembler giving error. Googled again and found this link - &lt;a href="http://kerneltrap.org/node/5785"&gt;http://kerneltrap.org/node/5785&lt;/a&gt;. It seems newer gnu assembler(&gt;=2.16) wont support long read/write operations(mov) on segment registers(ds,ss...). So changed the above source to &lt;b&gt;movw&lt;/b&gt; %%ss, %o and it compiled perfectly. :)&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/22080276-8877293892210461888?l=samueldotj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/J7kSjxTS-G4qgiFd9pfTrGggjIw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/J7kSjxTS-G4qgiFd9pfTrGggjIw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/J7kSjxTS-G4qgiFd9pfTrGggjIw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/J7kSjxTS-G4qgiFd9pfTrGggjIw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/BCiPY/~4/x0hQyvUGbLk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://samueldotj.blogspot.com/feeds/8877293892210461888/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=22080276&amp;postID=8877293892210461888" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/8877293892210461888?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/8877293892210461888?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/BCiPY/~3/x0hQyvUGbLk/debugging-gcc-behavior.html" title="Debugging gcc behavior" /><author><name>Samuel</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://3.bp.blogspot.com/_fvvvrkKNkOQ/S3Uq3uF53jI/AAAAAAAAAiw/kEyMmo3OI_c/S220/sam.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://samueldotj.blogspot.com/2009/08/debugging-gcc-behavior.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEYMQH4-eCp7ImA9WxNREEk.&quot;"><id>tag:blogger.com,1999:blog-22080276.post-1203944236296685294</id><published>2009-04-09T16:52:00.005+05:30</published><updated>2009-09-04T10:59:41.050+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-09-04T10:59:41.050+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Programming" /><category scheme="http://www.blogger.com/atom/ns#" term="Ace" /><title>Unreferenced symbols - EXPORT_SYMBOL</title><content type="html">&lt;p class="MsoNormal"&gt;I wrote ACPI driver for Ace and try to load it into kernel. It was failing with the error message symbol not found. &lt;/p&gt;  &lt;p class="MsoNormal"&gt;The log file content says AcpiGetName was not found.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;blockquote&gt;$ cat log.txt&lt;br /&gt;Driver for id acpi : acpi.sys&lt;br /&gt;../src/kernel/pm/elf.c:343:FindElfSymbolByName(): Symbol not found AcpiGetName(c01a2148:1869) string table c01aa619&lt;/blockquote&gt; &lt;/span&gt;&lt;p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;After exploring the Acpi-CA source code and Ace kernel code, I couldn’t figure out why the symbol is missing. Then I tried to dump the symbol table for Acpi library and kernel.sys. &lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$ nm build/default/src/kernel/libacpi.a | grep GetName&lt;br /&gt;        U AcpiExGetNameString&lt;br /&gt;000001e3 T AcpiExGetNameString&lt;br /&gt;000001b7 T AcpiPsGetName&lt;br /&gt;000000f4 T AcpiGetName&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;$ nm build/default/src/kernel/kernel.sys | grep GetName&lt;br /&gt;c0135163 T AcpiExGetNameString&lt;br /&gt;c0137bfb T AcpiPsGetName&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;It is obvious during kernel link process some how the linker is losing AcpiGetName. Within few seconds I realized that the linker is doing optimization on the output to remove unreferenced sections. So I googled for how to avoid this and found --no-gc-sections is the ld option to do it. However even after giving this option to linker to was removing the unreferenced symbols; I kept on trying to find a solution for making the linker to include unreferenced symbols in the output… I didn’t find the solution.&lt;/div&gt;&lt;p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Then I started thinking how linux kernel is avoiding this problem and I it flashed seeing EXPORT_SYMBOL kind of macro in some source. So I googled for it and got the answer – use the symbol in storage, so that it will be referenced, so that linker will include it in the output.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;/blockquote&gt;&lt;p class="MsoNormal"&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;struct kernel_symbol&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;unsigned long symbol;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;char * name;&lt;br /&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;#ifndef MODULE_SYMBOL_PREFIX&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;#define MODULE_SYMBOL_PREFIX ""&lt;br /&gt;#endif&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;#define __EXPORT_SYMBOL(sym, sec) \&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;static const char __kstrtab_##sym[] \&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;__attribute__((section("__ksymtab_strings"))) \&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;= MODULE_SYMBOL_PREFIX#sym; \&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;static const struct kernel_symbol __ksymtab_##sym \&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;__attribute__((section("__ksymtab" sec), unused)) \&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;= { (unsigned long)&amp;amp;sym, __kstrtab_##sym }&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;#define EXPORT_SYMBOL(sym) \&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;__EXPORT_SYMBOL(sym, "")&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:100%;"&gt;&lt;span class="Apple-style-span"  style="font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/22080276-1203944236296685294?l=samueldotj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/7xvC6TeaVLSK2QRPxXyBVGBAZc4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/7xvC6TeaVLSK2QRPxXyBVGBAZc4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/7xvC6TeaVLSK2QRPxXyBVGBAZc4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/7xvC6TeaVLSK2QRPxXyBVGBAZc4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/BCiPY/~4/yDGnN2LTxWk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://samueldotj.blogspot.com/feeds/1203944236296685294/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=22080276&amp;postID=1203944236296685294" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/1203944236296685294?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/1203944236296685294?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/BCiPY/~3/yDGnN2LTxWk/unreferenced-symbols-exportsymbol.html" title="Unreferenced symbols - EXPORT_SYMBOL" /><author><name>Samuel</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://3.bp.blogspot.com/_fvvvrkKNkOQ/S3Uq3uF53jI/AAAAAAAAAiw/kEyMmo3OI_c/S220/sam.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://samueldotj.blogspot.com/2009/04/unreferenced-symbols-exportsymbol.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DU4MQng5eip7ImA9WxVUEkU.&quot;"><id>tag:blogger.com,1999:blog-22080276.post-8135446797884719058</id><published>2009-03-17T16:24:00.003+05:30</published><updated>2009-03-17T16:36:23.622+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-17T16:36:23.622+05:30</app:edited><title>Better build system</title><content type="html">&lt;p class="MsoNormal"&gt;I was using “make”(&lt;a href="http://en.wikipedia.org/wiki/GNU_build_system"&gt;http://en.wikipedia.org/wiki/GNU_build_system&lt;/a&gt;) to build and clean my projects. The makefiles grew bigger enough to not maintainable state. Recently I came to know about waf(&lt;a href="http://code.google.com/p/waf/"&gt;http://code.google.com/p/waf/&lt;/a&gt;) from a forum, so decided to give a try. I went through the waf documentation and it took 2 hours to understand how it works and it took 2 days to convert all my makefiles to waf wscripts and wscript_build files.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;The basic problem with make was I have write rules to how to build object files from source and&lt;/p&gt;&lt;img src="http://3.bp.blogspot.com/_fvvvrkKNkOQ/Sb-DiahMw_I/AAAAAAAAAP0/DuBBogS8C6M/s320/ace_compile.jpg" style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;width: 320px; height: 183px;" border="0" alt="" id="BLOGGER_PHOTO_ID_5314110712577836018" /&gt;then to clean I have to write how to delete the object files. With waf the problem is simplified, you have to tell what all source files and it will take care of how to compile and link. It will also take care of how to clean the project and the dependency between files are also taken care, so no need for gcc –M and dependency files etc. The feature I liked in waf is it has colored output with progress bar :)&lt;p class="MsoNormal"&gt;The other problem solved in Ace project compilation was build configuration. Waf will configure the project for the first time, so it solved the different cross compiler required for Ace OS.&lt;/p&gt;&lt;p class="MsoNormal"&gt;Waf(&lt;a href="http://code.google.com/p/waf/"&gt;http://code.google.com/p/waf/&lt;/a&gt;) is really good alternative/replacement for make tools.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/22080276-8135446797884719058?l=samueldotj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Ag3YAOpt85n1PpkYdqEXn-3qIlE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Ag3YAOpt85n1PpkYdqEXn-3qIlE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Ag3YAOpt85n1PpkYdqEXn-3qIlE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Ag3YAOpt85n1PpkYdqEXn-3qIlE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/BCiPY/~4/ZRO7KsNfnBA" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://samueldotj.blogspot.com/feeds/8135446797884719058/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=22080276&amp;postID=8135446797884719058" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/8135446797884719058?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/8135446797884719058?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/BCiPY/~3/ZRO7KsNfnBA/better-build-system.html" title="Better build system" /><author><name>Samuel</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://3.bp.blogspot.com/_fvvvrkKNkOQ/S3Uq3uF53jI/AAAAAAAAAiw/kEyMmo3OI_c/S220/sam.JPG" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/_fvvvrkKNkOQ/Sb-DiahMw_I/AAAAAAAAAP0/DuBBogS8C6M/s72-c/ace_compile.jpg" height="72" width="72" /><thr:total>1</thr:total><feedburner:origLink>http://samueldotj.blogspot.com/2009/03/better-build-system.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0UGQH89eSp7ImA9WxVQFUg.&quot;"><id>tag:blogger.com,1999:blog-22080276.post-5137064110273817805</id><published>2008-12-16T12:17:00.005+05:30</published><updated>2009-02-02T11:43:41.161+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-02-02T11:43:41.161+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Softwares" /><category scheme="http://www.blogger.com/atom/ns#" term="Tools" /><category scheme="http://www.blogger.com/atom/ns#" term="Tips" /><category scheme="http://www.blogger.com/atom/ns#" term="Windows" /><title>Putty Tips</title><content type="html">&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="color: rgb(204, 0, 0);"&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;Putty title&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;I wanted to change putty title to reflect current working directory of the remote machine to distinguish multiple putty windows easily. &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;PUTTY_TITLE=`hostname`:`tty | cut -f 4 -d "/"`&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;export PS1='$PWD&gt;^[]2;$PWD:$PUTTY_TITLE^G'&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;To insert in vi editor the "^[" character in insert mode press control-V and then the Escape key. ^G is created by pressing control-G.&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Reference: &lt;a href="http://www.unix.com/sun-solaris/23038-change-terminal-title-2.html"&gt;http://www.unix.com/sun-solaris/23038-change-terminal-title-2.html&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:'Times New Roman';"&gt;&lt;div style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; width: auto; font: normal normal normal 100%/normal Georgia, serif; text-align: left; "&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;&lt;span class="Apple-style-span" style="color: rgb(204, 0, 0);"&gt;Passwordless connection to HPUX machines&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Since I was forgetting my passwords for HPUX machines, I decided to try SSH public/private key authentication to get rid of passwords. After some struggle I managed to login in to HPUX machines using Putty without entering a password.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Before I forget all those steps which are not part of my daily job, I wanted to log them and so here it is.&lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;Login to HPUX machine using your login and password&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Create a .ssh directory under your home directory &lt;span class="Apple-style-span" style="font-weight: bold; "&gt;mkdir .ssh&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Create public/private key pair &lt;span class="Apple-style-span" style="font-weight: bold; "&gt;ssh-keygen –t rsa&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Add the public key to authorized_keys2 file &lt;span class="Apple-style-span" style="font-weight: bold; "&gt;cat id_rsa.pub&gt;&gt; authorized_keys2&lt;span class="Apple-style-span" style="font-weight: normal; "&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-weight: bold; "&gt;&lt;span class="Apple-style-span" style="font-weight: normal; "&gt;Now ftp the private key file(id_rsa) to your Windows machine.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-weight: bold; "&gt;&lt;span class="Apple-style-span" style="font-weight: normal; "&gt;Covert the private key file format to putty private key file format. (Use puttygen.exe and then load and save the private key file).&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-weight: bold; "&gt;&lt;span class="Apple-style-span" style="font-weight: normal; "&gt;Now in putty, select the host and select SSH as protocol and in SSH options on the left hand tab select Auth and select the private key file.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;If you get “server refused our key” error then I would suggest running sshd with debug option. (&lt;span class="Apple-style-span" style="font-weight: bold; "&gt;/usr/sbin/sshd -d -d -d &amp;amp;&lt;/span&gt;)&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You can also check the permission of your files and folders.&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;chmod 600 authorized_keys2&lt;br /&gt;&lt;/li&gt;&lt;li&gt;chmod 700 .ssh&lt;/li&gt;&lt;li&gt;Also check your home directory permission.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;It should work. If it is not, you can try running the ssh client in debug mode from the same server. (&lt;span class="Apple-style-span" style="font-weight: bold; "&gt;ssh -l &lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;&lt;span class="Apple-style-span" style="font-weight: bold; "&gt;username servername&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-weight: bold; "&gt; -v -v -v&lt;/span&gt;)&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold; "&gt;&lt;span class="Apple-style-span"  style=" ;font-size:18px;"&gt;&lt;span class="Apple-style-span" style="color: rgb(204, 0, 0); "&gt;Passwordless connection to Tru64 machines&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;It is almost same as HPUX configuration but the directory name should be ".ssh2" instead of ".ssh". And it should contain a text file named "authorization"; the contents of that file should be list of public key files separated by newline.&lt;/div&gt;&lt;div&gt;Example:&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;/home/samuel/.ssh2&gt;ls&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;authorization      id_rsa_2048_a      id_rsa_2048_a.pub  random_seed&lt;/div&gt;&lt;div&gt;/home/samuel/.ssh2&gt;cat authorization&lt;/div&gt;&lt;div&gt;Key id_rsa_2048_a.pub&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(204, 0, 0); "&gt;Someother tools&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; I came to know when I was searching Putty enchancements&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;I wanted some small utility to avoid digging through Start menu Programsto find Putty or any other program to launch it. I want a small command line kind of utility and found &lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 0, 153);"&gt;&lt;a href="http://www.launchy.net/"&gt;Launchy&lt;/a&gt; &lt;/span&gt;&lt;/span&gt; it can launch any program by typing few letters of that program.&lt;/li&gt;&lt;li&gt;Sometime I start source control/compilation of kernel from my office and want to continue things from my home. But since terminal emulators such as Putty are bound to local machine, I used to open new terminal session or use remote desktop connection to my office machine to continue my work. One of my colleagues told me about &lt;a href="http://www.gnu.org/software/screen/"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;GNU screen&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;  and how it can solve the problem.  Here is some good&lt;a href="http://www.kuro5hin.org/story/2004/3/9/16838/14935"&gt; introduction to screen&lt;/a&gt;.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="color: rgb(204, 0, 0);"&gt;Putty sessions&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;I was searching for method to launch Putty session quickly and saw the following article Multiple putty addons &lt;a href="http://www.thegeekstuff.com/2008/08/turbocharge-putty-with-12-powerful-add-ons-software-for-geeks-3/"&gt;http://www.thegeekstuff.com/2008/08/turbocharge-putty-with-12-powerful-add-ons-software-for-geeks-3/&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Previously I was using "&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;Putty Session Manager&lt;/span&gt;" to categorize and lanuch putty sessions.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="color:#CC0000;"&gt;Enabling colors in vim in putty terminal&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://vim.wikia.com/wiki/Using_vim_color_schemes_with_Putty"&gt;http://vim.wikia.com/wiki/Using_vim_color_schemes_with_Putty&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/22080276-5137064110273817805?l=samueldotj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/_2ZT285ST7UEki6BMQfN0rAf9uo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/_2ZT285ST7UEki6BMQfN0rAf9uo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/_2ZT285ST7UEki6BMQfN0rAf9uo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/_2ZT285ST7UEki6BMQfN0rAf9uo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/BCiPY/~4/SeYLHl3WMtM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://samueldotj.blogspot.com/feeds/5137064110273817805/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=22080276&amp;postID=5137064110273817805" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/5137064110273817805?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/5137064110273817805?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/BCiPY/~3/SeYLHl3WMtM/putty-tips.html" title="Putty Tips" /><author><name>Samuel</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://3.bp.blogspot.com/_fvvvrkKNkOQ/S3Uq3uF53jI/AAAAAAAAAiw/kEyMmo3OI_c/S220/sam.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://samueldotj.blogspot.com/2008/12/putty-tips.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0YBSXk_fyp7ImA9WxVSE0Q.&quot;"><id>tag:blogger.com,1999:blog-22080276.post-5590876626919114639</id><published>2008-11-22T18:06:00.002+05:30</published><updated>2009-01-08T10:35:58.747+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-01-08T10:35:58.747+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C" /><category scheme="http://www.blogger.com/atom/ns#" term="Tools" /><category scheme="http://www.blogger.com/atom/ns#" term="make" /><category scheme="http://www.blogger.com/atom/ns#" term="Ace" /><title>Porting to “Intel C Compiler”</title><content type="html">&lt;div&gt;In this post, I will explain how to easy it is to compile/port C programs and makefiles designed for GCC(GNU compiler collection) can be used with ICC(intel c compiler)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The necessity for using ICC happened to me because gcc was generating much bigger object files. Ace is using ACPI-CA(http://acpica.org/) as it is ACPI driver. After compilation the ACPI library is around 7M in debug version and around 500K in non-debug version. But from http://acpica.org/download/changes.txt it seems Microsoft C compiler produce smaller code.&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    Non-Debug Version:  81.2K Code, 17.0K Data,  98.2K Total&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    Debug Version:     155.8K Code, 49.1K Data, 204.9K Total&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So I decided to try “Intel Compiler” as replacement for GCC. Things were easy, since icc has options which is similar to gcc.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You can get the details of portability options from icc documentation -http://www.intel.com/software/products/compilers/docs/clin/main_cls/index.htm.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I just changed my make.conf file to check the compiler in use and use appropriate options. I removed -fno-leading-underscore and –Wall. I removed –Wall because it was giving lot of warnings, we have to fix our code sometime soon. I removed -fno-leading-underscore because there is no equivalent option in icc, however icc does not adds underscores to symbols anyway. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I added –O1 option because the kernel was panicked during boot with invalid opcode exception, I believe it was because of some MMX register usage by icc. So I settled with –O1 now.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;ifeq ($(CC),gcc)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;    DEBUG_FLAGS= -gdwarf-2 -g3&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;    CFLAGS+= -Wall -Wno-multichar $(DEFINES) -nostartfiles -ffreestanding -funsigned-char -fno-leading-underscore -c -fno-stack-protector $(DEBUG_FLAGS) $(CUSTOM_FLAG)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;else&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;    DEBUG_FLAGS= -gdwarf-2 -g&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;    CFLAGS+= -O1 -Wno-multichar $(DEFINES) -nostartfiles -ffreestanding -funsigned-char -c -fno-stack-protector $(DEBUG_FLAGS) $(CUSTOM_FLAG)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;endif&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I also made some static variables in kernel/i386/gdb_stub.c to non-static because icc appends .0 to static variables but it forgets the same name when referenced in a inline assembly code in the same file. After removing the static attribute it is working fine.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;gcc compiler took the following time to compile Ace source code.&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0);"&gt;real    0m51.125s&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0);"&gt;user    0m36.975s&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0);"&gt;sys     0m11.185s&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;icc compiler took the following time to compile Ace source code.&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new'; font-size: 13px; "&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;real    1m44.366s&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;user    0m59.107s&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;sys     0m20.946s&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Gcc produced double the size of kernel.sys produced by icc. (I used GNU linker(ld) and ar).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;gcc output size:&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new'; font-size: 13px; "&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 102, 0);"&gt;[samuel@linux Ace3]$ ls -lh /home/samuel/Projects/Ace3/obj/&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 102, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new'; font-size: 13px;"&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 102, 0);"&gt;-rw-rw-r-- 1 samuel samuel 372K 2008-11-22 18:17 acpi.a&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 102, 0);"&gt;-rw-rw-r-- 1 samuel samuel 545K 2008-11-22 18:17 arch.a&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 102, 0);"&gt;-rwxrwxr-x 1 samuel samuel 1.3M 2008-11-22 18:17 kernel.sys&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 102, 0);"&gt;-rw-rw-r-- 1 samuel samuel  62K 2008-11-22 18:17 libds.a&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 102, 0);"&gt;-rw-rw-r-- 1 samuel samuel  40K 2008-11-22 18:17 libheap.a&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 102, 0);"&gt;-rw-rw-r-- 1 samuel samuel  39K 2008-11-22 18:17 libstring.a&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 102, 0);"&gt;-rw-rw-r-- 1 samuel samuel 9.5K 2008-11-22 18:17 libsync.a&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 102, 0);"&gt;-rw-rw-r-- 1 samuel samuel  91K 2008-11-22 18:17 pic.a&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 102, 0);"&gt;-rw-rw-r-- 1 samuel samuel  23K 2008-11-22 18:17 pit.a&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 102, 0);"&gt;-rw-rw-r-- 1 samuel samuel  21K 2008-11-22 18:17 rtc.a&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;icc output:&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;[samuel@linux Ace3]$ ls -lh /home/samuel/Projects/Ace3/obj/&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;-rw-rw-r-- 1 samuel samuel 352K 2008-11-22 16:25 acpi.a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;-rw-rw-r-- 1 samuel samuel 230K 2008-11-22 16:24 arch.a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;-rwxrwxr-x 1 samuel samuel 528K 2008-11-22 16:25 kernel.sys&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;-rw-rw-r-- 1 samuel samuel  38K 2008-11-22 16:23 libds.a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;-rw-rw-r-- 1 samuel samuel  22K 2008-11-22 16:23 libheap.a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;-rw-rw-r-- 1 samuel samuel  21K 2008-11-22 16:23 libstring.a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;-rw-rw-r-- 1 samuel samuel  11K 2008-11-22 16:23 libsync.a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;-rw-rw-r-- 1 samuel samuel  19K 2008-11-22 16:24 pic.a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;-rw-rw-r-- 1 samuel samuel 8.4K 2008-11-22 16:24 pit.a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;-rw-rw-r-- 1 samuel samuel  13K 2008-11-22 16:24 rtc.a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So it is easy to use icc instead of gcc. However since I am using Windows and icc is free only for Linux for non commerical purposes. I stick to gcc to compile Ace in Windows. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/22080276-5590876626919114639?l=samueldotj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/j8c96zhFVXj6dVoeqx88Flji0iM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/j8c96zhFVXj6dVoeqx88Flji0iM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/j8c96zhFVXj6dVoeqx88Flji0iM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/j8c96zhFVXj6dVoeqx88Flji0iM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/BCiPY/~4/d2kMmenl4DY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://samueldotj.blogspot.com/feeds/5590876626919114639/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=22080276&amp;postID=5590876626919114639" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/5590876626919114639?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/5590876626919114639?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/BCiPY/~3/d2kMmenl4DY/porting-to-intel-c-compiler.html" title="Porting to “Intel C Compiler”" /><author><name>Samuel</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://3.bp.blogspot.com/_fvvvrkKNkOQ/S3Uq3uF53jI/AAAAAAAAAiw/kEyMmo3OI_c/S220/sam.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://samueldotj.blogspot.com/2008/11/porting-to-intel-c-compiler.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkMFRnw9eCp7ImA9WxRVFUw.&quot;"><id>tag:blogger.com,1999:blog-22080276.post-3288424217832800283</id><published>2008-11-06T21:28:00.005+05:30</published><updated>2008-11-12T22:50:17.260+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-11-12T22:50:17.260+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Programming" /><category scheme="http://www.blogger.com/atom/ns#" term="make" /><title>GNU make slow build process</title><content type="html">&lt;div&gt;While building one my project it was taking too much time; the project was taking around 40-60 seconds to build and around 20 seconds to clean. I was frustrated with this because the debugging cycle time for my project was going high.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So I decided to stop debugging my project and start debugging the build process. In my makefile I had .SILENT option and I removed it to see what is going.  The following was the output&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;make[1]: Entering directory `/cygdrive/g/Projects/Ace3/src/lib'&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;make[2]: Entering directory `/cygdrive/g/Projects/Ace3/src/lib/string'&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;make[2]: Nothing to be done for `all'.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;..&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;make[1]: Leaving directory `/cygdrive/g/Projects/Ace3/src/lib'&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;make[1]: Entering directory `/cygdrive/g/Projects/Ace3/src/kernel'&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;..&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;make[2]: Leaving directory `/cygdrive/g/Projects/Ace3/src/kernel/pic'&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;New kernel is at /cygdrive/g/Projects/Ace3/obj/kernel.sys&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;/cygdrive/g/Projects/Ace3/img/create_bootcd.sh&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;Everything was fast, however there was huge delay before getting the output “&lt;span class="Apple-style-span" style="font-style: italic;"&gt;make[1]: Leaving directory `/cygdrive/g/Projects/Ace3/src/lib&lt;/span&gt;'”&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Then I tried invoking make with &lt;span class="Apple-style-span" style="font-weight: bold;"&gt;–d (debug)&lt;/span&gt; option and it gave the following output&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;This program built for i686-pc-cygwin&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Reading makefiles...&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Reading makefile `makefile'...&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Reading makefile `/cygdrive/g/Projects/Ace3/make.conf' (search path) (no ~ expansion)...&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Reading makefile `boot_module.d' (search path) (don't care) (no ~ expansion)...&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Reading makefile `interrupt.d' (search path) (don't care) (no ~ expansion)...&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Reading makefile `ktrace.d' (search path) (don't care) (no ~ expansion)...&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Reading makefile `main.d' (search path) (don't care) (no ~ expansion)...&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;And it took lot of time before continuing the from the above step, so I knew something wrong with the main.c dependency file, so I opened it and it had too many entries. I casually checked the size of the file and it was 50MB. That explained why make was slow. I carefully examined the dependency entries and found they were repeating. I opened make.conf and checked the rule for making dependency file and found the culprit &lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;blockquote&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;%.d:    %.c&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;@$(CC) -c -M $&lt; -I$(INCLUDE) $(CFLAGS) &gt;&gt; $@&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;The output redirection symbol &gt;&gt; caused the problem. It appended the dependency rules every time I compiled and increased the size of .d file.  I replaced &gt;&gt; with &gt; and now incremental build process completes in 3 seconds.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/22080276-3288424217832800283?l=samueldotj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/qx8vxdzuOiwsJIoC1jhuDfFZRkg/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/qx8vxdzuOiwsJIoC1jhuDfFZRkg/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/qx8vxdzuOiwsJIoC1jhuDfFZRkg/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/qx8vxdzuOiwsJIoC1jhuDfFZRkg/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/BCiPY/~4/SrcsaYwaAzQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://samueldotj.blogspot.com/feeds/3288424217832800283/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=22080276&amp;postID=3288424217832800283" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/3288424217832800283?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/3288424217832800283?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/BCiPY/~3/SrcsaYwaAzQ/gnu-make-slow.html" title="GNU make slow build process" /><author><name>Samuel</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://3.bp.blogspot.com/_fvvvrkKNkOQ/S3Uq3uF53jI/AAAAAAAAAiw/kEyMmo3OI_c/S220/sam.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://samueldotj.blogspot.com/2008/11/gnu-make-slow.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUcDQno-eCp7ImA9WxRXEEo.&quot;"><id>tag:blogger.com,1999:blog-22080276.post-2746596602519155628</id><published>2008-10-15T17:07:00.000+05:30</published><updated>2008-10-15T17:47:53.450+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-10-15T17:47:53.450+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Tools" /><title>Editing PDF files</title><content type="html">&lt;p class="MsoNormal"&gt;Today, I have to fill a form which is in the form of PDF and send it to some other city. Although it is a PDF file, it doesn’t have any input fields, so I have to take print out of the form and fill and then send it through postal mail. Instead I decided to try some pdf converters and after some searches got the link for &lt;a href="http://www.pdfonline.com/pdf2word/index.asp"&gt;http://www.pdfonline.com/pdf2word/index.asp&lt;/a&gt;. It is fast and produces rtf files.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt;I also got the following comparison pdf to word conversion utilities &lt;a href="http://www.freewaregenius.com/2008/03/28/how-to-convert-pdf-to-word-doc-for-free-a-comparative-test/"&gt;http://www.freewaregenius.com/2008/03/28/how-to-convert-pdf-to-word-doc-for-free-a-comparative-test/&lt;/a&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/22080276-2746596602519155628?l=samueldotj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/tN956v8lGfNu6E3X9oul1Vo22H4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/tN956v8lGfNu6E3X9oul1Vo22H4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/tN956v8lGfNu6E3X9oul1Vo22H4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/tN956v8lGfNu6E3X9oul1Vo22H4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/BCiPY/~4/kK5nWaJR7eA" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://samueldotj.blogspot.com/feeds/2746596602519155628/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=22080276&amp;postID=2746596602519155628" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/2746596602519155628?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/2746596602519155628?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/BCiPY/~3/kK5nWaJR7eA/editing-pdf-files.html" title="Editing PDF files" /><author><name>Samuel</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://3.bp.blogspot.com/_fvvvrkKNkOQ/S3Uq3uF53jI/AAAAAAAAAiw/kEyMmo3OI_c/S220/sam.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://samueldotj.blogspot.com/2008/10/editing-pdf-files.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A04EQn09fCp7ImA9WxRWEkQ.&quot;"><id>tag:blogger.com,1999:blog-22080276.post-1094555097120608965</id><published>2008-09-22T12:03:00.012+05:30</published><updated>2008-10-29T22:35:03.364+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-10-29T22:35:03.364+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C" /><category scheme="http://www.blogger.com/atom/ns#" term="Softwares" /><category scheme="http://www.blogger.com/atom/ns#" term="Windows" /><title>CodeLite - IDE for C</title><content type="html">For my C projects I was using Notepad++ as my editor/IDE for some time. Although notepad++ is good, it is lacking the integration with a code browser, source control and debugger.&lt;img src="http://4.bp.blogspot.com/_fvvvrkKNkOQ/SNc925QHgaI/AAAAAAAAAGs/Xui7mQdAcCc/s320/screen.JPG" style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer;" alt="" id="BLOGGER_PHOTO_ID_5248731904014254498" border="0" /&gt;&lt;br /&gt;I came to know about &lt;a href="http://www.blogger.com/www.codelite.org"&gt;CodeLite &lt;/a&gt;when I was searching for ctags for windows. It has integrated &lt;a href="http://subversion.tigris.org/"&gt;Subversion&lt;/a&gt;, &lt;a href="http://ctags.sourceforge.net/"&gt;ctags&lt;/a&gt;, &lt;a href="http://sourceware.org/gdb"&gt;gdb&lt;/a&gt; under one roof.&lt;br /&gt;&lt;br /&gt;Since it is multiplatform GUI, I was little reluctant to install and try(I have tried lot of multiplatform GUI applications and never satisfied with the look and feel of them). But wxWidgets makes the CodeLite to look like native windows application.&lt;br /&gt;&lt;br /&gt;CodeLite has lot of features and it looks very similar to VC++ IDE.&lt;br /&gt;&lt;br /&gt;Code browsing is very easy with CodeLite. It is has a very light explorer and also workspace view through which you can browse your project “easily”. You can switch between header and c file “easily” using the “Swap Header/implementation file” in the context menu. Context menus “Goto declaration” and “Goto Implementation” are handy to browse through code quickly.&lt;br /&gt;&lt;br /&gt;If you are using cygwin and custom makefile - you can use a script as custom build command -&lt;span class="Apple-style-span" style="font-weight: bold;"&gt; &lt;/span&gt;see &lt;a href="http://samueldotj.blogspot.com/2007/10/notepad-as-ide.html"&gt;http://samueldotj.blogspot.com/2007/10/notepad-as-ide.html&lt;/a&gt; for more details.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I use the following command to build(because I use gcc cross compiler)&lt;/div&gt;&lt;div&gt;c:\cygwin\bin\bash -l -c 'cd $ACE_ROOT/src;PATH=/usr/cross/i586-elf/bin/:$PATH:;make 2&gt; err; sed -e "s@\(\/cygdrive\/\)\([a-zA-Z]\)@\2:@g" err; rm err’. And the following command to clean&lt;/div&gt;&lt;div&gt;c:\cygwin\bin\bash -l -c 'cd $ACE_ROOT/src;PATH=/usr/cross/i586-elf/bin/:$PATH:;make clean’&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Codelite supports debugging through gdb; embedded and remote targets also supported. Since I am using a emulator to test my kernel, I have to use remote debugging in GDB to test my OS. Codelite integrates well with GDB remote debugging. I use the following GDB commands as startup gdb commands.&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;set print pretty on&lt;/div&gt;&lt;div&gt;directory src/kernel &lt;br /&gt;&lt;/div&gt;&lt;div&gt;symbol obj/kernel.sys&lt;/div&gt;&lt;div&gt;source img/gdb/general.gdb&lt;br /&gt;&lt;/div&gt;&lt;div&gt;source img/gdb/stack.gdb&lt;/div&gt;&lt;div&gt;source img/gdb/vm.gdb&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If SVN is configured, using codelite you can see difference between two versions of a same file. By default codelite uses the default diff viewer. It can be changed from Plugins menu -&gt; Subversion-&gt;Options and setting the value appropriately. I use &lt;a href="http://www.winmerge.org/"&gt;WinMerge &lt;/a&gt;to see differnece of source files and have the following settings:&lt;br /&gt;&lt;/div&gt;&lt;div&gt;External Diff viewer: &lt;span class="Apple-style-span" style="font-weight: bold;"&gt;C:\Program Files\WinMerge\WinMergeU.exe&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Arguments&lt;span class="Apple-style-span" style="font-weight: bold;"&gt; : /dl %bname /dr %mname %base %mine &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;Another good thing about CodeLite is still under development and your bug report/feature requests are solved within short time frame.&lt;br /&gt;&lt;br /&gt;You can download CodeLite from &lt;cite&gt;&lt;a href="http://www.codelite.org/"&gt;www.&lt;b&gt;codelite&lt;/b&gt;.org&lt;/a&gt;. It has installer for Windows and Linux also.&lt;/cite&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/22080276-1094555097120608965?l=samueldotj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/zxe5g_3_rgBXLVrxJrqRBE6FO2g/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/zxe5g_3_rgBXLVrxJrqRBE6FO2g/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/zxe5g_3_rgBXLVrxJrqRBE6FO2g/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/zxe5g_3_rgBXLVrxJrqRBE6FO2g/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/BCiPY/~4/899FQJMzSlw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://samueldotj.blogspot.com/feeds/1094555097120608965/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=22080276&amp;postID=1094555097120608965" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/1094555097120608965?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/1094555097120608965?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/BCiPY/~3/899FQJMzSlw/codelite-ide-for-c.html" title="CodeLite - IDE for C" /><author><name>Samuel</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://3.bp.blogspot.com/_fvvvrkKNkOQ/S3Uq3uF53jI/AAAAAAAAAiw/kEyMmo3OI_c/S220/sam.JPG" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/_fvvvrkKNkOQ/SNc925QHgaI/AAAAAAAAAGs/Xui7mQdAcCc/s72-c/screen.JPG" height="72" width="72" /><thr:total>4</thr:total><feedburner:origLink>http://samueldotj.blogspot.com/2008/09/codelite-ide-for-c.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CU4GRHg-fip7ImA9WxRTEE4.&quot;"><id>tag:blogger.com,1999:blog-22080276.post-3493290624884259807</id><published>2008-07-21T15:52:00.003+05:30</published><updated>2008-08-29T23:48:45.656+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-08-29T23:48:45.656+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C" /><category scheme="http://www.blogger.com/atom/ns#" term="Programming" /><category scheme="http://www.blogger.com/atom/ns#" term="Tools" /><category scheme="http://www.blogger.com/atom/ns#" term="Windows" /><title>Source code browsing tool</title><content type="html">In UNIX environment there is the famous “&lt;span style="font-weight: bold;"&gt;cscope&lt;/span&gt;”, to browse the source code and make changes. Using cscope it is easy to browse/edit the source code, cross reference all the functions calling a function, including a file etc.&lt;br /&gt;&lt;br /&gt;In windows, I was using notepad++’s find files options browse C source code. Today I decided to find an open source full fledged source navigator for windows.&lt;br /&gt;&lt;br /&gt;I started with notepad++ plugin – “Function List”. But it is just not enough for a project source browsing. Google searches gave me cscope port of windows(http://cscope.sourceforge.net/). However I wanted more – the GUI. With few more searches I found &lt;span style="font-weight: bold;"&gt;Source Navigator&lt;/span&gt; - http://sourcenav.sourceforge.net/&lt;br /&gt;&lt;br /&gt;Soucrce Navigator is very useful, I just added my project and it give me full list of symbols. Editing a function is just clicking it. Since I am using notepad++ for editing anything, I changed the editor preference to notepad++. To do go to Source Navigator-&gt;File menu-&gt;Project Preference-&gt;Edit-&gt; External editor and give the following line &lt;span style="font-weight: bold;font-family:courier new;" &gt;&lt;br /&gt;"C:\Program Files\Notepad++\notepad++.exe" -n%l&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now I can easily browse the source code in Source Navigator and edit it in Notepad++ with few keystrokes.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/22080276-3493290624884259807?l=samueldotj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/BHaLbYKP2_pWvc5HBkFXCDaxlMo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/BHaLbYKP2_pWvc5HBkFXCDaxlMo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/BHaLbYKP2_pWvc5HBkFXCDaxlMo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/BHaLbYKP2_pWvc5HBkFXCDaxlMo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/BCiPY/~4/pvWQ1DH_KvY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://samueldotj.blogspot.com/feeds/3493290624884259807/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=22080276&amp;postID=3493290624884259807" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/3493290624884259807?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/3493290624884259807?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/BCiPY/~3/pvWQ1DH_KvY/source-code-browsing-tool.html" title="Source code browsing tool" /><author><name>Samuel</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://3.bp.blogspot.com/_fvvvrkKNkOQ/S3Uq3uF53jI/AAAAAAAAAiw/kEyMmo3OI_c/S220/sam.JPG" /></author><thr:total>1</thr:total><feedburner:origLink>http://samueldotj.blogspot.com/2008/07/source-code-browsing-tool.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CU4CQXg5fCp7ImA9WxRTEE4.&quot;"><id>tag:blogger.com,1999:blog-22080276.post-8871192515567250868</id><published>2008-07-05T15:05:00.005+05:30</published><updated>2008-08-29T23:49:20.624+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-08-29T23:49:20.624+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Tools" /><category scheme="http://www.blogger.com/atom/ns#" term="Windows" /><category scheme="http://www.blogger.com/atom/ns#" term="Ace" /><title>Network Booting</title><content type="html">After creating Ace bootable CD, I decided to try to make Ace bootable from network also to completely avoid creation of disk images. Network booting also helps to boot test machine (real machine) on the same network with ease.&lt;br /&gt;&lt;br /&gt;Earlier I had grub installed (on a disk) on a test machine (real machine) with network support. Grub can get the kernel using tftp and boots the system.&lt;br /&gt;&lt;br /&gt;Now I wanted to avoid installing grub on a disk. So I had only one option diskless boot. So I decided to use PXE(Preboot eXecution Environment).&lt;br /&gt;&lt;br /&gt;To make PXE work, I needed a DHCP server and TFTP server. There are lot of tools available for Linux but for Windows, very very less tools available. After some internet searches, I found and downloaded perfect tools: Dual Server &lt;a href="http://sourceforge.net/projects/dhcp-dns-server/"&gt;http://sourceforge.net/projects/dhcp-dns-server/&lt;/a&gt; and TFTP Server &lt;a href="http://sourceforge.net/projects/tftp-server/"&gt;http://sourceforge.net/projects/tftp-server/&lt;/a&gt; both projects are developed and maintained by Achal Dhir. The other tftp/dhcp servers available windows doesn’t have large set of options provided by Dual Server and TFTP server.&lt;br /&gt;&lt;br /&gt;Since I wanted to try PXE boot on emulators, I needed to create software network tap adapter. Without software tap adapter, emulated network card cant talk to the physical network. So I downloaded OpenVPN, which has tool to create tap devices from &lt;a href="http://openvpn.net/index.php/downloads.html"&gt;http://openvpn.net/index.php/downloads.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;If you are using real machine, you may need to download and install PXE roms from etherboot.org &lt;a href="http://rom-o-matic.net/"&gt;http://rom-o-matic.net/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;To boot from network, grub should be compiled with appropriate network driver and other flags. Since grub has some problem with compiling under Windows, I used a Linux machine to compile.&lt;br /&gt;cvs -z3 -d:pserver:anonymous@cvs.savannah.gnu.org:/sources/grub co grub&lt;br /&gt;cd grub&lt;br /&gt;./configure –-enable-diskless –-enable-pxe –-enable-rtl8139&lt;br /&gt;You might want to compile in the preset menu also using the --preset option.&lt;br /&gt;&lt;br /&gt;Now configure Dual DHCP server to provide IP address, boot file information to qemu&lt;br /&gt;#qemu-ne2k-pci&lt;br /&gt;[52:54:00:12:34:56]&lt;br /&gt;IP_Addr=192.168.2.200&lt;br /&gt;HostName=QemuBox&lt;br /&gt;DNS_Server=192.168.2.10&lt;br /&gt;Router=192.168.2.10&lt;br /&gt;Boot_File=pxegrub-ne2k-pci&lt;br /&gt;Next_Server=192.168.2.10&lt;br /&gt;&lt;br /&gt;Then configure TFTP server for the correct tftp home folder.&lt;br /&gt;&lt;br /&gt;Now it is time to run, Qemu. Note – Windows port of Qemu 0.9.0 has some problem with obtaining DHCP, so install Qemu 0.9.1 and run the following command, it will boot from network.&lt;br /&gt;&lt;br /&gt;qemu -L "$QEMU_BIOS_DIR" -M pc -m 32 -no-kqemu -hdc c.img -boot n -net nic,model=ne2k_pci,macaddr=52:54:00:12:34:56,vlan=0 -net tap,vlan=0,ifname=tap0&lt;br /&gt;&lt;br /&gt;I am able to PXE boot qemu only with NE2000 cards, for other cards it failing. PXE boot on vmware only works if I configure grub using ifconfig command. Otherwise vmware machines get assigned with some wrong gateway address. No luck to PXE boot Ace on bochs.&lt;br /&gt;&lt;br /&gt;For booting my test machine(real machine), I setup my router (DD-WRT box) with boot-dhcp option in &lt;span class="postbody"&gt;DNSMasq.&lt;/span&gt;&lt;br /&gt;&lt;a href="http://www.dd-wrt.com/phpBB2/viewtopic.php?t=4662&amp;amp;highlight=pxe"&gt;http://www.dd-wrt.com/phpBB2/viewtopic.php?t=4662&amp;amp;highlight=pxe&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/22080276-8871192515567250868?l=samueldotj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/5SWiYJLjVz5XNQEKcDV9J09mlPU/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/5SWiYJLjVz5XNQEKcDV9J09mlPU/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/5SWiYJLjVz5XNQEKcDV9J09mlPU/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/5SWiYJLjVz5XNQEKcDV9J09mlPU/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/BCiPY/~4/4tCL9kkmWLw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://samueldotj.blogspot.com/feeds/8871192515567250868/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=22080276&amp;postID=8871192515567250868" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/8871192515567250868?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/8871192515567250868?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/BCiPY/~3/4tCL9kkmWLw/network-booting.html" title="Network Booting" /><author><name>Samuel</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://3.bp.blogspot.com/_fvvvrkKNkOQ/S3Uq3uF53jI/AAAAAAAAAiw/kEyMmo3OI_c/S220/sam.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://samueldotj.blogspot.com/2008/07/network-booting.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkcEQ30-fyp7ImA9WxRTEE4.&quot;"><id>tag:blogger.com,1999:blog-22080276.post-8579960267036637003</id><published>2008-07-05T14:38:00.002+05:30</published><updated>2008-08-29T23:50:02.357+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-08-29T23:50:02.357+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Tools" /><category scheme="http://www.blogger.com/atom/ns#" term="kernel" /><category scheme="http://www.blogger.com/atom/ns#" term="Ace" /><title>Bootable CD with Grub</title><content type="html">Last week, I decided to boot Ace using CD image rather than floppy image because booting was slow when floppy image is used in bochs.&lt;br /&gt;&lt;br /&gt;To create bootable cd with grub, stage2_eltorito should compiled from the grub source. The mkisofs is also needed to create the image. http://smithii.com/cdrtools contains windows cygwin port of the cdrtools which contains mkisofs.&lt;br /&gt;&lt;br /&gt;mkdir -p $ACE_ROOT/img/iso/boot/grub&lt;br /&gt;cp $ACE_ROOT/img/boot/grub/stage2_eltorito $ACE_ROOT/img/iso/boot/grub&lt;br /&gt;cp $ACE_ROOT/img/boot/grub/menu.lst $ACE_ROOT/img/iso/boot/grub&lt;br /&gt;cp $ACE_ROOT/obj/kernel.sys $ACE_ROOT/img/iso/&lt;br /&gt;&lt;br /&gt;mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o $ACE_ROOT/img/bootcd.iso $ACE_ROOT/img/iso&lt;br /&gt;&lt;br /&gt;This image can be written to a CD using a cd writing tool like nero.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/22080276-8579960267036637003?l=samueldotj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/NVyBKWntTumkw5Ozs-QqhC5WHU0/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/NVyBKWntTumkw5Ozs-QqhC5WHU0/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/NVyBKWntTumkw5Ozs-QqhC5WHU0/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/NVyBKWntTumkw5Ozs-QqhC5WHU0/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/BCiPY/~4/n8jau3NhOd0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://samueldotj.blogspot.com/feeds/8579960267036637003/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=22080276&amp;postID=8579960267036637003" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/8579960267036637003?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/8579960267036637003?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/BCiPY/~3/n8jau3NhOd0/bootable-cd-with-grub.html" title="Bootable CD with Grub" /><author><name>Samuel</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://3.bp.blogspot.com/_fvvvrkKNkOQ/S3Uq3uF53jI/AAAAAAAAAiw/kEyMmo3OI_c/S220/sam.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://samueldotj.blogspot.com/2008/07/bootable-cd-with-grub.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEQGR3s9eip7ImA9WxdRFkk.&quot;"><id>tag:blogger.com,1999:blog-22080276.post-923386131352886615</id><published>2008-06-05T11:35:00.002+05:30</published><updated>2008-06-05T11:42:06.562+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-06-05T11:42:06.562+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C" /><category scheme="http://www.blogger.com/atom/ns#" term="Programming" /><title>Bitfield inside a Union</title><content type="html">When coding Ace physical memory manager, I came to a situation where I have to use lot of bit operations on a integer variable. The code looked little ugly because of the explicit bit operations(left shift&lt;&lt;, and &amp;amp; …), so I changed the code to use C bitfields.  &lt;br /&gt;&lt;pre&gt;&lt;br /&gt;typedef struct struct_x&lt;br /&gt;{&lt;br /&gt; union&lt;br /&gt; {&lt;br /&gt;  int all;&lt;br /&gt;  int x:1,y:1,z:30,&lt;br /&gt; };&lt;br /&gt;};&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The above code wasn’t working; debugging further I found that the values for bitfields are not calculated correctly.&lt;br /&gt;&lt;br /&gt;After some digging I found that, the bitfield hint is ignored by the compiler since it is directly under union. So the compiler treated the fields x,y,z as separate integer instead of considering as one.&lt;br /&gt;&lt;br /&gt;I modified the code to pack the bitfields inside a structure and it worked correctly.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;typedef struct struct_x&lt;br /&gt;{&lt;br /&gt; union&lt;br /&gt; {&lt;br /&gt;  int all;&lt;br /&gt;  struct&lt;br /&gt;  {&lt;br /&gt;   int x:1, y:1, z:30,&lt;br /&gt;  }_;&lt;br /&gt; };&lt;br /&gt;};&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;And yes, just an underscore(_) is a valid identifier.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/22080276-923386131352886615?l=samueldotj.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/nI201v9p9YwsT9kBDHmP3vLTIZs/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/nI201v9p9YwsT9kBDHmP3vLTIZs/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/nI201v9p9YwsT9kBDHmP3vLTIZs/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/nI201v9p9YwsT9kBDHmP3vLTIZs/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/BCiPY/~4/NbZAkUvegI4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://samueldotj.blogspot.com/feeds/923386131352886615/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=22080276&amp;postID=923386131352886615" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/923386131352886615?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/22080276/posts/default/923386131352886615?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/blogspot/BCiPY/~3/NbZAkUvegI4/bitfield-inside-union.html" title="Bitfield inside a Union" /><author><name>Samuel</name><uri>http://www.blogger.com/profile/06562486253389167106</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="30" height="32" src="http://3.bp.blogspot.com/_fvvvrkKNkOQ/S3Uq3uF53jI/AAAAAAAAAiw/kEyMmo3OI_c/S220/sam.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://samueldotj.blogspot.com/2008/06/bitfield-inside-union.html</feedburner:origLink></entry></feed>

