Posted in Linux, Other, Tutorials/Tips

Audi RNS-E controlling Kodi in Raspberry Pi 2/3

As the title says this guide will cover steps needed to configure Raspberry pi (2/3) to accept messages from RNS-E. This will allow to use RNS-E buttons to control Kodi player on the Raspberry PI (2/3).You will need:

  1. RNS-E. It can be from A4 and from A6, it can be model 1 and model 2 (media button and LED screen). I will be using A4 first model RNS-E. Most of this guide should work with RNS-D too.
  2. Original TV Tuner of Audi or Multimedia Adapter IMA Interface RNS-E Symphony 3 Video TV Cable Plug Audi. I am using Multimedia Adapter from Ebay.
  3. Raspberry 2 or 3 with accessories (microSD card and charger).  Both will work and have identical steps.
  4. A/V Composite Cable – 3.5mm to 3 x RCA. Make sure you get correct cable, as it did have some changes between Raspberry versions. Pi (2/3) has 4 sectors in the cable, one of them is ground, without it, you might have some static noise.
  5. PiCAN2 CAN-Bus Board for Raspberry Pi 2. Bought it from skpang. Took a box too, which is optional.

I have used 16GB Class 10 micro SD card, you can use the one you have and smaller storage, but keep in mind that Kodi does requires fast storage.
For the base of this project I have selected 2016-05-10-raspbian-jessie-lite image, you should be able to use any Raspbian based operating system, but I selected this to keep packages to the minimal amount.

In order to begin write image to the microSD card and insert it to the Raspberry Pi. Plug in the Ethernet cable and power it on.

Use SSH client (Putty for example) to connect to it, for that you will need IP address of the device, check your router in order to locate it.

Putty

Default login information is:
pi
raspberry

Once you are logged in we need to enable some features and update the image we are using, in order to do so type:
sudo raspi-config
Raspi-configIn this tool you need to go through these sections:

  • 1. Expand Filesystem – Select it and wait few moments, then just click Ok.
  • 3. Boot Options – Select it and then in the next windows “Console Autologin”, then click OK.
  • 4 Wait for Network at Boot – Select it and then “Fast Boot without waiting for network connection”. This will speed up Kodi launch a lot.
  • 9 Advanced Options – Select it and then “A5 SPI”, select “Yes” to enable SPI Interface.
  • Now select “Finish” and reboot.

You will be disconnected from the Raspberry, wait few moment and re-connect back with your SSH client. Now we need to update current software in the operating system. In order to do so type:

sudo apt-get update
sudo apt-get upgrade

This might take a while, after that is done install some other packages which we will need to use later:

sudo apt-get install git python-setuptools autoconf libtool
Now it is good time to adjust boot configuration file to load needed modules:
sudo nano /boot/config.txt
Command above will open text file which we need to modify. Note please that # means that parameter is commented out and does not work. Leaving it in there as a referrence, as that was parameter which you had to use in previous Rasbian versions.
dtparam=spi=on
#dtoverlay=mcp2515-can0-overlay,oscillator=16000000,interrupt=25
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25
dtoverlay=spi-bcm2835-overlay
sdtv_mode=2
sdtv_aspect=3
disable_splash=1

Now some explanations. First 4 lines (including #) are for canbus module, other 3 are to force video format and disable splash. As RNS-E is quite old device, we need to force Raspberry to use PAL signal. Now we need to reboot to apply all changes and new boot commands.
sudo reboot
Then re-connect again and use this command, if all is ok you should not receive any response:
sudo /sbin/ip link set can0 up type can bitrate 100000
Then type
ifconfig
You should see this can0-00:
ifconfigIf all is as above, then we can continue. Now we need to use these commands, there must be no error reports at all:
git clone https://github.com/linux-can/can-utils.git
cd can-utils
./autogen.sh
./configure
make
sudo make install

autogen

Now whole PiCan side is done, yet we still need to start it automatically with the system. in order to do that:
sudo nano /etc/rc.local
Then scroll down and just above “exit 0” type this:
sudo python /home/pi/python_can.py

rc-local

At the moment python_can.py file does not exist and we need to create. In order to do so:
nano /home/pi/python_can.py
And paste this text in to it. This is needed to auto start can0 and to launch kodi as root. I personally no longer start kodi as root:
import os
#os.system("sudo ip link set can0 up type can bitrate 100000 restart-ms 100 loopback on")
os.system("ip link set can0 up type can bitrate 100000 restart-ms 100")
#os.system("kodi")

python_can
Now while you are in /home/pi type:
wget https://dl.dropboxusercontent.com/u/45262183/vaipui/RNS-E/hardbyte-python.tar
tar -xvf hardbyte-python.tar
cd /home/pi/hardbyte-python
sudo python setup.py install
sudo nano /usr/local/lib/python2.7/dist-packages/python_can-1.4.3-py2.7.egg/can/interfaces/interface.py

Last command will open editor, which you need to use to add two lines:
can.rc['interface'] = 'socketcan_ctypes'
can.rc['channel'] = 'can0'

python-can2

PiCan part is completed. Now we need to install Kodi:
sudo apt-get install kodi

Installation will take a while to complete. After that:
sudo nano edit /etc/default/kodi
In there change user name from kodi to pi and change auto-start Enable 0 to 1
Once that is done reboot your system and and re-connect. Kodi should start automatically now, as there are no other GUI.

Now we need to install some add-ins for Kodi:
wget https://dl.dropboxusercontent.com/u/45262183/vaipui/RNS-E/script.service.JanssuuhRnseBediening_shutdown.zip
wget https://dl.dropboxusercontent.com/u/45262183/vaipui/RNS-E/skin.audi_rns_LITE.zip

You can install them from Kodi settings, addons install from zip. While you are in the settings of kodi you also should go to Settings – Services – Webserver – Allow control via HTTP.

That is pretty much it. This article is collection of the information I have located from various sources.

5 thoughts on “Audi RNS-E controlling Kodi in Raspberry Pi 2/3

  1. Is there only certain mmi adapters that will allow you to control the pi?
    I was looking at one but not sure how to tell if it will work for this?

    1. I’m looking back into doing something on the lines of this with a different board (latte panda)
      Would like to ask if you know about useing a can bus adaptor with the arduino. Not to sure if same principals would apply.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s