initial work on raspberrypi3 support

This commit is contained in:
Calin Crisan 2016-03-04 21:54:15 +02:00
parent b36a40994d
commit afc9c81a9b
17 changed files with 4747 additions and 0 deletions

View File

@ -0,0 +1 @@
../raspberrypi/cleanups.sh

View File

@ -0,0 +1 @@
dwc_otg.fiq_fix_enable=1 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait ro rootflags=noload panic=10 quiet loglevel=1

View File

@ -0,0 +1,6 @@
start_file=start.elf
fixup_file=fixup.elf
gpu_mem=128
gpu_mem_256=128
gpu_mem_512=128
disable_camera_led=0

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
../raspberrypi/mkimage.sh

View File

@ -0,0 +1,232 @@
# Copyright (c) 2015 Calin Crisan
# This file is part of motionEyeOS.
#
# motionEyeOS is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import logging
import os.path
from config import additional_config
import streameyectl
CONFIG_TXT = '/boot/config.txt'
OVERCLOCK = {
700: '700|250|400|0',
800: '800|250|400|0',
900: '900|250|450|0',
950: '950|250|450|0',
1000: '1000|500|600|6',
1001: '1001|500|500|2'
}
def _get_board_settings():
gpu_mem = 128
camera_led = True
arm_freq = 700
if os.path.exists(CONFIG_TXT):
logging.debug('reading board settings from %s' % CONFIG_TXT)
with open(CONFIG_TXT) as f:
for line in f:
line = line.strip()
if not line or line.startswith('#'):
continue
parts = line.split('=', 1)
if len(parts) != 2:
continue
name, value = parts
name = name.strip()
value = value.strip()
if name == 'gpu_mem':
gpu_mem = int(value)
elif name == 'arm_freq':
arm_freq = int(value)
elif name == 'disable_camera_led':
camera_led = value == '0'
#overclock = OVERCLOCK.get(arm_freq, '700|250|400|0')
s = {
'gpuMem': gpu_mem,
#'overclock': overclock,
'cameraLed': camera_led
}
#logging.debug('board settings: gpu_mem=%(gpuMem)s, overclock=%(overclock)s, camera_led=%(cameraLed)s' % s)
logging.debug('board settings: gpu_mem=%(gpuMem)s, camera_led=%(cameraLed)s' % s)
return s
def _set_board_settings(s):
s.setdefault('gpuMem', 128)
#s.setdefault('overclock', '700|250|400|0')
s.setdefault('cameraLed', True)
old_settings = _get_board_settings()
if s == old_settings:
return # nothing has changed
seen = set()
#logging.debug('writing board settings to %s: ' % CONFIG_TXT +
# 'gpu_mem=%(gpuMem)s, overclock=%(overclock)s, camera_led=%(cameraLed)s' % s)
logging.debug('writing board settings to %s: ' % CONFIG_TXT +
'gpu_mem=%(gpuMem)s, camera_led=%(cameraLed)s' % s)
#arm_freq, gpu_freq, sdram_freq, over_voltage = s['overclock'].split('|')
lines = []
if os.path.exists(CONFIG_TXT):
with open(CONFIG_TXT) as f:
lines = f.readlines()
for i, line in enumerate(lines):
line = line.strip()
if not line:
continue
line = line.strip('#')
try:
name, _ = line.split('=', 1)
name = name.strip()
except:
continue
seen.add(name)
if name == 'gpu_mem':
lines[i] = '%s=%s' % (name, s['gpuMem'])
#elif name == 'arm_freq':
# lines[i] = 'arm_freq=%s' % arm_freq
#
#elif name in ['gpu_freq', 'core_freq']:
# lines[i] = '%s=%s' % (name, gpu_freq)
#
#elif name == 'sdram_freq':
# lines[i] = 'sdram_freq=%s' % sdram_freq
#
#elif name == 'over_voltage':
# lines[i] = 'over_voltage=%s' % over_voltage
elif name == 'disable_camera_led':
lines[i] = 'disable_camera_led=%s' % ['1', '0'][s['cameraLed']]
if 'gpu_mem' not in seen:
lines.append('gpu_mem=%s' % s['gpuMem'])
if 'arm_freq' not in seen:
lines.append('arm_freq=%s' % arm_freq)
if 'gpu_freq' not in seen:
lines.append('gpu_freq=%s' % gpu_freq)
if 'sdram_freq' not in seen:
lines.append('sdram_freq=%s' % sdram_freq)
if 'over_voltage' not in seen:
lines.append('over_voltage=%s' % over_voltage)
if 'disable_camera_led' not in seen:
lines.append('disable_camera_led=%s' % ['1', '0'][s['cameraLed']])
logging.debug('remounting /boot read-write')
if os.system('mount -o remount,rw /boot'):
logging.error('failed to remount /boot read-write')
with open(CONFIG_TXT, 'w') as f:
for line in lines:
if not line.strip():
continue
if not line.endswith('\n'):
line += '\n'
f.write(line)
@additional_config
def boardSeparator():
return {
'type': 'separator',
'section': 'expertSettings',
'advanced': True
}
@additional_config
def gpuMem():
return {
'label': 'GPU Memory',
'description': 'set the amount of memory reserved for the GPU (choose at least 96MB if you use the CSI camera board)',
'type': 'number',
'min': '16',
'max': '944',
'section': 'expertSettings',
'advanced': True,
'reboot': True,
'get': _get_board_settings,
'set': _set_board_settings,
'get_set_dict': True
}
@additional_config
def cameraLed():
return {
'label': 'Enable CSI Camera Led',
'description': 'control the led on the CSI camera board',
'type': 'bool',
'section': 'expertSettings',
'advanced': True,
'reboot': True,
'get': _get_board_settings,
'set': _set_board_settings,
'get_set_dict': True
}
#@additional_config
#def overclock():
# return {
# 'label': 'Overclocking',
# 'description': 'choose an overclocking preset for your Raspberry PI',
# 'type': 'choices',
# 'choices': [
# ('700|250|400|0', 'none (700/250/400/0)'),
# ('800|250|400|0', 'modest (800/250/400/0)'),
# ('900|250|450|0', 'medium (900/250/450/0)'),
# ('950|250|450|0', 'high (950/250/450/0)'),
# ('1000|500|600|6', 'turbo (1000/500/600/6)'),
# ('1001|500|500|2', 'Pi2 (1000/500/500/2)')
# ],
# 'section': 'expertSettings',
# 'advanced': True,
# 'reboot': True,
# 'get': _get_board_settings,
# 'set': _set_board_settings,
# 'get_set_dict': True
# }

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
raspberrypi3

