R-Car/Boards/Porter:PEXT01

Introduction
This is the official Wiki for Porter Infotainment Expansion Board.

Please refer to R-Car/Boards/Porter for Renesas R-Car M2 Porter board Rev C.

Hardware
This section contains information about Porter Expansion Board hardware.

Hardware Features

 * Ethernet AVB phy
 * KSZ9031 phy
 * MOST interface
 * Support both 3-pin and 6-pin MLB interface
 * Pinout compatible with Microchip evaluation boards
 * LVDS camera interface
 * MAX9272 deserializer
 * 8-bit wide video bus connected to VI2 interface of R-Car M2 CPU
 * 5V or 12V selectable supply voltage for camera with current limiting
 * High quality 24-bit audio codec PCM3168A
 * 6 input channels (3 stereo jacks for microphone connection)
 * 6 line out channels (RCA connectors)
 * 6 HP outputs (3 stereo jack connectors for direct headphones connection)
 * 44100/48000 Hz sampling frequency
 * Si4689 base AM/FM/DAB radio
 * Digital audio interface to R-Car M2 CPU
 * Additional flash storage for fast radio boot
 * Supply for active DAB antennas with current limit (5 or 12 V)
 * LIN interface (TJA1027 driver)
 * On-board +12V generator or external +12V
 * GPS/GLONASS receiver
 * Serial and i2c interface to R-Car
 * 9-axis sensor:
 * 3D digital linear acceleration sensor
 * 3D digital angular rate sensor
 * 3D digital magnetic sensor
 * WiFi/BT module Texas Instruments WL1837
 * Altera MAX II CPLD:
 * gpio-extender
 * voltage translator for WiFi/BT signals
 * sound stream mux/demuxing

Jumper Positions
J1 - voltage select for LVDS camera "5V" - supply 5V to LVDS camera "12V" - supply 12V from CN4 to LVDS camera open - do not supply power to LVDS camera



J2 - power supply for LIN interface "Int" - use on-board +12V generator (default) "Ext" - use power from CN4



J3 - Si4689 firmware flash write enable: open - write disabled (default) closed - write enabled (for radio firmware update only)



J4 - DAB/FM antenna power supply (CN6) "5V" - supply +5V for DAB/FM antenna. 300 mA limit "12V" - supply +12V for DAB/FM antenna. 300 mA limit open - do not supply power for DAB/FM antenna. For passive antennas or antennas with own power supply. (default)



LEDs Explanation
LED1 - EthAVB activity LED2 - EthAVB link LED3 - LVDS camera deserializer status LED4 - LVDS camera deserializer LOCK indicator

Hardware
PCM3168A: 24-Bit, 96-kHz/192-kHz, 6-In/8-Out Audio Codec with Differential Input/Output (only 6 output channels used) TPA6133A2: Stereo Headphone Amplifiers for Headphones outputs OPA2134: High Performance Audio Operational Amplifiers for Line-outs and Microphone/Line-ins Connected to R-Car M2 processor through SSI3 and 4 in I2S TDM mode (Time Division Multiplexed Audio Interface).

Sound Stream Splitting/Mixing
CPLD is used to divide audio streams between Audio Codec and Bluetooth module. BT module occupied two last channels of 8-channel input and output stream. Stream muxing/demuxing is done fully transparent.



Input stream mixing is done similar way.



Software
From SW point of view PCM3168A codec is represented as 8-ch playback and 8-ch capture device. Due to share of WS and BCLK pins between SSI3 and SSI4 both playback and capture can be done with same sample rate only (48000 or 44100). Channels 6 and 7 of capture device is BT input stream. If WL1837 PCM interface is inactive silence will be captured on these channels. Same with playback - channels 6 and 7 are routed to PCM interface of WL1837 module. Using a PulseAudio soundcard can be splitted to several sink/sources.

