Posted in Other, Tutorials/Tips

Audi A4/A6 B6/B7/C5 – RNS-E controlling Raspberry Pi 3 with Kodi

This guide will cover steps needed to configure Raspberry Pi 3 (2 works just fine too) to accept messages from RNS-E (via canbus). This will allow to use RNS-E buttons to control Kodi player on the Raspberry Pi. You will need:

  1. RNS-E – it can be from any Audi car, both first and second generation (media button and LED screen indicates second generation) RNS-E are OK for this. I will be using A4B6, first model RNS-E.
    RNS-E
  2. Multimedia Adapter IMA Interface RNS-E Symphony 3 Video TV Cable Plug Audi or any other interface which can give you RCA input to RNS-E. Original TV tuner which comes with Audi should do the trick too, as I did not have it, I had to purchase this.
    IMA Interface
  3. RCA cables
    RCA
  4. HDMI2AV converter. It will be used to convert HDMI signal, to RCA/Composite. Note: You could go directly from Raspberry Pi to RCA via it’s built in composite output, but if you would look up forums you would notice that they are full of complains about poor audio quality and static noise. Been there, tried suggestions, they did not help a lot.
    hdmi2av
  5. HDMI cable, try to get short one.
    hdmi
  6. Raspberry Pi 3
    Raspberry Pi 3
  7. PiCAN2 CAN-Bus Board
    PiCAN2 CAN-Bus Board
  8. microSD card – make sure you get fastest microSD card you can get, I am using Class 10 which works quite nice.
    microSD

For the base of this project I have selected Raspbian Lite, you should be able to use any Raspbian based operating system, but I selected this to keep packages to the minimal amount. You can download it from here. At the moment of writing this tutorial, latest version is 2016-05-27.

Once you have file downloaded, extract it, you will get .img. Use Win32 Disk Imager to write it to your microSD card.
Win32 Disk Imager

Then 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. Enter IP address and port 22.
putty_pi

During the first connection, you will receive a security alert, that is normal, click Yes.  putty_pi3
Once you are connected login, the default username is:
pi
The default password is:
raspberry

Before we continue, it is a good idea to update all packages to the latest version and enable some features. Type this to the putty:
sudo apt-get update
sudo apt-get upgrade
sudo reboot

Then re-connect to the device via putty again and re-login, now type this:
sudo raspi-config
It will launch the tool which we need to use to configure the device.
Raspi-config

  • 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 it will ask if you would like to wait during boot until you get the connection, select No.
  • 9 Advanced Options – Select it and then “A5 SPI”, select “Yes” to enable SPI Interface.
  • Now select “Finish” and reboot.

Then re-connect again. We need to install some packages which we will be using later:
sudo apt-get install git python-setuptools autoconf libtool
Now type:
sudo nano /boot/config.txt
The command above will open a text file which we need to modify. Note please that # means that parameter is commented out and does not work. Leaving old parameter in there as a reference, as that was the parameter which you had to use in previous Rasbian versions and now it has been changed. Scroll down to the bottom of the file and add the lines which are bellow. Your config already should have dtparam=spi=on in there.

#module
dtparam=spi=on
dtparam=audio=on
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25
dtoverlay=spi-bcm2835-overlay
#memory
gpu_mem_256=128
gpu_mem_512=256
gpu_mem_1024=256
#analog
#disable_audio_dither=1
#hdmi_ignore_edid_audio=1
#PAL
#sdtv_mode=2
#sdtv_aspect=3
disable_splash=1
#terminal zoom
framebuffer_width=400
framebuffer_height=240
#hdmi
hdmi_force_hotplug=1
# Adapt overscan values to your needs
#overscan_scale=1
# disable_overscan=1
# overscan_left=57
#overscan_right=-59
# overscan_top=20
# overscan_bottom=20
lcd_rotate=2

Now some explanation:

dtoverlay – parameters to enable can-bus board
disable splash – disables that color rainbow which is shown during each boot
framebugger – to have readable console during the boot

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:
ifconfig

If you can see it, 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

Some notes regarding nano editor, CTRL+X will close it and ask if you want to save, click Y and then Enter.

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:
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")

python

Type:

EDIT 2017: for some reason, dropbox no longer allows direct links, as result wget will no longer allow downloading the files. Please download them manually via browser and simply put them to pi, then use same steps as usual:
Google Drive Backup for files

cd ..
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 in the correct location:
can.rc['interface'] = 'socketcan_ctypes'
can.rc['channel'] = 'can0'

python-can2

PiCan part is now fully done, now we need to install Kodi and the EmulationStation. Personally, I would recommend using RetroPie script for this, it might not be as clean as doing it by your self, but it for sure will work.
Script and steps how to do that are in here they might change as time passes, but at the moment I am writing them down as they are now. Again make sure you are in /home/pi folder then type:
git clone --depth=1 https://github.com/RetroPie/RetroPie-Setup.git
cd RetroPie-Setup
sudo ./retropie_setup.sh

