LinuxConsulting

- Nicu Pavel personal page

PaNiC Random Rant (or how we used to call it: .plan)


Friday, March 19, 2010

This blog has moved



This blog is now located at http://blog.linuxconsulting.ro/.
You will be automatically redirected in 30 seconds, or you may click here.

For feed subscribers, please update your feed subscriptions to
http://blog.linuxconsulting.ro/feeds/posts/default.

posted by panic @ 12:16 PM 0 Comments


Tuesday, November 24, 2009

The irrepressible ... Bing


Rumors grew of a "new" search engine shadowing the internet. It uses the power of lie, deceit and bribery to grow, soon it will engulf everything in predetermined results (we have 1000+ monkeys and we're using them), devious filters (we see no point in indexing open source websites since most of them are out of date) and evil spell checking (Did you mean IIS server ? No? Apache ? Well I still think you are looking for IIS so I'll show you the IIS results).
So how can it be stopped ? Well this is no ordinary (or should I say standard ?) bad guy, so it won't be stopped with your measly robots.txt file by adding:

User-agent: msnbot
Disallow: /

in it. No, this requires a higher magic, but we can rely on apache mod_setenvif wisdom by adding:
BrowserMatchNoCase msnbot goBang
Order Deny,Allow
Deny from env=goBang

in your .htaccess file.
This should make Bing go with a Bang.
If you're using something light(http)er you might want to check this.

Labels: , ,

posted by panic @ 7:44 AM 0 Comments


Monday, August 3, 2009

QMake with Visual Studio: Generating debug information (pdb) files


Working with multiple libraries on different subdirs in Visual Studio using QMake tools brings a problem when you try to debug code that is contained in those libraries: the debug files (pdb) are generated with same name (vc80.pdb or similar) in libraries dirs which results in visual studio being unable to get the right debug information. To fix this problem pdb files need to be renamed and placed in the location where the executable is run for debugging.
As an example we have a main .pro file which it's a subdirs template to compile code in multiple subdirs:

TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS += mbl_utils \
mbl_usb \
mbl_encoder \
mbl_renderer \
nanoGUI


For each .pro file in the libraries subdirectory we will have to add on a debug:win32 entry the following code:


debug:win32 {
# Hack to get pdb files generated with proper name
QMAKE_CXXFLAGS += -Fd$${TARGET}.pdb
# Hack to get pdb files copied in Bin folder from where the binary is run
pdbtarget.files = $${TARGET}.pdb
pdbtarget.path = $${BINDIR}
pdbtarget.command = copy /y $${TARGET}.pdb $${BINDIR}
INSTALLS += pdbtarget
}


Where TARGET is defined as the library name and BINDIR is where the executable file is copied after compilation. This should create proper debug information files where the project executable is being run.

Labels: , , ,

posted by panic @ 12:44 PM 0 Comments


Monday, June 22, 2009

lcdproc 0.5.3 released and ubuntu package for picoLCD


A new version(0.5.3) of lcdproc has been released. This release has a lot of improvements for picoLCD and other drivers.
I made a quick ubuntu package for picoLCD (models 20x2 and 20x4) which can be downloaded from the link below. This package has only the picoLCD driver and the configuration is made for picoLCD (note that ServerScreen is set to off to fix some problems with mythtv).
To start lcdproc execute /etc/init.d/LCDd start and start any client you want (lcdproc, lcdvc etc).

If you intend to use the IR functionality don't forget to add :

REMOTE="Network (UDP)"
REMOTE_MODULES=""
REMOTE_DRIVER="udp"

REMOTE_LIRCD_ARGS="--listen=8765"

to /etc/lirc/hardware.conf

To start lirc manually you can use: lircd --driver=udp --listen=8765

uploads-blog/lcdproc_0.5.3-1_i386.deb

Labels: , ,

posted by panic @ 9:38 AM 2 Comments


Thursday, June 18, 2009

Using video RAM ...


Since I was playing with some jffs images, I wanted to quickly write to a "dummy" mtd device and test the image from there. I remembered some time ago on slashdot there was an interesting article on how to use the video ram as storage. As I couldn't find it anymore I decided to try it myself.

Usually mounting jffs images requires some steps and the mtd2block kernel module:

losetup /dev/loop0 rootfs.jffs2
modprobe block2mtd block2mtd=/dev/loop0,131072
modprobe jffs2
modprobe mtdblock
mkdir /mnt/loop0
mount -t jffs2 -o ro /dev/mtdblock0 /mnt/loop0

Using the video ram:

1. Find out the starting address of video memory:
> lspci -v
2:00.0 VGA compatible controller: nVidia Corporation G94 [GeForce 9600 GT] (rev a1)
Subsystem: LeadTek Research Inc. Device 2ac1
Flags: bus master, fast devsel, latency 0, IRQ 18
Memory at fd000000 (32-bit, non-prefetchable) [size=16M]
Memory at d0000000 (64-bit, prefetchable) [size=256M]
Memory at fa000000 (64-bit, non-prefetchable) [size=32M]
I/O ports at ec00 [size=128]
[virtual] Expansion ROM at feb80000 [disabled] [size=512K]

As above the video memory starts at 0xd0000000

2. Map the video ram into a mtd block
> modprobe slram map=VRAM,0xd2000000,+0x4000000

Note that I maped from 0xd0000000 + 32Mb to let some video memory to be used by framebuffer/X (if you use nv driver you can specify VideoRam 32765 in xorg.conf to limit the memory mappings).
The third parameter (+0x4000000) is the memory size (64Mb)
If everything is ok you should see something like this in dmesg log:

slram: Mapped from 0xf8f00000 to 0xfaf00000
slram: devname=VRAM, devstart=0xd2000000, devlength=0x2000000