PulseAudio
If you using PulseAudio you can simply split this 8-channel sound card into two sinks: surround 5.1 and stereo BT output $ pactl load-module module-remap-sink sink_name=Surround51 remix=no master=alsa_output.platform-sound.13.analog-surround-71 channels=6 master_channel_map=front-left,front-right,rear-left,rear-right,front-center,lfe channel_map=front-left,front-right,rear-left,rear-right,front-center,lfe $ pactl load-module module-remap-sink sink_name=BluetoothPCM remix=no master=alsa_output.platform-sound.13.analog-surround-71 channels=2 master_channel_map=side-left,side-right channel_map=front-left,front-right Check sinks $ pactl list sinks Sink #0 State: RUNNING Name: alsa_output.platform-sound.13.analog-surround-71 Description: pcm3168a Analog Surround 7.1 Driver: module-alsa-card.c      Sample Specification: s24-32le 8ch 48000Hz Channel Map: front-left,front-right,rear-left,rear-right,front-center,lfe,side-left,side-right Owner Module: 1 Mute: no      Volume: front-left: 30419 /  46% / -20.00 dB,   front-right: 30419 /  46% / -20.00 dB,   rear-left: 30419 /  46% / -20.00 dB, rear-right: 30419 /  46% / -20.00 dB,   front-center: 30419 /  46% / -20.00 dB,   lfe: 30419 /  46% / -20.00 dB,   side-left: 30419 /  46% / -20.00 dB,   side-right: 30419 /  46% / -20.00 dB               balance 0.00 Base Volume: 65536 / 100% / 0.00 dB      Monitor Source: alsa_output.platform-sound.13.analog-surround-71.monitor Latency: 21030 usec, configured 21333 usec Flags: HARDWARE HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY Properties: alsa.resolution_bits = "32" device.api = "alsa" device.class = "sound" alsa.class = "generic" alsa.subclass = "generic-mix" alsa.name = "" alsa.id = "rsnd-dai.0-pcm3168a pcm3168a-0" alsa.subdevice = "0" alsa.subdevice_name = "subdevice #0" alsa.device = "0" alsa.card = "0" alsa.card_name = "pcm3168a" alsa.long_card_name = "pcm3168a" device.bus_path = "platform-sound.13" sysfs.path = "/devices/sound.13/sound/card0" device.string = "surround71:0" device.buffering.buffer_size = "32768" device.buffering.fragment_size = "8192" device.access_mode = "mmap+timer" device.profile.name = "analog-surround-71" device.profile.description = "Analog Surround 7.1" device.description = "pcm3168a Analog Surround 7.1" module-udev-detect.discovered = "1" device.icon_name = "audio-card" Ports: analog-output: Analog Output (priority: 9900) Active Port: analog-output Formats: pcm Sink #1 State: SUSPENDED Name: alsa_output.platform-sound.14.analog-stereo Description: ak464x Analog Stereo Driver: module-alsa-card.c      Sample Specification: s16le 2ch 48000Hz Channel Map: front-left,front-right Owner Module: 2 Mute: no      Volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB               balance 0.00 Base Volume: 65536 / 100% / 0.00 dB      Monitor Source: alsa_output.platform-sound.14.analog-stereo.monitor Latency: 0 usec, configured 0 usec Flags: HARDWARE DECIBEL_VOLUME LATENCY Properties: alsa.resolution_bits = "16" device.api = "alsa" device.class = "sound" alsa.class = "generic" alsa.subclass = "generic-mix" alsa.name = "" alsa.id = "rsnd-dai.1-ak4642-hifi ak4642-hifi-0" alsa.subdevice = "0" alsa.subdevice_name = "subdevice #0" alsa.device = "0" alsa.card = "1" alsa.card_name = "ak464x" alsa.long_card_name = "ak464x" device.bus_path = "platform-sound.14" sysfs.path = "/devices/sound.14/sound/card1" device.string = "hw:1" device.buffering.buffer_size = "32768" device.buffering.fragment_size = "8192" device.access_mode = "mmap+timer" device.profile.name = "analog-stereo" device.profile.description = "Analog Stereo" device.description = "ak464x Analog Stereo" module-udev-detect.discovered = "1" device.icon_name = "audio-card" Ports: analog-output: Analog Output (priority: 9900) Active Port: analog-output Formats: pcm Sink #2 State: SUSPENDED Name: Surround51 Description: Remapped pcm3168a Analog Surround 7.1 Driver: module-remap-sink.c      Sample Specification: s24-32le 6ch 48000Hz Channel Map: front-left,front-right,rear-left,rear-right,front-center,lfe Owner Module: 12 Mute: no      Volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB,   rear-left: 65536 / 100% / 0.00 dB, rear-right: 65536 / 100% / 0.00 dB,   front-center: 65536 / 00% / 0.00 dB,   lfe: 65536 / 100% / 0.00 dB               balance 0.00 Base Volume: 65536 / 100% / 0.00 dB      Monitor Source: Surround51.monitor Latency: 0 usec, configured 0 usec Flags: DECIBEL_VOLUME LATENCY Properties: device.master_device = "alsa_output.platform-sound.13.analog-surround-71" device.class = "filter" device.description = "Remapped pcm3168a Analog Surround 7.1" device.icon_name = "audio-card" Formats: pcm Sink #3 State: IDLE Name: BluetoothPCM Description: Remapped pcm3168a Analog Surround 7.1 Driver: module-remap-sink.c      Sample Specification: s24-32le 2ch 48000Hz Channel Map: front-left,front-right Owner Module: 13 Mute: no      Volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB               balance 0.00 Base Volume: 65536 / 100% / 0.00 dB      Monitor Source: BluetoothPCM.monitor Latency: 20734 usec, configured 21333 usec Flags: DECIBEL_VOLUME LATENCY Properties: device.master_device = "alsa_output.platform-sound.13.analog-surround-71" device.class = "filter" device.description = "Remapped pcm3168a Analog Surround 7.1" device.icon_name = "audio-card" Formats: pcm

