GNU/Linux Tweaks
This section contains a collection of some GNU/Linux tips and tweaks. An overview:
- Tab completion
- Modifying the Grub splash image
- Booting from an installer ISO image
- Some great vim features
- Profiling multiple instances of one executable
- Using git to backup your private projects over ssh
- Embedding fonts in a PDF
- Producing proper handouts from OpenOffice Impress
- Programming Xilinx FPGAs
Tab completion
By default, tab completion on several distributions does not show the list of all possible options immediately, without having to hit the TAB-key several times. Add the line "set show-all-if-ambiguous on" to your /etc/inputrc or /.inputrc file to make the TAB-key show all completion options immediately.
Modifying the Grub splash image
Using the GIMP for example, create a .xpm image consisting of 14 colours. Gzip this image and put it in /boot/grub. Now edit /boot/grub/grub.conf and add/modify the splashimage parameter into: splashimage=(hd0,0)/grub/yourimage.xpm.gz .
Booting from an installer ISO image
First, mount the ISO image and copy the files initrd-2.6..., System.map-2.6... and vmlinuz-2.6... to /boot. (as of Fedora 10) Copy images/install.img to the directory containing the ISO file (preserve the images/ directory).
Next, edit your Grub configuration and add an entry for the installer. The easiest way to do this, is by copying the default grub entry and changing the filenames in that entry accordingly.
Reboot your system and select the new entry. The installer will launch and ask you to enter the location of the ISO image. If you had downloaded the ISO into /data/iso, and /data is the mount point for partition /dev/sda3, then you need to select /dev/sda3 in the menu and enter /iso in the path field.
Some great vim features
The vim editor offers a vast amount of features. I really like the following:
- Ctrl+a and Ctrl+x to increment resp. decrement the current number under your cursor. When you're using screen (with Ctrl+a as command character), use Ctrl+a, a to increment.
- Ctrl+n in insert mode to complete a word. Shows a browsable list when multiple alternatives are possible.
- Starting vim with command line option +42 opens the file at line 42.
- Press * to search for the current word under your cursor.
- Remember that i (insert) is also just a command, which means it can be repeated using . (dot) like any other command.
- When jumping back and forth in large files, it may be convenient to use markers. Use m followed by a letter to set the marker; then use ` (backtick) followed by the letter to go back to a previously set marker.
- Use ! to launch a shell command. If you're really too lazy to open up another console, you can even launch a shell prompt from vim by entering :!bash. Entering exit returns you to vim.
Profiling multiple instances of one executable
Suppose you want to profile (using gprof) an executable of which several instances will be running at the same time. By default, only one gmon.out file will be created, which will be overwritten by the different instances. To get a separate gmon.out for every instance of the executable, set the GMON_OUT_PREFIX environment variable before running the executable.
Using git to backup your private projects over ssh
If you have an ssh account on some server, you can use git to easily backup anything you want. First, login to the ssh server and setup a bare repository:
ssh username@server.org mkdir myrepo.git cd myrepo.git git init --bare
Then, on your local machine, setup a repo as follows:
cd yourproject git init git add yourfiles git commit git remote add origin ssh://username@server.org/path/to/myrepo.git git push origin master
From now on, you can simply use git push to backup your project (provided that you first git-commit your local changes). To retrieve the backup, simply clone the repo:
git clone ssh://username@server.org/path/to/myrepo.git
Note that cloning an empty repo (which has just been initialized using git init --bare) will give an error message "fatal: no matching remote head", so you can clone only after committing and pushing at least one file.
Embedding fonts in a PDF
When preparing the final manuscript of a conference paper, all fonts need to be embedded into the PDF file. To accomplish this, run the following (after producing a .dvi file):
dvips -t letter -Ppdf -G0 paper.dvi -o paper.ps
Replace ''letter'' with ''a4'' depending on the conference requirements. Then, run the following to produce the final PDF:
ps2pdf -dPDFSETTINGS=/printer -dMaxSubsetPct=100 \
-dSubsetFonts=true -dEmbedAllFonts=true paper.pdf
To inspect the resulting PDF, run:
pdffonts paper.pdf
If all fonts are properly embedded, there should be no ''no'' in the ''emb'' column.
Producing proper handouts from OpenOffice Impress
I found that OpenOffice 3.2.1 produces low-resolution, pixelated and distorted graphics when printing handouts with e.g. 6 slides per page. After trying various workarounds, I found the following solution:
- Install the pdfjam package, which contains pdfnup.
- Export your slides to PDF.
- Run
pdfnup --nup 2x3 --frame true --delta "1cm 1cm" \ --scale 0.9 file.pdf
Programming Xilinx FPGAs
How to program a Xilinx FPGA board on a GNU/Linux system? In this section, I describe a possible method.
What do I need?
- A Linux system. ORLY? YARLY, I used a Fedora Core 6 system.
- An FPGA board. I have tested both the ML310 and XUP-V2P boards, both containing a Xilinx Virtex 2 Pro.
- Xilinx Parallel Cable IV. Parallel Cable III might also work.
- The libusb-driver library, available at http://www.rmdir.de/~michael/xilinx/. Don't be confused by the name, it also supports parallel cables. :)
- Xilinx iMPACT, which comes with ISE 9.2 for example.
Got all of that, what's next?
1. Compile the libusb-driver. Make the LD_PRELOAD environment variable point to libusb-driver.so.2. Make sure the modules parport, parport_pc and ppdev are active. Use the modprobe command when necessary.
3. Make sure that permissions for the parallel port are set up correctly. If you get a "permission denied" error, it is likely this is not the case.
4. Now run iMPACT, setup the JTAG programming chain and program the FPGA device. Programming will take a while, since the libusb-driver does not support the parallel cable at full speed. Particularly the last percent of the progress bar takes a while to complete. Just be patient, it will eventually complete. :)

