Raspberry Pi 3 notes

This post was written by eli on January 15, 2017
Posted Under: ARM,DVB,Linux,Linux kernel

These are messy, random notes that I took while setting up my little Raspberry Pi 3. Odds are that by the time you read this, I’ve replaced it with a mini-PC. So if you ask a question, my answer will probably be “I don’t remember”.

Even though the Pi is cool, it didn’t supply what I really wanted from it, which is simultaneous output on SDTV and HDMI. It also turns out that it’s unable to handle a large portion of the video streams and apps out there on the web, seemingly because the lack of processing power vs. the resolution of these streams (running Kodi, which I suppose is the best optimized application for the Pi). So as a catch-all media center attached to a TV set, it’s rather useless.


  • Used the 2016-11-25-raspbian-jessie.zip image
  • Raspbian: To get remote access over ssh, do “service ssh start” and login as “pi” with password “raspberry”. Best to remove these before really working. To make ssh permanent, go
    # systemctl enable ssh
  • Cheap USB charger from Ebay didn’t hold the system up, and a reboot occurred every time the system attempted to boot up. The original LG G4 charger is strong enough, though.
  • Kodi installed cleanly with
    # apt-get update
    # apt-get install --install-suggests kodi
    # apt-get install --install-suggests vlc
  • … but it seems like vlc doesn’t use video acceleration, and I tried a lot to make it work. It didn’t. So it’s quite useless.
  • Enabling Composite output: Use a four-lead 3.5mm plug (a stereo plug doesn’t work). The Samsung screen refused to work, but Radiance detected the signal OK.
    I used old Canon Powershot’s video cable, but attached to the RED plug for video, and not the yellow.
    In /boot/config.txt, uncomment 


    however composite video is disabled when an HDMI monitor is detected, and Q&A’s on the web seem to suggest that simultaneous outputs is not possible. Following this page, I tried setting (so that the HDMI output matches)


    and got 576i (PAL) on the HDMI output but the signals on the composite output were dead (checked with a scope).

  • Added “eli” as a user:
    # adduser --gid 500 --uid 1010 eli
  • Add “eli as sudoer”. Add the file /etc/sudoers.d/010_eli-nopasswd saying
  • Manually edit /etc/groups, find all the places it says “pi” and add “eli” — so they have some groups. Compare “id” outputs.
  • Add ssh keys for password-less access (use ssh-copy-id)
  • Change the timezone
    $ sudo raspi-config

    pick “4 Internationalisation Options” and change the timezone to Jerusalem

  • Set “eli” as the default login: One possibility would have been to change the config script (usr/bin/raspi-config) as suggested on this page. Or change /etc/lightdm/lightdm.conf so it says

    as for console login, the key line in raspi-config is

    ln -fs /etc/systemd/system/autologin@.service /etc/systemd/system/getty.target.wants/getty@tty1.service

    so the change is to edit /etc/systemd/system/autologin@.service so it says

    ExecStart=-/sbin/agetty --autologin eli --noclear %I $TERM
  • Turn off scrrensaver / blanking: First check the current situation (from an ssh session, therefore specific about display)
    $ xset -display :0 q
    Keyboard Control:
      auto repeat:  on    key click percent:  0    LED mask:  00000000
      XKB indicators:
        00: Caps Lock:   off    01: Num Lock:    off    02: Scroll Lock: off
        03: Compose:     off    04: Kana:        off    05: Sleep:       off
        06: Suspend:     off    07: Mute:        off    08: Misc:        off
        09: Mail:        off    10: Charging:    off    11: Shift Lock:  off
        12: Group 2:     off    13: Mouse Keys:  off
      auto repeat delay:  500    repeat rate:  33
      auto repeating keys:  00ffffffdffffbbf
      bell percent:  50    bell pitch:  400    bell duration:  100
    Pointer Control:
      acceleration:  20/10    threshold:  10
    Screen Saver:
      prefer blanking:  yes    allow exposures:  yes
      timeout:  600    cycle:  600
      default colormap:  0x20    BlackPixel:  0x0    WhitePixel:  0xffffff
    Font Path:
    DPMS (Energy Star):
      Standby: 600    Suspend: 600    Off: 600
      DPMS is Enabled
      Monitor is On

    So turn it off, according to this thread. Edit /etc/kbd/config to say (in different places of the file)


    and then append these lines to ~/.config/lxsession/LXDE-pi/autostart (this is a per-user thing):

    @xset s noblank
    @xset s off
    @xset -dpms