Same can be done for input source using module-remap-source PulseAudio module. Set surround output as default sink: $ pactl set-default-sink Surround51 Check: $ pactl stat Currently in use: 5 blocks containing 160.0 KiB bytes total. ....  Default Sink: Surround51 .... Test: $ gst-launch-1.0 filesrc location=path/to/file.mp3 ! mad ! pulsesink Note: you don't need to add audioconvert and audioresample to pipeline when using pulsesink. PulseAudio will do all necessary conversion. Please refer to PulseAudio documentation for additional information.

Hardware
Si4689 single-chip digital receiver. SPI host control interface. I2S audio interface routed to SSI5 of R-Car M2 SST25VF016 16Mbit serial flash for firmware and setting

Software
From SW point of view Radio represented as stereo sound capture device and spidev. To control Si4689 several user-space tools provided.
 * si_init - properly initialize radio chip
 * si_flash - tool to flash attached SPI flash (firmware storage)
 * si_ctl - tool to boot radio chip, tune, scan and get status

Minimal command set to boot radio in FM mode and tune to defined frequency: $ si_init $ si_ctl -b fm # boot in FM from SPI flash $ si_ctl -c 106000 # tune to 106.0 MHz To scan for station use command $ si_ctl -l up # scan up To get status $ si_ctl -s -d -m # get system status, RSQ status and RDS info After radio chip is up in FM, AM or DAB mode ALSA device can be used to capture radio. (directly or through PulseAudio)

EthernetAVB
This section provides information about Ethernet for Audio Video Bridging (AVB) for R-Car M2 Porter board.

R-Car M2 SoC provides Ethernet AVB functionality with 1000Mbps speed. This IP block shares pins with Ethernet MAC so only one of these interfaces can be used. R-Car M2 Porter board provides Ethernet MAC with KSZ8041RNLI PHY and Ethernet AVB connector (CN3). You can find this connector on the Porter hardware page. Thus it is necessary to disconnect KSZ8041RNLI PHY before using Ethernet AVB. To achieve this you should remove resistor R321. Resistors R1005 and R1006 allows to connect PHY reset pin to different SoC pins. Please, check that resistor R1005 is installed and R1006 is not. This resistor connects KSZ8041RNLI PHY reset pin with R-Car M2 SoC. Without this resistor MAC PHY remains in the reset mode and does not use shared pins. Next step you should set JP7 in open state. Pext01 board generates own 125MHz refclock.

Schematics
Porter Expansion Board schematics can be found in

Building the Yocto image
Install 'repo' tool from Google

$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo $ chmod a+x ~/bin/repo

Init repo in working directory

