August 2009
59 posts
Kirtika took on a really difficult project for her summer of code and made wonderful progress. In short she wrote a ton of recipes to build as much of Nokia’s Maemo distro as possible from OpenEmbedded. A really neat project and I expect it to just get better and attract more developers in time.
I went off the deep end earlier this year and decided I must have a full GUI IDE for writing code. No one can explain this phenomena, seeing how througout all of 2007 and 2008 I used ratpoison exclusively as my window manager.
With an increased need to develop and test GNOME components I did eventually switch to a full GNOME desktop environment on my work PC and with that came a sort of freakish hunger to use Anjuta or Eclipse or whatever to reach some kinda of mouse-clicky C-navigating nirvana.
Big mistake. I won’t go into the reasons why Eclipse’s CDT code indexer just breaks all over itself on epic codebases such as Linux (which use lots of macro defs and GCC extensions) or why Anjuta insists on littering my git repository with things I simply don’t want. The point is that I came back to my senses and once again started using vim with cscope.
The following is a quick set of steps to get cscope up and running quickly for the specific case of Linux kernel development. I won’t be setting up some central location for storing cscope files such as ~/cscope/ nor will I by using $CSCOPE_DB. Instead I’m just going to create the index files in the root of my kernel git tree where they will safely be ignored by the .gitignore file there.
The working directory will need to always be the root of my kernel tree this way. IE, if I cd to $LINUX/drivers/video/omap/ and then open a file there, cscope will not work for me. Instead cd simply to $LINUX and then ‘vim drivers/video/omap/whatever.c’. Got it? Good.
Install cscope if you haven’t already. For Debian derivatives:
sudo apt-get install cscope
For convenience install the vim keymap plugin for cscope from here. The rest of this tutorial will take place in the top level of the kernel source:
cd ~/linux-omap-2.6/
Use the following command to create a list of files to index. More notes on this method below the code block:
find . -path "./arch/*" ! -path "./arch/arm*" -prune -o -path "./include/asm-*" ! -path "./include/asm-arm*" -prune -o -path "./tmp*" -prune -o -path "./Documentation*" -prune -o -path "./scripts*" -prune -o -name "*.[chxsS]" -print > cscope.files
The above find command populates cscope.files with a list files for indexing. This includes drivers and arch/arm since I care about OMAP and ARM. However I don’t care about indexing code from other architectures, nor do I care about indexing the docs, scripts and other stuff. I could also fine tune this to only care about OMAP-specific arch stuff, but I’ve left it as generic for all ARM machines for readability.
Experiment with that command to construct a list of files that is perfect for your needs. Now lets use cscope.files to generate the data needed by cscope proper:
cscope -b -q -k
This command will create cscope.out and some other files. Now I’m ready to start using the index. First I’ll skip straight to the definition of some symbol:
vim -t spi_device
The above will probably pull up a text menu giving me options with the line from each relevant source file containing that symbol. In my kernel sources I get four options, the fourth of which is the actual struct definition in include/linux/spi/spi.h. I just need to press ‘4’ and ‘enter’ and boom I’m whisked away to that file. Neat huh?
Now inside of spi.h I will put cursor anywhere over the file path in:
#include <linux/device.h>
and quickly tap Ctrl-\ + f. That is to say “hold control and backslash at the same time and then quickly tap f”. The “f” in this combo means “take me to the file under my cursor” and of course is only relevant to file paths. This becomes handy quickly.
Say I open drivers/video/omap2/displays/panel-zoom2.c and put my cursor over the path in:
#include <mach/mux.h>
Hitting Ctrl-\ + f results in the following menu popping up:
Cscope tag: mach/mux.h
# line filename / context / line
1 1 arch/arm/mach-davinci/include/mach/mux.h <<<unknown>>>
2 1 arch/arm/plat-omap/include/mach/mux.h <<<unknown>>>
Type number and <Enter> (empty cancels):
For anyone that has had to keep track of multiple architectures or get used to a new kernel version that has a different layout of code this is clearly helpful.
Probably the feature I use the most is the cursor symbol search. This works identical to the cursor file search above, but instead of placing the cursor on a file path you just place it over a symbol. For example in the same panel-zoom2.c I can put my mouse over the function name in:
static void zoom2_panel_disable(struct omap_dss_device *dssdev)
{
if (dssdev->platform_disable)
dssdev->platform_disable(dssdev);
mdelay(4);
}
and press Ctrl-\ + s. This present a menu showing all of the uses of ‘zoom2_panel_disable’ in the code. In this case they are all local to panel-zoom2.c but they could be all over the place. Likewise if I just want the global defininition of a symbol instead of a list of every place it exists I can use Ctrl-\ + g.
I don’t have have my cursor over a symbol to search for it either (though this will often by the case). In vim’s command mode I can run:
:cscope find s omap3_enable_io_chain
And I will be greeted with the familiar window you get when using cursor symbol search. To see more options for command mode search just run:
:cscope
Finally I can use Ctrl-t to pop these search results off of the stack and effectively go backwards through my search. This is helpful for digging into code I am not familiar with in a source file, finding out all of the details through cscope searches, and then backing out to my original files to write slightly more enlightened code.
I’m currently in the process of pushing Zoom2 support to upstream Poky. I feel like there is a lot of unfocused energy that wants this to happen at TI, but no one is set on doing it. Conveniently I enjoy such work so very slowly I have started to send merge requests to Richard Purdie’s tree.
The first of the commits can be found here and here. No display is present since the kernel recipes so far don’t include the pending DSS2 changes. Hopefully those will get merged soon or I’ll have to patch them in or make yet another kernel recipe.
Some interesting design issues are up for debate. What is the most graceful way to build GLES libs from the publically available SDK? Which kernels should be supported? IE, Google’s OMAP Android tree, Tony Lindgren’s upstream linux-omap, feature trees like Kevin Hilman’s linux-omap-pm or Tomi Valkeinen’s DSS2 tree.
I’ve also been in talks with Rob Clark about how best to write recipes that build DSP-side code. I’m fond of a generic coprocessor.bbclass that any recipe can use as a template for specifying toolchain oddities, architecture type (so DSP recipes don’t get mixed with your primary board architecture) and other bits that might be useful to a wide array of different coprocessors.
I’d like any such changes to make to both Poky and OpenEmbedded, so if you have thoughts these subjects please chime in!
Ah tumblr. How I missed thee. Apparently tumblr hasn’t been missing me. I am surprised to find that this blog has carried on like a bizarro version of twitter, steadily republishing tweets, brightkite updates and delicious bookmark saves for months and months. Who knew?
Well there is a new sheriff in town and I’m conscripting this blog into the OMAP Linux Expeditionary Force. May our enterprise prosper and profit!
So what does it all mean? This blog will immediately cease to regurgitate all of my digital living and instead be re-purposed as a true web log, complete with punditry, projects, pictures and prospecting. If you still want to track all of my digital doings online (and why wouldn’t you?) you can do so on twitter, where one can easily find fascinating topics such as where I am located, recent github.com commits and my latest bookmarks saved to delicious. Substantiating!
Some topics I hope to cover on this blog are SDR on the Beagle board, GNOME Mobile development, Zoom2 hacking, power management on OMAP and my prognostications on the fascinating and turbulent wireless market. I also hack on Poky, a mobile-focused OpenEmbedded derivative and my paycheck is primarily resultant from Android kernel development which seems a popular item at the moment. Please drop me a line, suggest a topic for discussion and in general be an awesome netizen.
woke up in a cold sweat; I had forgotten today was the ISO audit! Got to work in record time and cleaned up my cube something fierce.
I’m at Texas Instruments Inc - http://bkite.com/0aR3b
I’m at Highland Park - http://bkite.com/0aPEK
hell yeah! finally a new #fon coming to the USA! http://bit.ly/2z2Klj
lap 1
I’m at Dallas-Fort Worth International Airport - http://bkite.com/0aMmN
got hit with overage charge on my AT&T wireless bill. I want a data-only plan with a nice voip solution. voice sucks.
I’m at Texas Instruments Inc - http://bkite.com/0aJWG
I’m at Highland Park - http://bkite.com/0aG3l
Just added myself to the http://wefollow.com twitter directory under: #linux #cycling #opensource
I’m at Texas Instruments Inc - http://bkite.com/0aFbZ
srsly, facebook is evil. don’t be fooled by the friendfeed thing. http://bit.ly/aQwD
it can be hard to focus on the same project every day. that is why one needs other projects to focus on. diversity is important.
I’m at Highland Park - http://bkite.com/0aAx5
watching sesame street during breakfast. how is it possible that big bird can’t read a book after all these years?
lap 2
lap 1
gonna try some homemade steamed egg rolls filled with sweet potato on tomorrow’s ride. hopefully i have invented the perfect on-bike food!
I’m at Highland Park - http://bkite.com/0avaA
starting ride.
lap 5
lap 3
fin!
lap 4
I’m at Chipotle - Central Expressway - http://bkite.com/0awFL
shared a workout on Strands on http://www.strands.com/mturquette/posts/12737581: ‘Rode intervals and did sprint-repeats in Allen. Was …
Start using Mint.com to manage your money today! http://bit.ly/GLBHi
2009 Rouleur Magazine - Competitive Cyclist http://bit.ly/I9HvU
linux-omap Mail Archive http://bit.ly/ndS0u
vim and linux CodingStyle - Bart’s Blog http://bit.ly/1a4IEE
stomach ache today. think i’ve been drinking too much coffee.
I’m at Texas Instruments Inc - http://bkite.com/0amAf
Inline Functions In C http://bit.ly/9ppPS