Category Archives: Raspberry Pi

Enable SSH server in a headless Raspberry Pi

Raspbian come by default with SSH server deactivated so if you have a headless Raspberry Pi you won’t be able to access it. The easy way to activate SSH server without even powering on the device is by editing one file in the system partition of the SD card.

As you may know services in Raspbian are started and stoped depending on what runlevel you are booting into. Those runlevel/service relations are configured by SysV Init in /etc/rcX.d folders were X are the numbers from 0 to 6, each for one runlevel. Raspbian’s default runlevel is 2 so if you go to /etc/rc2.d in your SD card’s ext4 partition (not the boot partition in FAT32 format) you’ll see somethin like this:

Raspbian K01ssh

That “K” in K01ssh means “kill”. So SSH is not going to be started in runlevel 2. If you change that symlink name to S01ssh SSH server will “start” on boot.

Raspbian S01ssh

It’s that simple, just change the “K” (kill) for an “S” (start) in the appropriate runlevel for the service you want to change.

CPU load indicator using Pi-Stop with a Raspberry Pi

I bought a Pi-Stop just for fun and to introduce my nieces to coding. Pi-Stop is an educational pistop traffic light add-on for Raspberry Pi and was designed in partnership between 4Tronix.co.uk and PiHardware.com.

piStopCpuLoad

I first started trying some simple Python scripts to use the GPIO lines, then used the RPIO library to dim the LEDs with PWM, etc. Then it come to my mind that this simple and funny device could be used for something more serius: a CPU load indicator. Just some minutes later I had it done. It’s my first real Python program so it may be not perfect but it’s been a good start on the language. The code can be downloaded from github. Contributions are really appreciated 🙂

https://github.com/enekochan/piStopCpuLoad

The are 2 different versions of it:

  • piStopCpuLoad.py: Uses RPi.GPIO to interface with the GPIO port.
  • piStopCpuLoadPwm.py: Uses RPIO library and a PWM approach to dim the LEDs. You’ll have to install RPIO to use this script.

You can see it in action here:

Adding custom action to a keycode in XBMC

There are some USB IR remotes out there specifically made to be used in media centers. I bought one of those to setup my parents Raspberry Pi.

usb-ir-remote

It looked like everything worked out of the box with XBMC but then we noticed that the volume down button was not doing anything. So I had to check which keycode was being issued to bind it to the appropiate action in XBMC. You have to activate the debug on XBMC (Settings->System->Debugging) and then pressed the key a couple of times. Then look at the log file (temp/xbmc.log in your userdata directory, which in Linux is ~/.xbmc) for something like this:

18:25:59 T3034951680   DEBUG: OnKey: f14 (0xf09d) pressed, action is ...

You can use cat and grep for that:

$ cat ~/.xbmc/temp/xbmc.log | grep pressed

And there you have your keycode in hexadecimal format. Just convert it to decimal, which in this case is 65197, and then you need to know the name of the action you want to give to that keycode. The list can be found in ButtonTranslator.cpp:

        {"volumedown"        , ACTION_VOLUME_DOWN},

Finally add the key binding in keymaps/keyboard.xml file in your userdata directory:

<keymap>
  <global>
    <keyboard>
      <key id="65197">volumedown</key>
    </keyboard>
  </global>
</keymap>

Ref: http://wiki.xbmc.org/index.php?title=keymap#Keyboards
http://wiki.xbmc.org/index.php?title=HOW-TO:Modify_keyboard.xml

Boost low volume in XBMC

AC3 encoded movies usually have very low volume. To fix this edit the /usr/share/xbmc/system/advancedsettings.xml file and add this audio ac3downmixgain parameter inside the <advancedsettings>...</advancedsettings> tags:

<advancedsettings>
  ...
  <audio>
    <ac3downmixgain>24.0</ac3downmixgain>
  </audio>
</advancedsettings>

It’s default value is 12.0 so change it until it fits the volume you want and beware because althougt the option says ac3downmixgain it boosts the volume for ALL codecs.

speaker

Ref: http://forum.xbmc.org/showthread.php?tid=164929&pid=1421472#pid1421472

Fix no video problem in XBMC

Although is recommended using a dedicated media center distribution (raspbmc, openelec or xbian for example) because they come already configured, if you decide to install XBMC on your own in Raspbian you may have problems playing videos. If you don’t see video and it just plays the audio when opening a movie it may be caused because XBMC is trying to use hardware acceleration and you don’t have the MPEG-2 license in your Raspberry Pi.

xbmc-no-video

To use software decoding follow those steps:

  • Go to System -> Settings and then select the “Video” tab.
  • Change the “Settings level” in the lower left corner to “Expert”. This will reveal the “Acceleration” menu option.
  • Now go to the “Acceleration” menu option and change “Decoding method” to “Software”.

Settings.videos.acceleration

You can see a video doing those steps here.

If this doesn’t fix the problem by itself try adding this option to /boot/config.txt:

start_x=1

This enables the use of “_x” firmware files (start_x.elf) and should allow software codecs to work.

Ref: http://forum.xbmc.org/showthread.php?tid=170832