Category Archives: Raspbian

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.

Fix apt-get “cannot copy extracted data for ‘…’ to ‘…': unexpected end of file or stream”

I was doing an apt-get upgrade and got this error:

Preparing to replace liborc-0.4-0:armhf 1:0.4.16-2 (using .../liborc-0.4-0_1%3a0.4.18-1rpi1rpi2_armhf.deb) ...
Unpacking replacement liborc-0.4-0:armhf ...
dpkg-deb (subprocess): decompressing archive member: internal gzip read error: ': incorrect data check'
dpkg-deb: error: subprocess  returned error exit status 2
dpkg: error processing /var/cache/apt/archives/liborc-0.4-0_1%3a0.4.18-1rpi1rpi2_armhf.deb (--unpack):
 cannot copy extracted data for './usr/lib/arm-linux-gnueabihf/liborc-0.4.so.0.18.0' to '/usr/lib/arm-linux-gnueabihf/liborc-0.4.so.0.18.0.dpkg-new': unexpected end of file or stream

I tried deleting the faulty deb file:

sudo rm /var/cache/apt/archives/liborc-0.4-0_1%3a0.4.18-1rpi1rpi2_armhf.deb

And upgrade again:

sudo apt-get upgrade

But it failed complaining with unresolved dependencies and said to force the process with the -f parameter:

sudo apt-get -f upgrade

Then it failed again with the first error. Then I figured that cleaning all the deb cache could fix it and it did. Just had to run:

sudo apt-get clean

And then the upgrade process worked fine.

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