More jots

  • The script that warns against the unchanged password for “pi” user is at /etc/xdg/lxsession/LXDE-pi/sshpwd.sh, and is launched by /etc/xdg/autostart/pprompt.desktop
  • For some info on how to run a power fail safe system by mounting most of the filesystem as readonly, see this page.
  • Obtaining the .config file (from the kernel build guide):
    On Raspberry’s official kernel, check out git ID 4eb9a81002485a7abfa53a334dde5bc10328079f (as 4.4.34), and go 

    $ make ARCH=arm bcm2709_defconfig

Kodi setup

  • Change setting level to Advanced
  • System > Settings > Enable TV
  • System > Settings > System > Power savings, set Shutdown function to Minimise (actually, it didn’t help regarding the blackout of the screen on exit)
  • Enable and Configure PVR IPTV Simple Client
  • On exit, use Ctrl-Alt-F1 and then Ctrl-Alt-F7 to get back from the blank screen it leaves (/bin/chvt should do this as well?)

Video issues

I wanted to get a simultaneous SDTV / HDMI output. Everyone says it’s impossible, but I wanted to give it a try. I mean, it’s the drivers that say no-no, but one can find a combination of registers that gets it working. The alternative is an external HDMI splitter, and then an HDMI to CVBS converter. Spoiler: I gave up in the end. Not saying it’s impossible, only that it’s not worth the bother. So:

Broadcom implements the OpenMAX API, which seems to have a limited set of GPGPU capabilities. For example see firmware/opt/vc/src/hello_pi/hello_fft/ in Raspberry’s official git repo. The QPU is documented in VideoCoreIV-AG100-R.pdf, and there’s an open source assembler for it, vc4asm. and possibly this one is better, mentioned on this page. Also look at this blog.

This page details the VideoCore interface for Raspberry.

An utility for switching between HDMI/SDTV outputs (in hindsight, I would go for the official tvservice instead, but this is what I did):

$ git clone https://github.com/adammw/rpi-output-swapper.git

But that didn’t work:

eli@raspberrypi:~/rpi-output-swapper $ make
cc -Wall -DHAVE_LIBBCM_HOST -DUSE_EXTERNAL_LIBBCM_HOST -DUSE_VCHIQ_ARM -I/opt/vc/include/ -I/opt/vc/include/interface/vcos/pthreads -I./ -g -c video_swap.c -o video_swap.o -Wno-deprecated-declarations
cc -o video_swap.bin -Wl,--whole-archive video_swap.o -L/opt/vc/lib/ -lbcm_host -lvcos -lvchiq_arm -Wl,--no-whole-archive -rdynamic
rm video_swap.o
eli@raspberrypi:~/rpi-output-swapper $ sudo ./video_swap.bin --status
failed to connect to tvservice

which comes from this part in tvservice_init():

    if ( vc_vchi_tv_init( vchi_instance, &vchi_connections, 1) != 0) {
        fprintf(stderr, "failed to connect to tvservice\n");

which is implemented in userland/interface/vmcs_host/vc_vchi_tvservice.c, header file vc_tvservice.h in same directory (Raspberry’s official git repo).

After a lot of back and forth, I compared with the official repo’s tvservice utitlity and discovered that it doesn’t check vc_vhci_tv_init()’s return value. So I ditched the check on video_swap as well, and it worked. But the results on the screen were so messy, that I didn’t want to pursue this direction.

In what follows, some things I found out while trying to solve the problem: The program opens /dev/vchiq on bcm_host_init(), and performs a lot of ioctl()’s on it. The rest of tvservice_init() until the error message causes no system calls at all!

/dev/vchiq had major/minor 248/0 on my system. According to /proc/devices, it belongs to the vchiq module (not a big surprise…). Drivers are at drivers/misc/vc04_services/interface/vchiq_arm/ Seemingly with vchiq_arm.c as the top level file, and are enabled with CONFIG_BCM2708_VCHIQ.

There’s a utility, vcgencmd , for setting a lot of different things, log levels among them, but I didn’t manage to figure out where the log messages go to.

Reader Comments

Hello sir
i need help in my project programming .i made a home automation system Resberypi3 based,used 4 relays fan ,water pump,lights and door.i need a programming for this.kindly help me for this.

Written By imran ali on February 10th, 2017 @ 22:28

Add a Comment

required, use real name
required, will not be published
optional, your blog address