ccmp15: connectcore demo: fix autostart of demo application on top of weston

This commit is similar to those required to launch crank applications on top of
weston in ConnectCore MP 15 platform, it must wait for the socket
'/run/user/0/wayland-1' after weston is initialized.

See commits 7de8270beda64236cdd1c46857906315a37dc4fe and
1ec5cc172c.

Signed-off-by: Tatiana Leon <Tatiana.Leon@digi.com>
This commit is contained in:
Tatiana Leon 2023-02-02 11:03:57 +01:00
parent b305808539
commit feea2179ad
3 changed files with 77 additions and 36 deletions

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
#=============================================================================== #===============================================================================
# #
# Copyright (C) 2022 by Digi International Inc. # Copyright (C) 2022, 2023 by Digi International Inc.
# All rights reserved. # All rights reserved.
# #
# This program is free software; you can redistribute it and/or modify it # This program is free software; you can redistribute it and/or modify it
@ -16,10 +16,26 @@
# Source function library # Source function library
. /etc/init.d/functions . /etc/init.d/functions
readonly DEMO_DISPLAY="##CC_DEMO_DISPLAY##"
readonly DEMO_ENV="##CC_DEMO_ENV##"
readonly COG_BINARY="/usr/bin/cog" readonly COG_BINARY="/usr/bin/cog"
readonly DEMOSERVER_BINARY="/srv/www/demoserver.py" readonly DEMOSERVER_BINARY="/srv/www/demoserver.py"
readonly STOP_TIMEOUT="5" readonly STOP_TIMEOUT="5"
wait_for_wayland() {
local count=20
local wayland_socket="/run/user/0/${DEMO_DISPLAY}"
while [ ! -S "${wayland_socket}" ]; do
sleep 1
count=$((count-1))
if [ "${count}" = 0 ]; then
return 1
fi
done
return 0
}
stop_process() { stop_process() {
# try to stop gracefully # try to stop gracefully
killproc "${1}" >/dev/null 2>&1 killproc "${1}" >/dev/null 2>&1
@ -32,35 +48,43 @@ stop_process() {
done done
} }
export_environment_variables() { stop() {
export DISPLAY=:0.0 stop_process "${COG_BINARY}"
export XDG_RUNTIME_DIR=/run/user/0 stop_process "${DEMOSERVER_BINARY}"
export WAYLAND_DISPLAY=wayland-0
export COG_PLATFORM_WL_VIEW_FULLSCREEN=1
# FULLSCREEN variable will have preference over other geometry variables.
if [ -f "/sys/class/graphics/fb0/virtual_size" ]; then
COG_PLATFORM_WL_VIEW_WIDTH="$(cut -d',' -f1 /sys/class/graphics/fb0/virtual_size)"
COG_PLATFORM_WL_VIEW_HEIGHT="$(cut -d',' -f2 /sys/class/graphics/fb0/virtual_size)"
[ -n "${COG_PLATFORM_WL_VIEW_WIDTH}" ] && export COG_PLATFORM_WL_VIEW_WIDTH
[ -n "${COG_PLATFORM_WL_VIEW_HEIGHT}" ] && export COG_PLATFORM_WL_VIEW_HEIGHT
fi
} }
case "$1" in start() {
start) local COG_ENV="${DEMO_ENV}"
${DEMOSERVER_BINARY} > /dev/null 2>&1 &
export_environment_variables ${DEMOSERVER_BINARY} > /dev/null 2>&1 &
${COG_BINARY} \
if [ -d "/usr/share/wayland" ]; then
wait_for_wayland
COG_ENV="${COG_ENV} COG_PLATFORM_WL_VIEW_FULLSCREEN=1"
# FULLSCREEN variable will have preference over other geometry variables.
if [ -f "/sys/class/graphics/fb0/virtual_size" ]; then
width="$(cut -d',' -f1 /sys/class/graphics/fb0/virtual_size)"
heigth="$(cut -d',' -f2 /sys/class/graphics/fb0/virtual_size)"
[ -n "${width}" ] && COG_ENV="${COG_ENV} COG_PLATFORM_WL_VIEW_WIDTH=${width}"
[ -n "${heigth}" ] && COG_ENV="${COG_ENV} COG_PLATFORM_WL_VIEW_HEIGHT=${heigth}"
fi
fi
env ${COG_ENV} ${COG_BINARY} \
--allow-file-access-from-file-urls=true \ --allow-file-access-from-file-urls=true \
--allow-universal-access-from-file-urls=false \ --allow-universal-access-from-file-urls=false \
--enable-offline-web-application-cache=false \ --enable-offline-web-application-cache=false \
--enable-page-cache=false \ --enable-page-cache=false \
--allow-modal-dialogs=true \ --allow-modal-dialogs=true \
/srv/www/index.html > /dev/null 2>&1 & /srv/www/index.html > /dev/null 2>&1 &
}
case "$1" in
start)
start
;; ;;
stop) stop)
stop_process "${COG_BINARY}" stop
stop_process "${DEMOSERVER_BINARY}"
;; ;;
restart) restart)
$0 stop $0 stop