$ repo init -u https://github.com/CogentEmbedded/manifest.git -b v1.10.0_pext01

Sync sources

$ repo sync

Download evaluation version of proprietary graphics and multimedia drivers from Renesas.

To download Multimedia and Graphics library, please use the following link: https://www.renesas.com/en-eu/software/D3017410.html To download related Linux drivers, please use the following link: https://www.renesas.com/en-eu/media/secret/solutions/automotive/rcar-demoboard/R-Car_Series_Evaluation_Software_Package_of_Linux_Drivers-20151228.zip

Graphic drivers are required for X11 and Wayland. Multimedia drivers are optional.

Unzip proprietary driver modules to ./proprietary folder. You should see the following files: $ ls -lh ./proprietary total 8.1M -rw-r--r-- 1 builduser builduser 5.8M Dec 28 17:21 R-Car_Series_Evaluation_Software_Package_for_Linux-20151228.tar.gz   -rw-r--r-- 1 builduser builduser 2.3M Dec 28 17:21 R-Car_Series_Evaluation_Software_Package_of_Linux_Drivers-20151228.tar.gz

Setup Environment

$ source meta-renesas/scripts/envsetup.sh porter-ext01 [builddir]

edit local.conf to setup workstation specific settings, for example DL_DIR could be pointed to a single download location for all builds

Build base image

$ bitbake core-image-weston

Building image can take up to a few hours depending on your host system performance. After the build has been completed successfully, you should see the output similar to:

NOTE: Tasks Summary: Attempted 4704 tasks of which 31 didn't need to be rerun and all succeeded.

and the command prompt should return. Bitbake has generated all the necessary files in ./tmp/deploy/images directory

Running Yocto image
Refer to Yocto for steps necessary for running a Yocto image.

Gigabit Ethernet port
Connect port to workstation/network via Ethernet switch or directly. Set up eth0 interface: $ ifconfig eth0 up Set up network address (via dhcp, for example): $ udhcpc -i eth0 After that you can optionaly check speed of Ethernet port by iperf util (add it to IMAGE_INSTALL_append in local.conf or build directly by bitbake and install via ipk): $ iperf -s

Now run on your host machine iperf client: $ iperf -c 

LIN interface
LIN bus can be accessed through slLIN UART TTY line-discipline driver which makes it available through SocketCAN interface.

NOTE:See https://github.com/lin-bus/linux-lin/blob/master/sllin/README.txt:

$ ldattach 25 /dev/ttySC9 $ ip link set sllin0 up

Use cangen util to send frames via lin.

Sound
NOTE: these examples directly use ALSA devices. Stop PulseAudio before (/etc/init.d/pulse stop). Check existence of sound devices via aplay/arecord:

$ aplay -l **** List of PLAYBACK Hardware Devices **** card 0: pcm3168a [pcm3168a], device 0: rsnd-dai.0-pcm3168a pcm3168a-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0 card 1: ak464x [ak464x], device 0: rsnd-dai.1-ak4642-hifi ak4642-hifi-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0

$ arecord -l **** List of CAPTURE Hardware Devices **** card 0: pcm3168a [pcm3168a], device 0: rsnd-dai.0-pcm3168a pcm3168a-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0 card 1: ak464x [ak464x], device 0: rsnd-dai.1-ak4642-hifi ak4642-hifi-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0 card 2: radio [radio], device 0: rsnd-dai.2-si468x-pcm si468x-pcm-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0

Simple playback test can be done this way: speaker-test -c 8 -t wav

Playing mp3 through 5.1 sound card with gstreamer: gst-launch-1.0 filesrc location=./test.mp3 ! mad ! audioresample ! audioconvert ! audio/x-raw, format=S32LE, rate=48000, channels=8 ! autoaudiosink

Recording sound from microphone of 5.1 sound card and playing it back: arecord -D hw:0 -c 8 -f S24_LE -r 48000 1.raw aplay -D hw:0 -c 8 -f S24_LE -r 48000 1.raw

NOTE: sound card jack inputs are made universal and you could is it as line inputs and/or microphone inputs.

