diff options
author | Jorge Cisneros <jorge.cisneros@hpe.com> | 2020-09-04 00:09:03 +0300 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2020-09-09 16:49:10 +0300 |
commit | 8a445a08318f2c25be409851d9bb6a491d923953 (patch) | |
tree | fb27b0e6ae23f656ff33de9974a81b9aa024174d /meta-hpe/meta-common/recipes-phosphor | |
parent | 4d14968af13ba43fb00d0a89a1ff4e18a8d25c69 (diff) | |
download | openbmc-8a445a08318f2c25be409851d9bb6a491d923953.tar.xz |
Added new layers and new conf dl360poc
(From meta-hpe rev: 32ae68cd72e95760e004fa6443278e4e703535c0)
Signed-off-by: Jorge Cisneros <jorge.cisneros@hpe.com>
Change-Id: I611c734ab19f6a5a3bded6b8979791560ced082d
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'meta-hpe/meta-common/recipes-phosphor')
5 files changed, 672 insertions, 0 deletions
diff --git a/meta-hpe/meta-common/recipes-phosphor/image/obmc-phosphor-image.bbappend b/meta-hpe/meta-common/recipes-phosphor/image/obmc-phosphor-image.bbappend new file mode 100644 index 0000000000..7c21fb4d23 --- /dev/null +++ b/meta-hpe/meta-common/recipes-phosphor/image/obmc-phosphor-image.bbappend @@ -0,0 +1,151 @@ +inherit image_version +unset do_get_version[noexec] +do_get_version[depends] = "os-release" + +# do_get_version() is copied from meta-phosphor/classes/image_version.bbclass and +# modified to append the date and time to the version if a file named "developer" +# exists in the openbmc/build directory +def do_get_version(d): + import configparser + import io + path = d.getVar('STAGING_DIR_TARGET', True) + d.getVar('sysconfdir', True) + path = os.path.join(path, 'os-release') + parser = configparser.SafeConfigParser(strict=False) + parser.optionxform = str + version = '' + try: + with open(path, 'r') as fd: + buf = '[root]\n' + fd.read() + fd = io.StringIO(buf) + parser.readfp(fd) + version = parser['root']['VERSION_ID'] + dev_path = d.getVar('PWD', True) + dev_path = os.path.join(dev_path, 'developer') + if os.path.isfile(dev_path): + version = version[:-1] + str(d.getVar('IMAGE_VERSION_SUFFIX', True)).strip() + except: + pass + return version + +HPE_GXP_BOOTBLOCK_IMAGE ?= "gxp-bootblock.bin" +HPE_UBOOT_SIGNING_HEADER ?= "hpe-uboot-header.section" +HPE_UBOOT_SIGNING_KEY ?= "hpe-uboot-signing-key.pem" + +FLASH_SIZE = "31552" +FLASH_UBOOT_OFFSET = "0" +FLASH_KERNEL_OFFSET = "512" +FLASH_ROFS_OFFSET = "5376" +FLASH_RWFS_OFFSET = "29184" +FLASH_SECTION_OFFSET = "31552" +FLASH_SECTION_END = "32768" + +UBOOT_IMG_SIZE = "393216" + +do_generate_static[depends] += " \ + gxp-bootblock:do_deploy \ + gxp-bootblock:do_populate_sysroot \ + " + + +make_image_links_append() { + ln -sf ${DEPLOY_DIR_IMAGE}/hpe-section image-section +} + +do_mk_static_symlinks_append() { + ln -sf hpe-section image-section +} + +do_generate_static_prepend() { + bb.build.exec_func("do_generate_hpe_image", d) +} + +do_generate_static_append() { + _append_image(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), + 'hpe-section'), + int(d.getVar('FLASH_SECTION_OFFSET', True)), + int(d.getVar('FLASH_SECTION_END', True))) +} + +do_generate_hpe_image() { + # Extract uboot 256K + dd if=/dev/zero bs=1k count=256 > ${DEPLOY_DIR_IMAGE}/u-boot-tmp.${UBOOT_SUFFIX} + dd bs=1k conv=notrunc seek=0 count=256\ + if=${DEPLOY_DIR_IMAGE}/u-boot.${UBOOT_SUFFIX} \ + of=${DEPLOY_DIR_IMAGE}/u-boot-tmp.${UBOOT_SUFFIX} + + # Sign uboot 256K + openssl sha256 -sign ${DEPLOY_DIR_IMAGE}/${HPE_UBOOT_SIGNING_KEY} -out ${DEPLOY_DIR_IMAGE}/gxp_tmp.sig \ + ${DEPLOY_DIR_IMAGE}/u-boot-tmp.${UBOOT_SUFFIX} + + # Expand (header+signature) to 4K + cat ${DEPLOY_DIR_IMAGE}/${HPE_UBOOT_SIGNING_HEADER} ${DEPLOY_DIR_IMAGE}/gxp_tmp.sig \ + > ${DEPLOY_DIR_IMAGE}/gxp.sig + + # Add Header and Signature to hpe-section (from 60K) + dd bs=1k conv=notrunc seek=60 \ + if=${DEPLOY_DIR_IMAGE}/gxp.sig \ + of=${DEPLOY_DIR_IMAGE}/hpe-section + + # Add ubb to hpe-section + dd bs=1k conv=notrunc seek=64 \ + if=${DEPLOY_DIR_IMAGE}/${HPE_GXP_BOOTBLOCK_IMAGE} \ + of=${DEPLOY_DIR_IMAGE}/hpe-section + + # Expand uboot to 384K + dd if=/dev/zero bs=1k count=384 > ${DEPLOY_DIR_IMAGE}/u-boot-tmp.${UBOOT_SUFFIX} + dd bs=1k conv=notrunc seek=0 count=384\ + if=${DEPLOY_DIR_IMAGE}/u-boot.${UBOOT_SUFFIX} \ + of=${DEPLOY_DIR_IMAGE}/u-boot-tmp.${UBOOT_SUFFIX} + + # Remove unnecessary files + rm ${DEPLOY_DIR_IMAGE}/u-boot.${UBOOT_SUFFIX} \ + ${DEPLOY_DIR_IMAGE}/gxp_tmp.sig \ + ${DEPLOY_DIR_IMAGE}/gxp.sig + + mv ${DEPLOY_DIR_IMAGE}/u-boot-tmp.${UBOOT_SUFFIX} ${DEPLOY_DIR_IMAGE}/u-boot.${UBOOT_SUFFIX} + + # Check uboot image size equals to 384K + size="$(wc -c < "${DEPLOY_DIR_IMAGE}/u-boot.${UBOOT_SUFFIX}")" + if [ ${size} -ne ${UBOOT_IMG_SIZE} ] + then + echo "ERROR: STATIC - uBoot image size ${size} incorrect. Please try it again." + exit 1 + fi +} + +make_tar_of_images() { + type=$1 + shift + extra_files="$@" + + # Create the tar archive + tar -h -cvf ${IMGDEPLOYDIR}/${IMAGE_NAME}.$type.mtd.tar \ + image-u-boot image-kernel image-rofs image-rwfs image-section $extra_files + + cd ${IMGDEPLOYDIR} + ln -sf ${IMAGE_NAME}.$type.mtd.tar ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.$type.mtd.tar +} + +do_generate_static_tar[depends] += " obmc-phosphor-image:do_generate_static" + +do_generate_static_tar() { + + ln -sf ${S}/MANIFEST MANIFEST + ln -sf ${S}/publickey publickey + make_image_links ${OVERLAY_BASETYPE} ${IMAGE_BASETYPE} + + # Check uboot image size equals to 384K + size="$(wc -c < "image-u-boot")" + if [ ${size} != ${UBOOT_IMG_SIZE} ] + then + echo "ERROR: TAR - uBoot image size ${size} incorrect. Please try it again." + exit 1 + fi + + make_signatures image-u-boot image-kernel image-rofs image-rwfs image-section MANIFEST publickey + make_tar_of_images static MANIFEST publickey ${signature_files} + + # Maintain non-standard legacy link. + cd ${IMGDEPLOYDIR} + ln -sf ${IMAGE_NAME}.static.mtd.tar ${IMGDEPLOYDIR}/${MACHINE}-${DATETIME}.tar +} diff --git a/meta-hpe/meta-common/recipes-phosphor/initrdscripts/files/gxp-obmc-init.sh b/meta-hpe/meta-common/recipes-phosphor/initrdscripts/files/gxp-obmc-init.sh new file mode 100644 index 0000000000..e2a9ebcb62 --- /dev/null +++ b/meta-hpe/meta-common/recipes-phosphor/initrdscripts/files/gxp-obmc-init.sh @@ -0,0 +1,452 @@ +#!/bin/sh + +fslist="proc sys dev run" +rodir=run/initramfs/ro +rwdir=run/initramfs/rw +upper=$rwdir/cow +work=$rwdir/work + +cd / +mkdir -p $fslist +mount dev dev -tdevtmpfs +mount sys sys -tsysfs +mount proc proc -tproc +if ! grep run proc/mounts +then + mount tmpfs run -t tmpfs -o mode=755,nodev +fi + +mkdir -p $rodir $rwdir + +cp -rp init shutdown update whitelist bin sbin usr lib etc var run/initramfs + +# To start a interactive shell with job control at this point, run +# getty 38400 ttyS4 + +findmtd() { + m=$(grep -xl "$1" /sys/class/mtd/*/name) + m=${m%/name} + m=${m##*/} + echo $m +} + +blkid_fs_type() { + # Emulate util-linux's `blkid -s TYPE -o value $1` + # Example busybox blkid output: + # # blkid /dev/mtdblock5 + # /dev/mtdblock5: TYPE="squashfs" + # Process output to extract TYPE value "squashfs". + blkid $1 | sed -e 's/^.*TYPE="//' -e 's/".*$//' +} + +probe_fs_type() { + fst=$(blkid_fs_type $1) + echo ${fst:=jffs2} +} + +# This fw_get_env_var is a possibly broken version of fw_printenv that +# does not check the crc or flag byte. +# The u-boot environment starts with a crc32, followed by a flag byte +# when a redundannt environment is configured, followed by var=value\0 sets. +# The flag byte for nand is a 1 byte counter; for nor it is a 1 or 0 byte. + +get_fw_env_var() { + # do we have 1 or 2 copies of the environment? + # count non-blank non-comment lines + # copies=$(grep -v ^# /etc/fw_env.config | grep -c [::alnum::]) + # ... we could if we had the fw_env.config in the initramfs + copies=2 + + # * Change \n to \r and \0 to \n + # * Skip to the 5th byte to skip over crc + # * then skip to the first or 2nd byte to skip over flag if it exists + # * stop parsing at first empty line corresponding to the + # double \0 at the end of the environment. + # * print the value of the variable name passed as argument + + envdev=$(findmtd u-boot-env) + if test -n $envdev + then + cat /dev/$envdev | + tr '\n\000' '\r\n' | + tail -c +5 | tail -c +${copies-1} | + sed -ne '/^$/,$d' -e "s/^$1=//p" + fi +} + +setup_resolv() { + runresolv=/run/systemd/resolve/resolv.conf + etcresolv=/etc/resolv.conf + + if test ! -e $etcresolv -a ! -L $etcresolv + then + mkdir -p ${runresolv%/*} + ln -s $runresolv $etcresolv + fi + if test ! -f $runresolv + then + cat /proc/net/pnp > $runresolv + fi + + return 0 +} + +try_tftp() { + # split into tftp:// host:port/ path/on/remote + # then spilt off / and then :port from the end of host:port/ + # and : from the beginning of port + + rest="${1#tftp://}" + path=${rest#*/} + host=${rest%$path} + host="${host%/}" + port="${host#${host%:*}}" + host="${host%$port}" + port="${port#:}" + + setup_resolv + + if test -z "$host" -o -z "$path" + then + debug_takeover "Invalid tftp download url '$url'." + elif echo "Downloading '$url' from $host ..." && + ! tftp -g -r "$path" -l /run/image-rofs "$host" ${port+"$port"} + then + debug_takeover "Download of '$url' failed." + fi +} + +try_wget() { + setup_resolv + + echo "Downloading '$1' ..." + if ! wget -O /run/image-rofs "$1" + then + debug_takeover "Download of '$url' failed." + fi +} + +debug_takeover() { + echo "$@" + read -t 5 -n 1 -s -r -p "Press any key to log in and try to manually fix, force recovery in 5 seconds" + if test $? -gt 0 + then + mkdir -p /var/lock + envdev=$(findmtd u-boot-env) + echo -e "/dev/${envdev}\t0x00000\t0x10000" > /etc/fw_env.config + echo -e "/dev/${envdev}\t0x10000\t0x10000" >> /etc/fw_env.config + fw_setenv force_recovery 1 + fw_setenv last_booterrmsg "$@" + devmem 0xc0000000 32 0x01 + fi + cat << HERE +After fixing run exit to continue this script, or reboot -f to retry, or +touch /takeover and exit to become PID 1 allowing editing of this script. +HERE + + while ! sulogin && ! test -f /takeover + do + echo getty failed, retrying + done + + # Touch /takeover in the above getty to become pid 1 + if test -e /takeover + then + cat << HERE + +Takeover of init requested. Executing /bin/sh as PID 1. +When finished exec new init or cleanup and run reboot -f. + +Warning: No job control! Shell exit will panic the system! +HERE + export PS1=init#\ + exec /bin/sh + fi +} + +# Check System Maintenace Switch 7 and load factory default +check_dip() { + devmem 0x800000b8 16 0xFF + dip=$(devmem 0x800000b8 16) + + value1=$((( $dip & 0xFF00 ) >> 8 )) + value2=$((( $dip & 0x0040 ) >> 6 )) + + if [ $value1 -eq 0 ] && [ $value2 -eq 1 ] + then + echo "Detect System Maintenace Switch 7 on. Will load factory default" + return 0 + fi + return 1 +} + +rofs=$(findmtd rofs) +rwfs=$(findmtd rwfs) + +rodev=/dev/mtdblock${rofs#mtd} +rwdev=/dev/mtdblock${rwfs#mtd} + +# Set to y for yes, anything else for no. +force_rwfst_jffs2=y +flash_images_before_init=n +consider_download_files=y +consider_download_tftp=y +consider_download_http=y +consider_download_ftp=y + +rofst=squashfs +rwfst=$(probe_fs_type $rwdev) +roopts=ro +rwopts=rw + +image=/run/initramfs/image- +trigger=${image}rwfs + +init=/sbin/init +fsckbase=/sbin/fsck. +fsck=$fsckbase$rwfst +fsckopts=-a +optfile=/run/initramfs/init-options +optbase=/run/initramfs/init-options-base +urlfile=/run/initramfs/init-download-url +update=/run/initramfs/update + +if test -e /${optfile##*/} +then + cp /${optfile##*/} $optfile +fi + +if test -e /${optbase##*/} +then + cp /${optbase##*/} $optbase +else + touch $optbase +fi + +if test ! -f $optfile +then + cat /proc/cmdline $optbase > $optfile + get_fw_env_var openbmcinit >> $optfile + get_fw_env_var openbmconce >> $optfile +fi + +echo rofs = $rofs $rofst rwfs = $rwfs $rwfst + +if grep -w debug-init-sh $optfile +then + debug_takeover "Debug initial shell requested by command line." +fi + +if test "x$consider_download_files" = xy && + grep -w openbmc-init-download-files $optfile +then + if test -f ${urlfile##*/} + then + cp ${urlfile##*/} $urlfile + fi + if test ! -f $urlfile + then + get_fw_env_var openbmcinitdownloadurl > $urlfile + fi + url="$(cat $urlfile)" + rest="${url#*://}" + proto="${url%$rest}" + + if test -z "$url" + then + echo "Download url empty. Ignoring download request." + elif test -z "$proto" + then + echo "Download failed." + elif test "$proto" = tftp:// + then + if test "x$consider_download_tftp" = xy + then + try_tftp "$url" + else + echo "Download failed." + fi + elif test "$proto" = http:// + then + if test "x$consider_download_http" = xy + then + try_wget "$url" + else + echo "Download failed." + fi + elif test "$proto" = ftp:// + then + if test "x$consider_download_ftp" = xy + then + try_wget "$url" + else + echo "Download failed." + fi + else + echo "Download failed." + fi +fi + +# If there are images in root move them to /run/initramfs/ or /run/ now. +imagebasename=${image##*/} +if test -n "${imagebasename}" && ls /${imagebasename}* > /dev/null 2>&1 +then + if test "x$flash_images_before_init" = xy + then + echo "Flash images found, will update before starting init." + mv /${imagebasename}* ${image%$imagebasename} + else + echo "Flash images found, will use but deferring flash update." + mv /${imagebasename}* /run/ + fi +fi + +if grep -w clean-rwfs-filesystem $optfile +then + echo "Cleaning of read-write overlay filesystem requested." + touch $trigger +fi + +if grep -w factory-reset $optfile || check_dip +then + echo "Factory reset requested." + touch $trigger + do_save=--no-save-files +else + do_save=--save-files +fi + +if test "x$force_rwfst_jffs2" = xy -a $rwfst != jffs2 -a ! -f $trigger +then + echo "Converting read-write overlay filesystem to jffs2 forced." + touch $trigger +fi + +if ls $image* > /dev/null 2>&1 +then + if ! test -x $update + then + debug_takeover "Flash update requested but $update missing!" + elif test -f $trigger -a ! -s $trigger + then + if [ $do_save = "--save-files" ] + then + echo "Saving selected files from read-write overlay filesystem." + else + echo "No files will be selected for save." + fi + $update --no-restore-files $do_save + echo "Clearing read-write overlay filesystem." + flash_eraseall /dev/$rwfs + echo "Restoring saved files to read-write overlay filesystem." + touch $trigger + $update --no-save-files --clean-saved-files + else + $update --clean-saved-files $do_save + fi + + rwfst=$(probe_fs_type $rwdev) + fsck=$fsckbase$rwfst +fi + +if grep -w overlay-filesystem-in-ram $optfile +then + rwfst=none +fi + +copyfiles= +if grep -w copy-files-to-ram $optfile +then + rwfst=none + copyfiles=y +fi + +# It would be nice to do this after fsck but that mean rofs is mounted +# which triggers the mtd is mounted check +if test "$rwfst$copyfiles" = noney +then + touch $trigger + $update --copy-files --clean-saved-files --no-restore-files +fi + +if grep -w copy-base-filesystem-to-ram $optfile && + test ! -e /run/image-rofs && ! cp $rodev /run/image-rofs +then + # Remove any partial copy to avoid attempted usage later + if test -e /run/image-rofs + then + ls -l /run/image-rofs + rm -f /run/image-rofs + fi + debug_takeover "Copying $rodev to /run/image-rofs failed." +fi + +if test -s /run/image-rofs +then + rodev=/run/image-rofs + roopts=$roopts,loop +fi + +mount $rodev $rodir -t $rofst -o $roopts + +if test -x $rodir$fsck +then + for fs in $fslist + do + mount --bind $fs $rodir/$fs + done + chroot $rodir $fsck $fsckopts $rwdev + rc=$? + for fs in $fslist + do + umount $rodir/$fs + done + if test $rc -gt 1 + then + debug_takeover "fsck of read-write fs on $rwdev failed (rc=$rc)" + fi +elif test "$rwfst" != jffs2 -a "$rwfst" != none +then + echo "No '$fsck' in read only fs, skipping fsck." +fi + +if test "$rwfst" = none +then + echo "Running with read-write overlay in RAM for this boot." + echo "No state will be preserved unless flash update performed." +elif ! mount $rwdev $rwdir -t $rwfst -o $rwopts +then + msg="$(cat)" << HERE + +Mounting read-write $rwdev filesystem failed. Please fix and run + mount $rwdev $rwdir -t $rwfst -o $rwopts +to to continue, or do change nothing to run from RAM for this boot. +HERE + debug_takeover "$msg" +fi + +rm -rf $work +mkdir -p $upper $work + +mount -t overlay -o lowerdir=$rodir,upperdir=$upper,workdir=$work cow /root + +while ! chroot /root /bin/sh -c "test -x '$init' -a -s '$init'" +do + msg="$(cat)" << HERE + +Unable to confirm /sbin/init is an executable non-empty file +in merged file system mounted at /root. + +Change Root test failed! Invoking emergency shell. +HERE + debug_takeover "$msg" +done + +for f in $fslist +do + mount --move $f root/$f +done + +# switch_root /root $init +exec chroot /root $init + diff --git a/meta-hpe/meta-common/recipes-phosphor/initrdscripts/obmc-phosphor-initfs.bbappend b/meta-hpe/meta-common/recipes-phosphor/initrdscripts/obmc-phosphor-initfs.bbappend new file mode 100644 index 0000000000..cdf163cea7 --- /dev/null +++ b/meta-hpe/meta-common/recipes-phosphor/initrdscripts/obmc-phosphor-initfs.bbappend @@ -0,0 +1,11 @@ +FILESEXTRAPATHS_prepend :="${THISDIR}/files:" + +SRC_URI += "file://gxp-obmc-init.sh \ + " + +do_install_append() { + install -m 0755 ${WORKDIR}/gxp-obmc-init.sh ${D}/init +} + +FILES_${PN} += " /init /shutdown /update /whitelist /dev " +FILES_${PN} += " /init-options /init-download-url " diff --git a/meta-hpe/meta-common/recipes-phosphor/packagegroups/packagegroup-hpe-apps.bb b/meta-hpe/meta-common/recipes-phosphor/packagegroups/packagegroup-hpe-apps.bb new file mode 100644 index 0000000000..82a748b91c --- /dev/null +++ b/meta-hpe/meta-common/recipes-phosphor/packagegroups/packagegroup-hpe-apps.bb @@ -0,0 +1,48 @@ +SUMMARY = "OpenBMC for HPE - Applications" +PR = "r1" + +inherit packagegroup + +PROVIDES = "${PACKAGES}" +PACKAGES = " \ + ${PN}-chassis \ + ${PN}-fans \ + ${PN}-flash \ + ${PN}-system \ + " + +PROVIDES += "virtual/obmc-chassis-mgmt" +PROVIDES += "virtual/obmc-fan-mgmt" +PROVIDES += "virtual/obmc-flash-mgmt" +PROVIDES += "virtual/obmc-system-mgmt" + +RPROVIDES_${PN}-chassis += "virtual-obmc-chassis-mgmt" +RPROVIDES_${PN}-fans += "virtual-obmc-fan-mgmt" +RPROVIDES_${PN}-flash += "virtual-obmc-flash-mgmt" +RPROVIDES_${PN}-system += "virtual-obmc-system-mgmt" + +SUMMARY_${PN}-chassis = "HPE Chassis" +RDEPENDS_${PN}-chassis = " \ + obmc-phosphor-buttons-signals \ + obmc-phosphor-buttons-handler \ + obmc-op-control-power \ + obmc-host-failure-reboots \ + " + +SUMMARY_${PN}-fans = "HPE Fans" +RDEPENDS_${PN}-fans = " \ + phosphor-pid-control \ + " + +SUMMARY_${PN}-flash = "HPE Flash" +RDEPENDS_${PN}-flash = " \ + obmc-control-bmc \ + " + +SUMMARY_${PN}-system = "HPE System" +RDEPENDS_${PN}-system = " \ + bmcweb \ + phosphor-webui \ + phosphor-ipmi-ipmb \ + dbus-sensors \ + " diff --git a/meta-hpe/meta-common/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bbappend b/meta-hpe/meta-common/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bbappend new file mode 100644 index 0000000000..fc6a055102 --- /dev/null +++ b/meta-hpe/meta-common/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bbappend @@ -0,0 +1,10 @@ +RDEPENDS_${PN}-logging += "phosphor-logging" +RDEPENDS_${PN}-extras += " bmcweb \ + phosphor-webui \ + phosphor-image-signing \ + phosphor-pid-control \ +" + +RDEPENDS_${PN}-fan-control = " \ + ${VIRTUAL-RUNTIME_obmc-fan-control} \ + " |