Difference between revisions of "Dedicated SBC Camera Monitor"

From ZoneMinder Wiki
Jump to navigationJump to search
Line 33: Line 33:
Edit the config for dwm
Edit the config for dwm
<pre> nano dwm/config.def.h</pre>
<pre> nano dwm/config.def.h</pre>
* Disable the bar
* Later Disable the bar
* Remove all workspaces except for 1 (*tags)
* Later Remove all workspaces except for 1 (*tags)
* (leave #1 only)
* Set Mod4Mask as modkey
* Set Mod4Mask as modkey
* Set MODKEY|Shiftmask to 0 and XK_c to XK_F12 for killclient (personal preference)
* Set MODKEY|Shiftmask to 0 and XK_c to XK_F12 for killclient (personal preference)
*Later disable spawm of dmenucmd and termcmd, but for now leave enabled.
* Later disable spawm of dmenucmd and termcmd, but for now leave enabled.


<pre>
<pre>
Line 61: Line 60:
make install
make install
</pre>
</pre>
=== Intermediate Cleanup Time ===
=== Intermediate Cleanup Time ===
<pre>apt-get remove nfs-common rpcbind wpasupplicant avahi-daemon ofono apache2</pre>
<pre>apt-get remove nfs-common rpcbind wpasupplicant avahi-daemon ofono apache2</pre>

Revision as of 23:39, 4 March 2017

A guide for setting up a dedicated kiosk SBC (here beaglebone) or Desktop that will monitor the video feed from a camera that you choose, auto logging into the video feed. OS will be devuan, WM will be dwm, terminal st, and browser will be surf. It will be a minimal installation with no DE, no extra programs. Leaner than LXDE.

Second, I'll include steps on setting up I2C on the beagle and being able to read a value from a sensor. Combine this with ZMTrigger.

Setup

Install OS and Programs

Requirements:

  • >=4GB SD Card (not a cheap one)
  • SBC (although this works on a desktop)
  • Internet connection
  • Computer monitor
  • HDMI cable for BBB (I use a HDMI to DVI adaptor).

Install beaglebone black using elinux.com's BeagleBoardDebian page.

Use the direct image (under Demo, below NetInstall). Not the netinstall, which is slower, unless you know what you are doing.

After you boot from SD card, make sure the network interface is set to load in:

nano /etc/network/interfaces

Then migrate to devuan using Dev1fanboy Upgrade-Install-Devuan wiki guide. Skip the part about the display environment. Reboot after apt-get dist-upgrade. Try the purge of libsystemd0 in DE section, may not work. RCN repo seems to want it.

Next complete the following commands

 sudo su
 apt-get install xorg libx11-dev libxft-dev libxinerama-dev gcc make htop sudo tcpdump

Complete these for Surf

 apt-get install libwebkitgtk-dev libgtk2.0-dev linux-headers-$(uname -r)

Then download our three stars of the night.

 git clone http://git.suckless.org/dwm && git clone git://git.suckless.org/st && git clone git://git.suckless.org/surf

Edit the config for dwm

 nano dwm/config.def.h
  • Later Disable the bar
  • Later Remove all workspaces except for 1 (*tags)
  • Set Mod4Mask as modkey
  • Set MODKEY|Shiftmask to 0 and XK_c to XK_F12 for killclient (personal preference)
  • Later disable spawm of dmenucmd and termcmd, but for now leave enabled.
cd dwm
make
make install
cd ../st
nano config.def.h
  • Set termname[] to xterm (resolves some issues with programs that don't understand default termname).
make
make install
cd ../surf
nano config.def.h
  • Review options
  • Later set runinfullscreen to TRUE
  • Later set kioskmode to TRUE once debugging is over
make
make install

Intermediate Cleanup Time

apt-get remove nfs-common rpcbind wpasupplicant avahi-daemon ofono apache2

Of course, leave wpasupplicant if you use wifi. Net installer may want to install acpid. Beware of removing cron. Just disable the service.

Should be about 40MB RAM, and <5% CPU. Remove Exim4 if you want as well.

Clock

This is optional. You can decide whether you need to keep time or not.

# apt-get install ntpdate

Set cron to run ntpdate periodically

*/5 * * * * ntpdate pool.ntp.org

This is leaner than running ntpd 24/7

Auto Start

Here you edit .xinitrc, /etc/rc.local, /etc/inittab, and .bashrc to make the machine auto startx without requiring a login, and have it load surf with the path of the zm server monitor feed. We will also disable the screensaver.


Added to /etc/inittab (replace existing):

1:2345:respawn:/bin/login -f USERNAME tty1 </dev/tty1 >/dev/tty1 2>&1

Copy /etc/profile to user that will be auto logging in:

cp /etc/profile ~/.bash_profile

Appended to ~/.bash_profile for USERNAME:

exec startx

When startx loads, it will pull settings from ~/.xinitrc for USERNAME so edit that:

#!/bin/bash
/usr/local/bin/surf "localhost/zm/cgi-bin/nph-zms??mode=jpeg&monitor=1&scale=100&maxfps=5&buffer=1000&user=user&pass=pass" &
exec dwm


Make sure you add another user besides the one used for the auto login, otherwise ssh will fail. ssh will try to startx when it loads, and it won't be able to.

# adduser USERNAME2
nano /etc/sudoers

and add USERNAME2 permissions.

Next disable screensaver per Arch Wiki: Display Power Management SIgnaling

nano /etc/rc.local

export DISPLAY=:0
xset s off
xset -dpms

Note: When troubleshooting xset. You must be the same user that is running X (ssh in as another user, then su to user). And, you must export DISPLAY to :0 or similar. Then xset q should query the current settings.

Using the Breakout Headers

Device Trees and Pin Initialization

Here are some notes, from my own setup of I2C on the BBB. It can be confusing if you are new to the BBB. This guide is helpful for configuring the peripherals or GPIO of the BBB.

https://github.com/beagleboard/bb.org-overlays

Follow this link. Ignore the part about pre built kernels if you used the RCN based installer or image from elinux.org's BeagleBoardDebian. You already have cape manager support.

If you don't have DTC where is asks for it in the 2nd step for dtc -version, ignore that step. The ./dtc_overlay.sh script will install the latest compatible device tree compiler.

Next

https://github.com/cdsteinkuehler/beaglebone-universal-io

And use this to configure the pins.

There are also preset modes with the pins configured in various states, but I found it more satisfying to customize them to my needs.

cd ..
git clone https://github.com/cdsteinkuehler/beaglebone-universal-io
cd beaglebone-universal-io

No installation is required for config-pin.

Test it now:

 ./config-pin overlay cape-universal

This will allow a lot of pins to be edited. This must be done first. Then you can configure pins. There are other modes as well, see github. Cape-universal exports all pins except for HDMI and EMMC pins.

#:~/beaglebone-universal-io# cat /sys/devices/platform/bone_capemgr/slots
 0: PF----  -1
 1: PF----  -1
 2: PF----  -1
 3: PF----  -1
 7: P-O-L-  0 Override Board Name, 00A0,Override Manuf, cape-universal

Now you can run something like this:

./config-pin p8_07 hi

To set Pin 07 on header 8 to GPIO HI

To see more options

./config-pin -h

e.g.

./config-pin -l 9_11
default gpio gpio_pu gpio_pd uart

Showing us we can set the pin to UART or one of the GPIO modes.

 ./config-pin -a 9_11 uart

Then we can access the UART through either the direct memory registers, or the linux file system access (search online for more details).

The config-pin overlay cape-universal can be set in /etc/rc.local as well as individual pin settings.

I2C Usage

 
# apt-get install i2c-tools

List

# i2cdetect -l

The i2c peripheral, after being connected to the BBB, will be on one of the three i2c buses. Either 0,1, or 2.

# i2cdetect -r 0

Here we search on 0.

I used a BMP180 barometer and mine showed up at 77.

Unfortunately, the sensor can't be read from without a driver. What you will need to do is recompile the kernel with that driver included, as linux has a driver for the BMP085, but not by default.


References: (from http://elinux.org/EBC_Exercise_12_I2C) [1] [2]

Recompile Kernel With Sensor Driver

I tried building the kernel natively on the Beagle, but this failed. It is best to cross compile from a Debian based distro. I received an error trying to cross compile on Gentoo.

http://elinux.org/EBC_Installing_Kernel_Source is a good guide that doesn't require javascript (as RCN's docs do).

Finally, with the kernel built with support for your i2c device, (in this case a barometer):

su root
echo bmp085 0x77 > /sys/class/i2c-adaptor/i2c-1/new_device

Again, these steps are only valid for the bmp085, and when it's on i2c-1. Review dmesg

$ dmesg -T

Finally for the BMP085, you can navigate to /sys/bus/i2c/drivers/bmp085/1-0077/ and review what the file system provides access to from the BMP driver to interface with the sensor.


References: [3] [4]

Troubleshooting

Video feed freezes once a day?

I've had the video crash on me on average once a day at 720p. Lowering the resolution to 640x480 or using a more powerful SBC may help.


Installing and updating programs takes too long!

While these SBCs are slower, it is also possible you have a counterfeit SD card that is slowing down all installs. A counterfeit or non name brand SD may take one day, what takes 2 hours to do with a name brand card. Beware.