Radio
To scan and play radio FM stations you could use this shell script: #!/bin/sh si_init si_ctl -b fm si_ctl -l up  gst-launch-1.0 alsasrc device='hw:2,0' ! \     queue ! \     audioconvert ! audioresample ! \     audio/x-raw,rate=48000 ! \     alsasink sync=false device='hw:1,0'

To set radio station and change FM/AM see si_ctl util.

GPS/GLONASS
Available as NMEA through /dev/ttySC7 $cat /dev/ttySC7

WiFi
To check wifi and scan available WAPs run: $ ifconfig wlan0 up $ iwlist wlan0 scan

Bluetooth
To check bluetooth and scan available BT devices run: $ hciconfig hci0 up $ hcitool -i hci0 scan To stream to a2dp sink: Check that bluetooth daemon running: $ ps | grep blue 739 root     3880 S    /usr/lib/bluez5/bluetooth/bluetoothd Check that pulseaudio running: $ ps | grep pulse 711 pulse    124m S <  pulseaudio -D --system --disallow-exit --resample-me Check that module-bluetooth-discover is loaded: $ pactl list modules .... Module #18 Name: module-bluetooth-discover .... Start bluetoothctl and power on BT adapter: $ bluetoothctl [bluetooth]# power on [bluetooth]# agent on  [bluetooth]# default-agent Start scannig: [bluetooth]# scan on Wait for your device: [NEW] Device xx:xx:xx:xx:xx:xx Bose Color SoundLink Pair [bluetooth]# pair xx:xx:xx:xx:xx:xx Attempting to pair with xx:xx:xx:xx:xx:xx [CHG] Device xx:xx:xx:xx:xx:xx Connected: yes [CHG] Device xx:xx:xx:xx:xx:xx Modalias: bluetooth:v009Ep4006d0101 [CHG] Device xx:xx:xx:xx:xx:xx UUIDs has unsupported type Pairing successful And connect: [bluetooth]# connect xx:xx:xx:xx:xx:xx Attempting to connect to xx:xx:xx:xx:xx:xx [CHG] Device xx:xx:xx:xx:xx:xx Connected: yes Connection successful [CHG] Device xx:xx:xx:xx:xx:xx Modalias: bluetooth:v009Ep4006d0101 Now you should get new PulseAudio sink: $ pactl list sinks ... Sink #5 State: SUSPENDED Name: bluez_sink.xx_xx_xx_xx_xx_xx Description: Bose Color SoundLink ... Some BT devices support several profiles. Check it $ pactl list cards ... Profiles: headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 20, available: yes) a2dp_sink: High Fidelity Playback (A2DP Sink) (sinks: 1, sources: 0, priority: 10, available: yes) off: Off (sinks: 0, sources: 0, priority: 0, available: yes) Active Profile: headset_head_unit ... Set a2dp profile: $ pactl set-card-profile bluez_card.xx_xx_xx_xx_xx_xx a2dp_sink Now you can set it as default sink: $ pactl set-default-sink bluez_sink.xx_xx_xx_xx_xx_xx And test playback: $ gst-launch-1.0 audiotestsrc ! pulsesink

Sensors (LSM9DS0)
Accelerometer -- /dev/input/event0 Magnetometer -- /dev/input/event1 Gyroscope -- /dev/input/event2

Installing Porter Expansion Board
Use the following procedure to install Porter Expansion Board to the Porter Board. 1. Find EXIO and Ethernet AVB connectors on both Porter and Porter Expansion boards. 2. Align and carefully push them to each other until Ethernet AVB and EXIO connectors are fully inserted. 3. SD Cable connection. 3.1 Take SD Adapter. Carefully pull up brown cable latch. 3.2 Take SD cable. Plug one side of this flat cable to the cable port. Connectors on the cable should fit port connectors. (Position the side of SD cable with the connectors on the opposite side from the latch, as displayed on the Step 3.) 3.3 Lock the latch by carefully pushing it down. 3.4 Repeat the aforementioned steps with another cable's side and SDIO port (CN9). 4. Plug SD Adapter to the Porter Board's SD Card slot (CN9). 5. Now, when boards are reliably mounted and connected with SD adapter, use 12V power supply splitter cables to connect both Porter and Porter Expansion board's power plugs to one power adapter.