MycroftOS: Initial setup for rpi3
This commit is contained in:
parent
a6afd572f6
commit
b68a2beb9e
|
@ -0,0 +1,32 @@
|
||||||
|
image boot.vfat {
|
||||||
|
vfat {
|
||||||
|
files = {
|
||||||
|
"bcm2708-rpi-b.dtb",
|
||||||
|
"bcm2708-rpi-b-plus.dtb",
|
||||||
|
"bcm2708-rpi-cm.dtb",
|
||||||
|
"rpi-firmware/bootcode.bin",
|
||||||
|
"rpi-firmware/cmdline.txt",
|
||||||
|
"rpi-firmware/config.txt",
|
||||||
|
"rpi-firmware/fixup.dat",
|
||||||
|
"rpi-firmware/start.elf",
|
||||||
|
"zImage"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
size = 32M
|
||||||
|
}
|
||||||
|
|
||||||
|
image sdcard.img {
|
||||||
|
hdimage {
|
||||||
|
}
|
||||||
|
|
||||||
|
partition boot {
|
||||||
|
partition-type = 0xC
|
||||||
|
bootable = "true"
|
||||||
|
image = "boot.vfat"
|
||||||
|
}
|
||||||
|
|
||||||
|
partition rootfs {
|
||||||
|
partition-type = 0x83
|
||||||
|
image = "rootfs.ext4"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
image boot.vfat {
|
||||||
|
vfat {
|
||||||
|
files = {
|
||||||
|
"bcm2708-rpi-b-plus.dtb",
|
||||||
|
"rpi-firmware/bootcode.bin",
|
||||||
|
"rpi-firmware/cmdline.txt",
|
||||||
|
"rpi-firmware/config.txt",
|
||||||
|
"rpi-firmware/fixup.dat",
|
||||||
|
"rpi-firmware/start.elf",
|
||||||
|
"zImage"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
size = 32M
|
||||||
|
}
|
||||||
|
|
||||||
|
image sdcard.img {
|
||||||
|
hdimage {
|
||||||
|
}
|
||||||
|
|
||||||
|
partition boot {
|
||||||
|
partition-type = 0xC
|
||||||
|
bootable = "true"
|
||||||
|
image = "boot.vfat"
|
||||||
|
}
|
||||||
|
|
||||||
|
partition rootfs {
|
||||||
|
partition-type = 0x83
|
||||||
|
image = "rootfs.ext4"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
image boot.vfat {
|
||||||
|
vfat {
|
||||||
|
files = {
|
||||||
|
"bcm2708-rpi-0-w.dtb",
|
||||||
|
"rpi-firmware/bootcode.bin",
|
||||||
|
"rpi-firmware/cmdline.txt",
|
||||||
|
"rpi-firmware/config.txt",
|
||||||
|
"rpi-firmware/fixup.dat",
|
||||||
|
"rpi-firmware/start.elf",
|
||||||
|
"rpi-firmware/overlays",
|
||||||
|
"zImage"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
size = 32M
|
||||||
|
}
|
||||||
|
|
||||||
|
image sdcard.img {
|
||||||
|
hdimage {
|
||||||
|
}
|
||||||
|
|
||||||
|
partition boot {
|
||||||
|
partition-type = 0xC
|
||||||
|
bootable = "true"
|
||||||
|
image = "boot.vfat"
|
||||||
|
}
|
||||||
|
|
||||||
|
partition rootfs {
|
||||||
|
partition-type = 0x83
|
||||||
|
image = "rootfs.ext4"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
image boot.vfat {
|
||||||
|
vfat {
|
||||||
|
files = {
|
||||||
|
"bcm2709-rpi-2-b.dtb",
|
||||||
|
"rpi-firmware/bootcode.bin",
|
||||||
|
"rpi-firmware/cmdline.txt",
|
||||||
|
"rpi-firmware/config.txt",
|
||||||
|
"rpi-firmware/fixup.dat",
|
||||||
|
"rpi-firmware/start.elf",
|
||||||
|
"zImage"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
size = 32M
|
||||||
|
}
|
||||||
|
|
||||||
|
image sdcard.img {
|
||||||
|
hdimage {
|
||||||
|
}
|
||||||
|
|
||||||
|
partition boot {
|
||||||
|
partition-type = 0xC
|
||||||
|
bootable = "true"
|
||||||
|
image = "boot.vfat"
|
||||||
|
}
|
||||||
|
|
||||||
|
partition rootfs {
|
||||||
|
partition-type = 0x83
|
||||||
|
image = "rootfs.ext4"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
image boot.vfat {
|
||||||
|
vfat {
|
||||||
|
files = {
|
||||||
|
"bcm2710-rpi-3-b.dtb",
|
||||||
|
"bcm2837-rpi-3-b.dtb",
|
||||||
|
"rpi-firmware/bootcode.bin",
|
||||||
|
"rpi-firmware/cmdline.txt",
|
||||||
|
"rpi-firmware/config.txt",
|
||||||
|
"rpi-firmware/fixup.dat",
|
||||||
|
"rpi-firmware/start.elf",
|
||||||
|
"Image"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
size = 32M
|
||||||
|
}
|
||||||
|
|
||||||
|
image sdcard.img {
|
||||||
|
hdimage {
|
||||||
|
}
|
||||||
|
|
||||||
|
partition boot {
|
||||||
|
partition-type = 0xC
|
||||||
|
bootable = "true"
|
||||||
|
image = "boot.vfat"
|
||||||
|
}
|
||||||
|
|
||||||
|
partition rootfs {
|
||||||
|
partition-type = 0x83
|
||||||
|
image = "rootfs.ext4"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
image boot.vfat {
|
||||||
|
vfat {
|
||||||
|
files = {
|
||||||
|
"bcm2710-rpi-3-b.dtb",
|
||||||
|
"bcm2710-rpi-3-b-plus.dtb",
|
||||||
|
"bcm2710-rpi-cm3.dtb",
|
||||||
|
"rpi-firmware/bootcode.bin",
|
||||||
|
"rpi-firmware/cmdline.txt",
|
||||||
|
"rpi-firmware/config.txt",
|
||||||
|
"rpi-firmware/fixup.dat",
|
||||||
|
"rpi-firmware/start.elf",
|
||||||
|
"rpi-firmware/overlays",
|
||||||
|
"zImage"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
size = 32M
|
||||||
|
}
|
||||||
|
|
||||||
|
image sdcard.img {
|
||||||
|
hdimage {
|
||||||
|
}
|
||||||
|
|
||||||
|
partition boot {
|
||||||
|
partition-type = 0xC
|
||||||
|
bootable = "true"
|
||||||
|
image = "boot.vfat"
|
||||||
|
}
|
||||||
|
|
||||||
|
partition rootfs {
|
||||||
|
partition-type = 0x83
|
||||||
|
image = "rootfs.ext4"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -u
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Add a console on tty1
|
||||||
|
if [ -e ${TARGET_DIR}/etc/inittab ]; then
|
||||||
|
grep -qE '^tty1::' ${TARGET_DIR}/etc/inittab || \
|
||||||
|
sed -i '/GENERIC_SERIAL/a\
|
||||||
|
tty1::respawn:/sbin/getty -L tty1 0 vt100 # HDMI console' ${TARGET_DIR}/etc/inittab
|
||||||
|
fi
|
|
@ -0,0 +1,61 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
BOARD_DIR="$(dirname $0)"
|
||||||
|
BOARD_NAME="$(basename ${BOARD_DIR})"
|
||||||
|
GENIMAGE_CFG="${BOARD_DIR}/genimage-${BOARD_NAME}.cfg"
|
||||||
|
GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
|
||||||
|
|
||||||
|
for arg in "$@"
|
||||||
|
do
|
||||||
|
case "${arg}" in
|
||||||
|
--add-pi3-miniuart-bt-overlay)
|
||||||
|
if ! grep -qE '^dtoverlay=' "${BINARIES_DIR}/rpi-firmware/config.txt"; then
|
||||||
|
echo "Adding 'dtoverlay=pi3-miniuart-bt' to config.txt (fixes ttyAMA0 serial console)."
|
||||||
|
cat << __EOF__ >> "${BINARIES_DIR}/rpi-firmware/config.txt"
|
||||||
|
|
||||||
|
# fixes rpi3 ttyAMA0 serial console
|
||||||
|
dtoverlay=pi3-miniuart-bt
|
||||||
|
__EOF__
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
--aarch64)
|
||||||
|
# Run a 64bits kernel (armv8)
|
||||||
|
sed -e '/^kernel=/s,=.*,=Image,' -i "${BINARIES_DIR}/rpi-firmware/config.txt"
|
||||||
|
if ! grep -qE '^arm_control=0x200' "${BINARIES_DIR}/rpi-firmware/config.txt"; then
|
||||||
|
cat << __EOF__ >> "${BINARIES_DIR}/rpi-firmware/config.txt"
|
||||||
|
|
||||||
|
# enable 64bits support
|
||||||
|
arm_control=0x200
|
||||||
|
__EOF__
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Enable uart console
|
||||||
|
if ! grep -qE '^enable_uart=1' "${BINARIES_DIR}/rpi-firmware/config.txt"; then
|
||||||
|
cat << __EOF__ >> "${BINARIES_DIR}/rpi-firmware/config.txt"
|
||||||
|
|
||||||
|
# enable rpi3 ttyS0 serial console
|
||||||
|
enable_uart=1
|
||||||
|
__EOF__
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
--gpu_mem_256=*|--gpu_mem_512=*|--gpu_mem_1024=*)
|
||||||
|
# Set GPU memory
|
||||||
|
gpu_mem="${arg:2}"
|
||||||
|
sed -e "/^${gpu_mem%=*}=/s,=.*,=${gpu_mem##*=}," -i "${BINARIES_DIR}/rpi-firmware/config.txt"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
|
rm -rf "${GENIMAGE_TMP}"
|
||||||
|
|
||||||
|
genimage \
|
||||||
|
--rootpath "${TARGET_DIR}" \
|
||||||
|
--tmppath "${GENIMAGE_TMP}" \
|
||||||
|
--inputpath "${BINARIES_DIR}" \
|
||||||
|
--outputpath "${BINARIES_DIR}" \
|
||||||
|
--config "${GENIMAGE_CFG}"
|
||||||
|
|
||||||
|
exit $?
|
|
@ -0,0 +1,93 @@
|
||||||
|
Raspberry Pi
|
||||||
|
|
||||||
|
Intro
|
||||||
|
=====
|
||||||
|
|
||||||
|
These instructions apply to all models of the Raspberry Pi:
|
||||||
|
- the original models A and B,
|
||||||
|
- the "enhanced" models A+ and B+,
|
||||||
|
- the model B2 (aka Raspberry Pi 2)
|
||||||
|
- the model B3 (aka Raspberry Pi 3).
|
||||||
|
|
||||||
|
How to build it
|
||||||
|
===============
|
||||||
|
|
||||||
|
Configure Buildroot
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
There are two RaspberryPi defconfig files in Buildroot, one for each
|
||||||
|
major variant, which you should base your work on:
|
||||||
|
|
||||||
|
For models A, B, A+ or B+:
|
||||||
|
|
||||||
|
$ make raspberrypi_defconfig
|
||||||
|
|
||||||
|
For model Zero (model A+ in smaller form factor):
|
||||||
|
|
||||||
|
$ make raspberrypi0_defconfig
|
||||||
|
|
||||||
|
For model 2 B:
|
||||||
|
|
||||||
|
$ make raspberrypi2_defconfig
|
||||||
|
|
||||||
|
For model 3 B and B+:
|
||||||
|
|
||||||
|
$ make raspberrypi3_defconfig
|
||||||
|
|
||||||
|
Build the rootfs
|
||||||
|
----------------
|
||||||
|
|
||||||
|
Note: you will need to have access to the network, since Buildroot will
|
||||||
|
download the packages' sources.
|
||||||
|
|
||||||
|
You may now build your rootfs with:
|
||||||
|
|
||||||
|
$ make
|
||||||
|
|
||||||
|
(This may take a while, consider getting yourself a coffee ;-) )
|
||||||
|
|
||||||
|
Result of the build
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
After building, you should obtain this tree:
|
||||||
|
|
||||||
|
output/images/
|
||||||
|
+-- bcm2708-rpi-b.dtb [1]
|
||||||
|
+-- bcm2708-rpi-b-plus.dtb [1]
|
||||||
|
+-- bcm2709-rpi-2-b.dtb [1]
|
||||||
|
+-- bcm2710-rpi-3-b.dtb [1]
|
||||||
|
+-- bcm2710-rpi-3-b-plus.dtb [1]
|
||||||
|
+-- boot.vfat
|
||||||
|
+-- rootfs.ext4
|
||||||
|
+-- rpi-firmware/
|
||||||
|
| +-- bootcode.bin
|
||||||
|
| +-- cmdline.txt
|
||||||
|
| +-- config.txt
|
||||||
|
| +-- fixup.dat
|
||||||
|
| +-- start.elf
|
||||||
|
| `-- overlays/ [2]
|
||||||
|
+-- sdcard.img
|
||||||
|
`-- zImage
|
||||||
|
|
||||||
|
[1] Not all of them will be present, depending on the RaspberryPi
|
||||||
|
model you are using.
|
||||||
|
|
||||||
|
[2] Only for the Raspberry Pi 3 Model (overlay pi3-miniuart-bt is needed
|
||||||
|
to enable the RPi3 serial console otherwise occupied by the bluetooth
|
||||||
|
chip). Alternative would be to disable the serial console in cmdline.txt
|
||||||
|
and /etc/inittab.
|
||||||
|
|
||||||
|
How to write the SD card
|
||||||
|
========================
|
||||||
|
|
||||||
|
Once the build process is finished you will have an image called "sdcard.img"
|
||||||
|
in the output/images/ directory.
|
||||||
|
|
||||||
|
Copy the bootable "sdcard.img" onto an SD card with "dd":
|
||||||
|
|
||||||
|
$ sudo dd if=output/images/sdcard.img of=/dev/sdX
|
||||||
|
|
||||||
|
Insert the SDcard into your Raspberry Pi, and power it up. Your new system
|
||||||
|
should come up now and start two consoles: one on the serial port on
|
||||||
|
the P1 header, one on the HDMI output where you can login using a USB
|
||||||
|
keyboard.
|
|
@ -0,0 +1 @@
|
||||||
|
raspberrypi
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,183 @@
|
||||||
|
BR2_arm=y
|
||||||
|
BR2_cortex_a53=y
|
||||||
|
BR2_ARM_FPU_NEON_VFPV4=y
|
||||||
|
BR2_DL_DIR="../downloads"
|
||||||
|
BR2_CCACHE=y
|
||||||
|
BR2_CCACHE_DIR="../ccache"
|
||||||
|
BR2_OPTIMIZE_FAST=y
|
||||||
|
BR2_GLOBAL_PATCH_DIR="../buildroot-patches"
|
||||||
|
BR2_TOOLCHAIN_EXTERNAL=y
|
||||||
|
BR2_TARGET_GENERIC_HOSTNAME="MycroftOS"
|
||||||
|
BR2_TARGET_GENERIC_ISSUE="Welcome to MycroftOS"
|
||||||
|
BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV=y
|
||||||
|
BR2_TARGET_GENERIC_ROOT_PASSWD="mycroft"
|
||||||
|
BR2_SYSTEM_BIN_SH_BASH=y
|
||||||
|
BR2_SYSTEM_DHCP="eth0"
|
||||||
|
# BR2_ENABLE_LOCALE_PURGE is not set
|
||||||
|
BR2_GENERATE_LOCALE="en_US en_US.UTF-8"
|
||||||
|
BR2_TARGET_TZ_INFO=y
|
||||||
|
BR2_ROOTFS_OVERLAY="../buildroot-external/rootfs-overlay"
|
||||||
|
BR2_ROOTFS_POST_BUILD_SCRIPT="../buildroot-external/board/raspberrypi3/post-build.sh"
|
||||||
|
BR2_ROOTFS_POST_IMAGE_SCRIPT="../buildroot-external/board/raspberrypi3/post-image.sh"
|
||||||
|
BR2_ROOTFS_POST_SCRIPT_ARGS="--add-pi3-miniuart-bt-overlay"
|
||||||
|
BR2_LINUX_KERNEL=y
|
||||||
|
BR2_LINUX_KERNEL_CUSTOM_GIT=y
|
||||||
|
BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/raspberrypi/linux.git"
|
||||||
|
BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="7c063ed121b219110602993d09d021fbf82628b6"
|
||||||
|
BR2_LINUX_KERNEL_DEFCONFIG="bcm2709"
|
||||||
|
BR2_LINUX_KERNEL_DTS_SUPPORT=y
|
||||||
|
BR2_LINUX_KERNEL_INTREE_DTS_NAME="bcm2710-rpi-3-b bcm2710-rpi-3-b-plus bcm2710-rpi-cm3"
|
||||||
|
BR2_PACKAGE_BUSYBOX_CONFIG="../buildroot-external/busybox.config"
|
||||||
|
BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
|
||||||
|
BR2_PACKAGE_BUSYBOX_INDIVIDUAL_BINARIES=y
|
||||||
|
BR2_PACKAGE_ALSA_UTILS=y
|
||||||
|
BR2_PACKAGE_ALSA_UTILS_ALSACONF=y
|
||||||
|
BR2_PACKAGE_ALSA_UTILS_ACONNECT=y
|
||||||
|
BR2_PACKAGE_ALSA_UTILS_ALSALOOP=y
|
||||||
|
BR2_PACKAGE_ALSA_UTILS_ALSAUCM=y
|
||||||
|
BR2_PACKAGE_ALSA_UTILS_ALSATPLG=y
|
||||||
|
BR2_PACKAGE_ALSA_UTILS_AMIDI=y
|
||||||
|
BR2_PACKAGE_ALSA_UTILS_AMIXER=y
|
||||||
|
BR2_PACKAGE_ALSA_UTILS_APLAY=y
|
||||||
|
BR2_PACKAGE_ALSA_UTILS_APLAYMIDI=y
|
||||||
|
BR2_PACKAGE_ALSA_UTILS_ARECORDMIDI=y
|
||||||
|
BR2_PACKAGE_ALSA_UTILS_ASEQDUMP=y
|
||||||
|
BR2_PACKAGE_ALSA_UTILS_ASEQNET=y
|
||||||
|
BR2_PACKAGE_ALSA_UTILS_BAT=y
|
||||||
|
BR2_PACKAGE_ALSA_UTILS_IECSET=y
|
||||||
|
BR2_PACKAGE_ALSA_UTILS_SPEAKER_TEST=y
|
||||||
|
BR2_PACKAGE_BLUEZ_ALSA=y
|
||||||
|
BR2_PACKAGE_ESPEAK=y
|
||||||
|
BR2_PACKAGE_ESPEAK_AUDIO_BACKEND_ALSA=y
|
||||||
|
BR2_PACKAGE_FFMPEG_GPL=y
|
||||||
|
BR2_PACKAGE_FFMPEG_NONFREE=y
|
||||||
|
BR2_PACKAGE_FLAC=y
|
||||||
|
BR2_PACKAGE_MIMIC=y
|
||||||
|
BR2_PACKAGE_MIMIC_AUDIO_BACKEND_ALSA=y
|
||||||
|
BR2_PACKAGE_MPG123=y
|
||||||
|
BR2_PACKAGE_MPV=y
|
||||||
|
BR2_PACKAGE_PULSEAUDIO=y
|
||||||
|
BR2_PACKAGE_PULSEAUDIO_DAEMON=y
|
||||||
|
BR2_PACKAGE_VLC=y
|
||||||
|
BR2_PACKAGE_GZIP=y
|
||||||
|
BR2_PACKAGE_LZ4=y
|
||||||
|
BR2_PACKAGE_P7ZIP=y
|
||||||
|
BR2_PACKAGE_UNRAR=y
|
||||||
|
BR2_PACKAGE_UNZIP=y
|
||||||
|
BR2_PACKAGE_BINUTILS=y
|
||||||
|
BR2_PACKAGE_BINUTILS_TARGET=y
|
||||||
|
BR2_PACKAGE_CHECK=y
|
||||||
|
BR2_PACKAGE_DIFFUTILS=y
|
||||||
|
BR2_PACKAGE_FINDUTILS=y
|
||||||
|
BR2_PACKAGE_GIT=y
|
||||||
|
BR2_PACKAGE_GREP=y
|
||||||
|
BR2_PACKAGE_JQ=y
|
||||||
|
BR2_PACKAGE_MAKE=y
|
||||||
|
BR2_PACKAGE_PKGCONF=y
|
||||||
|
BR2_PACKAGE_E2FSPROGS=y
|
||||||
|
BR2_PACKAGE_E2FSPROGS_RESIZE2FS=y
|
||||||
|
BR2_PACKAGE_NTFS_3G=y
|
||||||
|
BR2_PACKAGE_RPI_BT_FIRMWARE=y
|
||||||
|
BR2_PACKAGE_RPI_FIRMWARE=y
|
||||||
|
BR2_PACKAGE_RPI_FIRMWARE_X=y
|
||||||
|
BR2_PACKAGE_RPI_WIFI_FIRMWARE=y
|
||||||
|
BR2_PACKAGE_DBUS_PYTHON=y
|
||||||
|
BR2_PACKAGE_KBD=y
|
||||||
|
BR2_PACKAGE_PARTED=y
|
||||||
|
BR2_PACKAGE_RPI_USERLAND=y
|
||||||
|
BR2_PACKAGE_PYTHON3=y
|
||||||
|
BR2_PACKAGE_PYTHON3_PY_ONLY=y
|
||||||
|
BR2_PACKAGE_PYTHON3_BZIP2=y
|
||||||
|
BR2_PACKAGE_PYTHON3_CODECSCJK=y
|
||||||
|
BR2_PACKAGE_PYTHON3_CURSES=y
|
||||||
|
BR2_PACKAGE_PYTHON3_DECIMAL=y
|
||||||
|
BR2_PACKAGE_PYTHON3_OSSAUDIODEV=y
|
||||||
|
BR2_PACKAGE_PYTHON3_SQLITE=y
|
||||||
|
BR2_PACKAGE_PYTHON3_XZ=y
|
||||||
|
BR2_PACKAGE_PYTHON_ALSAAUDIO=y
|
||||||
|
BR2_PACKAGE_PYTHON_ARROW=y
|
||||||
|
BR2_PACKAGE_PYTHON_BEAUTIFULSOUP4=y
|
||||||
|
BR2_PACKAGE_PYTHON_CFFI=y
|
||||||
|
BR2_PACKAGE_PYTHON_CONFIGSHELL_FB=y
|
||||||
|
BR2_PACKAGE_PYTHON_DAEMONIZE=y
|
||||||
|
BR2_PACKAGE_PYTHON_GOBJECT=y
|
||||||
|
BR2_PACKAGE_PYTHON_LXML=y
|
||||||
|
BR2_PACKAGE_PYTHON_NETADDR=y
|
||||||
|
BR2_PACKAGE_PYTHON_NETIFACES=y
|
||||||
|
BR2_PACKAGE_PYTHON_OAUTHLIB=y
|
||||||
|
BR2_PACKAGE_PYTHON_PILLOW=y
|
||||||
|
BR2_PACKAGE_PYTHON_PSUTIL=y
|
||||||
|
BR2_PACKAGE_PYTHON_PYCLI=y
|
||||||
|
BR2_PACKAGE_PYTHON_PYCRYPTO=y
|
||||||
|
BR2_PACKAGE_PYTHON_PYTZ=y
|
||||||
|
BR2_PACKAGE_PYTHON_PYYAML=y
|
||||||
|
BR2_PACKAGE_PYTHON_SERIAL=y
|
||||||
|
BR2_PACKAGE_PYTHON_TEXTTABLE=y
|
||||||
|
BR2_PACKAGE_PYTHON_TORNADO=y
|
||||||
|
BR2_PACKAGE_PYTHON_WEBSOCKET_CLIENT=y
|
||||||
|
BR2_PACKAGE_AUDIOFILE=y
|
||||||
|
BR2_PACKAGE_PORTAUDIO_OSS=y
|
||||||
|
BR2_PACKAGE_SPEEXDSP=y
|
||||||
|
BR2_PACKAGE_WEBRTC_AUDIO_PROCESSING=y
|
||||||
|
BR2_PACKAGE_LIBARCHIVE=y
|
||||||
|
BR2_PACKAGE_LIBARCHIVE_BSDTAR=y
|
||||||
|
BR2_PACKAGE_LIBARCHIVE_BSDCPIO=y
|
||||||
|
BR2_PACKAGE_LIBARCHIVE_BSDCAT=y
|
||||||
|
BR2_PACKAGE_LIBZIP=y
|
||||||
|
BR2_PACKAGE_LZO=y
|
||||||
|
BR2_PACKAGE_SNAPPY=y
|
||||||
|
BR2_PACKAGE_CA_CERTIFICATES=y
|
||||||
|
BR2_PACKAGE_LIBOPENSSL_BIN=y
|
||||||
|
BR2_PACKAGE_LIBOPENSSL_ENGINES=y
|
||||||
|
BR2_PACKAGE_LIBCONFIG=y
|
||||||
|
BR2_PACKAGE_LIBNFS=y
|
||||||
|
BR2_PACKAGE_JPEG=y
|
||||||
|
BR2_PACKAGE_LIBPNG=y
|
||||||
|
BR2_PACKAGE_BCM2835=y
|
||||||
|
BR2_PACKAGE_WIRINGPI=y
|
||||||
|
BR2_PACKAGE_LIBMPEG2=y
|
||||||
|
BR2_PACKAGE_LIBMPEG2_BINS=y
|
||||||
|
BR2_PACKAGE_LIBOPENH264=y
|
||||||
|
BR2_PACKAGE_LIBTHEORA=y
|
||||||
|
BR2_PACKAGE_LIBCURL=y
|
||||||
|
BR2_PACKAGE_CURL=y
|
||||||
|
BR2_PACKAGE_LIBFRIBIDI=y
|
||||||
|
BR2_PACKAGE_LIBUNISTRING=y
|
||||||
|
BR2_PACKAGE_NCURSES_WCHAR=y
|
||||||
|
BR2_PACKAGE_NCURSES_TARGET_PROGS=y
|
||||||
|
BR2_PACKAGE_PCRE_16=y
|
||||||
|
BR2_PACKAGE_PCRE_32=y
|
||||||
|
BR2_PACKAGE_CONNMAN=y
|
||||||
|
BR2_PACKAGE_CONNMAN_WIFI=y
|
||||||
|
BR2_PACKAGE_CONNMAN_BLUETOOTH=y
|
||||||
|
BR2_PACKAGE_DROPBEAR=y
|
||||||
|
BR2_PACKAGE_IW=y
|
||||||
|
BR2_PACKAGE_NTP=y
|
||||||
|
BR2_PACKAGE_OPENSSH=y
|
||||||
|
BR2_PACKAGE_WGET=y
|
||||||
|
BR2_PACKAGE_WPA_SUPPLICANT_AP_SUPPORT=y
|
||||||
|
BR2_PACKAGE_WPA_SUPPLICANT_CLI=y
|
||||||
|
BR2_PACKAGE_WPA_SUPPLICANT_WPA_CLIENT_SO=y
|
||||||
|
BR2_PACKAGE_WPA_SUPPLICANT_PASSPHRASE=y
|
||||||
|
BR2_PACKAGE_BASH_COMPLETION=y
|
||||||
|
BR2_PACKAGE_FILE=y
|
||||||
|
BR2_PACKAGE_SCREEN=y
|
||||||
|
BR2_PACKAGE_TIME=y
|
||||||
|
BR2_PACKAGE_WHICH=y
|
||||||
|
BR2_PACKAGE_HTOP=y
|
||||||
|
BR2_PACKAGE_START_STOP_DAEMON=y
|
||||||
|
BR2_PACKAGE_TAR=y
|
||||||
|
BR2_PACKAGE_UTIL_LINUX_FSCK=y
|
||||||
|
BR2_PACKAGE_UTIL_LINUX_HWCLOCK=y
|
||||||
|
BR2_PACKAGE_UTIL_LINUX_KILL=y
|
||||||
|
BR2_PACKAGE_UTIL_LINUX_MORE=y
|
||||||
|
BR2_PACKAGE_UTIL_LINUX_MOUNT=y
|
||||||
|
BR2_PACKAGE_NANO=y
|
||||||
|
BR2_PACKAGE_VIM=y
|
||||||
|
BR2_TARGET_ROOTFS_EXT2=y
|
||||||
|
BR2_TARGET_ROOTFS_EXT2_4=y
|
||||||
|
BR2_TARGET_ROOTFS_EXT2_SIZE="768M"
|
||||||
|
# BR2_TARGET_ROOTFS_TAR is not set
|
||||||
|
BR2_PACKAGE_HOST_DOSFSTOOLS=y
|
||||||
|
BR2_PACKAGE_HOST_GENIMAGE=y
|
||||||
|
BR2_PACKAGE_HOST_MTOOLS=y
|
|
@ -1,2 +1,2 @@
|
||||||
name: MycroftOS
|
name: MYCROFTOS
|
||||||
desc: MycroftOS Buildroot tree
|
desc: MycroftOS Buildroot tree
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
defaults.ctl.card 0
|
||||||
|
defaults.pcm.card 0
|
||||||
|
defaults.pcm.device 0
|
||||||
|
|
||||||
|
pcm.!default {
|
||||||
|
type plug
|
||||||
|
slave.pcm "master"
|
||||||
|
}
|
||||||
|
|
||||||
|
ctl.!default {
|
||||||
|
type hw card 0
|
||||||
|
}
|
||||||
|
|
||||||
|
pcm.master {
|
||||||
|
type softvol
|
||||||
|
slave.pcm "plughw:0"
|
||||||
|
control.name "Master"
|
||||||
|
control.card 0
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
# <file system> <mount pt> <type> <options> <dump> <pass>
|
||||||
|
/dev/root / ext2 rw,noauto 0 1
|
||||||
|
proc /proc proc defaults 0 0
|
||||||
|
devpts /dev/pts devpts defaults,gid=5,mode=620,ptmxmode=0666 0 0
|
||||||
|
tmpfs /dev/shm tmpfs mode=0777 0 0
|
||||||
|
tmpfs /tmp tmpfs mode=1777 0 0
|
||||||
|
tmpfs /run tmpfs mode=0755,nosuid,nodev 0 0
|
||||||
|
sysfs /sys sysfs defaults 0 0
|
||||||
|
tmpfs /var/log tmpfs defaults 0 0
|
||||||
|
tmpfs /var/tmp tmpfs defaults 0 0
|
||||||
|
tmpfs /ramdisk tmpfs rw,nodev,nosuid,size=20M 0 0
|
|
@ -0,0 +1,23 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Auto resize root partition at first boot after init_resize
|
||||||
|
#
|
||||||
|
|
||||||
|
start() {
|
||||||
|
printf "Starting resize2fs_once: "
|
||||||
|
ROOT_DEV=$(findmnt / -o source -n) &&
|
||||||
|
resize2fs $ROOT_DEV &&
|
||||||
|
rm /etc/init.d/S00resizefs_once &&
|
||||||
|
echo "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
start
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: $0 {start}"
|
||||||
|
exit 1
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit $?
|
|
@ -0,0 +1,2 @@
|
||||||
|
modprobe snd-bcm2835
|
||||||
|
#modprobe snd-usb-audio
|
|
@ -0,0 +1,4 @@
|
||||||
|
alsactl init
|
||||||
|
amixer cset numid=3 1
|
||||||
|
amixer sset PCM 95%
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Prepare Mycroft software stack.
|
||||||
|
#
|
||||||
|
|
||||||
|
start() {
|
||||||
|
# set the right locale / language settings
|
||||||
|
export LC_ALL=en_US.UTF-8
|
||||||
|
export LANG=en_US.UTF-8
|
||||||
|
export LANGUAGE=en_US.UTF-8
|
||||||
|
|
||||||
|
# Check if Mycroft log folders are present and if not
|
||||||
|
# create those logging folders
|
||||||
|
if [[ ! -w /var/log/mycroft/ ]] ; then
|
||||||
|
# Creating needed folders
|
||||||
|
printf "Creating /var/log/mycroft/ directory"
|
||||||
|
if [[ ! -d /var/log/mycroft/ ]] ; then
|
||||||
|
mkdir /var/log/mycroft/
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
start
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: $0 {start}"
|
||||||
|
exit 1
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit $?
|
|
@ -0,0 +1,37 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Starts Mycroft services.
|
||||||
|
#
|
||||||
|
|
||||||
|
start() {
|
||||||
|
printf "Starting Mycroft services: "
|
||||||
|
umask 077
|
||||||
|
bash /usr/bin/start-mycroft.sh all
|
||||||
|
echo "OK"
|
||||||
|
}
|
||||||
|
stop() {
|
||||||
|
printf "Stopping Mycroft services: "
|
||||||
|
bash /usr/bin/stop-mycroft.sh all
|
||||||
|
echo "OK"
|
||||||
|
}
|
||||||
|
restart() {
|
||||||
|
stop
|
||||||
|
start
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
start
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
stop
|
||||||
|
;;
|
||||||
|
restart|reload)
|
||||||
|
restart
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: $0 {start|stop|restart}"
|
||||||
|
exit 1
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit $?
|
|
@ -0,0 +1,31 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
mount -t proc proc /proc
|
||||||
|
mount -t sysfs sys /sys
|
||||||
|
mount -t tmpfs tmp /run
|
||||||
|
|
||||||
|
mount /boot
|
||||||
|
mount / -o remount,rw
|
||||||
|
|
||||||
|
sed -i 's| init=/etc/init.d/init_resize.sh||' /boot/cmdline.txt
|
||||||
|
sync
|
||||||
|
|
||||||
|
DEVICE="/dev/mmcblk0"
|
||||||
|
PARTNR="p2"
|
||||||
|
|
||||||
|
CURRENTSIZEB=`fdisk -l $DEVICE$PARTNR | grep "Disk $DEVICE$PARTNR" | cut -d' ' -f5`
|
||||||
|
CURRENTSIZE=`expr $CURRENTSIZEB / 1024 / 1024`
|
||||||
|
MAXSIZEMB=`printf %s\\n 'unit MB print list' | parted | grep "Disk ${DEVICE}" | cut -d' ' -f3 | tr -d MB`
|
||||||
|
|
||||||
|
echo "[ok] applying resize operation.."
|
||||||
|
parted ${DEVICE} resizepart ${PARTNR} ${MAXSIZEMB}
|
||||||
|
echo "[done]"
|
||||||
|
|
||||||
|
partprobe $DEVICE
|
||||||
|
|
||||||
|
umount /boot
|
||||||
|
mount / -o remount,ro
|
||||||
|
sync
|
||||||
|
|
||||||
|
reboot
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"play_wav_cmdline": "aplay -Dhw:0,0 %1",
|
||||||
|
"play_mp3_cmdline": "mpg123 -a hw:0,0 %1",
|
||||||
|
"ipc_path": "/ramdisk/mycroft/ipc/",
|
||||||
|
"ignore_logs": ["enclosure.mouth.viseme", "enclosure.mouth.display"],
|
||||||
|
"log_level": "INFO"
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
#!/usr/bin/pulseaudio -nF
|
||||||
|
#
|
||||||
|
# This file is part of PulseAudio.
|
||||||
|
#
|
||||||
|
# PulseAudio is free software; you can redistribute it and/or modify it
|
||||||
|
# under the terms of the GNU Lesser General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# PulseAudio 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 Lesser General Public License
|
||||||
|
# along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# This startup script is used only if PulseAudio is started in system
|
||||||
|
# mode.
|
||||||
|
|
||||||
|
### Automatically load driver modules depending on the hardware available
|
||||||
|
.ifexists module-detect.so
|
||||||
|
### Use the static hardware detection module (for systems that lack udev/hal support)
|
||||||
|
load-module module-detect
|
||||||
|
.endif
|
||||||
|
|
||||||
|
### Load several protocols
|
||||||
|
.ifexists module-esound-protocol-unix.so
|
||||||
|
load-module module-esound-protocol-unix
|
||||||
|
.endif
|
||||||
|
load-module module-native-protocol-unix
|
||||||
|
|
||||||
|
### Automatically restore the volume of streams and devices
|
||||||
|
load-module module-stream-restore
|
||||||
|
load-module module-device-restore
|
||||||
|
|
||||||
|
### Automatically restore the default sink/source when changed by the user
|
||||||
|
### during runtime
|
||||||
|
### NOTE: This should be loaded as early as possible so that subsequent modules
|
||||||
|
### that look up the default sink/source get the right value
|
||||||
|
load-module module-default-device-restore
|
||||||
|
|
||||||
|
### Automatically move streams to the default sink if the sink they are
|
||||||
|
### connected to dies, similar for sources
|
||||||
|
load-module module-rescue-streams
|
||||||
|
|
||||||
|
### Make sure we always have a sink around, even if it is a null sink.
|
||||||
|
load-module module-always-sink
|
||||||
|
|
||||||
|
### Automatically suspend sinks/sources that become idle for too long
|
||||||
|
#load-module module-suspend-on-idle
|
||||||
|
|
||||||
|
### Enable positioned event sounds
|
||||||
|
load-module module-position-event-sounds
|
||||||
|
|
||||||
|
#allow localhost connections
|
||||||
|
load-module module-native-protocol-tcp auth-anonymous=true
|
|
@ -0,0 +1 @@
|
||||||
|
../.mycroft
|
|
@ -0,0 +1,161 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Copyright 2017 Mycroft AI Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
SOURCE="${BASH_SOURCE[0]}"
|
||||||
|
|
||||||
|
script=${0}
|
||||||
|
script=${script##*/}
|
||||||
|
cd -P "$( dirname "$SOURCE" )"
|
||||||
|
DIR="$( pwd )"
|
||||||
|
|
||||||
|
function help() {
|
||||||
|
echo "${script}: Mycroft command/service launcher"
|
||||||
|
echo "usage: ${script} [command] [params]"
|
||||||
|
echo
|
||||||
|
echo "Services:"
|
||||||
|
echo " all runs core services: bus, audio, skills, voice"
|
||||||
|
echo " debug runs core services, then starts the CLI"
|
||||||
|
echo
|
||||||
|
echo "Services:"
|
||||||
|
echo " audio the audio playback service"
|
||||||
|
echo " bus the messagebus service"
|
||||||
|
echo " skills the skill service"
|
||||||
|
echo " voice voice capture service"
|
||||||
|
echo " enclosure mark_1 enclosure service"
|
||||||
|
echo
|
||||||
|
echo "Tools:"
|
||||||
|
echo " cli the Command Line Interface"
|
||||||
|
echo " unittest run mycroft-core unit tests (requires pytest)"
|
||||||
|
echo " skillstest run the skill autotests for all skills (requires pytest)"
|
||||||
|
echo
|
||||||
|
echo "Utils:"
|
||||||
|
echo " audiotest attempt simple audio validation"
|
||||||
|
echo " audioaccuracytest more complex audio validation"
|
||||||
|
echo " sdkdoc generate sdk documentation"
|
||||||
|
echo
|
||||||
|
echo "Examples:"
|
||||||
|
echo " ${script} all"
|
||||||
|
echo " ${script} cli"
|
||||||
|
echo " ${script} unittest"
|
||||||
|
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
_module=""
|
||||||
|
function name-to-script-path() {
|
||||||
|
case ${1} in
|
||||||
|
"bus") _module="mycroft.messagebus.service" ;;
|
||||||
|
"skills") _module="mycroft.skills" ;;
|
||||||
|
"audio") _module="mycroft.audio" ;;
|
||||||
|
"voice") _module="mycroft.client.speech" ;;
|
||||||
|
"cli") _module="mycroft.client.text" ;;
|
||||||
|
"audiotest") _module="mycroft.util.audio_test" ;;
|
||||||
|
"audioaccuracytest") _module="mycroft.audio-accuracy-test" ;;
|
||||||
|
"enclosure") _module="mycroft.client.enclosure" ;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo "Error: Unknown name '${1}'"
|
||||||
|
exit 1
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
function launch-process() {
|
||||||
|
name-to-script-path ${1}
|
||||||
|
|
||||||
|
# Launch process in foreground
|
||||||
|
echo "Starting $1"
|
||||||
|
python3 -m ${_module} $_params
|
||||||
|
}
|
||||||
|
|
||||||
|
function launch-background() {
|
||||||
|
# Check if given module is running and start (or restart if running)
|
||||||
|
name-to-script-path ${1}
|
||||||
|
if pgrep -f "python3 -m ${_module}" > /dev/null ; then
|
||||||
|
echo "Restarting: ${1}"
|
||||||
|
"${DIR}/stop-mycroft.sh" ${1}
|
||||||
|
else
|
||||||
|
echo "Starting background service $1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Security warning/reminder for the user
|
||||||
|
if [[ "${1}" == "bus" ]] ; then
|
||||||
|
echo "CAUTION: The Mycroft bus is an open websocket with no built-in security"
|
||||||
|
echo " measures. You are responsible for protecting the local port"
|
||||||
|
echo " 8181 with a firewall as appropriate."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Launch process in background, sending logs to standard location
|
||||||
|
python3 -m ${_module} $_params >> /var/log/mycroft/${1}.log 2>&1 &
|
||||||
|
}
|
||||||
|
|
||||||
|
function launch-all() {
|
||||||
|
echo "Starting all mycroft-core services"
|
||||||
|
launch-background bus
|
||||||
|
launch-background skills
|
||||||
|
launch-background audio
|
||||||
|
launch-background voice
|
||||||
|
|
||||||
|
# Determine platform type
|
||||||
|
if [[ -r /etc/mycroft/mycroft.conf ]] ; then
|
||||||
|
mycroft_platform=$( jq -r ".enclosure.platform" < /etc/mycroft/mycroft.conf )
|
||||||
|
if [[ $mycroft_platform = "mycroft_mark_1" ]] ; then
|
||||||
|
# running on a Mark 1, start enclosure service
|
||||||
|
launch-background enclosure
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_opt=$1
|
||||||
|
shift
|
||||||
|
_params=$@
|
||||||
|
|
||||||
|
case ${_opt} in
|
||||||
|
"all")
|
||||||
|
launch-all
|
||||||
|
;;
|
||||||
|
"bus")
|
||||||
|
launch-background ${_opt}
|
||||||
|
;;
|
||||||
|
"audio")
|
||||||
|
launch-background ${_opt}
|
||||||
|
;;
|
||||||
|
"skills")
|
||||||
|
launch-background ${_opt}
|
||||||
|
;;
|
||||||
|
"voice")
|
||||||
|
launch-background ${_opt}
|
||||||
|
;;
|
||||||
|
"debug")
|
||||||
|
launch-all
|
||||||
|
launch-process cli
|
||||||
|
;;
|
||||||
|
"cli")
|
||||||
|
launch-process ${_opt}
|
||||||
|
;;
|
||||||
|
"audiotest")
|
||||||
|
launch-process ${_opt}
|
||||||
|
;;
|
||||||
|
"audioaccuracytest")
|
||||||
|
launch-process ${_opt}
|
||||||
|
;;
|
||||||
|
"enclosure")
|
||||||
|
launch-background ${_opt}
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
help
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
|
@ -0,0 +1,131 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Copyright 2017 Mycroft AI Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
SOURCE="${BASH_SOURCE[0]}"
|
||||||
|
|
||||||
|
script=${0}
|
||||||
|
script=${script##*/}
|
||||||
|
cd -P "$( dirname "$SOURCE" )"
|
||||||
|
|
||||||
|
function help() {
|
||||||
|
echo "${script}: Mycroft service stopper"
|
||||||
|
echo "usage: ${script} [service]"
|
||||||
|
echo
|
||||||
|
echo "Service:"
|
||||||
|
echo " all ends core services: bus, audio, skills, voice"
|
||||||
|
echo " (none) same as \"all\""
|
||||||
|
echo " bus stop the Mycroft messagebus service"
|
||||||
|
echo " audio stop the audio playback service"
|
||||||
|
echo " skills stop the skill service"
|
||||||
|
echo " voice stop voice capture service"
|
||||||
|
echo " enclosure stop mark_1 enclosure service"
|
||||||
|
echo
|
||||||
|
echo "Examples:"
|
||||||
|
echo " ${script}"
|
||||||
|
echo " ${script} audio"
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function process-running() {
|
||||||
|
if [[ $( pgrep -f "python3 -m mycroft.*${1}" ) ]] ; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function end-process() {
|
||||||
|
if process-running $1 ; then
|
||||||
|
echo -n "Stopping $1..."
|
||||||
|
pid=$( pgrep -f "python3 -m mycroft.*${1}" )
|
||||||
|
kill -SIGINT ${pid}
|
||||||
|
|
||||||
|
# Wait up to 5 seconds (50 * 0.1) for process to stop
|
||||||
|
c=1
|
||||||
|
while [ $c -le 50 ] ; do
|
||||||
|
if process-running $1 ; then
|
||||||
|
sleep 0.1
|
||||||
|
(( c++ ))
|
||||||
|
else
|
||||||
|
c=999 # end loop
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if process-running $1 ; then
|
||||||
|
echo "failed to stop."
|
||||||
|
echo -n " Killing $1..."
|
||||||
|
kill -9 ${pid}
|
||||||
|
echo "killed."
|
||||||
|
result=120
|
||||||
|
else
|
||||||
|
echo "stopped."
|
||||||
|
if [ $result -eq 0 ] ; then
|
||||||
|
result=100
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
result=0 # default, no change
|
||||||
|
|
||||||
|
OPT=$1
|
||||||
|
shift
|
||||||
|
|
||||||
|
case ${OPT} in
|
||||||
|
"all")
|
||||||
|
;&
|
||||||
|
"")
|
||||||
|
echo "Stopping all mycroft-core services"
|
||||||
|
end-process messagebus.service
|
||||||
|
end-process skills
|
||||||
|
end-process audio
|
||||||
|
end-process speech
|
||||||
|
|
||||||
|
# determine platform type
|
||||||
|
if [[ -r /etc/mycroft/mycroft.conf ]] ; then
|
||||||
|
mycroft_platform=$( jq -r ".enclosure.platform" < /etc/mycroft/mycroft.conf )
|
||||||
|
if [[ $mycroft_platform == "mycroft_mark_1" ]] ; then
|
||||||
|
# running on a Mark 1, stop enclosure service
|
||||||
|
end-process enclosure
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
"bus")
|
||||||
|
end-process messagebus.service
|
||||||
|
;;
|
||||||
|
"audio")
|
||||||
|
end-process audio
|
||||||
|
;;
|
||||||
|
"skills")
|
||||||
|
end-process skills
|
||||||
|
;;
|
||||||
|
"voice")
|
||||||
|
end-process speech
|
||||||
|
;;
|
||||||
|
"enclosure")
|
||||||
|
end-process enclosure
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
help
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Exit codes:
|
||||||
|
# 0 if nothing changed (e.g. --help or no process was running)
|
||||||
|
# 100 at least one process was stopped
|
||||||
|
# 120 if any process had to be killed
|
||||||
|
exit $result
|
Loading…
Reference in New Issue