The last command will take some time to complete, as it needs to load and install some extra packages before it even can start installing EmulationStation. Once it completes you will be greeted with the tool which looks similar as raspi-config, yet due to the putty, it did look kinda weird on my side.
RetroPie

You need to select the first option (Manage Packages) and then the first option again (Quick Install), then select Yes that you want to use that option. Now leave it working, as it will take long time to complete.

Once it is done you will need to go to the “opt manage optional packages” option, it just bellows in the second window 5th option after “Quick Install”. In there scroll down and locate Kodi. Install it.

Once that is done select “Back” few times until you are in the very first menu. In there select “Setup / Tools”, then select “autostart”, in there select “Start Kodi at boot (exit for EmulationStation). To my surprise, it was NOT there few days ago. Way to go RetroPie developer!!

EDIT 2017: for some reason, dropbox no longer allows direct links, as result wget will no longer allow downloading the files. Please download them manually via browser and simply put them to pi, then use same steps as usual:
Google Drive Backup for files

I have selected that I wanted to reboot, but it did not work, so I had to exit from that tool and type:
sudo reboot
Now we need to install skin and service. Download these files and install them to the kodi from: System – Add-ons – Install from zip file
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_e.zip

PS: Source of the skin is in here. I have made some modifications to suite my needs and preferences:
Removed car image from the center of skin.
Arcade button added to bottom right side (quits kodi)
Song progress bar moved to bottom instead of just cover
Removed song genre
Enabled Song Artist and name wrapping to other line and centralizing instead of cutting text behind the image
Adjusted cover size and song name in full-screen visualization
Removed OSD from full-screen video playback, controls are done via up/down button for rewind, next video via next button which works for songs too
Removed clock, as it was showing wrong time all the time in my car (no sync with car time)
Added global background and back button to music tab
Removed search and other fancy stuff from music tab
Made some text alignments for EN language, which mostly backfired for other languages
Extended size of right size images, as before it was not covering whole screen and whole right side had black line, plus extra separator added, this done in many windows
Added GlobalBackground to the full screen video playback, which should prevent from seeing terminal when video does not fill whole screen due to video screen ratio

Once that is done do not switch to the skin yet, we still need to configure kodi, and new skin is not quite good for that. Firstly add your Music and Video sources, personally I have created new folder for each of them in the home directory, they can be accessed already via FTP client. You also can upload your game ROMs to the /home/pi/RetroPie/roms

 

Go to the Settings – Services. Scroll the way down and select “Settings level” set it to the “Expert”.
Now go to the “Web server” option and select “Allow remote control via HTTP”, change the user name to pi, do not enter the password.
Kodi
That is practically it, yet personally I still do some extra tweaking here and there in the Settings menu:
Appearance – File lists. I disable “Show “Add source buttons” and enable “Show hidden files and directories”.
Appearance – Screensaver –   Screensaver mode – Set it to None. If it is enabled it will go to sleep and console will be visible.
Video – Playback – Enable “Play next video automatically”
Video – Playback – Adjust “Display 4:3 video as” I personally set it as “Stretch 16:9”
System – Input devices – Peripherals – CEC Adapter. Un-check “Enable” option to disable it, this always pop-ups when Kodi starts.

Now you can use custom skin or use the one you desire. A custom skin has “Arcade” button but it just performs c the mmand to Exit the Kodi which any skin can do.

You also can tweak a bit the EmulationStation. Exit Kodi and wait a bit, it will load EmulationStation, once it is loaded it will ask to configure your controller (USB joystick or Keybaord), do it, then go to the “RetroPie” entry and go to the “RetroPie-Setup”. In there go to the “Setup / Tools” – “esthemes”, use it to install new skins for the EmulationStation. I personally use “pixel” and “material”.

Then go to the “splashscreen” which is in the same level as “esthemes”. You can use custom images and even vidoes in here, yet video might end sooner or even take longer than the boot takes, avoid using images/videos which have bright colors in the edges as during boot you might not have use of whole screen, so try to stick with dark background images.

Now connecting all of this to the car, that is quite simple.
If you use Multimedia Adapter IMA Interface  then it needs to be plugged in to the back of RNS-E, once it is plugged you will have to connect ground and Can-H/Can-L from it to the RNS-E, check top of RNS-E to know what is what, you also might need to code your RNS-E to enable TV mode.

RNS-E

Now you need to get another wires from Can-H/Can-L to the PiCAN2 CAN-Bus Board, check the board, it is written what is what. I personally connected just these two wires to the module.
PiCan