View File

@ -0,0 +1,43 @@
#!/bin/bash
gpio=35
check_interval=30
export=/sys/class/gpio/export
readv=/sys/class/gpio/gpio$gpio/value
test -n "$os_version" || source /etc/init.d/base
configure() {
echo $gpio > $export
}
watch() {
while true; do
if [ "$(cat $readv)" == "0" ]; then
logger -t brownout -s "low power supply voltage detected"
fi
sleep $check_interval
done
}
case "$1" in
start)
msg_begin "Starting brownout detector"
configure
test $? == 0 && msg_done || msg_fail
watch &
;;
stop)
msg_begin "Stopping brownout detector"
ps | grep brownout | grep -v $$ | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1 | xargs -r kill
test $? == 0 && msg_done || msg_fail
;;
*)
echo $"Usage: $0 {start|stop}"
exit 1
esac
exit $?

View File

@ -0,0 +1,51 @@
#!/bin/sh
motioneye_conf_dir="/data/etc/"
test -n "$os_version" || source /etc/init.d/base
enabled() {
test $(ls -1 $motioneye_conf_dir/thread-*.conf 2>/dev/null| wc -l) == 1 || return 1
grep '# @proto mjpeg' $motioneye_conf_dir/thread-1.conf &>/dev/null || return 1
grep -E '# @url http://(.*)127.0.0.1:' $motioneye_conf_dir/thread-1.conf &>/dev/null || return 1
return 0
}
enabled || exit 0
start() {
msg_begin "Starting streameye"
streameye.sh start
test $? == 0 && msg_done || msg_fail
}
stop() {
msg_begin "Stopping streameye"
streameye.sh stop
test $? == 0 && msg_done || msg_fail
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?

View File

@ -0,0 +1,5 @@
#!/bin/bash
sn=$(cat /proc/cpuinfo | grep Serial | tr -d ' ' | cut -d ':' -f 2)
echo ${sn: -8}

View File

@ -0,0 +1 @@
bcm2835-v4l2 max_video_width=2592 max_video_height=1944

View File

@ -0,0 +1,36 @@
#!/bin/bash
MOTION_SVN="/usr/bin/motion-svn"
MOTION_MRDAVE="/usr/bin/motion-mrdave"
MOTION_MMAL="/usr/bin/motion-mmal"
if [ "$1" == "-h" ]; then
# when asked about version, always report MrDave's,
# as it's the most featureful one
motion=$MOTION_MRDAVE
else
conf_count=$(ls -1 /data/etc/thread-*.conf 2>/dev/null | wc -l)
if [ "$conf_count" -eq 0 ]; then # no cameras
motion=$MOTION_MRDAVE
elif [ "$conf_count" -eq 1 ]; then # one camera
if cat /data/etc/thread-*.conf | grep -E '^videodevice' &>/dev/null &&
lsmod | grep bcm2835_v4l2 &>/dev/null; then # RPI CSI camera module
motion=$MOTION_MMAL
else
motion=$MOTION_MRDAVE
fi
else # two or more cameras
motion=$MOTION_MRDAVE
fi
fi
echo "using motion binary $motion"
exec $motion "$@"

View File

@ -0,0 +1,93 @@
#!/bin/bash
RASPIMJPEG_CONF=/data/etc/raspimjpeg.conf
RASPIMJPEG_LOG=/var/log/raspimjpeg.log
MOTIONEYE_CONF=/data/etc/motioneye.conf
STREAMEYE_CONF=/data/etc/streameye.conf
STREAMEYE_LOG=/var/log/streameye.log
test -r $RASPIMJPEG_CONF || exit 1
test -r $STREAMEYE_CONF || exit 1
watch() {
count=0
while true; do
sleep 5
if ! ps aux | grep raspimjpeg.py | grep -v grep &>/dev/null; then
logger -t streameye -s "not running, respawning"
start
fi
done
}
function start() {
pid=$(ps | grep raspimjpeg.py | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1)
if [ -n "$pid" ]; then
return
fi
raspimjpeg_opts=""
while read line; do
if echo "$line" | grep false &>/dev/null; then
continue
fi
if echo "$line" | grep true &>/dev/null; then
line=$(echo $line | cut -d ' ' -f 1)
fi
raspimjpeg_opts="$raspimjpeg_opts --$line"
done < $RASPIMJPEG_CONF
source $STREAMEYE_CONF
streameye_opts="-p $PORT"
if [ -n "$CREDENTIALS" ] && [ "$AUTH" = "basic" ]; then
streameye_opts="$streameye_opts -a basic -c $CREDENTIALS"
fi
if [ -r $MOTIONEYE_CONF ] && grep 'log-level debug' $MOTIONEYE_CONF >/dev/null; then
raspimjpeg_opts="$raspimjpeg_opts -d"
streameye_opts="$streameye_opts -d"
fi
raspimjpeg.py $raspimjpeg_opts 2>$RASPIMJPEG_LOG | streameye $streameye_opts &>$STREAMEYE_LOG &
}
function stop() {
# stop the streameye background watch process
ps | grep streameye | grep -v $$ | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1 | xargs -r kill
# stop the raspimjpeg process
pid=$(ps | grep raspimjpeg.py | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1)
if [ -z "$pid" ]; then
return
fi
kill -HUP "$pid" &>/dev/null
count=0
while kill -0 "$pid" &>/dev/null && [ $count -lt 5 ]; do
sleep 1
count=$(($count + 1))
done
kill -KILL "$pid" &>/dev/null || true
}
case "$1" in
start)
start
watch &
;;
stop)
stop
;;
restart)
stop
start
watch &
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac

View File

@ -0,0 +1 @@
../raspberrypi/postscript.sh

View File

@ -0,0 +1,120 @@
BR2_arm=y
BR2_cortex_a7=y
BR2_ARM_EABIHF=y
BR2_ARM_FPU_NEON_VFPV4=y
BR2_DL_DIR="$(TOPDIR)/.download"
BR2_CCACHE=y
BR2_CCACHE_DIR="$(TOPDIR)/.buildroot-ccache-raspberrypi3"
BR2_OPTIMIZE_2=y
BR2_KERNEL_HEADERS_VERSION=y
BR2_DEFAULT_KERNEL_VERSION="4.1.18"
BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_1=y
BR2_TOOLCHAIN_BUILDROOT_GLIBC=y
BR2_GLIBC_VERSION_2_21=y
BR2_BINUTILS_VERSION_2_25_X=y
BR2_GCC_VERSION_4_8_X=y
BR2_EXTRA_GCC_CONFIG_OPTIONS="--with-float=hard"
BR2_TOOLCHAIN_BUILDROOT_CXX=y
BR2_TARGET_OPTIMIZATION="-pipe -mhard-float"
BR2_TARGET_GENERIC_HOSTNAME=""
BR2_TARGET_GENERIC_ISSUE=""
BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y
BR2_ROOTFS_SKELETON_CUSTOM=y
BR2_ROOTFS_SKELETON_CUSTOM_PATH="board/common/skeleton"
BR2_ROOTFS_OVERLAY="board/common/overlay board/raspberrypi3/overlay"
BR2_ROOTFS_POST_BUILD_SCRIPT="board/common/postscript.sh"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_TARBALL=y
BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="https://github.com/raspberrypi/linux/archive/e9e9ccf11ac5b6ee9b65416980900ababdd6c48c.tar.gz"
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/raspberrypi3/kernel.config"
BR2_LINUX_KERNEL_ZIMAGE=y
BR2_PACKAGE_BUSYBOX_CONFIG="board/common/busybox-1.22.x.config"
BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
BR2_PACKAGE_MOTIONEYE=y
BR2_PACKAGE_FFMPEG=y
BR2_PACKAGE_FFMPEG_GPL=y
BR2_PACKAGE_FFMPEG_NONFREE=y
BR2_PACKAGE_FFMPEG_SWSCALE=y
BR2_PACKAGE_LIBWEBCAM=y
BR2_PACKAGE_MOTION=y
BR2_PACKAGE_MOTION_MMAL=y
BR2_PACKAGE_MOTION_MRDAVE=y
BR2_PACKAGE_STREAMEYE=y
BR2_PACKAGE_GZIP=y
BR2_PACKAGE_GETTEXT=y
BR2_PACKAGE_TAR=y
BR2_PACKAGE_CIFS_UTILS=y
# BR2_PACKAGE_E2FSPROGS_BADBLOCKS is not set
# BR2_PACKAGE_E2FSPROGS_CHATTR is not set
BR2_PACKAGE_E2FSPROGS_DEBUGFS=y
# BR2_PACKAGE_E2FSPROGS_DUMPE2FS is not set
# BR2_PACKAGE_E2FSPROGS_E2FREEFRAG is not set
# BR2_PACKAGE_E2FSPROGS_E2LABEL is not set
# BR2_PACKAGE_E2FSPROGS_E2UNDO is not set
# BR2_PACKAGE_E2FSPROGS_FILEFRAG is not set
# BR2_PACKAGE_E2FSPROGS_FINDFS is not set
# BR2_PACKAGE_E2FSPROGS_LOGSAVE is not set
# BR2_PACKAGE_E2FSPROGS_LSATTR is not set
# BR2_PACKAGE_E2FSPROGS_MKLOSTFOUND is not set
# BR2_PACKAGE_E2FSPROGS_TUNE2FS is not set
# BR2_PACKAGE_E2FSPROGS_UUIDGEN is not set
BR2_PACKAGE_NTFS_3G=y
BR2_PACKAGE_B43_FIRMWARE=y
BR2_PACKAGE_LINUX_FIRMWARE=y
BR2_PACKAGE_LINUX_FIRMWARE_ATHEROS_7010=y
BR2_PACKAGE_LINUX_FIRMWARE_ATHEROS_9170=y
BR2_PACKAGE_LINUX_FIRMWARE_ATHEROS_9271=y
BR2_PACKAGE_LINUX_FIRMWARE_BRCM_BCM43XX=y
BR2_PACKAGE_LINUX_FIRMWARE_BRCM_BCM43XXX=y
BR2_PACKAGE_LINUX_FIRMWARE_RALINK_RT61=y
BR2_PACKAGE_LINUX_FIRMWARE_RALINK_RT73=y
BR2_PACKAGE_LINUX_FIRMWARE_RALINK_RT2XX=y
BR2_PACKAGE_LINUX_FIRMWARE_RTL_81XX=y
BR2_PACKAGE_LINUX_FIRMWARE_RTL_87XX=y
BR2_PACKAGE_LINUX_FIRMWARE_RTL_88XX=y
BR2_PACKAGE_RPI_FIRMWARE=y
BR2_PACKAGE_RPI_FIRMWARE_X=y
BR2_PACKAGE_I2C_TOOLS=y
BR2_PACKAGE_RPI_USERLAND=y
BR2_PACKAGE_PYTHON_SSL=y
BR2_PACKAGE_PYTHON_HASHLIB=y
BR2_PACKAGE_PYTHON_JINJA2=y
BR2_PACKAGE_PYTHON_PICAMERA=y
BR2_PACKAGE_PYTHON_PILLOW=y
BR2_PACKAGE_PYTHON_PYCURL=y
BR2_PACKAGE_PYTHON_PYTZ=y
BR2_PACKAGE_PYTHON_RPI_GPIO=y
BR2_PACKAGE_PYTHON_TORNADO=y
BR2_PACKAGE_PYTHON_VERSIONTOOLS=y
BR2_PACKAGE_CA_CERTIFICATES=y
BR2_PACKAGE_NETTLE=y
BR2_PACKAGE_LIBFUSE=y
BR2_PACKAGE_LIBV4L=y
BR2_PACKAGE_LIBV4L_UTILS=y
BR2_PACKAGE_LIBXML2=y
BR2_PACKAGE_LIBCURL=y
BR2_PACKAGE_CURL=y
BR2_PACKAGE_LIBCAP=y
BR2_PACKAGE_PCRE=y
BR2_PACKAGE_CRDA=y
BR2_PACKAGE_DHCP=y
BR2_PACKAGE_DHCP_CLIENT=y
BR2_PACKAGE_IPTABLES=y
BR2_PACKAGE_NETCAT=y
BR2_PACKAGE_NET_TOOLS=y
BR2_PACKAGE_NTP=y
BR2_PACKAGE_NTP_NTPDATE=y
BR2_PACKAGE_OPENSSH=y
BR2_PACKAGE_PPPD=y
BR2_PACKAGE_PROFTPD=y
BR2_PACKAGE_SAMBA4=y
BR2_PACKAGE_WGET=y
BR2_PACKAGE_WIRELESS_TOOLS=y
BR2_PACKAGE_WPA_SUPPLICANT=y
BR2_PACKAGE_WPA_SUPPLICANT_EAP=y
BR2_PACKAGE_WPA_SUPPLICANT_CLI=y
BR2_PACKAGE_BASH=y
BR2_PACKAGE_UTIL_LINUX_BINARIES=y
BR2_PACKAGE_UTIL_LINUX_PARTX=y
BR2_PACKAGE_NANO=y