View File

@ -1,7 +1,10 @@
[Unit] [Unit]
Description=Initialization of the ConnectCore demo example Description=Initialization of the ConnectCore demo example
After=weston.service busybox-httpd.service After=busybox-httpd.service
Requires=weston.service
# Make sure we are started after graphic service is available
After=##WESTON_SERVICE##
Requires=##WESTON_SERVICE##
[Service] [Service]
Type=forking Type=forking

View File

@ -1,4 +1,4 @@
# Copyright (C) 2022 Digi International. # Copyright (C) 2022, 2023 Digi International.
require dey-examples-src.inc require dey-examples-src.inc
@ -13,6 +13,14 @@ SRC_URI += " \
file://connectcore-demo-example.service \ file://connectcore-demo-example.service \
" "
WESTON_SERVICE ?= "weston.service"
WESTON_SERVICE:ccmp15 ?= "weston-launch.service"
CC_DEMO_DISPLAY ?= "wayland-0"
CC_DEMO_DISPLAY:ccmp15 ?= "wayland-1"
CC_DEMO_ENV ?= "DISPLAY=:0.0 XDG_RUNTIME_DIR=/run/user/0 WAYLAND_DISPLAY=\${DEMO_DISPLAY}"
CC_DEMO_ENV:ccimx6ul ?= ""
RDEPENDS:${PN} = " \ RDEPENDS:${PN} = " \
busybox-httpd \ busybox-httpd \
libdigiapix-python3 \ libdigiapix-python3 \
@ -30,22 +38,28 @@ S = "${WORKDIR}/connectcore-demo-example"
inherit systemd update-rc.d inherit systemd update-rc.d
do_install() { do_install() {
install -d ${D}/srv/www install -d ${D}/srv/www
cp -r ${WORKDIR}/git/connectcore-demo-example/* ${D}/srv/www/ cp -r ${WORKDIR}/git/connectcore-demo-example/* ${D}/srv/www/
# Remove unused images # Remove unused images
find ${D}/srv/www/static/images/ -type f -name '*_board.png' -not -name '${MACHINE}_board.png' -delete find ${D}/srv/www/static/images/ -type f -name '*_board.png' -not -name '${MACHINE}_board.png' -delete
if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then # Install systemd service
# Install systemd unit files if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
install -d ${D}${systemd_unitdir}/system # Install systemd unit files
install -m 0644 ${WORKDIR}/connectcore-demo-example.service ${D}${systemd_unitdir}/system/ install -d ${D}${systemd_unitdir}/system
fi install -m 0644 ${WORKDIR}/connectcore-demo-example.service ${D}${systemd_unitdir}/system/
sed -i -e "s,##WESTON_SERVICE##,${WESTON_SERVICE},g" \
"${D}${systemd_unitdir}/system/connectcore-demo-example.service"
fi
# connectcore-demo-example-init # Install connectcore-demo-example-init
install -d ${D}${sysconfdir}/init.d/ install -d ${D}${sysconfdir}/init.d/
install -m 755 ${WORKDIR}/connectcore-demo-example-init ${D}${sysconfdir}/connectcore-demo-example install -m 755 ${WORKDIR}/connectcore-demo-example-init ${D}${sysconfdir}/connectcore-demo-example
ln -sf /etc/connectcore-demo-example ${D}${sysconfdir}/init.d/connectcore-demo-example sed -i -e "s@##CC_DEMO_ENV##@${CC_DEMO_ENV}@g" \
-e "s@##CC_DEMO_DISPLAY##@${CC_DEMO_DISPLAY}@g" \
"${D}${sysconfdir}/connectcore-demo-example"
ln -sf ${sysconfdir}/connectcore-demo-example ${D}${sysconfdir}/init.d/connectcore-demo-example
} }
FILES:${PN} += " \ FILES:${PN} += " \