devstart and devlength depend on your parameters.

Doing cat /proc/mtd should output:
mtd0: 02000000 00004000 "VRAM"

3. Add the kernel mtd modules and create the mtdblock devices

modprobe mtd
modprobe mtd_blkdevs
modprobe mtdblock

mknod /dev/mtdblock0 b 31 0
mknod /dev/mtd0 c 90 0

Now you can use the /dev/mtdblock0 to write jffs images or use it as a very fast swap (mkswap /dev/mtdblock0, swapon)

Notice that you can't create partitions directly in /dev/mtdblock0 with fdisk and use /dev/mtdblock0p1. Partitions are usually created in a device driver mapping or by specifing mtdparts= parameter at kernel boot.

Labels: ,

posted by panic @ 7:39 PM 2 Comments


Hijacking library calls


From time to time you might want to override a function call by a binary or library with your own supplied code. This might be useful for example binding a program to a certain address considering that the program doesn't have an option for that. It can also be used for debugging or other obscure tasks. The attached example it's pretty simple, it saves the real address of connect function from libc to a function pointer named real_connect, reads the address/port information from environment and issues the new parameters after the bind call has been performed to the real_connect function.

For your "library" to be preloaded it has to be added to /etc/ld.so.preload by simply doing:
echo "/path/to/libc-highjack.so" > /etc/ld.so.preload

To use it, before starting a program, export HIGHHACK_PORT and HIGHJACK_IP to the values that you need.

The compiling instructions are in the source code.


uploads-blog/libc-highjack.c

Labels: , ,

posted by panic @ 4:42 PM 0 Comments


Sunday, May 11, 2008

Ubuntu (8.04) Linux on MacBook Air (updated)


Ubuntu 9.04 looks like it's working out of the box on MacBook Air. The new intel video card driver in 9.04 it's pretty bad and it's suggested to use the old driver till a fix is issued. (June 18, 2009)

As I received a MacBook Air for development "on-the-road", I installed Ubuntu on it.
Installation is pretty easy:
1. Use MacOS BootCamp to create a "Windows" partition.
2. Get a external USB cdrom or use isotostick script to install from a USB stick.
3. Press C to start booting from CDROM and install Ubuntu (don't forget to make the "Windows" partition active after the installation or it won't show up in BootCamp).

What works:

1. Video Card
Works ok without tweaks even with 3D support/Compiz/XV. I noticed some vertical flickering might be from dot clock but till now ModeLine settings didn't help.
Update:
Flickering is caused by backlight settings a flicker free backlight setting for me is

xrandr --output LVDS --set BACKLIGHT 8000

2. TouchPad/Multitouch
Basic TouchPad/1 button click works ok but if you want multitouch for mouse gestures/scroll/right-click you need to get touchd from http://touchd.sf.net and add a
small modification to multitouch.c by changing the USB IDs looked up by openusb_find_dev_* to: 0x05ac, 0x0223.
The only issue is that touchd has problems comming up from suspend/resume, which can be solved by adding a new script in /etc/acpi/resume.d/ to restart touchd process.

3. Wireless
Need to install ndiswrapper and use the winxp broadcom drivers supplied on DVD or look-up Apple BootCamp drivers on torrents. Other drivers don't work ok either freeze on suspend/resume or have limited capabilities.
Broadcom drivers seems to work ok and also power_profile can be set (iwpriv wlan0 power_profile 0) along with other powersaving settings.

4. Sound
Works by adding: options snd_hda_intel model=mbp3 to /etc/modprobe.d/options. Microphone might need a little alsa patching but haven't tested yet.

5. iSight Camera
Works ok after install the module is uvcvideo

6. CPU Freq Scaling
Works ok after install. Can be tweaked further from /etc/laptop-mode or powerd

7. BlueTooth
Works ok after install.

8. LCD Brightness levels.
This should be handled by pommed/applesmc kernel module but didn't work for me (even tried a 2.6.25 applesmc module with mactel patches) looks like macbook air isn't yet supported by applesmc.
Instead xbacklight (apt-get install xbacklight) works fine which can be binded to F1/F2 keys (I use xmodmap to define keys with scancode 101 and 212 and xbindkeys to bind them to actions like xbacklight +2 or xbacklight -2)

9. Keyboard Leds
Works with a small patch to applesmc.c (in drivers/hwmon/applesmc.c). You can set the keyboard leds levels by echoing values here:
/sys/devices/platform/applesmc.768/leds/smc::kbd_backlight/brightness
This can be done with a small script and xbindkeys to assing the script to F5/F6 keys.

See below for patch download and a sample script.

10. Multimedia keys
Sound keys/Eject keys are working by default the rest can be detected/added to keyboard shorcuts by detecting them with xev

For power saving I recommed using powertop (apt-get install powertop), iwconfig/iwpriv to set wireless power mode, xbacklight and power management tweaks to blank screen faster with DPMS. At this moment battery times in Mac OS X and Ubuntu Hardy are similar (touchd wakes up CPU pretty often but it's not a big drain).

/applesmc-macbookair-2.6.24-17-patch.txt

/keybacklight.sh

Labels: , ,

posted by panic @ 10:25 PM 6 Comments


Friday, October 19, 2007

New monitor, new desktop.


Although I'm not a big fan of LCD monitors I finally got myself one. It's a Samsung 2232 BW and I'm pretty satisfied by it's quality except that I believe it's too bright on top and bottom parts of the screen and gradients don't look that great. With new monitor came a new desktop based on ubuntu beryl and stuff from gnome-look.org. I got the highest ranked themes (seems that everybody likes the look of vista :P ) and icon packs. I'm not sure that it will have a long life since it's too dark for my taste. Here is a screenshot:

Labels:

posted by panic @ 6:44 PM 0 Comments