From: Tadao Tanikawa Date: Tue, 20 Dec 2016 12:34:46 +0000 (+0900) Subject: Support systemd services of MOST for CES2017 Demo X-Git-Tag: 3.0.0~34 X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?p=AGL%2Fmeta-agl-demo.git;a=commitdiff_plain;h=af4a22aeda5e5dfede3dd3f1a65165ccb5632ce0 Support systemd services of MOST for CES2017 Demo This change is for booting all stuff for MOST automatically after WindowManager launched. All services except insmod are in systemd user mode. Change-Id: I15043493c797511275e4f02173a85f06a7298ca0 Signed-off-by: Tadao Tanikawa --- diff --git a/recipes-demo-hmi/unicens/files/0001-Support-booting-by-systemd.patch b/recipes-demo-hmi/unicens/files/0001-Support-booting-by-systemd.patch new file mode 100644 index 000000000..5c18aacdc --- /dev/null +++ b/recipes-demo-hmi/unicens/files/0001-Support-booting-by-systemd.patch @@ -0,0 +1,147 @@ +From 7942933a4f1508966375326c4ee230812f504f4b Mon Sep 17 00:00:00 2001 +From: Tadao Tanikawa +Date: Tue, 20 Dec 2016 19:04:48 +0900 +Subject: [PATCH] Support booting by systemd + +Hack for CES2017 demo integration. + +Loading modules would be done by systemd, so loadDriver.sh +could skip all insmod. + +Change-Id: I1d0d6db6faad789754707ffff127099f70150b1f +Signed-off-by: Tadao Tanikawa +--- + scripts/loadDriver.sh | 95 +++++++++++++++++++++++++++++---------------------- + 1 file changed, 55 insertions(+), 40 deletions(-) + +diff --git a/scripts/loadDriver.sh b/scripts/loadDriver.sh +index f55fdde..a3979cc 100755 +--- a/scripts/loadDriver.sh ++++ b/scripts/loadDriver.sh +@@ -1,4 +1,7 @@ + #!/bin/bash ++# ++# Usage: loadDriver.sh [--systemd] ++# + + if [ ! "$(whoami)" = "root" ] + then +@@ -13,63 +16,75 @@ else + echo Searching driver in folder:$(pwd) + fi + +-#unload MOST Kernel modules +-lsmod | grep "^mxc_mlb\>" > /dev/null && +- rmmod mxc_mlb && echo "unloaded mxc_mlb" ++load_modules() ++{ ++ #unload MOST Kernel modules ++ lsmod | grep "^mxc_mlb\>" > /dev/null && ++ rmmod mxc_mlb && echo "unloaded mxc_mlb" ++ ++ lsmod | grep "^hdm_dim2_mx6q\>" > /dev/null && ++ rmmod hdm_dim2_mx6q && echo "unloaded hdm_dim2_mx6q" + +-lsmod | grep "^hdm_dim2_mx6q\>" > /dev/null && +- rmmod hdm_dim2_mx6q && echo "unloaded hdm_dim2_mx6q" ++ lsmod | grep "^hdm_dim2\>" > /dev/null && ++ rmmod hdm_dim2 && echo "unloaded hdm_dim2" + +-lsmod | grep "^hdm_dim2\>" > /dev/null && +- rmmod hdm_dim2 && echo "unloaded hdm_dim2" ++ lsmod | grep "^hdm_usb\>" > /dev/null && ++ rmmod hdm_usb && echo "unloaded hdm_usb" + +-lsmod | grep "^hdm_usb\>" > /dev/null && +- rmmod hdm_usb && echo "unloaded hdm_usb" ++ lsmod | grep "^aim_sound\>" > /dev/null && ++ rmmod aim_sound && echo "unloaded aim_sound" + +-lsmod | grep "^aim_sound\>" > /dev/null && +- rmmod aim_sound && echo "unloaded aim_sound" ++ lsmod | grep "^aim_v4l2\>" > /dev/null && ++ rmmod aim_v4l2 && echo "unloaded aim_v4l2" + +-lsmod | grep "^aim_v4l2\>" > /dev/null && +- rmmod aim_v4l2 && echo "unloaded aim_v4l2" ++ lsmod | grep "^aim_cdev\>" > /dev/null && ++ rmmod aim_cdev && echo "unloaded aim_cdev" + +-lsmod | grep "^aim_cdev\>" > /dev/null && +- rmmod aim_cdev && echo "unloaded aim_cdev" ++ lsmod | grep "^aim_network\>" > /dev/null && ++ rmmod aim_network && echo "unloaded aim_network" + +-lsmod | grep "^aim_network\>" > /dev/null && +- rmmod aim_network && echo "unloaded aim_network" ++ lsmod | grep "^mostcore\>" > /dev/null && ++ rmmod mostcore && echo "unloaded mostcore" + +-lsmod | grep "^mostcore\>" > /dev/null && +- rmmod mostcore && echo "unloaded mostcore" ++ echo ++ #load V4L support ++ lsmod | grep "^media\>" || ++ insmod /lib/modules/$(uname -r)/kernel/drivers/media/media.ko + +-echo +-#load V4L support +-lsmod | grep "^media\>" || +- insmod /lib/modules/$(uname -r)/kernel/drivers/media/media.ko ++ lsmod | grep "^videodev\>" || ++ insmod /lib/modules/$(uname -r)/kernel/drivers/media/v4l2-core/videodev.ko + +-lsmod | grep "^videodev\>" || +- insmod /lib/modules/$(uname -r)/kernel/drivers/media/v4l2-core/videodev.ko ++ #load MOST Kernel modules ++ insmod mostcore.ko && echo "loaded mostcore" ++ insmod aim_cdev.ko && echo "loaded aim_cdev" + +-#load MOST Kernel modules +-insmod mostcore.ko && echo "loaded mostcore" +-insmod aim_cdev.ko && echo "loaded aim_cdev" ++ [ -e aim_network.ko ] && ++ insmod aim_network.ko && echo "loaded aim_network" + +-[ -e aim_network.ko ] && +- insmod aim_network.ko && echo "loaded aim_network" ++ [ -e aim_sound.ko ] && ++ insmod aim_sound.ko && echo "loaded sound" + +-[ -e aim_sound.ko ] && +- insmod aim_sound.ko && echo "loaded sound" ++ [ -e aim_v4l2.ko ] && ++ insmod aim_v4l2.ko && echo "loaded v4l2" + +-[ -e aim_v4l2.ko ] && +- insmod aim_v4l2.ko && echo "loaded v4l2" ++ [ -e hdm_usb.ko ] && ++ insmod hdm_usb.ko && echo "loaded hdm_usb" + +-[ -e hdm_usb.ko ] && +- insmod hdm_usb.ko && echo "loaded hdm_usb" ++ [ -e hdm_dim2.ko ] && ++ insmod hdm_dim2.ko clock_speed=4096fs fcnt=3 && echo "loaded hdm_dim2" + +-[ -e hdm_dim2.ko ] && +- insmod hdm_dim2.ko clock_speed=4096fs fcnt=3 && echo "loaded hdm_dim2" ++ [ -e hdm_dim2_mx6q.ko ] && ++ insmod hdm_dim2_mx6q.ko && echo "loaded hdm_dim2_mx6q" ++} + +-[ -e hdm_dim2_mx6q.ko ] && +- insmod hdm_dim2_mx6q.ko && echo "loaded hdm_dim2_mx6q" ++# ++# Systemd load modules when booting system already. ++# If argv[1] == "--systemd" then skip load modules ++# ++if [ "$1" != "--systemd" ]; then ++ echo "Load modules" ++ load_modules ++fi + + DEVS=/sys/devices/virtual/most/mostcore/devices + AIMS=/sys/devices/virtual/most/mostcore/aims +-- +2.7.4 + diff --git a/recipes-demo-hmi/unicens/files/most-network-manager.service b/recipes-demo-hmi/unicens/files/most-network-manager.service new file mode 100644 index 000000000..61e17b2d4 --- /dev/null +++ b/recipes-demo-hmi/unicens/files/most-network-manager.service @@ -0,0 +1,11 @@ +[Unit] +Description=Most Network Manager Service +After=WindowManager.service most-network-startup.service + +[Service] +Type=simple +ExecStart=/usr/AGL/most/MostNetworkManager -i /usr/AGL/most/config-agl.xml +Restart=always + +[Install] +WantedBy=default.target diff --git a/recipes-demo-hmi/unicens/files/most-network-startup.service b/recipes-demo-hmi/unicens/files/most-network-startup.service new file mode 100644 index 000000000..4fd037531 --- /dev/null +++ b/recipes-demo-hmi/unicens/files/most-network-startup.service @@ -0,0 +1,12 @@ +[Unit] +Description=Most Network Startup Service +After=WindowManager.service + +[Service] +Type=simple +RemainAfterExit=yes +ExecStart=/usr/AGL/most/loadDriver.sh --systemd +Restart=always + +[Install] +WantedBy=default.target diff --git a/recipes-demo-hmi/unicens/unicens_0.1.bb b/recipes-demo-hmi/unicens/unicens_0.1.bb index 176baa402..0fc0afc93 100644 --- a/recipes-demo-hmi/unicens/unicens_0.1.bb +++ b/recipes-demo-hmi/unicens/unicens_0.1.bb @@ -10,18 +10,40 @@ DEPENDS += "libxml2" SRC_URI = "git://gerrit.automotivelinux.org/gerrit/src/unicens;protocol=https" SRC_URI += "file://0001-Fix-cross-compilation-with-yocto.patch" +SRC_URI += "file://0001-Support-booting-by-systemd.patch \ + file://most-network-startup.service \ + file://most-network-manager.service" S = "${WORKDIR}/git" #SRCREV = "8c5f2324d7aa61669324aec1a0ad091fe1379489" SRCREV = "${AUTOREV}" do_install() { - install -m 0755 -d ${D}${bindir} ${D}/home/root - install -m 0755 ${S}/NetworkManager ${D}${bindir}/MostNetworkManager - install -m 0644 ${S}/scripts/config-agl.xml ${D}/home/root - install -m 0644 ${S}/scripts/camera-os88122-ts.script ${D}/home/root - install -m 0644 ${S}/scripts/i2c-slim-amplifier-v2.3.script ${D}/home/root - install -m 0644 ${S}/scripts/i2c-uda1388-v2.3.script ${D}/home/root - install -m 0755 ${S}/scripts/loadDriver.sh ${D}/home/root + install -m 0755 -d ${D}/usr/AGL/most + install -m 0755 ${S}/NetworkManager ${D}/usr/AGL/most/MostNetworkManager + install -m 0644 ${S}/scripts/config-agl.xml ${D}/usr/AGL/most/ + install -m 0644 ${S}/scripts/camera-os88122-ts.script ${D}/usr/AGL/most/ + install -m 0644 ${S}/scripts/i2c-slim-amplifier-v2.3.script ${D}/usr/AGL/most/ + install -m 0644 ${S}/scripts/i2c-uda1388-v2.3.script ${D}/usr/AGL/most + install -m 0755 ${S}/scripts/loadDriver.sh ${D}/usr/AGL/most + + # Install MOST network startup systemd service (user) + if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then + install -m 644 -p -D ${WORKDIR}/most-network-startup.service ${D}${systemd_user_unitdir}/most-network-startup.service + install -m 644 -p -D ${WORKDIR}/most-network-manager.service ${D}${systemd_user_unitdir}/most-network-manager.service + + # Execute install manually for root user on behalf of systemctl script + # because it doesn't support user mode of systemd. + install -m 0755 -d ${D}/home/root/.config/systemd/user/default.target.wants/ + ln -sf ${systemd_user_unitdir}/most-network-startup.service ${D}/home/root/.config/systemd/user/default.target.wants/most-network-startup.service + ln -sf ${systemd_user_unitdir}/most-network-manager.service ${D}/home/root/.config/systemd/user/default.target.wants/most-network-manager.service + fi } -FILES_${PN} += "/home/root*" + +FILES_${PN} += " \ + /usr/AGL/most \ + ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', '${systemd_user_unitdir}/most-network-startup.service', '', d)} \ + ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', '${systemd_user_unitdir}/most-network-manager.service', '', d)} \ + ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', '/home/root/.config/systemd/user/default.target.wants/most-network-startup.service', '', d)} \ + ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', '/home/root/.config/systemd/user/default.target.wants/most-network-manager.service', '', d)} \ + " diff --git a/recipes-kernel/aim-cdev/aim-cdev.bb b/recipes-kernel/aim-cdev/aim-cdev.bb index b51fe2362..b43800ecf 100644 --- a/recipes-kernel/aim-cdev/aim-cdev.bb +++ b/recipes-kernel/aim-cdev/aim-cdev.bb @@ -16,3 +16,11 @@ SRCREV = "ad245bdd60434dd46d6461f585d49db1b3b0d75b" # The inherit of module.bbclass will automatically name module packages with # "kernel-module-" prefix as required by the oe-core build environment. + +do_install_append () { + # modprobe automatically at boot + if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then + install -d ${D}${sysconfdir}/modules-load.d + echo "aim_cdev" > ${D}${sysconfdir}/modules-load.d/aim_cdev.conf + fi +} diff --git a/recipes-kernel/aim-network/aim-network.bb b/recipes-kernel/aim-network/aim-network.bb index b51fe2362..ce3d76773 100644 --- a/recipes-kernel/aim-network/aim-network.bb +++ b/recipes-kernel/aim-network/aim-network.bb @@ -16,3 +16,11 @@ SRCREV = "ad245bdd60434dd46d6461f585d49db1b3b0d75b" # The inherit of module.bbclass will automatically name module packages with # "kernel-module-" prefix as required by the oe-core build environment. + +do_install_append () { + # modprobe automatically at boot + if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then + install -d ${D}${sysconfdir}/modules-load.d + echo "aim_network" > ${D}${sysconfdir}/modules-load.d/aim_network.conf + fi +} diff --git a/recipes-kernel/aim-sound/aim-sound.bb b/recipes-kernel/aim-sound/aim-sound.bb index b51fe2362..02d790770 100644 --- a/recipes-kernel/aim-sound/aim-sound.bb +++ b/recipes-kernel/aim-sound/aim-sound.bb @@ -16,3 +16,11 @@ SRCREV = "ad245bdd60434dd46d6461f585d49db1b3b0d75b" # The inherit of module.bbclass will automatically name module packages with # "kernel-module-" prefix as required by the oe-core build environment. + +do_install_append () { + # modprobe automatically at boot + if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then + install -d ${D}${sysconfdir}/modules-load.d + echo "aim_sound" > ${D}${sysconfdir}/modules-load.d/aim_sound.conf + fi +} diff --git a/recipes-kernel/aim-v4l2/aim-v4l2.bb b/recipes-kernel/aim-v4l2/aim-v4l2.bb index b51fe2362..123369601 100644 --- a/recipes-kernel/aim-v4l2/aim-v4l2.bb +++ b/recipes-kernel/aim-v4l2/aim-v4l2.bb @@ -16,3 +16,11 @@ SRCREV = "ad245bdd60434dd46d6461f585d49db1b3b0d75b" # The inherit of module.bbclass will automatically name module packages with # "kernel-module-" prefix as required by the oe-core build environment. + +do_install_append () { + # modprobe automatically at boot + if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then + install -d ${D}${sysconfdir}/modules-load.d + echo "aim_v4l2" > ${D}${sysconfdir}/modules-load.d/aim_v4l2.conf + fi +} diff --git a/recipes-kernel/hdm-dim2/hdm-dim2.bb b/recipes-kernel/hdm-dim2/hdm-dim2.bb index b51fe2362..d9cdf4d8c 100644 --- a/recipes-kernel/hdm-dim2/hdm-dim2.bb +++ b/recipes-kernel/hdm-dim2/hdm-dim2.bb @@ -16,3 +16,11 @@ SRCREV = "ad245bdd60434dd46d6461f585d49db1b3b0d75b" # The inherit of module.bbclass will automatically name module packages with # "kernel-module-" prefix as required by the oe-core build environment. + +do_install_append () { + # modprobe automatically at boot + if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then + install -d ${D}${sysconfdir}/modules-load.d + echo "hdm_dim2" > ${D}${sysconfdir}/modules-load.d/hdm_dim2.conf + fi +} diff --git a/recipes-kernel/hdm-i2c/hdm-i2c.bb b/recipes-kernel/hdm-i2c/hdm-i2c.bb index b51fe2362..6e51106b2 100644 --- a/recipes-kernel/hdm-i2c/hdm-i2c.bb +++ b/recipes-kernel/hdm-i2c/hdm-i2c.bb @@ -16,3 +16,11 @@ SRCREV = "ad245bdd60434dd46d6461f585d49db1b3b0d75b" # The inherit of module.bbclass will automatically name module packages with # "kernel-module-" prefix as required by the oe-core build environment. + +do_install_append () { + # modprobe automatically at boot + if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then + install -d ${D}${sysconfdir}/modules-load.d + echo "hdm_i2c" > ${D}${sysconfdir}/modules-load.d/hdm_i2c.conf + fi +} diff --git a/recipes-kernel/hdm-usb/hdm-usb.bb b/recipes-kernel/hdm-usb/hdm-usb.bb index b51fe2362..d8724d4f9 100644 --- a/recipes-kernel/hdm-usb/hdm-usb.bb +++ b/recipes-kernel/hdm-usb/hdm-usb.bb @@ -16,3 +16,11 @@ SRCREV = "ad245bdd60434dd46d6461f585d49db1b3b0d75b" # The inherit of module.bbclass will automatically name module packages with # "kernel-module-" prefix as required by the oe-core build environment. + +do_install_append () { + # modprobe automatically at boot + if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then + install -d ${D}${sysconfdir}/modules-load.d + echo "hdm_usb" > ${D}${sysconfdir}/modules-load.d/hdm_usb.conf + fi +} diff --git a/recipes-kernel/mocca-usb/mocca-usb.bb b/recipes-kernel/mocca-usb/mocca-usb.bb index 6f4e5861c..034585f14 100644 --- a/recipes-kernel/mocca-usb/mocca-usb.bb +++ b/recipes-kernel/mocca-usb/mocca-usb.bb @@ -12,3 +12,11 @@ SRCREV = "02ba272c0eb51b06160307b6cb71f91684772c8c" # The inherit of module.bbclass will automatically name module packages with # "kernel-module-" prefix as required by the oe-core build environment. + +do_install_append () { + # modprobe automatically at boot + if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then + install -d ${D}${sysconfdir}/modules-load.d + echo "mocca_usb" > ${D}${sysconfdir}/modules-load.d/mocca_usb.conf + fi +} diff --git a/recipes-kernel/mostcore/mostcore.bb b/recipes-kernel/mostcore/mostcore.bb index 3a2e1cfe7..f170c58db 100644 --- a/recipes-kernel/mostcore/mostcore.bb +++ b/recipes-kernel/mostcore/mostcore.bb @@ -16,3 +16,11 @@ SRCREV = "7850efa9077fa84536e0442c65d39a36e25e39d1" # The inherit of module.bbclass will automatically name module packages with # "kernel-module-" prefix as required by the oe-core build environment. + +do_install_append () { + # modprobe automatically at boot + if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then + install -d ${D}${sysconfdir}/modules-load.d + echo "mostcore" > ${D}${sysconfdir}/modules-load.d/mostcore.conf + fi +}