Now simply plug RCA cables to the Multimedia Adapter IMA Interface, then RCA to the HDMI2AV, and it via HDMI to Raspberry Pi.
Connecting

This article is combination of various forums and pages. Main source is in here, he is the one who created script for controlling Kodi . Yet due some outdated and syntax errors it was quite hard to follow, as result I made this one to be able to restore my build quickly from one page.
EmulationStation was added with the help of RetroPie forum.

Enjoy:

emu

31 thoughts on “Audi A4/A6 B6/B7/C5 – RNS-E controlling Raspberry Pi 3 with Kodi

  1. sveikas, gal zinai ar veiktu viskas su kitais magais, tarkim rns-d ar vw mfd? Ar skirsis can komandos ir neis valdyt ?

    1. Su rns-e manyčiau turėtu veikti, dėl mfd nežinau.
      Negaliu garantuoti, bet teoriškai kai turi multifunkcini vairą, tai komandos veikia tiek and rns-e tiek and rns-d, tai spėčiau kad canbus komanda tokia pat.

  2. Hey,

    cool stuff. Just ordered the PiCAN2 and try this myself. The only thing I was wondering, do I have to use 120Ω Terminator (JP3) on the PiCAN2 port or is this not nescessary?

    Thanks

    1. Hello,
      You need only to put it on PI (that will power the pican2 board) and then connect can hi and can low from board to rns-e. That is it.

      1. Thank you, so I don’t need to solder a jumper bridge to JP3 on the board, great news. Do you have any experience in also connecting PWR and GRND directly to the PiCAN board because I was wondering if this means, that the board automatically turns on/off the PI when there is either an electronic ignition respectively when the key gets removed. Normally PWR (which goes to the RNS-E) is a steady positive pole but I wasn’t sure if the PiCAN recognises ignition and stuff like that because it is also connected to CAN-High and CAN-Low.

      2. Nope, you do not need that.
        I was powering it from PI, have not used GRND either.
        When I start a car, it powers my USB charger, when charger gets power it powers Pi and turn it on automatically.
        When I turn my key in the ignition to off position, it sends signal via can which is read by PI and it shutdowns.
        Only draw back that I cannot just quickly turn the key off and get out, I have to wait a bit until Pi powers off cleanly.

  3. Hi,
    would it be possible to reupload skin + hardbyte code pls?
    it would be awesome ❤
    thanks in advance

    1. Hello,

      Dropbox changed their policy and it no longer allows direct links, as results wget will no longer work 😦
      You still can open these links in your browser, on your computer, and download them, then upload them via FTP client to the pi.

  4. From my audi video interface i have Can-H/Can-L, but what are the wire black/white and the wire blue/yellow?

    1. If I remember correctly:
      can-high is yellow
      can-low is blue
      black is ground
      white is sigan/power

      Sorry, sold the car recently, so not quite sure.

      1. from audi interface i have 4 wires:
        red – power
        brown – GND
        wire black/white (this is can-high or can-low??)
        wire blue/yellow (this is can-high or can-low??)

  5. Hey man, great write up! I’m installing a Pi3 in my Audi as I write this. I’m using the same multimedia interface you are using and have a question about wiring. Where do the four wires go that come from the multimedia interface adapter? There is a red and brown wire, and a black & white and blue & yellow wire that are both twisted together. I’m not sure where to connect these ends. Any help is appreciated!

  6. my idea was to put the image of the mobile phone android for my RNS-E.
    With the screen off, and the image only in RNS-E.

    1. Yea tried that with OnePlus One and some “miracast” device from china. Sounds working, video kinda…
      Quality from FullHD to RNS-E screen was just terrible, you would not be able to see without putting your face up to the screen, everything was pixalated.
      It might have been my china device too, as quality did not improve once I connected it to the TV too.
      Also that chine device did not have switch to change from PAL to NTSC and vica versa, so another headache.

  7. there is not a direct adapter :
    32 pin – audi multimedia interface hdmi
    or other easier way without so many cables and adapters ?

      1. it is even necessary to feed the converter with 5v ? I ‘ve seen in some videos that are not necessary but they were testing monitors and televisions.

      2. HDMI2AVI did said low power, and it indeed does work without power, weirdly enough, but as my Pi had only few ports used I fed it from Pi.

    1. I am not familiar with that device, if it has RCA output, then you can plug basically anything. Yet CanBus might and mostly does sent other signals, as result controls might need to be adjusted.

      1. Thanks – The RNS-E and RNS510 from VW is very similar. I have ordered the Kufatec IMA input and a PiCAN2 to use for canbus.

        The CAN signals for VW and Audi should be very similar yes?

      2. Thanks, will let you know how it goes. Appreciate the great write-up.

        Sorry for last question – in theory I could use openelec instead of rasbian?

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