diff options
Diffstat (limited to 'meta-google')
76 files changed, 1118 insertions, 153 deletions
diff --git a/meta-google/MAINTAINERS b/meta-google/MAINTAINERS index 7b9b8f033..52bbc037e 100644 --- a/meta-google/MAINTAINERS +++ b/meta-google/MAINTAINERS @@ -47,3 +47,6 @@ M: William Kennington <wak@google.com> <wak-work!> M: Benjamin Fair <benjaminfair@google.com> <benjaminfair!> M: Ed Tanous <edtanous@google.com> <edtanous!> M: Brandon Kim <brandonkim@google.com> <brandonk!> +M: Willy Tu <wltu@google.com> <wltu!> +M: Zhenfei Tai <ztai@google.com> <ztai!> +M: Nan Zhou <nanzhoumails@gmail.com> <fighternan!> diff --git a/meta-google/OWNERS b/meta-google/OWNERS index 6608f2e5b..44cdb497d 100644 --- a/meta-google/OWNERS +++ b/meta-google/OWNERS @@ -4,3 +4,6 @@ owners: - benjaminfair@google.com - edtanous@google.com - brandonkim@google.com +- wltu@google.com +- ztai@google.com +- nanzhoumails@gmail.com diff --git a/meta-google/classes/image_types_hoth.bbclass b/meta-google/classes/image_types_hoth.bbclass new file mode 100644 index 000000000..0db4183a1 --- /dev/null +++ b/meta-google/classes/image_types_hoth.bbclass @@ -0,0 +1,150 @@ +# The offsets of the partitions that change when Hoth is enabled +# From the device tree, in kB +FLASH_IMAGE_DESC_OFFSET:npcm7xx:hoth = "${@960 if FLASH_SIZE == '65536' else 7232}" +FLASH_HOTH_UPDATE_OFFSET:npcm7xx:hoth = "${@1024 if FLASH_SIZE == '65536' else 31744}" +FLASH_HOTH_MAILBOX_OFFSET:npcm7xx:hoth = "${@65472 if FLASH_SIZE == '65536' else 7168}" +unset FLASH_UBOOT_ENV_OFFSET + +python do_generate_static:append() { + _append_image(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), + 'image-hoth-update'), + int(d.getVar('FLASH_HOTH_UPDATE_OFFSET', True)), + int(d.getVar('FLASH_SIZE', True))) +} +do_generate_static[depends] += "virtual/hoth-firmware:do_deploy" + +python do_generate_layout () { + import time + import json + + def convertPart(name, startKb, endKb, static=False, wp=False, persist=False): + regionTypes = [] + extraAttrs = {} + if static: + regionTypes.append('STATIC') + if wp: + regionTypes.append('WRITE_PROTECTED') + if persist: + regionTypes.append('PERSISTENT') + if name == 'hoth_mailbox': + regionTypes.append('MAILBOX') + extraAttrs['mailbox_length'] = 1024 + + start = int(startKb) * 1024 + end = int(endKb) * 1024 + + return { + 'name': name, + 'offset': start, + 'length': end - start, + 'region_type': regionTypes, + **extraAttrs, + } + + # TODO: make this work for Aspeed too + region = [ + convertPart( + 'u_boot', + d.getVar('FLASH_UBOOT_OFFSET'), + d.getVar('FLASH_IMAGE_DESC_OFFSET'), + static=True, + wp=True), + convertPart( + 'image_descriptor', + d.getVar('FLASH_IMAGE_DESC_OFFSET'), + d.getVar('FLASH_HOTH_UPDATE_OFFSET'), + static=True, + wp=True), + convertPart( + 'hoth_update', + d.getVar('FLASH_HOTH_UPDATE_OFFSET'), + d.getVar('FLASH_KERNEL_OFFSET')), + convertPart( + 'kernel', + d.getVar('FLASH_KERNEL_OFFSET'), + d.getVar('FLASH_ROFS_OFFSET'), + static=True, + wp=True), + convertPart( + 'rofs', + d.getVar('FLASH_ROFS_OFFSET'), + d.getVar('FLASH_RWFS_OFFSET'), + static=True, + wp=True), + convertPart( + 'rwfs', + d.getVar('FLASH_RWFS_OFFSET'), + d.getVar('FLASH_HOTH_MAILBOX_OFFSET'), + persist=True), + convertPart( + 'hoth_mailbox', + d.getVar('FLASH_HOTH_MAILBOX_OFFSET'), + d.getVar('FLASH_SIZE')), + ] if d.getVar('FLASH_SIZE') == '65536' else [ + convertPart( + 'u_boot', + d.getVar('FLASH_UBOOT_OFFSET'), + d.getVar('FLASH_KERNEL_OFFSET'), + static=True, + wp=True), + convertPart( + 'kernel', + d.getVar('FLASH_KERNEL_OFFSET'), + d.getVar('FLASH_HOTH_MAILBOX_OFFSET'), + static=True, + wp=True), + convertPart( + 'hoth_mailbox', + d.getVar('FLASH_HOTH_MAILBOX_OFFSET'), + d.getVar('FLASH_IMAGE_DESC_OFFSET')), + convertPart( + 'image_descriptor', + d.getVar('FLASH_IMAGE_DESC_OFFSET'), + d.getVar('FLASH_ROFS_OFFSET'), + static=True, + wp=True), + convertPart( + 'rofs', + d.getVar('FLASH_ROFS_OFFSET'), + d.getVar('FLASH_RWFS_OFFSET'), + static=True, + wp=True), + convertPart( + 'rwfs', + d.getVar('FLASH_RWFS_OFFSET'), + d.getVar('FLASH_HOTH_UPDATE_OFFSET'), + persist=True), + convertPart( + 'hoth_update', + d.getVar('FLASH_HOTH_UPDATE_OFFSET'), + d.getVar('FLASH_SIZE')), + ] + + machine = d.getVar('MACHINE') + platform = d.getVar('PLATFORM') + name = '{} {} image'.format(machine, d.getVar('DISTRO')) + version = d.getVar('GBMC_VERSION').split('.') + + if not platform: + raise NameError('PLATFORM not found, unable to generate layout, stopping build') + + layout = { + 'name': name, + 'major': int(version[0]), + 'minor': int(version[1]), + 'point': int(version[2]), + 'subpoint': int(version[3]), + 'platform': platform, + 'flash_capacity': int(d.getVar('FLASH_SIZE')) * 1024, + 'build_timestamp': int(time.time()), + 'region': region, + } + + dir = d.getVar('DEPLOY_DIR_IMAGE') + os.makedirs(dir, exist_ok=True) + path = os.path.join(dir, 'cr51-image-layout.json') + with open(path, 'w') as f: + json.dump(layout, f, sort_keys=True, indent=4) +} + +addtask generate_layout before do_image_complete diff --git a/meta-google/conf/distro/gbmc.conf b/meta-google/conf/distro/gbmc.conf index 0aca6318c..bbba7efed 100644 --- a/meta-google/conf/distro/gbmc.conf +++ b/meta-google/conf/distro/gbmc.conf @@ -7,14 +7,21 @@ DISTRO_NAME = "gBMC (OpenBMC + Google customizations)" DISTRO_VERSION = "gbmc-release-${GBMC_VERSION}" DISTROOVERRIDES .= ":gbmc" -DISTRO_FEATURES_remove = "ldap" -DISTRO_FEATURES_remove = "slp" +# Possible values: "dev", "prod" +GBMC_CONFIG ?= "dev" +OVERRIDES .= ":${GBMC_CONFIG}:" + +DISTRO_FEATURES:remove = "ldap" +DISTRO_FEATURES:remove = "slp" # Required to get entity-manager to build with FruDevice service -DISTRO_FEATURES_append = " ipmi-fru" +DISTRO_FEATURES:append = " ipmi-fru" + +# Disable u-boot shell for prod builds +DISTRO_FEATURES:append:prod = " disable-u-boot-shell" WATCHDOG_PKG ?= "watchdog" -SANITY_TESTED_DISTROS_append = " Debian-rodete \n debian-rodete \n " +SANITY_TESTED_DISTROS:append = " Debian-rodete \n debian-rodete \n " PREFERRED_PROVIDER_virtual/bmc-update ?= "inplace-gbmc-update" diff --git a/meta-google/conf/layer.conf b/meta-google/conf/layer.conf index ed605d1e6..47379e427 100644 --- a/meta-google/conf/layer.conf +++ b/meta-google/conf/layer.conf @@ -14,4 +14,4 @@ BBFILES_DYNAMIC += " \ BBFILE_COLLECTIONS += "google-layer" BBFILE_PATTERN_google-layer := "^${LAYERDIR}/" LAYERVERSION_google-layer = "1" -LAYERSERIES_COMPAT_google-layer = "gatesgarth hardknott" +LAYERSERIES_COMPAT_google-layer = "hardknott honister" diff --git a/meta-google/dynamic-layers/aspeed-layer/recipes-kernel/linux/linux-aspeed_%.bbappend b/meta-google/dynamic-layers/aspeed-layer/recipes-kernel/linux/linux-aspeed_%.bbappend index 1f704ca9b..cf7dd2465 100644 --- a/meta-google/dynamic-layers/aspeed-layer/recipes-kernel/linux/linux-aspeed_%.bbappend +++ b/meta-google/dynamic-layers/aspeed-layer/recipes-kernel/linux/linux-aspeed_%.bbappend @@ -1,4 +1,4 @@ -FILESEXTRAPATHS_prepend := "${THISDIR}/../../../../recipes-kernel/linux/files:" -SRC_URI_append_gbmc = " file://gbmc.cfg" -SRC_URI_append_gbmc_dev = " file://gbmc-dev.cfg" -SRC_URI_append_gbmc_prod = " file://gbmc-prod.cfg" +FILESEXTRAPATHS:prepend := "${THISDIR}/../../../../recipes-kernel/linux/files:" +SRC_URI:append:gbmc = " file://gbmc.cfg" +SRC_URI:append:gbmc:dev = " file://gbmc-dev.cfg" +SRC_URI:append:gbmc:prod = " file://gbmc-prod.cfg" diff --git a/meta-google/dynamic-layers/nuvoton-layer/recipes-bsp/images/npcm7xx-igps-native_%.bbappend b/meta-google/dynamic-layers/nuvoton-layer/recipes-bsp/images/npcm7xx-igps-native_%.bbappend index 890ebbb64..9eaffbf75 100644 --- a/meta-google/dynamic-layers/nuvoton-layer/recipes-bsp/images/npcm7xx-igps-native_%.bbappend +++ b/meta-google/dynamic-layers/nuvoton-layer/recipes-bsp/images/npcm7xx-igps-native_%.bbappend @@ -1,3 +1,3 @@ -FILESEXTRAPATHS_prepend_gbmc_hoth := "${THISDIR}/${BPN}:" +FILESEXTRAPATHS:prepend:gbmc:hoth := "${THISDIR}/${BPN}:" -SRC_URI_append_gbmc_hoth = " file://0001-Set-FIU0_DRD_CFG-and-FIU_Clk_divider-for-gbmc-hoth.patch" +SRC_URI:append:gbmc:hoth = " file://0001-Set-FIU0_DRD_CFG-and-FIU_Clk_divider-for-gbmc-hoth.patch" diff --git a/meta-google/dynamic-layers/nuvoton-layer/recipes-kernel/linux/linux-nuvoton_%.bbappend b/meta-google/dynamic-layers/nuvoton-layer/recipes-kernel/linux/linux-nuvoton_%.bbappend index 8de09b103..4cae4ba55 100644 --- a/meta-google/dynamic-layers/nuvoton-layer/recipes-kernel/linux/linux-nuvoton_%.bbappend +++ b/meta-google/dynamic-layers/nuvoton-layer/recipes-kernel/linux/linux-nuvoton_%.bbappend @@ -1,5 +1,5 @@ -FILESEXTRAPATHS_prepend := "${THISDIR}/files:${THISDIR}/../../../../recipes-kernel/linux/files:" -SRC_URI_append_gbmc = " file://gbmc.cfg" -SRC_URI_append_gbmc = " file://gbmc-nuvoton.cfg" -SRC_URI_append_gbmc_dev = " file://gbmc-dev.cfg" -SRC_URI_append_gbmc_prod = " file://gbmc-prod.cfg" +FILESEXTRAPATHS:prepend := "${THISDIR}/files:${THISDIR}/../../../../recipes-kernel/linux/files:" +SRC_URI:append:gbmc = " file://gbmc.cfg" +SRC_URI:append:gbmc = " file://gbmc-nuvoton.cfg" +SRC_URI:append:gbmc:dev = " file://gbmc-dev.cfg" +SRC_URI:append:gbmc:prod = " file://gbmc-prod.cfg" diff --git a/meta-google/recipes-connectivity/avahi/avahi_%.bbappend b/meta-google/recipes-connectivity/avahi/avahi_%.bbappend index 8fb53d3f5..bdf56904e 100644 --- a/meta-google/recipes-connectivity/avahi/avahi_%.bbappend +++ b/meta-google/recipes-connectivity/avahi/avahi_%.bbappend @@ -1,5 +1,5 @@ -FILESEXTRAPATHS_prepend_gbmc := "${THISDIR}/files:" -SRC_URI_append_gbmc = " file://avahi-daemon.conf" -do_install_append_gbmc() { +FILESEXTRAPATHS:prepend:gbmc := "${THISDIR}/files:" +SRC_URI:append:gbmc = " file://avahi-daemon.conf" +do_install:append:gbmc() { install -m0644 ${WORKDIR}/avahi-daemon.conf ${D}${sysconfdir}/avahi/ } diff --git a/meta-google/recipes-core/busybox/busybox_%.bbappend b/meta-google/recipes-core/busybox/busybox_%.bbappend index 9d8cb2d97..0f2210d7f 100644 --- a/meta-google/recipes-core/busybox/busybox_%.bbappend +++ b/meta-google/recipes-core/busybox/busybox_%.bbappend @@ -1,2 +1,2 @@ -FILESEXTRAPATHS_prepend_gbmc := "${THISDIR}/files:" -SRC_URI_append_gbmc = " file://gbmc.cfg" +FILESEXTRAPATHS:prepend:gbmc := "${THISDIR}/files:" +SRC_URI:append:gbmc = " file://gbmc.cfg" diff --git a/meta-google/recipes-core/dropbear/dropbear_%.bbappend b/meta-google/recipes-core/dropbear/dropbear_%.bbappend index 0b4349e00..f41990cc1 100644 --- a/meta-google/recipes-core/dropbear/dropbear_%.bbappend +++ b/meta-google/recipes-core/dropbear/dropbear_%.bbappend @@ -1,12 +1,12 @@ -FILESEXTRAPATHS_prepend_gbmc := "${THISDIR}/${PN}:" -SRC_URI_append_gbmc = " file://dropbear.default" -SYSTEMD_AUTO_ENABLE_${PN}_prod = "disable" +FILESEXTRAPATHS:prepend:gbmc := "${THISDIR}/${PN}:" +SRC_URI:append:gbmc = " file://dropbear.default" +SYSTEMD_AUTO_ENABLE:${PN}:prod = "disable" -FILESEXTRAPATHS_remove_gbmc_bandaid := "${THISDIR}/${PN}:" -SYSTEMD_AUTO_ENABLE_${PN}_bandaid_prod = "enable" +FILESEXTRAPATHS:remove:gbmc:bandaid := "${THISDIR}/${PN}:" +SYSTEMD_AUTO_ENABLE:${PN}:bandaid:prod = "enable" # Allow SSH to the gbmc-bridge node on DEV builds -do_install_append_gbmc_dev() { +do_install:append:gbmc:dev() { nftables_dir=${D}${sysconfdir}/nftables rules=$nftables_dir/50-dropbear-dev.rules install -d -m0755 $nftables_dir diff --git a/meta-google/recipes-core/os-release/os-release.bbappend b/meta-google/recipes-core/os-release/os-release.bbappend index ec6d64fcf..8c61bbccf 100644 --- a/meta-google/recipes-core/os-release/os-release.bbappend +++ b/meta-google/recipes-core/os-release/os-release.bbappend @@ -7,4 +7,4 @@ python() { d.setVar("BUILD_MEMO", memo) } -OS_RELEASE_FIELDS_append = " BUILD_MEMO" +OS_RELEASE_FIELDS:append = " BUILD_MEMO" diff --git a/meta-google/recipes-core/systemd/systemd_%.bbappend b/meta-google/recipes-core/systemd/systemd_%.bbappend index d40168e45..59751059a 100644 --- a/meta-google/recipes-core/systemd/systemd_%.bbappend +++ b/meta-google/recipes-core/systemd/systemd_%.bbappend @@ -1,8 +1,8 @@ # We want to be able to manage our coredumps -PACKAGECONFIG_append_gbmc = " coredump" +PACKAGECONFIG:append:gbmc = " coredump" # Disable timesync as we don't use it and it makes rebooting much slower -PACKAGECONFIG_remove_gbmc = "timesyncd" +PACKAGECONFIG:remove:gbmc = "timesyncd" # We don't need any legacy sysv rc compatability -PACKAGECONFIG_remove_gbmc = "sysvinit" +PACKAGECONFIG:remove:gbmc = "sysvinit" diff --git a/meta-google/recipes-devtools/protobuf/protobuf_%.bbappend b/meta-google/recipes-devtools/protobuf/protobuf_%.bbappend new file mode 100644 index 000000000..b709ea4cd --- /dev/null +++ b/meta-google/recipes-devtools/protobuf/protobuf_%.bbappend @@ -0,0 +1,3 @@ +# Reduces the size of the output binaries by ~300K +CFLAGS:append:class-target = " -flto" +CXXFLAGS:append:class-target = " -flto" diff --git a/meta-google/recipes-extended/networking/mstpd_git.bb b/meta-google/recipes-extended/networking/mstpd_git.bb index 4c3f4abc2..6970f5198 100644 --- a/meta-google/recipes-extended/networking/mstpd_git.bb +++ b/meta-google/recipes-extended/networking/mstpd_git.bb @@ -13,12 +13,12 @@ SRC_URI += "file://mstpd.service" inherit autotools pkgconfig systemd PACKAGES =+ "${PN}-mstpd" -FILES_${PN}-mstpd = "${sbindir}/mstpd ${sbindir}/mstpctl /sbin/bridge-stp" +FILES:${PN}-mstpd = "${sbindir}/mstpd ${sbindir}/mstpctl /sbin/bridge-stp" SYSTEMD_PACKAGES = "${PN}-mstpd" -SYSTEMD_SERVICE_${PN}-mstpd = "mstpd.service" +SYSTEMD_SERVICE:${PN}-mstpd = "mstpd.service" -do_install_append() { +do_install:append() { rm -r ${D}${libexecdir} install -d -m 0755 ${D}/sbin diff --git a/meta-google/recipes-extended/networking/sslh_git.bb b/meta-google/recipes-extended/networking/sslh_git.bb index ba26e2999..42cda6cb4 100644 --- a/meta-google/recipes-extended/networking/sslh_git.bb +++ b/meta-google/recipes-extended/networking/sslh_git.bb @@ -27,8 +27,12 @@ do_configure() { } do_compile() { + # Workaround for a non-installed and broken echosrv + sed -i 's,^\(all:.*\) echosrv,\1,' ${S}/Makefile + # Workaround for the broken dependencies in the Makefile oe_runmake sslh-conf.h + oe_runmake } diff --git a/meta-google/recipes-extended/zstd/zstd_%.bbappend b/meta-google/recipes-extended/zstd/zstd_%.bbappend new file mode 100644 index 000000000..84c6e55a4 --- /dev/null +++ b/meta-google/recipes-extended/zstd/zstd_%.bbappend @@ -0,0 +1,2 @@ +PACKAGES =+ "lib${BPN}" +FILES:lib${BPN} = "${libdir}/lib*${SOLIBS}" diff --git a/meta-google/recipes-google/acpi-power-state-daemon/acpi-power-state-daemon_git.bb b/meta-google/recipes-google/acpi-power-state-daemon/acpi-power-state-daemon_git.bb index 0755d4eab..0de07f93a 100644 --- a/meta-google/recipes-google/acpi-power-state-daemon/acpi-power-state-daemon_git.bb +++ b/meta-google/recipes-google/acpi-power-state-daemon/acpi-power-state-daemon_git.bb @@ -12,7 +12,7 @@ DEPENDS += " \ systemd \ " -SYSTEMD_SERVICE_${PN} = " \ +SYSTEMD_SERVICE:${PN} = " \ acpi-power-state.service \ host-s0-state.target \ host-s5-state.target \ diff --git a/meta-google/recipes-google/default-ca-dev/default-ca-dev.bb b/meta-google/recipes-google/default-ca-dev/default-ca-dev.bb index ecbb71267..3cce4cd46 100644 --- a/meta-google/recipes-google/default-ca-dev/default-ca-dev.bb +++ b/meta-google/recipes-google/default-ca-dev/default-ca-dev.bb @@ -5,7 +5,7 @@ LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5 SRC_URI += "file://certs/authority/" -FILES_${PN} = "${sysconfdir}/ssl/certs/authority/*" +FILES:${PN} = "${sysconfdir}/ssl/certs/authority/*" do_install(){ install -d ${D}${sysconfdir}/ssl/certs/authority diff --git a/meta-google/recipes-google/default-users/default-users.bb b/meta-google/recipes-google/default-users/default-users.bb index 76485ccd0..1dbf21577 100644 --- a/meta-google/recipes-google/default-users/default-users.bb +++ b/meta-google/recipes-google/default-users/default-users.bb @@ -8,16 +8,16 @@ EXCLUDE_FROM_WORLD = "1" DEPENDS = "bmcweb" DEPENDS += "phosphor-ipmi-host" DEPENDS += "phosphor-user-manager" -RDEPENDS_${PN} = "bmcweb" -RDEPENDS_${PN} += "phosphor-ipmi-host" -RDEPENDS_${PN} += "phosphor-user-manager" +RDEPENDS:${PN} = "bmcweb" +RDEPENDS:${PN} += "phosphor-ipmi-host" +RDEPENDS:${PN} += "phosphor-user-manager" inherit useradd USERADD_PACKAGES = "${PN}" -USERADD_PARAM_${PN} = "-m -N -u 1000 -g 100 -s /bin/nologin \ +USERADD_PARAM:${PN} = "-m -N -u 1000 -g 100 -s /bin/nologin \ -G 'web,redfish,priv-admin' Megapede; " -GROUPMEMS_PARAM_${PN} = "-g priv-admin -a root; " -GROUPMEMS_PARAM_${PN} += "-g ipmi -a root; " +GROUPMEMS_PARAM:${PN} = "-g priv-admin -a root; " +GROUPMEMS_PARAM:${PN} += "-g ipmi -a root; " -ALLOW_EMPTY_${PN} = "1" +ALLOW_EMPTY:${PN} = "1" diff --git a/meta-google/recipes-google/gpio/gpio-ctrl/lib.sh b/meta-google/recipes-google/gpio/gpio-ctrl/lib.sh new file mode 100644 index 000000000..a75c41306 --- /dev/null +++ b/meta-google/recipes-google/gpio/gpio-ctrl/lib.sh @@ -0,0 +1,250 @@ +#!/bin/bash +# Copyright 2021 Google LLC +# +# 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. + +# This is intended to be used as a library for managing gpio line values. +# Executing this directly will do nothing. +[ -n "${gpio_ctrl_init-}" ] && return + +# Map names of GPIOs to GPIO number +# This maps a schematic name to a gpiochip and line at a specific offset +declare -A GPIO_NAMES_TO_SCM=( + # Examples + #['SYS_RESET_N']='label=/pinctrl@f0800000/gpio@f0012000 21' + #['PWRBTN_N']='label=/pinctrl@f0800000/gpio@f0012000 23' + #['PCH_SLP_S5_R_N']='of_node=/ahb/apb/i2c@8e000/cpu_seq@6b 9' + #['PCH_PWRGOOD_R']='of_node=/ahb/apb/i2c@8e000/cpu_seq@6b 6' +) + +# Load configurations from a known location in the filesystem to populate +# named GPIOs +shopt -s nullglob +for conf in /usr/share/gpio-ctrl/conf.d/*.sh; do + source "$conf" +done + +declare -A gpio_sysfs_lookup_cache=() +declare -A gpio_lookup_cache=() + +declare -A gpio_init=() + +################################################## +# Looks up the sysfs GPIO number +# Arguments: +# $1: GPIO name +# Return: +# 0 if success, non-zero if error +# stdout: The GPIO number +################################################## +gpio_name_to_num() { + local name="$1" + + if [ -n "${gpio_lookup_cache["$name"]+1}" ]; then + echo "${gpio_lookup_cache["$name"]}" + return 0 + fi + + local scm="${GPIO_NAMES_TO_SCM["$name"]-}" + if [ -z "$scm" ]; then + echo "Missing gpio definition: $name" >&2 + return 1 + fi + local id="${scm% *}" + local type="${id%=*}" + local val="${id#*=}" + local offset="${scm#* }" + + local sysfs + if [ -n "${gpio_sysfs_lookup_cache["$id"]+1}" ]; then + sysfs="${gpio_sysfs_lookup_cache["$id"]}" + else + case "$type" in + label) + if ! sysfs="$(grep -xl "$val" /sys/class/gpio/gpiochip*/label)"; then + echo "Failed to find gpiochip: $val" >&2 + return 1 + fi + sysfs="${sysfs%/label}" + ;; + of_node) + for sysfs in $(echo /sys/class/gpio/gpiochip*); do + local link + # Ignore errors because not all devices have of_nodes + link="$(readlink -f "$sysfs/device/of_node" 2>/dev/null)" || continue + [ "${link#/sys/firmware/devicetree/base}" = "$val" ] && break + sysfs= + done + if [ -z "$sysfs" ]; then + echo "Failed to find gpiochip: $val" >&2 + return 1 + fi + ;; + *) + echo "Invalid GPIO type $type" >&2 + return 1 + ;; + esac + gpio_sysfs_lookup_cache["$id"]="$sysfs" + fi + + local ngpio=$(cat "$sysfs"/ngpio) + if (( ngpio <= offset )); then + echo "$name with gpiochip $sysfs only has $ngpio but wants $offset" >&2 + return 1 + fi + + gpio_lookup_cache["$name"]=$(( $(cat "$sysfs"/base) + offset )) + echo "${gpio_lookup_cache["$name"]}" +} + + +################################################## +# Populates the GPIO lookup cache +# Most calls to gpio_name_to_num that would +# normally cache the sysfs lookups for gpios run +# inside subshells. This prevents them from +# populating a global cache and greatly speeding +# up future lookups. This call allows scripts to +# populate the cache prior to looking up gpios. +################################################## +gpio_build_cache() { + local timeout="${1-0}" + shift + local gpios=("$@") + + if (( ${#gpios[@]} == 0 )); then + gpios="${!GPIO_NAMES_TO_SCM[@]}" + fi + + local deadline=$(( timeout + SECONDS )) + local name + for name in "${gpios[@]}"; do + while true; do + gpio_name_to_num "$name" >/dev/null && break + if (( deadline <= SECONDS )); then + echo "Timed out building gpio cache" >&2 + return 1 + fi + done + done +} + +################################################## +# Initializes the gpio state +# This operation is idempotent and can be applied +# repeatedly to the same gpio. It will make sure the +# gpio ends up in the initialized state even if it +# was. +# Arguments: +# $1: GPIO name +# Return: +# 0 if success, non-zero if error +################################################## +gpio_init_() { + local name="$1" + local num="$2" + + if [ -n "${gpio_init["$name"]+1}" ]; then + return 0 + fi + + if [ ! -e "/sys/class/gpio/gpio$num" ]; then + if ! echo "$num" >'/sys/class/gpio/export'; then + echo "Failed to export $name gpio$num" >&2 + return 1 + fi + fi + local active_low=0 + if [[ "${name%_N}" != "$name" ]]; then + active_low=1 + fi + if ! echo "$active_low" >"/sys/class/gpio/gpio$num/active_low"; then + echo "Failed to set active_low for $name gpio$num" >&2 + return 1 + fi + gpio_init["$name"]=1 +} +gpio_init() { + local name="$1" + + # Ensure the cache is updated by not running in a subshell + gpio_name_to_num "$name" >/dev/null || return + + gpio_init_ "$name" "$(gpio_name_to_num "$name")" +} + +################################################## +# Sets the output GPIO value. +# Arguments: +# $1: GPIO name +# $2: GPIO value, "1" or "0" +# Return: +# 0 if success, non-zero if error +################################################## +gpio_set_value_() { + local name="$1" + local num="$2" + local val="$3" + + gpio_init_ "$name" "$num" || return + if ! echo out >"/sys/class/gpio/gpio$num/direction"; then + echo "Failed to set output for $name gpio$num" >&2 + return 1 + fi + if ! echo "$val" >"/sys/class/gpio/gpio$num/value"; then + echo "Failed to set $name gpio$num = $val" >&2 + return 1 + fi +} +gpio_set_value() { + local name="$1" + local val="$2" + + # Ensure the cache is updated by not running in a subshell + gpio_name_to_num "$name" >/dev/null || return + + gpio_set_value_ "$name" "$(gpio_name_to_num "$name")" "$val" +} + +################################################## +# Get GPIO value +# Arguments: +# $1: GPIO name +# Return: +# 0 if success, non-zero if error +# stdout: The value of the gpio +################################################## +gpio_get_value_() { + local name="$1" + local num="$2" + + gpio_init_ "$name" "$num" || return + if ! cat "/sys/class/gpio/gpio$num/value"; then + echo "Failed to get $name gpio$num value" >&2 + return 1 + fi +} +gpio_get_value() { + local name="$1" + + # Ensure the cache is updated by not running in a subshell + gpio_name_to_num "$name" >/dev/null || return + + gpio_get_value_ "$name" "$(gpio_name_to_num "$name")" +} + +gpio_ctrl_init=1 +return 0 2>/dev/null +echo "gpio-ctrl is a library, not executed directly" >&2 +exit 1 diff --git a/meta-google/recipes-google/gpio/gpio-ctrl_git.bb b/meta-google/recipes-google/gpio/gpio-ctrl_git.bb new file mode 100644 index 000000000..c42b689ed --- /dev/null +++ b/meta-google/recipes-google/gpio/gpio-ctrl_git.bb @@ -0,0 +1,14 @@ +SUMMARY = "GPIO control library for bash scripts" +DESCRIPTION = "GPIO control library for bash scripts." +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" +PR = "r1" + +SRC_URI += "file://lib.sh" + +RDEPENDS:${PN} = "bash" + +do_install() { + install -d ${D}${datadir}/gpio-ctrl + install -m 0755 ${WORKDIR}/lib.sh ${D}${datadir}/gpio-ctrl/ +} diff --git a/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host-ensure-off.service b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host-ensure-off.service new file mode 100644 index 000000000..96c6d20df --- /dev/null +++ b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host-ensure-off.service @@ -0,0 +1,11 @@ +[Unit] +Description=Ensure host is off on clean AC cycle +Before=host-poweron.service +Before=firmware-updates-pre.target + +[Service] +Type=oneshot +ExecStart=/usr/bin/host_ensure_off.sh + +[Install] +WantedBy=multi-user.target diff --git a/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host-powercycle-watchdog.service b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host-powercycle-watchdog.service new file mode 100644 index 000000000..1b1236e9e --- /dev/null +++ b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host-powercycle-watchdog.service @@ -0,0 +1,7 @@ +[Unit] +Description=Powercycle host + +[Service] +Type=oneshot +Environment=DONT_STOP_WATCHDOG=1 +ExecStart=/usr/bin/host_powercycle.sh diff --git a/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host-powercycle.service b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host-powercycle.service new file mode 100644 index 000000000..7ff2244d8 --- /dev/null +++ b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host-powercycle.service @@ -0,0 +1,6 @@ +[Unit] +Description=Powercycle host + +[Service] +Type=oneshot +ExecStart=/usr/bin/host_powercycle.sh diff --git a/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host-poweroff-watchdog.service b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host-poweroff-watchdog.service new file mode 100644 index 000000000..175dd1f08 --- /dev/null +++ b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host-poweroff-watchdog.service @@ -0,0 +1,7 @@ +[Unit] +Description=Power off host + +[Service] +Type=oneshot +Environment=DONT_STOP_WATCHDOG=1 +ExecStart=/usr/bin/host_poweroff.sh diff --git a/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host-poweroff.service b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host-poweroff.service new file mode 100644 index 000000000..803e01082 --- /dev/null +++ b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host-poweroff.service @@ -0,0 +1,6 @@ +[Unit] +Description=Power off host + +[Service] +Type=oneshot +ExecStart=/usr/bin/host_poweroff.sh diff --git a/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host-poweron.service b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host-poweron.service new file mode 100644 index 000000000..1837248fd --- /dev/null +++ b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host-poweron.service @@ -0,0 +1,10 @@ +[Unit] +Description=Power on host +After=firmware-updates.target + +[Service] +Type=oneshot +ExecStart=/usr/bin/host_poweron.sh + +[Install] +WantedBy=multi-user.target diff --git a/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host-reset-cold-watchdog.service b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host-reset-cold-watchdog.service new file mode 100644 index 000000000..d60872c15 --- /dev/null +++ b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host-reset-cold-watchdog.service @@ -0,0 +1,7 @@ +[Unit] +Description=Cold Reset Host + +[Service] +Type=oneshot +Environment=DONT_STOP_WATCHDOG=1 +ExecStart=/usr/bin/host_reset.sh cold diff --git a/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host-reset-cold.service b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host-reset-cold.service new file mode 100644 index 000000000..a014350a9 --- /dev/null +++ b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host-reset-cold.service @@ -0,0 +1,6 @@ +[Unit] +Description=Cold Reset Host + +[Service] +Type=oneshot +ExecStart=/usr/bin/host_reset.sh cold diff --git a/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host-reset-warm-watchdog.service b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host-reset-warm-watchdog.service new file mode 100644 index 000000000..374380ec9 --- /dev/null +++ b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host-reset-warm-watchdog.service @@ -0,0 +1,7 @@ +[Unit] +Description=Warm Reset Host + +[Service] +Type=oneshot +Environment=DONT_STOP_WATCHDOG=1 +ExecStart=/usr/bin/host_reset.sh warm diff --git a/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host-reset-warm.service b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host-reset-warm.service new file mode 100644 index 000000000..2dd4a26fc --- /dev/null +++ b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host-reset-warm.service @@ -0,0 +1,6 @@ +[Unit] +Description=Warm Reset Host + +[Service] +Type=oneshot +ExecStart=/usr/bin/host_reset.sh warm diff --git a/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host_ensure_off.sh b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host_ensure_off.sh new file mode 100755 index 000000000..ab9f4726d --- /dev/null +++ b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host_ensure_off.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# Copyright 2021 Google LLC +# +# 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. + +if ! was_ac_reset.sh; then + echo "Not a tray reset, ignoring" >&2 + exit 0 +fi + +echo "Powering off the host" >&2 +host_poweroff.sh diff --git a/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host_isoff.sh b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host_isoff.sh new file mode 100755 index 000000000..459eca7e2 --- /dev/null +++ b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host_isoff.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# Copyright 2021 Google LLC +# +# 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 /usr/share/gpio-host-pwr/lib.sh || exit + +gpio_build_cache 10 "$HOST_GPIO_PGOOD" || return 255 +pgood="$(gpio_get_value "$HOST_GPIO_PGOOD")" || return 255 +echo "HOST_PGOOD=$pgood" >&2 +(( pgood == 0 )) diff --git a/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host_powercycle.sh b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host_powercycle.sh new file mode 100644 index 000000000..3c8f00259 --- /dev/null +++ b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host_powercycle.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# Copyright 2021 Google LLC +# +# 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 /usr/share/gpio-host-pwr/lib.sh || exit +gpio_build_cache 10 "$HOST_GPIO_PGOOD" "$HOST_GPIO_PWR_BTN" || exit + +rc=0 +host_poweroff.sh || rc=$? +# We want to ensure we aren't too quickly bouncing the power button +sleep 0.5 +host_poweron.sh || rc=$? +exit $rc diff --git a/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host_poweroff.sh b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host_poweroff.sh new file mode 100755 index 000000000..58c1da856 --- /dev/null +++ b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host_poweroff.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# Copyright 2021 Google LLC +# +# 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 /usr/share/gpio-host-pwr/lib.sh || exit + +gpio_build_cache 10 "$HOST_GPIO_PGOOD" "$HOST_GPIO_PWR_BTN" || exit +gpio_init "$HOST_GPIO_PGOOD" || exit + +# Set the power status LED +if [ -n "$HOST_LED_PWR" ]; then + echo 'none' > /sys/class/leds/"$HOST_LED_PWR"/trigger || true + echo '0' > /sys/class/leds/"$HOST_LED_PWR"/brightness || true +fi + +# Ensure the watchdog is no longer going to run +host_pwr_stop_watchdog || true + +# We don't want to do anything if the machine is already off +pgood="$(gpio_get_value "$HOST_GPIO_PGOOD")" || exit +if (( pgood == 0 )); then + echo 'Host is already off, doing nothing' >&2 + exit 0 +fi + +# Do a long push of the button if PGOOD +echo 'Stopping host power' >&2 +rc=0 +gpio_set_value "$HOST_GPIO_PWR_BTN" 1 || rc=$? + +# Loop until we realize that host power is off +# Limit the loop count to 10 seconds as we should never +# have to wait this long for poweroff +s=$SECONDS +while true; do + if ! pgood="$(gpio_get_value "$HOST_GPIO_PGOOD")"; then + rc=1 + break + fi + if (( pgood == 0 )); then + echo 'Host is now off' >&2 + break + fi + if (( SECONDS - s > 10 )); then + echo 'Poweroff timed out, terminating' >&2 + rc=2 + break + fi + sleep 0.1 +done + +gpio_set_value "$HOST_GPIO_PWR_BTN" 0 || rc=$? + +exit $rc diff --git a/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host_poweron.sh b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host_poweron.sh new file mode 100755 index 000000000..2e6eb0217 --- /dev/null +++ b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host_poweron.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# Copyright 2021 Google LLC +# +# 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 /usr/share/gpio-host-pwr/lib.sh || exit + +gpio_build_cache 10 "$HOST_GPIO_PGOOD" "$HOST_GPIO_PWR_BTN" || exit +gpio_init "$HOST_GPIO_PGOOD" || exit + +# Set the power status LED +if [ -n "$HOST_LED_PWR" ]; then + echo 'none' > /sys/class/leds/"$HOST_LED_PWR"/trigger || true + echo '255' > /sys/class/leds/"$HOST_LED_PWR"/brightness || true +fi + +# Ensure the watchdog is available before the host starts +host_pwr_start_watchdog || true + +# We don't want to do anything if the machine is already on +pgood="$(gpio_get_value "$HOST_GPIO_PGOOD")" || exit +if (( pgood == 1 )); then + echo 'Host is already running, doing nothing' >&2 + exit 0 +fi + +# Do a quick push of the button if PGOOD +echo "Starting host power" >&2 +rc=0 +gpio_set_value "$HOST_GPIO_PWR_BTN" 1 || rc=$? +sleep 0.1 +gpio_set_value "$HOST_GPIO_PWR_BTN" 0 || rc=$? + +# Loop until we realize that host power is on +# Limit the loop count to 10 seconds as we should never +# have to wait this long for poweroff +s=$SECONDS +while true; do + if ! pgood="$(gpio_get_value "$HOST_GPIO_PGOOD")"; then + rc=1 + break + fi + if (( pgood == 1 )); then + echo 'Host is now on' >&2 + break + fi + if (( SECONDS - s > 10 )); then + echo 'Poweron timed out, terminating' >&2 + rc=2 + break + fi + sleep 0.1 +done + +exit $rc diff --git a/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host_reset.sh b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host_reset.sh new file mode 100755 index 000000000..2f48a1240 --- /dev/null +++ b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/host_reset.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Copyright 2021 Google LLC +# +# 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 /usr/share/gpio-host-pwr/lib.sh || exit + +if [[ "${1-}" == "warm" ]]; then + rst_txt='WARM' >&2 + rst_gpio="$HOST_GPIO_WARM_RESET" +else + rst_txt='COLD' >&2 + rst_gpio="$HOST_GPIO_COLD_RESET" +fi + +gpio_build_cache 10 "$rst_gpio" || exit + +# Do a quick push of the button if PGOOD +echo "Issuing $rst_txt reset" >&2 +rc=0 +gpio_set_value "$rst_gpio" 1 || rc=$? +sleep 0.1 +gpio_set_value "$rst_gpio" 0 || rc=$? + +# Make sure the watchdog is stopped while the host is in reset +# and can't possibly restart it. +host_pwr_stop_watchdog || true + +exit $rc diff --git a/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/lib.sh b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/lib.sh new file mode 100644 index 000000000..16b36a58b --- /dev/null +++ b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr/lib.sh @@ -0,0 +1,69 @@ +#!/bin/bash +# Copyright 2021 Google LLC +# +# 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. + +# This is intended to be used as a library for managing gpio line values. +# Executing this directly will do nothing. +[ -n "${host_pwr_init-}" ] && return + +source /usr/share/gpio-ctrl/lib.sh || exit + +# Read by the tooling to determine if the machine is powered on or off +HOST_GPIO_PGOOD='unset' +# Set according to whether the host is powered on or off +HOST_LED_PWR='' +# Written by the tooling to assert the power button +HOST_GPIO_PWR_BTN='unset' +# Written by the tooling to assert a cold reset +HOST_GPIO_COLD_RESET='unset' +# Written by the tooling to assert a warm reset +HOST_GPIO_WARM_RESET='unset' + +# Load configurations from a known location in the filesystem to populate +# named GPIOs +shopt -s nullglob +for conf in /usr/share/gpio-host-pwr/conf.d/*.sh; do + source "$conf" +done + +################################################## +# Stop the host watchdog +# Return: +# 0 if success, non-zero if error +################################################## +host_pwr_stop_watchdog() { + # Check to see if we can stop the watchdog safely + # We don't want to stop if we are called from the watchdog itself + if [ -n "${DONT_STOP_WATCHDOG-}" ]; then + return 0 + fi + + echo 'Stopping the host watchdog' >&2 + systemctl stop phosphor-watchdog@host0 +} + +################################################## +# Start the host watchdog +# Return: +# 0 if success, non-zero if error +################################################## +host_pwr_start_watchdog() { + echo 'Starting the host watchdog' >&2 + systemctl start phosphor-watchdog@host0 +} + +host_pwr_init=1 +return 0 2>/dev/null +echo "gpio-host-pwr is a library, not executed directly" >&2 +exit 1 diff --git a/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr_git.bb b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr_git.bb new file mode 100644 index 000000000..e63260c56 --- /dev/null +++ b/meta-google/recipes-google/host-power-ctrl/gpio-host-pwr_git.bb @@ -0,0 +1,57 @@ +SUMMARY = "GPIO based powercontrol for a host system" +DESCRIPTION = "GPIO based powercontrol for a host system." +PR = "r1" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" + +inherit systemd + +RDEPENDS:${PN} += " \ + bash \ + gpio-ctrl \ + " + +SRC_URI += " \ + file://host-ensure-off.service \ + file://host-powercycle-watchdog.service \ + file://host-powercycle.service \ + file://host-poweroff-watchdog.service \ + file://host-poweroff.service \ + file://host-poweron.service \ + file://host-reset-cold-watchdog.service \ + file://host-reset-cold.service \ + file://host-reset-warm-watchdog.service \ + file://host-reset-warm.service \ + file://host_ensure_off.sh \ + file://host_isoff.sh \ + file://host_powercycle.sh \ + file://host_poweroff.sh \ + file://host_poweron.sh \ + file://host_reset.sh \ + file://lib.sh \ + " + +SYSTEMD_PACKAGES = "${PN}" +SYSTEMD_SERVICE:${PN} += " \ + host-reset-cold.service \ + host-reset-cold-watchdog.service \ + host-reset-warm.service \ + host-reset-warm-watchdog.service \ + host-ensure-off.service \ + host-powercycle.service \ + host-powercycle-watchdog.service \ + host-poweroff.service \ + host-poweroff-watchdog.service \ + host-poweron.service \ + " + +do_install() { + install -d ${D}${bindir} + install -m 0755 ${WORKDIR}/host_*.sh ${D}${bindir}/ + + install -d ${D}${datadir}/gpio-host-pwr + install -m 0755 ${WORKDIR}/lib.sh ${D}${datadir}/gpio-host-pwr/ + + install -d ${D}${systemd_system_unitdir} + install -m 0644 ${WORKDIR}/*.service ${D}${systemd_system_unitdir}/ +} diff --git a/meta-google/recipes-google/host-power-ctrl/libwatchdog/libwatchdog.sh b/meta-google/recipes-google/host-power-ctrl/libwatchdog/libwatchdog.sh new file mode 100644 index 000000000..dcb39692a --- /dev/null +++ b/meta-google/recipes-google/host-power-ctrl/libwatchdog/libwatchdog.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# Copyright 2021 Google LLC +# +# 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. + +################################################## +# Stop the host watchdog +# Return: +# 0 if success, non-zero if error +################################################## +stop_host_watchdog() { + if (( $# != 0 )); then + echo 'Usage: stop_host_watchdog' >&2 + return 1 + fi + + local srv='xyz.openbmc_project.Watchdog' + local obj='/xyz/openbmc_project/watchdog/host0' + local intf='xyz.openbmc_project.State.Watchdog' + local method='Enabled' + local args=('b' 'false') + busctl set-property "${srv}" "${obj}" "${intf}" "${method}" "${args[@]}" +} diff --git a/meta-google/recipes-google/host-power-ctrl/libwatchdog_git.bb b/meta-google/recipes-google/host-power-ctrl/libwatchdog_git.bb new file mode 100644 index 000000000..a9595c37c --- /dev/null +++ b/meta-google/recipes-google/host-power-ctrl/libwatchdog_git.bb @@ -0,0 +1,16 @@ +SUMMARY = "Watchdog Shell Library" +DESCRIPTION = "Watchdog Shell Library" +PR = "r1" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" + +SRC_URI += " \ + file://libwatchdog.sh \ +" + +RDEPENDS:${PN} = "bash" + +do_install() { + install -d ${D}${libexecdir} + install -m 0755 ${WORKDIR}/libwatchdog.sh ${D}${libexecdir}/ +} diff --git a/meta-google/recipes-google/ipmi/google-ipmi-i2c_git.bb b/meta-google/recipes-google/ipmi/google-ipmi-i2c_git.bb index aeba2a991..3d5504ea1 100644 --- a/meta-google/recipes-google/ipmi/google-ipmi-i2c_git.bb +++ b/meta-google/recipes-google/ipmi/google-ipmi-i2c_git.bb @@ -16,9 +16,9 @@ S = "${WORKDIR}/git" SRC_URI = "git://github.com/openbmc/google-ipmi-i2c" SRCREV = "b7d431199ac519e7c3cd5f3341d67f2ff0e09e10" -FILES_${PN}_append = " ${libdir}/ipmid-providers/lib*${SOLIBS}" -FILES_${PN}_append = " ${libdir}/host-ipmid/lib*${SOLIBS}" -FILES_${PN}_append = " ${libdir}/net-ipmid/lib*${SOLIBS}" -FILES_${PN}-dev_append = " ${libdir}/ipmid-providers/lib*${SOLIBSDEV} ${libdir}/ipmid-providers/*.la" +FILES:${PN}:append = " ${libdir}/ipmid-providers/lib*${SOLIBS}" +FILES:${PN}:append = " ${libdir}/host-ipmid/lib*${SOLIBS}" +FILES:${PN}:append = " ${libdir}/net-ipmid/lib*${SOLIBS}" +FILES:${PN}-dev:append = " ${libdir}/ipmid-providers/lib*${SOLIBSDEV} ${libdir}/ipmid-providers/*.la" HOSTIPMI_PROVIDER_LIBRARY += "libi2ccmds.so" diff --git a/meta-google/recipes-google/ipmi/google-ipmi-sys_git.bb b/meta-google/recipes-google/ipmi/google-ipmi-sys_git.bb index 801de4361..1310f7e00 100644 --- a/meta-google/recipes-google/ipmi/google-ipmi-sys_git.bb +++ b/meta-google/recipes-google/ipmi/google-ipmi-sys_git.bb @@ -21,15 +21,15 @@ S = "${WORKDIR}/git" SRC_URI = "git://github.com/openbmc/google-ipmi-sys" SRCREV = "b69209b498bf9b1c009c528e40280d13e68f8dbd" -FILES_${PN} += "${libdir}/ipmid-providers" +FILES:${PN} += "${libdir}/ipmid-providers" SYSTEMD_PACKAGES = "${PN}" -SYSTEMD_SERVICE_${PN} += " \ +SYSTEMD_SERVICE:${PN} += " \ gbmc-host-poweroff.target \ gbmc-psu-hardreset.target \ " EXTRA_OEMESON += "-Dtests=disabled" -CXXFLAGS_append_gbmc = '${@"" if not d.getVar("GBMC_NCSI_IF_NAME") else \ +CXXFLAGS:append:gbmc = '${@"" if not d.getVar("GBMC_NCSI_IF_NAME") else \ " -DNCSI_IPMI_CHANNEL=1 -DNCSI_IF_NAME=" + d.getVar("GBMC_NCSI_IF_NAME")}' diff --git a/meta-google/recipes-google/ipmi/ipmi-fru-sh.bb b/meta-google/recipes-google/ipmi/ipmi-fru-sh.bb index deaee7aac..881e623e9 100644 --- a/meta-google/recipes-google/ipmi/ipmi-fru-sh.bb +++ b/meta-google/recipes-google/ipmi/ipmi-fru-sh.bb @@ -3,14 +3,14 @@ PR = "r1" LICENSE = "Apache-2.0" LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" -FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" SRC_URI += "file://lib.sh" S = "${WORKDIR}" DATA = "${datadir}/ipmi-fru" -FILES_${PN} += "${DATA}" +FILES:${PN} += "${DATA}" -do_install_append() { +do_install:append() { install -d -m0755 ${D}${DATA} install -m0644 lib.sh ${D}${DATA}/ } diff --git a/meta-google/recipes-google/ipmi/metrics-ipmi-blobs_git.bb b/meta-google/recipes-google/ipmi/metrics-ipmi-blobs_git.bb index 531d824dd..943747834 100644 --- a/meta-google/recipes-google/ipmi/metrics-ipmi-blobs_git.bb +++ b/meta-google/recipes-google/ipmi/metrics-ipmi-blobs_git.bb @@ -13,6 +13,6 @@ DEPENDS += " \ protobuf \ " -FILES_${PN} += "${libdir}/blob-ipmid" +FILES:${PN} += "${libdir}/blob-ipmid" EXTRA_OEMESON += "-Dtests=disabled" diff --git a/meta-google/recipes-google/nanopb/nanopb_0.4.5.bb b/meta-google/recipes-google/nanopb/nanopb_0.4.5.bb index 232872e75..1737cddb0 100644 --- a/meta-google/recipes-google/nanopb/nanopb_0.4.5.bb +++ b/meta-google/recipes-google/nanopb/nanopb_0.4.5.bb @@ -13,12 +13,12 @@ S = "${WORKDIR}/git" DEPENDS = "protobuf-native python3-protobuf" -RDEPENDS_${PN}-generator += "python3 python3-protobuf" +RDEPENDS:${PN}-generator += "python3 python3-protobuf" -PACKAGES_prepend = "${PN}-generator ${PN}-runtime " +PACKAGES:prepend = "${PN}-generator ${PN}-runtime " -FILES_${PN}-generator = "${libdir}/python* ${bindir}" +FILES:${PN}-generator = "${libdir}/python* ${bindir}" -FILES_${PN}-runtime = "${libdir}/*.so.*" +FILES:${PN}-runtime = "${libdir}/*.so.*" BBCLASSEXTEND = "native" diff --git a/meta-google/recipes-google/ncsi/gbmc-ncsi-config.bb b/meta-google/recipes-google/ncsi/gbmc-ncsi-config.bb index 89890266b..6480be1da 100644 --- a/meta-google/recipes-google/ncsi/gbmc-ncsi-config.bb +++ b/meta-google/recipes-google/ncsi/gbmc-ncsi-config.bb @@ -16,25 +16,25 @@ SRC_URI += " \ S = "${WORKDIR}" -RDEPENDS_${PN} += " \ +RDEPENDS:${PN} += " \ gbmc-ip-monitor \ ncsid \ nftables-systemd \ sslh \ " -FILES_${PN} += " \ +FILES:${PN} += " \ ${datadir}/gbmc-ip-monitor \ ${systemd_unitdir} \ " -SYSTEMD_SERVICE_${PN} += " \ +SYSTEMD_SERVICE:${PN} += " \ gbmc-ncsi-sslh.service \ gbmc-ncsi-sslh.socket \ gbmc-ncsi-set-nicenabled.service \ " -do_install_append() { +do_install:append() { if_name='${GBMC_NCSI_IF_NAME}' if [ -z "$if_name" ]; then echo "Missing if_name" >&2 diff --git a/meta-google/recipes-google/ncsi/ncsid_git.bb b/meta-google/recipes-google/ncsi/ncsid_git.bb index 1acb45116..a67a3104b 100644 --- a/meta-google/recipes-google/ncsi/ncsid_git.bb +++ b/meta-google/recipes-google/ncsi/ncsid_git.bb @@ -10,7 +10,7 @@ EXTRA_OEMESON = " \ -Dtests=disabled \ " -SYSTEMD_SERVICE_${PN} += " \ +SYSTEMD_SERVICE:${PN} += " \ dhcp4@.service \ dhcp6@.service \ ncsid@.service \ @@ -26,7 +26,7 @@ DEPENDS += " \ stdplus \ " -RDEPENDS_${PN} += " \ +RDEPENDS:${PN} += " \ bash \ busybox \ iputils-arping \ diff --git a/meta-google/recipes-google/networking/gbmc-bridge.bb b/meta-google/recipes-google/networking/gbmc-bridge.bb index 37af84baf..dea14f00b 100644 --- a/meta-google/recipes-google/networking/gbmc-bridge.bb +++ b/meta-google/recipes-google/networking/gbmc-bridge.bb @@ -5,7 +5,7 @@ LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5 inherit systemd -FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" SRC_URI += " \ file://-bmc-gbmcbr.netdev \ file://-bmc-gbmcbr.network.in \ @@ -22,14 +22,14 @@ SRC_URI += " \ file://gbmc-br-nft.sh \ " -FILES_${PN}_append = " \ +FILES:${PN}:append = " \ ${datadir}/gbmc-ip-monitor \ ${systemd_unitdir}/network \ ${sysconfdir}/nftables \ ${sysconfdir}/avahi/services \ " -RDEPENDS_${PN}_append = " \ +RDEPENDS:${PN}:append = " \ bash \ gbmc-ip-monitor \ mstpd-mstpd \ @@ -37,7 +37,7 @@ RDEPENDS_${PN}_append = " \ ndisc6-rdisc6 \ " -SYSTEMD_SERVICE_${PN} += "gbmc-br-ensure-ra.service" +SYSTEMD_SERVICE:${PN} += "gbmc-br-ensure-ra.service" GBMC_BR_MAC_ADDR ?= "" @@ -98,7 +98,7 @@ do_install() { install -m0755 ${WORKDIR}/gbmc-br-ensure-ra.service ${D}${systemd_system_unitdir}/ } -do_rm_work_prepend() { +do_rm_work:prepend() { # HACK: Work around broken do_rm_work not properly calling rm with `--` # It doesn't like filenames that start with `-` rm -rf -- ${WORKDIR}/-* diff --git a/meta-google/recipes-google/networking/gbmc-bridge/50-gbmc-br.rules b/meta-google/recipes-google/networking/gbmc-bridge/50-gbmc-br.rules index 1a5e6331d..475cc02f9 100644 --- a/meta-google/recipes-google/networking/gbmc-bridge/50-gbmc-br.rules +++ b/meta-google/recipes-google/networking/gbmc-bridge/50-gbmc-br.rules @@ -16,10 +16,18 @@ table inet filter { jump gbmc_br_pub_input reject } + set gbmc_br_int_addrs { + type ipv6_addr; + flags interval + elements = { + ff00::/8, + fe80::/64, + fdb5:0481:10ce::/64, + } + } chain gbmc_br_int_input { - ip6 daddr ff00::/8 accept - ip6 daddr fe80::/64 accept - ip6 daddr fdb5:0481:10ce::/64 accept + ip6 daddr @gbmc_br_int_addrs accept + ip6 saddr @gbmc_br_int_addrs accept } chain gbmc_br_pub_input { ip6 nexthdr icmpv6 accept diff --git a/meta-google/recipes-google/networking/gbmc-ip-monitor.bb b/meta-google/recipes-google/networking/gbmc-ip-monitor.bb index 32804302b..1bf35bc9c 100644 --- a/meta-google/recipes-google/networking/gbmc-ip-monitor.bb +++ b/meta-google/recipes-google/networking/gbmc-ip-monitor.bb @@ -15,18 +15,18 @@ S = "${WORKDIR}" DEPENDS += "test-sh" -RDEPENDS_${PN} += " \ +RDEPENDS:${PN} += " \ bash \ iproute2 \ " -SYSTEMD_SERVICE_${PN} += "gbmc-ip-monitor.service" +SYSTEMD_SERVICE:${PN} += "gbmc-ip-monitor.service" do_compile() { SYSROOT="$PKG_CONFIG_SYSROOT_DIR" bash gbmc-ip-monitor-test.sh || exit } -do_install_append() { +do_install:append() { install -d -m0755 ${D}${libexecdir} install -m0755 gbmc-ip-monitor.sh ${D}${libexecdir}/ diff --git a/meta-google/recipes-google/networking/gbmc-iperf3.bb b/meta-google/recipes-google/networking/gbmc-iperf3.bb index 27ebdb7e0..3b78a405f 100644 --- a/meta-google/recipes-google/networking/gbmc-iperf3.bb +++ b/meta-google/recipes-google/networking/gbmc-iperf3.bb @@ -5,11 +5,11 @@ LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5 inherit systemd -RDEPENDS_${PN} += "iperf3" +RDEPENDS:${PN} += "iperf3" SRC_URI += "file://iperf3.service" -SYSTEMD_SERVICE_${PN} += "iperf3.service" +SYSTEMD_SERVICE:${PN} += "iperf3.service" do_install() { # Install service definitions @@ -18,7 +18,7 @@ do_install() { } # Allow IPERF3 to run on the gbmcbr node on DEV builds -do_install_append_dev() { +do_install:append:dev() { nftables_dir=${D}${sysconfdir}/nftables rules=$nftables_dir/50-gbmc-iperf3-dev.rules install -d -m0755 $nftables_dir diff --git a/meta-google/recipes-google/networking/gbmc-mac-config.bb b/meta-google/recipes-google/networking/gbmc-mac-config.bb index 6ca4c798b..7a3781d1f 100644 --- a/meta-google/recipes-google/networking/gbmc-mac-config.bb +++ b/meta-google/recipes-google/networking/gbmc-mac-config.bb @@ -12,14 +12,14 @@ SRC_URI += " \ S = "${WORKDIR}" -RDEPENDS_${PN} += " \ +RDEPENDS:${PN} += " \ bash \ ipmi-fru-sh \ " -FILES_${PN} += "${systemd_unitdir}" +FILES:${PN} += "${systemd_unitdir}" -SYSTEMD_SERVICE_${PN} += "gbmc-mac-config.service" +SYSTEMD_SERVICE:${PN} += "gbmc-mac-config.service" GBMC_MAC_EEPROM_OF_NAME ?= "" @@ -28,7 +28,7 @@ GBMC_MAC_EEPROM_OF_NAME ?= "" # Ex. "[0]=eth0 [2]=eth2" GBMC_MAC_IF_MAP ?= "" -do_install_append() { +do_install:append() { if [ -z '${GBMC_MAC_EEPROM_OF_NAME}' ]; then echo 'Missing GBMC_MAC_EEPROM_OF_NAME' >&2 exit 1 diff --git a/meta-google/recipes-google/networking/google-usb-network_git.bb b/meta-google/recipes-google/networking/google-usb-network_git.bb index ec51eaa5b..f0d15b94e 100644 --- a/meta-google/recipes-google/networking/google-usb-network_git.bb +++ b/meta-google/recipes-google/networking/google-usb-network_git.bb @@ -6,16 +6,16 @@ PV = "0.2" LICENSE = "Apache-2.0" LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" -FILESEXTRAPATHS_prepend = "${THISDIR}/${PN}:" +FILESEXTRAPATHS:prepend = "${THISDIR}/${PN}:" inherit systemd DEPENDS += "m4-native" DEPENDS += "systemd" -RDEPENDS_${PN} += "bash" +RDEPENDS:${PN} += "bash" SYSTEMD_PACKAGES = "${PN}" -SYSTEMD_SERVICE_${PN} = "usb_network.service" +SYSTEMD_SERVICE:${PN} = "usb_network.service" BMC_IP_ADDR ??= "169.254.95.118/16" BMC_USB_ECM_PRODUCT_ID ??= "" @@ -30,8 +30,8 @@ SRC_URI += "file://00-bmc-usb0.network.m4" SRC_URI += "file://usb_network.service.m4" SRC_URI += "file://usb_network.sh" -FILES_${PN} = "${bindir}/usb_network.sh" -FILES_${PN}_append = " ${systemd_unitdir}/network/${BMC_USB_CONFIG_FILENAME}" +FILES:${PN} = "${bindir}/usb_network.sh" +FILES:${PN}:append = " ${systemd_unitdir}/network/${BMC_USB_CONFIG_FILENAME}" do_compile() { test "X${BMC_IP_ADDR}" != "X" || bberror "Please define BMC_IP_ADDR" diff --git a/meta-google/recipes-google/networking/network-sh.bb b/meta-google/recipes-google/networking/network-sh.bb index a377b9e2a..921795b00 100644 --- a/meta-google/recipes-google/networking/network-sh.bb +++ b/meta-google/recipes-google/networking/network-sh.bb @@ -3,13 +3,13 @@ PR = "r1" LICENSE = "Apache-2.0" LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" -FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" SRC_URI += "file://lib.sh" SRC_URI += "file://test.sh" S = "${WORKDIR}" DATA = "${datadir}/network" -FILES_${PN} += "${DATA}" +FILES:${PN} += "${DATA}" DEPENDS += "test-sh" @@ -17,7 +17,7 @@ do_compile() { SYSROOT="$PKG_CONFIG_SYSROOT_DIR" bash test.sh || exit } -do_install_append() { +do_install:append() { install -d -m0755 ${D}${DATA} install -m0644 lib.sh ${D}${DATA}/ } diff --git a/meta-google/recipes-google/nftables/nftables-systemd.bb b/meta-google/recipes-google/nftables/nftables-systemd.bb index f4109ddc7..21a8b1aeb 100644 --- a/meta-google/recipes-google/nftables/nftables-systemd.bb +++ b/meta-google/recipes-google/nftables/nftables-systemd.bb @@ -13,9 +13,9 @@ SRC_URI += " \ file://nftables.service \ " -SYSTEMD_SERVICE_${PN} += "nftables.service" +SYSTEMD_SERVICE:${PN} += "nftables.service" -RDEPENDS_${PN} += " \ +RDEPENDS:${PN} += " \ bash \ nftables \ " diff --git a/meta-google/recipes-google/ssh/authorized-keys-comp.bb b/meta-google/recipes-google/ssh/authorized-keys-comp.bb index 81ee868a8..ef0379286 100644 --- a/meta-google/recipes-google/ssh/authorized-keys-comp.bb +++ b/meta-google/recipes-google/ssh/authorized-keys-comp.bb @@ -12,15 +12,15 @@ SRC_URI += " \ S = "${WORKDIR}" -RDEPENDS_${PN} += "bash" +RDEPENDS:${PN} += "bash" -SYSTEMD_SERVICE_${PN} += "authorized-keys-comp.service" +SYSTEMD_SERVICE:${PN} += "authorized-keys-comp.service" -FILES_${PN} += "/home" +FILES:${PN} += "/home" AUTHORIZED_KEYS_COMP_USERS ?= "root" -do_install_append() { +do_install:append() { install -d -m0755 ${D}${libexecdir} install -m0755 authorized-keys-comp.sh ${D}${libexecdir}/ diff --git a/meta-google/recipes-google/ssh/gbmc-dev-ssh-key.bb b/meta-google/recipes-google/ssh/gbmc-dev-ssh-key.bb index a9d371e70..a402f511f 100644 --- a/meta-google/recipes-google/ssh/gbmc-dev-ssh-key.bb +++ b/meta-google/recipes-google/ssh/gbmc-dev-ssh-key.bb @@ -7,7 +7,7 @@ SRC_URI += "file://gbmc-dev.pub" S = "${WORKDIR}" -FILES_${PN} += " ${datadir}/authorized_keys.d" +FILES:${PN} += " ${datadir}/authorized_keys.d" do_install() { install -d ${D}${datadir}/authorized_keys.d/root diff --git a/meta-google/recipes-google/systemd/gbmc-systemd-config.bb b/meta-google/recipes-google/systemd/gbmc-systemd-config.bb index 29d81f46a..6e26fc99d 100644 --- a/meta-google/recipes-google/systemd/gbmc-systemd-config.bb +++ b/meta-google/recipes-google/systemd/gbmc-systemd-config.bb @@ -7,23 +7,23 @@ inherit systemd S = "${WORKDIR}" -SRC_URI_append = " \ +SRC_URI:append = " \ file://firmware-updates.target \ file://firmware-updates-pre.target \ file://40-gbmc-forward.conf \ " -FILES_${PN}_append = " \ +FILES:${PN}:append = " \ ${systemd_unitdir}/coredump.conf.d/40-gbmc-coredump.conf \ ${systemd_unitdir}/resolved.conf.d/40-gbmc-nomdns.conf \ ${libdir}/sysctl.d/40-gbmc-forward.conf \ " -FILES_${PN}_append_dev = " \ +FILES:${PN}:append:dev = " \ ${libdir}/sysctl.d/40-gbmc-debug.conf \ " -SYSTEMD_SERVICE_${PN}_append = " \ +SYSTEMD_SERVICE:${PN}:append = " \ firmware-updates.target \ firmware-updates-pre.target \ " @@ -46,7 +46,7 @@ do_install() { install -m 0644 ${WORKDIR}/40-gbmc-forward.conf ${D}${libdir}/sysctl.d/ } -do_install_append_dev() { +do_install:append:dev() { printf "kernel.sysrq = 1\n" \ >${D}${libdir}/sysctl.d/40-gbmc-debug.conf } diff --git a/meta-google/recipes-google/test/test-sh.bb b/meta-google/recipes-google/test/test-sh.bb index 7edbb9189..eaca13739 100644 --- a/meta-google/recipes-google/test/test-sh.bb +++ b/meta-google/recipes-google/test/test-sh.bb @@ -3,19 +3,19 @@ PR = "r1" LICENSE = "Apache-2.0" LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" -FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" SRC_URI += "file://lib.sh" SRC_URI += "file://test.sh" S = "${WORKDIR}" DATA = "${datadir}/test" -FILES_${PN} += "${DATA}" +FILES:${PN} += "${DATA}" do_compile() { SYSROOT="$PKG_CONFIG_SYSROOT_DIR" bash test.sh || exit } -do_install_append() { +do_install:append() { install -d -m0755 ${D}${DATA} install -m0644 lib.sh ${D}${DATA}/ } diff --git a/meta-google/recipes-phosphor/console/glome_git.bb b/meta-google/recipes-phosphor/console/glome_git.bb new file mode 100644 index 000000000..4750de8be --- /dev/null +++ b/meta-google/recipes-phosphor/console/glome_git.bb @@ -0,0 +1,26 @@ +SUMMARY = "GLOME Login Client" +DESCRIPTION = "GLOME login is first application of the GLOME protocol. It is used to authorize serial console access to Linux machines" +PR = "r1" +PV = "0.1+git${SRCPV}" + +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57" + +inherit meson pkgconfig + +DEPENDS += " \ + openssl \ + glib-2.0 \ + " + +S = "${WORKDIR}/git" +SRC_URI = "git://github.com/google/glome.git" +SRCREV = "b7084b5c60682a0b4f4ae3f2ec6048e65212c377" + +FILES_${PN} += "${libdir}/security" + +PACKAGECONFIG ??= "" +PACKAGECONFIG[glome-cli] = "-Dglome-cli=true,-Dglome-cli=false" +PACKAGECONFIG[pam-glome] = "-Dpam-glome=true,-Dpam-glome=false,libpam" + +EXTRA_OEMESON = "-Dtests=disabled" diff --git a/meta-google/recipes-phosphor/dbus/phosphor-dbus-interfaces-mapper-config-native.bbappend b/meta-google/recipes-phosphor/dbus/phosphor-dbus-interfaces-mapper-config-native.bbappend index 8ba6e7c33..47e290b35 100644 --- a/meta-google/recipes-phosphor/dbus/phosphor-dbus-interfaces-mapper-config-native.bbappend +++ b/meta-google/recipes-phosphor/dbus/phosphor-dbus-interfaces-mapper-config-native.bbappend @@ -1,2 +1,2 @@ -PHOSPHOR_MAPPER_SERVICE_append = " com.google.gbmc" -PHOSPHOR_MAPPER_INTERFACE_append = " com.google.gbmc" +PHOSPHOR_MAPPER_SERVICE:append = " com.google.gbmc" +PHOSPHOR_MAPPER_INTERFACE:append = " com.google.gbmc" diff --git a/meta-google/recipes-phosphor/flash/dummy-gbmc-update.bb b/meta-google/recipes-phosphor/flash/dummy-gbmc-update.bb index 7eba3b0fc..4bff6e331 100644 --- a/meta-google/recipes-phosphor/flash/dummy-gbmc-update.bb +++ b/meta-google/recipes-phosphor/flash/dummy-gbmc-update.bb @@ -10,9 +10,9 @@ inherit systemd SRC_URI += "file://config-dummy.json" SRC_URI += "file://dummy-verify.service" -FILES_${PN} += "${datadir}/phosphor-ipmi-flash" +FILES:${PN} += "${datadir}/phosphor-ipmi-flash" -SYSTEMD_SERVICE_${PN} += "dummy-verify.service" +SYSTEMD_SERVICE:${PN} += "dummy-verify.service" do_install() { install -d ${D}${datadir}/phosphor-ipmi-flash diff --git a/meta-google/recipes-phosphor/flash/google-key.bb b/meta-google/recipes-phosphor/flash/google-key.bb index 220211526..f05f08245 100644 --- a/meta-google/recipes-phosphor/flash/google-key.bb +++ b/meta-google/recipes-phosphor/flash/google-key.bb @@ -5,8 +5,8 @@ PR = "r1" LICENSE = "Apache-2.0" LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" -RDEPENDS_${PN} += "bash" -RDEPENDS_${PN} += "gnupg" +RDEPENDS:${PN} += "bash" +RDEPENDS:${PN} += "gnupg-gpg" SRC_URI += " \ file://platforms_gbmc_bringup.gpg \ diff --git a/meta-google/recipes-phosphor/flash/inplace-gbmc-update.bb b/meta-google/recipes-phosphor/flash/inplace-gbmc-update.bb index c71a579e1..9e55afce5 100644 --- a/meta-google/recipes-phosphor/flash/inplace-gbmc-update.bb +++ b/meta-google/recipes-phosphor/flash/inplace-gbmc-update.bb @@ -8,10 +8,10 @@ LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5 inherit obmc-phosphor-systemd PROVIDES += "virtual/bmc-update" -RPROVIDES_${PN} += "virtual/bmc-update" +RPROVIDES:${PN} += "virtual/bmc-update" -RDEPENDS_${PN} += "google-key" -RDEPENDS_${PN} += "bash" +RDEPENDS:${PN} += "google-key" +RDEPENDS:${PN} += "bash" SRC_URI += " \ file://config-bmc.json \ @@ -21,10 +21,10 @@ SRC_URI += " \ file://inplace-gbmc-version.sh \ " -SYSTEMD_SERVICE_${PN} += "inplace-gbmc-verify.service" -SYSTEMD_SERVICE_${PN} += "inplace-gbmc-version.service" +SYSTEMD_SERVICE:${PN} += "inplace-gbmc-verify.service" +SYSTEMD_SERVICE:${PN} += "inplace-gbmc-version.service" -FILES_${PN} += "${datadir}/phosphor-ipmi-flash" +FILES:${PN} += "${datadir}/phosphor-ipmi-flash" do_install() { sed -i 's,@ALLOW_DEV@,,' ${WORKDIR}/inplace-gbmc-verify.sh @@ -39,6 +39,6 @@ do_install() { install -m 0644 ${WORKDIR}/config-bmc.json ${D}${datadir}/phosphor-ipmi-flash } -do_install_prepend_dev() { +do_install:prepend:dev() { sed -i 's,@ALLOW_DEV@,--allow-dev,' ${WORKDIR}/inplace-gbmc-verify.sh } diff --git a/meta-google/recipes-phosphor/flash/inplace-gbmc-update/inplace-gbmc-verify.sh b/meta-google/recipes-phosphor/flash/inplace-gbmc-update/inplace-gbmc-verify.sh index d5307d3d1..e7727cd72 100644 --- a/meta-google/recipes-phosphor/flash/inplace-gbmc-update/inplace-gbmc-verify.sh +++ b/meta-google/recipes-phosphor/flash/inplace-gbmc-update/inplace-gbmc-verify.sh @@ -54,4 +54,4 @@ echo "running" > ${STATUS_FILE} verify-bmc-image.sh @ALLOW_DEV@ "$IMAGE_FILE" "$SIGNATURE_FILE" || exit # Rename the staged file for initramfs updates. -mv ${IMAGE_FILE} ${VERIFIED_FILE}#!/bin/bash +mv ${IMAGE_FILE} ${VERIFIED_FILE} diff --git a/meta-google/recipes-phosphor/flash/inplace-gbmc-update/inplace-gbmc-version.sh b/meta-google/recipes-phosphor/flash/inplace-gbmc-update/inplace-gbmc-version.sh index 0c5c4e787..039101876 100644 --- a/meta-google/recipes-phosphor/flash/inplace-gbmc-update/inplace-gbmc-version.sh +++ b/meta-google/recipes-phosphor/flash/inplace-gbmc-update/inplace-gbmc-version.sh @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -grep '^VERSION_ID=' /etc/os-release | sed 's,.*-\([^-]*\),\1,g' | tr -d '\n'#!/bin/bash +grep '^VERSION_ID=' /etc/os-release | sed 's,.*-\([^-]*\),\1,g' | tr -d '\n' diff --git a/meta-google/recipes-phosphor/host/phosphor-host-postd_%.bbappend b/meta-google/recipes-phosphor/host/phosphor-host-postd_%.bbappend index 01669cca8..204ed0353 100644 --- a/meta-google/recipes-phosphor/host/phosphor-host-postd_%.bbappend +++ b/meta-google/recipes-phosphor/host/phosphor-host-postd_%.bbappend @@ -2,6 +2,6 @@ # while the machine is booting. Especially when host serial logs also get # written. This enables the verbose output of the daemon, providing # the logging behavior. -do_install_append_gbmc_dev() { +do_install:append:gbmc:dev() { sed -i '/^ExecStart=/ s,$, -v,' ${D}${systemd_system_unitdir}/lpcsnoop.service } diff --git a/meta-google/recipes-phosphor/images/obmc-phosphor-image.bbappend b/meta-google/recipes-phosphor/images/obmc-phosphor-image.bbappend index 942dfc14c..dce86826f 100644 --- a/meta-google/recipes-phosphor/images/obmc-phosphor-image.bbappend +++ b/meta-google/recipes-phosphor/images/obmc-phosphor-image.bbappend @@ -1,25 +1,25 @@ -OBMC_IMAGE_EXTRA_INSTALL_append = " google-ipmi-sys" -OBMC_IMAGE_EXTRA_INSTALL_append = " google-ipmi-i2c" -OBMC_IMAGE_EXTRA_INSTALL_append = " phosphor-ipmi-blobs" -OBMC_IMAGE_EXTRA_INSTALL_append = " phosphor-ipmi-ethstats" -OBMC_IMAGE_EXTRA_INSTALL_append = " phosphor-ipmi-flash" +OBMC_IMAGE_EXTRA_INSTALL:append = " google-ipmi-sys" +OBMC_IMAGE_EXTRA_INSTALL:append = " google-ipmi-i2c" +OBMC_IMAGE_EXTRA_INSTALL:append = " phosphor-ipmi-blobs" +OBMC_IMAGE_EXTRA_INSTALL:append = " phosphor-ipmi-ethstats" +OBMC_IMAGE_EXTRA_INSTALL:append = " phosphor-ipmi-flash" # Google BMC (gBMC) specific installs -OBMC_IMAGE_EXTRA_INSTALL_append_gbmc = " iproute2 iproute2-ss" -OBMC_IMAGE_EXTRA_INSTALL_append_gbmc = " gbmc-systemd-config" -OBMC_IMAGE_EXTRA_INSTALL_append_gbmc = " gbmc-iperf3" -OBMC_IMAGE_EXTRA_INSTALL_append_gbmc = " authorized-keys-comp" -OBMC_IMAGE_EXTRA_INSTALL_append_gbmc_dev = " gbmc-dev-ssh-key" -OBMC_IMAGE_EXTRA_INSTALL_append_gbmc = \ +OBMC_IMAGE_EXTRA_INSTALL:append:gbmc = " iproute2 iproute2-ss" +OBMC_IMAGE_EXTRA_INSTALL:append:gbmc = " gbmc-systemd-config" +OBMC_IMAGE_EXTRA_INSTALL:append:gbmc = " gbmc-iperf3" +OBMC_IMAGE_EXTRA_INSTALL:append:gbmc = " authorized-keys-comp" +OBMC_IMAGE_EXTRA_INSTALL:append:gbmc:dev = " gbmc-dev-ssh-key" +OBMC_IMAGE_EXTRA_INSTALL:append:gbmc = \ '${@"" if not d.getVar("GBMC_NCSI_IF_NAME") else " gbmc-ncsi-config"}' -OBMC_IMAGE_EXTRA_INSTALL_append_gbmc = \ +OBMC_IMAGE_EXTRA_INSTALL:append:gbmc = \ '${@"" if not d.getVar("GBMC_MAC_EEPROM_OF_NAME") else " gbmc-mac-config"}' # Include these useful utilities for all gbmc platforms -OBMC_IMAGE_EXTRA_INSTALL_append_gbmc = " ipmitool" -OBMC_IMAGE_EXTRA_INSTALL_append_gbmc = " iotools" -OBMC_IMAGE_EXTRA_INSTALL_append_gbmc = " lrzsz" +OBMC_IMAGE_EXTRA_INSTALL:append:gbmc = " ipmitool" +OBMC_IMAGE_EXTRA_INSTALL:append:gbmc = " iotools" +OBMC_IMAGE_EXTRA_INSTALL:append:gbmc = " lrzsz" # Add gBMC update recipes -OBMC_IMAGE_EXTRA_INSTALL_append_gbmc = " dummy-gbmc-update" -OBMC_IMAGE_EXTRA_INSTALL_append_gbmc = " virtual/bmc-update" +OBMC_IMAGE_EXTRA_INSTALL:append:gbmc = " dummy-gbmc-update" +OBMC_IMAGE_EXTRA_INSTALL:append:gbmc = " virtual/bmc-update" diff --git a/meta-google/recipes-phosphor/initrdscripts/obmc-phosphor-initfs.bbappend b/meta-google/recipes-phosphor/initrdscripts/obmc-phosphor-initfs.bbappend index 905a39a48..de696efb3 100644 --- a/meta-google/recipes-phosphor/initrdscripts/obmc-phosphor-initfs.bbappend +++ b/meta-google/recipes-phosphor/initrdscripts/obmc-phosphor-initfs.bbappend @@ -1,20 +1,20 @@ # This is needed to guarantee that our whitelist takes # precendence over the OpenBMC one -FILESEXTRAPATHS_prepend_gbmc := "${THISDIR}/${PN}:" +FILESEXTRAPATHS:prepend:gbmc := "${THISDIR}/${PN}:" -SRC_URI_append_gbmc_dev = " file://whitelist.dev" +SRC_URI:append:gbmc:dev = " file://whitelist.dev" -do_install_append_gbmc_dev() { +do_install:append:gbmc:dev() { cat ${WORKDIR}/whitelist.dev >>${D}/whitelist } -SRC_URI_append_gbmc_dev = " file://rwfs-clean-dev.patch" +SRC_URI:append:gbmc:dev = " file://rwfs-clean-dev.patch" # Required for the clean-dev patch to detect version changes -RDEPENDS_${PN}_append_gbmc_dev = " os-release" +RDEPENDS:${PN}:append:gbmc:dev = " os-release" -do_install_append_gbmc_prod() { +do_install:append:gbmc:prod() { echo "clean-rwfs-filesystem" > ${D}/init-options-base chmod 0644 ${D}/init-options-base } -FILES_${PN}_append_gbmc_prod = " /init-options-base" +FILES:${PN}:append:gbmc:prod = " /init-options-base" diff --git a/meta-google/recipes-phosphor/ipmi/phosphor-ipmi-config.bbappend b/meta-google/recipes-phosphor/ipmi/phosphor-ipmi-config.bbappend index 03e99b2d0..56f7933d4 100644 --- a/meta-google/recipes-phosphor/ipmi/phosphor-ipmi-config.bbappend +++ b/meta-google/recipes-phosphor/ipmi/phosphor-ipmi-config.bbappend @@ -1,13 +1,13 @@ -FILESEXTRAPATHS_prepend_gbmc := "${THISDIR}/${PN}:" +FILESEXTRAPATHS:prepend:gbmc := "${THISDIR}/${PN}:" -SRC_URI_append_gbmc = " file://gbmc_bridge.json" +SRC_URI:append:gbmc = " file://gbmc_bridge.json" -DEPENDS_append_gbmc = " jq-native" +DEPENDS:append:gbmc = " jq-native" GBMCBR_IPMI_CHANNEL ?= "11" # Replace a channel in config.json to add gbmcbr reporting -do_install_append_gbmc() { +do_install:append:gbmc() { chjson=${D}${datadir}/ipmi-providers/channel_config.json overlapping="$(jq '."${GBMCBR_IPMI_CHANNEL}" | .is_valid and .name != "gbmcbr"' $chjson)" if [ "$overlapping" != "false" ]; then diff --git a/meta-google/recipes-phosphor/ipmi/phosphor-ipmi-ethstats_%.bbappend b/meta-google/recipes-phosphor/ipmi/phosphor-ipmi-ethstats_%.bbappend index 4519baea6..0c05a9ece 100644 --- a/meta-google/recipes-phosphor/ipmi/phosphor-ipmi-ethstats_%.bbappend +++ b/meta-google/recipes-phosphor/ipmi/phosphor-ipmi-ethstats_%.bbappend @@ -1,2 +1,2 @@ # Enable registration via Google OEM Number in addition to OpenBMC. -EXTRA_OECONF_append = " --enable-google" +EXTRA_OECONF:append = " --enable-google" diff --git a/meta-google/recipes-phosphor/network/phosphor-network_%.bbappend b/meta-google/recipes-phosphor/network/phosphor-network_%.bbappend index 4a1cbe139..800355225 100644 --- a/meta-google/recipes-phosphor/network/phosphor-network_%.bbappend +++ b/meta-google/recipes-phosphor/network/phosphor-network_%.bbappend @@ -1,3 +1,3 @@ # Platforms with Hoth don't use the U-Boot environment since this would allow # bypassing attestation. -PACKAGECONFIG_remove_hoth = "uboot-env" +PACKAGECONFIG:remove:hoth = "uboot-env" diff --git a/meta-google/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bbappend b/meta-google/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bbappend new file mode 100644 index 000000000..46135c3d5 --- /dev/null +++ b/meta-google/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bbappend @@ -0,0 +1,11 @@ +# Remove unneeded packages installed +RDEPENDS:${PN}-extras:remove:gbmc = "obmc-ikvm" +RDEPENDS:${PN}-extras:remove:gbmc = "phosphor-rest" +RDEPENDS:${PN}-extras:remove:gbmc = "phosphor-dbus-monitor" +RDEPENDS:${PN}-extras:remove:gbmc = "phosphor-nslcd-cert-config" +RDEPENDS:${PN}-extras:remove:gbmc = "phosphor-nslcd-authority-cert-config" + +RDEPENDS:${PN}-extrasdev:remove:gbmc = "rest-dbus" + +# Disable bmcweb for gbmc machines without redfish. +RDEPENDS:${PN}-extras:remove:gbmc = '${@bb.utils.contains:any("MACHINE_FEATURES", ['redfish'], "", "bmcweb phosphor-bmcweb-cert-config", d)}' diff --git a/meta-google/recipes-phosphor/settings/phosphor-settings-manager_%.bbappend b/meta-google/recipes-phosphor/settings/phosphor-settings-manager_%.bbappend index 46d11234e..764f0c828 100644 --- a/meta-google/recipes-phosphor/settings/phosphor-settings-manager_%.bbappend +++ b/meta-google/recipes-phosphor/settings/phosphor-settings-manager_%.bbappend @@ -1,5 +1,5 @@ #Override the default time settings from BMC/NTP to Host/Manual, so that host #can set BMC time via an IPMI command. -FILESEXTRAPATHS_append_gbmc := ":${THISDIR}/${PN}" -SRC_URI_append_gbmc = " file://timemanager-default-HOST-MANUAL.override.yml" +FILESEXTRAPATHS:append:gbmc := ":${THISDIR}/${PN}" +SRC_URI:append:gbmc = " file://timemanager-default-HOST-MANUAL.override.yml" |