pondělí 1. července 2013

HW mod: Increase USB power on Raspberry Pi early rev. 1 boards

The early Raspberry PI (RPI) boards had polyfuses on the USB ports. They are electronic resettable 140 mA fuses. The problem is that they do not have zero ohm resistance. This means that by increasing the power drawn from the USB port the voltage drop across the polyfuse increases. By drawing approx. 100 mA and more from the USB port the voltage drops bellow the value allowed by the USB specification and the connected USB devices may behave incorrectly. I encountered this when I was backporting the R820T tuner driver to the kernel 3.9 (needed for some RTL2832 based DVB-T dongles). Some of the DVB-T cards I had worked OK, some exhibited random failures during I2C writes to the R820T registers which resulted in occasional kernel panics.

You can workaround this by using a USB powered hub or you can fix the RPI PCB. The fix is simple - just bypass the F1 and F2 polyfuses. This fix is already implemented on the later rev. 1 and rev. 2 boards, so the later boards don't exhibit this problem. You can remove the polyfuses and short the pins, but an easier approach is to leave the polyfuses on the PCB and just short them out by wire or just by tin. You will still have the protection from the main F3 polyfuse (0.7 A). The other advantage of this mod is that it will allow you to power the RPI from the USB hubs / devices that provide power upstream.

The F1 and F2 polyfuses are green (at least on my RPI boards) and are located near the status LEDs. This modification is applicable only to the early rev. 1 boards. They probably have the HW revision code 2 or less. You can get the HW revision code by running:

cat /proc/cpuinfo

If your HW revision code is 3 or above this problem is already fixed on your board.

pátek 14. června 2013

Use Windows screensavers in Linux for screen locking

This arise from the discussion with one person who we tried to migrate to Linux. Her argument was that she would miss the Bubble screensaver :). No doubt, the new D3D Windows screensavers are cool and especially for the Bubbles screensaver there is currently no Linux counterpart. But the argument doesn't stand, here is the quick and dirty solution - the Wine:

  • Copy the screensaver, e.g. for the bubble screensaver copy the \Windows\System32\Bubbles.scr to the /opt/screensavers/ directory (or elsewhere).
  • Install the xlockmore package
  • Run the screensaver by:
    xlock -mode blank -geometry 0x0 \
    -startCmd "wine /opt/screensavers/Bubbles.scr /s"

The trick is to instruct the xlock to blank the screen area consisting of zero number of pixels, so the display is let unmodified for the screensaver. This was tested on the Fedora 18 and Xfce and worked OK. If you need to configure the screensaver, you can run it with the /c parameter. Unfortunately the Bubbles screensaver doesn't have implemented the configuration dialog and the command will fail, but there are still some hidden settings you can alter through the registry. I focused only on the technical side of the problem, not the legal one, but I think it shouldn't be problem in case there is valid Windows license for the machine (e.g. machine with dual-boot).

neděle 7. dubna 2013

Tip: using oath-toolkit for HOTP/TOTP authentication

I packaged oath-toolkit for Fedora and it is currently submitted for the merge review. The toolkit provides oathtool which can be used as a generator for HOTP/TOTP (e.g. to authenticate against LinOTP). Usage is very simple, for HOTP:
$ oathtool -c COUNTER SEED
And for TOTP:
$ oathtool --totp SEED
The package also provides library and header files and more complex applications/GUIs can be easily based on it. There is also PAM module included that allows you to use your HOTP/TOTP HW/SW token for authentication against your machines (e.g. sshd). To enable it for sshd add the following line to the top of your /etc/pam.d/sshd:
auth sufficient pam_oath.so usersfile=/etc/users.oath window=20 digits=6
This will setup the SSH for 6 digits HOTP/TOTP and will check through the 20 values (the tolerance). Then create the /etc/users.oath file and add there a list of allowed users together with their prefix passwords (PINs) and seeds, e.g.:
HOTP/T30 root pw 00
HOTP user1 - 01
In the example above, the user root is configured for 30 seconds TOTP with the prefix password (PIN) pw and seed 00, the user user1 has no prefix password and uses the seed 01. As the file contains seeds and plain text PINs, do not forget to chown it to root:root and chmod it to 600. For correct function the "UsePAM yes" and "PasswordAuthentication yes" also needs to be specified in your /etc/ssh/sshd_config. Currently it may not work correctly with the SELinux (for details see the merge review).

neděle 24. března 2013

Fix: mediawiki@openshift is not saving user preferences

I encountered this when running Mediawiki through HTTPS/TLS on Openshift. The POST queries with full URLs didn't work - it resulted in inability to save user preferences, upload files and maybe there are other weird problems. After short debugging it showed that the problem is in the HTTPS detection in Mediawiki code. The code uses _SERVER['HTTPS'] == 'on' check which according to the PHP documentation is not correct - the Amazon's load balancer sets this to '1' instead of 'on'. It seems that the latest Mediawiki 1.20.3 is also affected by this so I filled http://bugzilla.wikimedia.org/show_bug.cgi?id=46511. The patch against mediawiki-1.16 (the Openshift Mediawiki example) is attached.

pátek 15. února 2013

Tip: Learn n900 to understand Map1.eu

Recently the alpha version of Map1.eu got online. It's nice project whose aim is to provide an all-purpose map of the whole Europe suitable for outdoor activities like hiking, biking, skiing or geocaching. The project is based on OpenStreetMap data. The great thing is that it contains hiking trails for both Czech and Slovakia. But the best thing is that it can be easily integrated into n900, the procedure:
  1. Install Mappero, e.g. "apt-get install maemo-mapper"
  2. Click Mappero -> Maps -> Tiles -> New, for Name, UniqID, Cache dir fill e.g. Map1.eu, as URL use http://alpha.map1.eu/tiles/%d/%d/%d.jpg, Type: XYZ_INV, Format: JPEG, click Save.
  3. Click Mappero -> Maps -> Tiles -> Repositories -> New, fill in the following: Name: e.g. Map1.eu, Min zoom: 5, Max zoom: 17, Zoom step: 1, Tiles: Map1.eu, click Save.
  4. Restart Mappero.
  5. In Mappero -> Maps -> Map repository select the Map1.eu
And you are done. The great thing is that you can also use this map offline, just download the tiles: in Mappero -> Maps -> Manage Maps... select Area (the current view is preselected) and interested zoom levels, click OK and the map will be downloaded for offline use.