From 194ff4f1f5d44b12e9cb06ddafa6adb20174a13c Mon Sep 17 00:00:00 2001 From: Dave Cobbley Date: Wed, 22 Aug 2018 21:40:54 -0400 Subject: [Subtree] Bring openbmc machines to top level The new subtree model brings the subtrees up from the openbmc-machines layer. Change-Id: I58a03ae1be374bc79ae1438e65e888375d12d0c0 Signed-off-by: Dave Cobbley Signed-off-by: Brad Bishop --- meta-mellanox/conf/layer.conf | 5 + meta-mellanox/meta-msn/conf/bblayers.conf.sample | 35 ++ meta-mellanox/meta-msn/conf/conf-notes.txt | 2 + meta-mellanox/meta-msn/conf/layer.conf | 9 + meta-mellanox/meta-msn/conf/local.conf.sample | 21 + meta-mellanox/meta-msn/conf/machine/msn.conf | 9 + .../recipes-connectivity/mlx-ipmid/mlx-ipmid.bb | 13 + .../recipes-connectivity/mlx-ipmid/mlx-ipmid.inc | 60 +++ .../mlx-ipmid/mlx-ipmid/mlx_ipmid.service | 12 + .../mlx-ipmid/mlx-ipmid/remove_libdir.patch | 67 ++++ .../recipes-kernel/linux/linux-aspeed/msn.cfg | 21 + .../recipes-kernel/linux/linux-aspeed_%.bbappend | 3 + .../images/obmc-phosphor-image.bbappend | 1 + .../recipes-phosphor/initfs/files/failsafe-boot.sh | 30 ++ .../recipes-phosphor/initfs/files/obmc-init.sh | 430 +++++++++++++++++++++ .../initfs/files/obmc-update_all.sh | 54 +++ .../recipes-phosphor/initfs/files/recovery.sh | 52 +++ .../initfs/obmc-phosphor-initfs.bbappend | 16 + meta-mellanox/meta-msn/recipes.txt | 1 + 19 files changed, 841 insertions(+) create mode 100644 meta-mellanox/conf/layer.conf create mode 100644 meta-mellanox/meta-msn/conf/bblayers.conf.sample create mode 100644 meta-mellanox/meta-msn/conf/conf-notes.txt create mode 100644 meta-mellanox/meta-msn/conf/layer.conf create mode 100644 meta-mellanox/meta-msn/conf/local.conf.sample create mode 100644 meta-mellanox/meta-msn/conf/machine/msn.conf create mode 100644 meta-mellanox/meta-msn/recipes-connectivity/mlx-ipmid/mlx-ipmid.bb create mode 100644 meta-mellanox/meta-msn/recipes-connectivity/mlx-ipmid/mlx-ipmid.inc create mode 100644 meta-mellanox/meta-msn/recipes-connectivity/mlx-ipmid/mlx-ipmid/mlx_ipmid.service create mode 100644 meta-mellanox/meta-msn/recipes-connectivity/mlx-ipmid/mlx-ipmid/remove_libdir.patch create mode 100644 meta-mellanox/meta-msn/recipes-kernel/linux/linux-aspeed/msn.cfg create mode 100644 meta-mellanox/meta-msn/recipes-kernel/linux/linux-aspeed_%.bbappend create mode 100644 meta-mellanox/meta-msn/recipes-phosphor/images/obmc-phosphor-image.bbappend create mode 100644 meta-mellanox/meta-msn/recipes-phosphor/initfs/files/failsafe-boot.sh create mode 100644 meta-mellanox/meta-msn/recipes-phosphor/initfs/files/obmc-init.sh create mode 100644 meta-mellanox/meta-msn/recipes-phosphor/initfs/files/obmc-update_all.sh create mode 100644 meta-mellanox/meta-msn/recipes-phosphor/initfs/files/recovery.sh create mode 100644 meta-mellanox/meta-msn/recipes-phosphor/initfs/obmc-phosphor-initfs.bbappend create mode 100644 meta-mellanox/meta-msn/recipes.txt (limited to 'meta-mellanox') diff --git a/meta-mellanox/conf/layer.conf b/meta-mellanox/conf/layer.conf new file mode 100644 index 000000000..9b1c6b976 --- /dev/null +++ b/meta-mellanox/conf/layer.conf @@ -0,0 +1,5 @@ +# We have a conf and classes directory, add to BBPATH +BBPATH .= ":${LAYERDIR}" + +BBFILE_COLLECTIONS += "mellanox" +BBFILE_PATTERN_mellanox = "" diff --git a/meta-mellanox/meta-msn/conf/bblayers.conf.sample b/meta-mellanox/meta-msn/conf/bblayers.conf.sample new file mode 100644 index 000000000..1f34a692e --- /dev/null +++ b/meta-mellanox/meta-msn/conf/bblayers.conf.sample @@ -0,0 +1,35 @@ +# LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf +# changes incompatibly +LCONF_VERSION = "8" + +BBPATH = "${TOPDIR}" +BBFILES ?= "" + +BBLAYERS ?= " \ + ##OEROOT##/meta \ + ##OEROOT##/meta-poky \ + ##OEROOT##/meta-openembedded/meta-oe \ + ##OEROOT##/meta-openembedded/meta-networking \ + ##OEROOT##/meta-openembedded/meta-perl \ + ##OEROOT##/meta-openembedded/meta-python \ + ##OEROOT##/meta-openembedded/meta-webserver \ + ##OEROOT##/meta-phosphor \ + ##OEROOT##/meta-aspeed \ + ##OEROOT##/meta-x86 \ + ##OEROOT##/meta-mellanox \ + ##OEROOT##/meta-mellanox/meta-msn \ + " +BBLAYERS_NON_REMOVABLE ?= " \ + ##OEROOT##/meta \ + ##OEROOT##/meta-poky \ + ##OEROOT##/meta-openembedded/meta-oe \ + ##OEROOT##/meta-openembedded/meta-networking \ + ##OEROOT##/meta-openembedded/meta-perl \ + ##OEROOT##/meta-openembedded/meta-python \ + ##OEROOT##/meta-openembedded/meta-webserver \ + ##OEROOT##/meta-phosphor \ + ##OEROOT##/meta-aspeed \ + ##OEROOT##/meta-x86 \ + ##OEROOT##/meta-mellanox \ + ##OEROOT##/meta-mellanox/meta-msn \ + " diff --git a/meta-mellanox/meta-msn/conf/conf-notes.txt b/meta-mellanox/meta-msn/conf/conf-notes.txt new file mode 100644 index 000000000..9b3c01a55 --- /dev/null +++ b/meta-mellanox/meta-msn/conf/conf-notes.txt @@ -0,0 +1,2 @@ +Common targets are: + obmc-phosphor-image diff --git a/meta-mellanox/meta-msn/conf/layer.conf b/meta-mellanox/meta-msn/conf/layer.conf new file mode 100644 index 000000000..a5711698f --- /dev/null +++ b/meta-mellanox/meta-msn/conf/layer.conf @@ -0,0 +1,9 @@ +# We have a conf and classes directory, add to BBPATH +BBPATH .= ":${LAYERDIR}" + +# We have recipes-* directories, add to BBFILES +BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \ + ${LAYERDIR}/recipes-*/*/*.bbappend" + +BBFILE_COLLECTIONS += "msn" +BBFILE_PATTERN_msn = "" diff --git a/meta-mellanox/meta-msn/conf/local.conf.sample b/meta-mellanox/meta-msn/conf/local.conf.sample new file mode 100644 index 000000000..2547907ca --- /dev/null +++ b/meta-mellanox/meta-msn/conf/local.conf.sample @@ -0,0 +1,21 @@ +MACHINE ??= "msn" +DISTRO ?= "openbmc-phosphor" +PACKAGE_CLASSES ?= "package_rpm" +SANITY_TESTED_DISTROS_append ?= " *" +EXTRA_IMAGE_FEATURES = "debug-tweaks" +USER_CLASSES ?= "buildstats image-mklibs image-prelink" +PATCHRESOLVE = "noop" +BB_DISKMON_DIRS = "\ + STOPTASKS,${TMPDIR},1G,100K \ + STOPTASKS,${DL_DIR},1G,100K \ + STOPTASKS,${SSTATE_DIR},1G,100K \ + STOPTASKS,/tmp,100M,100K \ + ABORT,${TMPDIR},100M,1K \ + ABORT,${DL_DIR},100M,1K \ + ABORT,${SSTATE_DIR},100M,1K \ + ABORT,/tmp,10M,1K" +CONF_VERSION = "1" +INHERIT += "extrausers" +EXTRA_USERS_PARAMS = " \ + usermod -p '\$1\$UGMqyqdG\$FZiylVFmRRfl9Z0Ue8G7e/' root; \ + " diff --git a/meta-mellanox/meta-msn/conf/machine/msn.conf b/meta-mellanox/meta-msn/conf/machine/msn.conf new file mode 100644 index 000000000..af2229e7f --- /dev/null +++ b/meta-mellanox/meta-msn/conf/machine/msn.conf @@ -0,0 +1,9 @@ +KMACHINE = "aspeed" +KERNEL_DEVICETREE = "${KMACHINE}-bmc-mellanox-${MACHINE}.dtb" + +UBOOT_MACHINE = "ast_g5_ncsi_config" + +FLASH_SIZE = "32768" + +require conf/machine/include/ast2500.inc +require conf/machine/include/obmc-bsp-common.inc diff --git a/meta-mellanox/meta-msn/recipes-connectivity/mlx-ipmid/mlx-ipmid.bb b/meta-mellanox/meta-msn/recipes-connectivity/mlx-ipmid/mlx-ipmid.bb new file mode 100644 index 000000000..0236c2485 --- /dev/null +++ b/meta-mellanox/meta-msn/recipes-connectivity/mlx-ipmid/mlx-ipmid.bb @@ -0,0 +1,13 @@ +PV = "git${SRCPV}" + +MLX_IPMID_BRANCH = "openbmc" + +FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" + +SRC_URI = "git://github.com/mellanoxbmc/ipmi.git;protocol=git;branch=${MLX_IPMID_BRANCH};" +SRC_URI += "file://mlx_ipmid.service" +SRC_URI += "file://remove_libdir.patch" + +SRCREV = "${AUTOREV}" + +require mlx-ipmid.inc diff --git a/meta-mellanox/meta-msn/recipes-connectivity/mlx-ipmid/mlx-ipmid.inc b/meta-mellanox/meta-msn/recipes-connectivity/mlx-ipmid/mlx-ipmid.inc new file mode 100644 index 000000000..73e7614f6 --- /dev/null +++ b/meta-mellanox/meta-msn/recipes-connectivity/mlx-ipmid/mlx-ipmid.inc @@ -0,0 +1,60 @@ +DESCRIPTION = "This is the OpenIPMI library, a library that makes simplifies building complex IPMI management software." +SECTION = "console/network" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f" +DEPENDS = " \ + openssl \ + popt \ + zlib \ + ncurses \ + glib-2.0 \ + gdbm \ + dbus \ + dbus-glib \ +" +RDEPENDS_${PN} += " bash dbus" + +INC_PR = "r2" + +inherit autotools gettext update-alternatives systemd pkgconfig + +PACKAGECONFIG ??= "net-snmp" + +PACKAGECONFIG[net-snmp] = ",--with-ucdsnmp=no,net-snmp" +PACKAGECONFIG[python] = "--with-python,--without-python,python," +PACKAGECONFIG[perl] = "--with-perl=${STAGING_BINDIR_NATIVE},--with-perl=no,perl," +PACKAGECONFIG[tcl] = "--with-tcl,--without-tcl,tcl," + +EXTRA_OECONF = "\ + --prefix=${prefix} \ + --with-mellanox \ + --with-dbus \ + " + +S = "${WORKDIR}/git" + +PARALLEL_MAKEINST = "" + +SYSTEMD_PACKAGES = "${PN}" + +SYSTEMD_SERVICE_${PN} = " mlx_ipmid.service" + + +do_install_append() { + install -d ${D}/etc/init.d + install -d ${D}/${systemd_unitdir}/system + install -m 644 ${WORKDIR}/mlx_ipmid.service ${D}/${systemd_unitdir}/system/mlx_ipmid.service + install -d ${D}${libdir}/mlx_ipmid + install -m 0644 ${B}/lanserv/mellanox/.libs/mellanox.so ${D}${libdir}/mlx_ipmid/ + install -Dpm 644 ${D}/var/mlx_ipmid/mellanox/50-mlx-events-4.10.rules ${D}/lib/udev/rules.d/50-mlx-events.rules + install -Dpm 644 ${D}/var/mlx_ipmid/mellanox/50-mlx-hwmon-4-10-events.rules ${D}/lib/udev/rules.d/50-mlx-hwmon-events.rules +} + +FILES_${PN} += "/usr/lib/perl5 \ + /usr/lib/mlx_ipmid \ + ${systemd_unitdir} \ + " + +FILES_${PN}-dev += "/usr/lib/OpenIPMI" + +FILES_${PN}-dbg += "/usr/lib/perl5/auto/OpenIPMI/.debug" diff --git a/meta-mellanox/meta-msn/recipes-connectivity/mlx-ipmid/mlx-ipmid/mlx_ipmid.service b/meta-mellanox/meta-msn/recipes-connectivity/mlx-ipmid/mlx-ipmid/mlx_ipmid.service new file mode 100644 index 000000000..09abe1e65 --- /dev/null +++ b/meta-mellanox/meta-msn/recipes-connectivity/mlx-ipmid/mlx-ipmid/mlx_ipmid.service @@ -0,0 +1,12 @@ +[Unit] +Description=mlx_ipmid + +[Service] +Restart=always +OOMScoreAdjust=-1000 + +ExecStart=/usr/bin/mlx_ipmid -n +TimeoutSec=120 + +[Install] +WantedBy=multi-user.target diff --git a/meta-mellanox/meta-msn/recipes-connectivity/mlx-ipmid/mlx-ipmid/remove_libdir.patch b/meta-mellanox/meta-msn/recipes-connectivity/mlx-ipmid/mlx-ipmid/remove_libdir.patch new file mode 100644 index 000000000..e74e06f2b --- /dev/null +++ b/meta-mellanox/meta-msn/recipes-connectivity/mlx-ipmid/mlx-ipmid/remove_libdir.patch @@ -0,0 +1,67 @@ +diff --git a/cmdlang/Makefile.am b/cmdlang/Makefile.am +index e80090d..b59ff24 100644 +--- a/cmdlang/Makefile.am ++++ b/cmdlang/Makefile.am +@@ -16,7 +16,7 @@ libOpenIPMIcmdlang_la_LIBADD = -lm \ + $(top_builddir)/utils/libOpenIPMIutils.la \ + $(top_builddir)/lib/libOpenIPMI.la + libOpenIPMIcmdlang_la_LDFLAGS = -rdynamic -version-info $(LD_VERSION) \ +- -Wl,-Map -Wl,libOpenIPMIcmdlang.map -L$(libdir) ++ -Wl,-Map -Wl,libOpenIPMIcmdlang.map + + bin_PROGRAMS = openipmish + +diff --git a/glib/Makefile.am b/glib/Makefile.am +index 671cae2..eff55f3 100644 +--- a/glib/Makefile.am ++++ b/glib/Makefile.am +@@ -11,14 +11,14 @@ libOpenIPMIglib_la_SOURCES = glib_os_hnd.c + libOpenIPMIglib_la_CFLAGS = $(GLIB_CFLAGS) $(AM_CFLAGS) + libOpenIPMIglib_la_LIBADD = $(GDBM_LIB) + libOpenIPMIglib_la_LDFLAGS = -rdynamic -version-info $(LD_VERSION) \ +- -Wl,-Map -Wl,libOpenIPMIglib.map $(GLIB_LIBS) -L$(libdir) \ ++ -Wl,-Map -Wl,libOpenIPMIglib.map $(GLIB_LIBS) \ + -rpath $(libdir) + + libOpenIPMIglib12_la_SOURCES = glib_os_hnd.c + libOpenIPMIglib12_la_CFLAGS = $(GLIB12_CFLAGS) $(AM_CFLAGS) + libOpenIPMIglib12_la_LIBADD = $(GDBM_LIB) + libOpenIPMIglib12_la_LDFLAGS = -rdynamic -version-info $(LD_VERSION) \ +- -Wl,-Map -Wl,libOpenIPMIglib12.map $(GLIB12_LIBS) -L$(libdir) \ ++ -Wl,-Map -Wl,libOpenIPMIglib12.map $(GLIB12_LIBS) \ + -rpath $(libdir) + + CLEANFILES = libOpenIPMIglib.map libOpenIPMIglib12.map +diff --git a/tcl/Makefile.am b/tcl/Makefile.am +index e2a98dc..256af0c 100644 +--- a/tcl/Makefile.am ++++ b/tcl/Makefile.am +@@ -11,7 +11,7 @@ libOpenIPMItcl_la_SOURCES = tcl_os_hnd.c + libOpenIPMItcl_la_CFLAGS = $(TCL_CFLAGS) $(AM_CFLAGS) + libOpenIPMItcl_la_LIBADD = $(GDBM_LIB) + libOpenIPMItcl_la_LDFLAGS = -rdynamic -version-info $(LD_VERSION) \ +- -Wl,-Map -Wl,libOpenIPMItcl.map $(TCL_LIBS) -L$(libdir) \ ++ -Wl,-Map -Wl,libOpenIPMItcl.map $(TCL_LIBS) \ + -rpath $(libdir) + + noinst_PROGRAMS = test_handlers +diff --git a/unix/Makefile.am b/unix/Makefile.am +index ac5b9f4..d5d4b82 100644 +--- a/unix/Makefile.am ++++ b/unix/Makefile.am +@@ -11,13 +11,13 @@ libOpenIPMIpthread_la_SOURCES = posix_thread_os_hnd.c selector.c + libOpenIPMIpthread_la_LIBADD = -lpthread $(GDBM_LIB) \ + $(top_builddir)/utils/libOpenIPMIutils.la + libOpenIPMIpthread_la_LDFLAGS = -rdynamic -version-info $(LD_VERSION) \ +- -Wl,-Map -Wl,libOpenIPMIpthread.map -L$(libdir) ++ -Wl,-Map -Wl,libOpenIPMIpthread.map + + libOpenIPMIposix_la_SOURCES = posix_os_hnd.c selector.c + libOpenIPMIposix_la_LIBADD = $(top_builddir)/utils/libOpenIPMIutils.la \ + $(GDBM_LIB) + libOpenIPMIposix_la_LDFLAGS = -rdynamic -version-info $(LD_VERSION) \ +- -Wl,-Map -Wl,libOpenIPMIposix.map -L$(libdir) ++ -Wl,-Map -Wl,libOpenIPMIposix.map + + noinst_HEADERS = heap.h + diff --git a/meta-mellanox/meta-msn/recipes-kernel/linux/linux-aspeed/msn.cfg b/meta-mellanox/meta-msn/recipes-kernel/linux/linux-aspeed/msn.cfg new file mode 100644 index 000000000..e0df616f2 --- /dev/null +++ b/meta-mellanox/meta-msn/recipes-kernel/linux/linux-aspeed/msn.cfg @@ -0,0 +1,21 @@ +CONFIG_NET_VENDOR_MELLANOX=y +CONFIG_MLXSW_CORE=y +CONFIG_MLXSW_CORE_HWMON=y +CONFIG_MLXSW_CORE_THERMAL=y +CONFIG_MLXSW_I2C=y +CONFIG_MLXSW_MINIMAL=y +CONFIG_OF_UNITTEST=y +CONFIG_OF_DYNAMIC=y +CONFIG_MFD_MLXREG_CORE=y +CONFIG_MFD_MLXREG_I2C=y +CONFIG_LEDS_MLXREG=y +CONFIG_MLXREG_HOTPLUG=y +CONFIG_SENSORS_TPS53679=y +CONFIG_SENSORS_TMP102=y +CONFIG_SENSORS_MAX6621=y +CONFIG_THERMAL=y +CONFIG_THERMAL_HWMON=y +CONFIG_THERMAL_OF=y +CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y +CONFIG_THERMAL_GOV_STEP_WISE=y +CONFIG_FSI=n diff --git a/meta-mellanox/meta-msn/recipes-kernel/linux/linux-aspeed_%.bbappend b/meta-mellanox/meta-msn/recipes-kernel/linux/linux-aspeed_%.bbappend new file mode 100644 index 000000000..35e9d9b33 --- /dev/null +++ b/meta-mellanox/meta-msn/recipes-kernel/linux/linux-aspeed_%.bbappend @@ -0,0 +1,3 @@ +FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" + +SRC_URI += "file://msn.cfg" \ No newline at end of file diff --git a/meta-mellanox/meta-msn/recipes-phosphor/images/obmc-phosphor-image.bbappend b/meta-mellanox/meta-msn/recipes-phosphor/images/obmc-phosphor-image.bbappend new file mode 100644 index 000000000..fb6a24439 --- /dev/null +++ b/meta-mellanox/meta-msn/recipes-phosphor/images/obmc-phosphor-image.bbappend @@ -0,0 +1 @@ +OBMC_IMAGE_EXTRA_INSTALL_append = " mlx-ipmid" diff --git a/meta-mellanox/meta-msn/recipes-phosphor/initfs/files/failsafe-boot.sh b/meta-mellanox/meta-msn/recipes-phosphor/initfs/files/failsafe-boot.sh new file mode 100644 index 000000000..ea1bd0711 --- /dev/null +++ b/meta-mellanox/meta-msn/recipes-phosphor/initfs/files/failsafe-boot.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +echo "---------------- +System entered recovery mode. Running from backup flash!!! +help for get ip: +ifconfig eth0 $IP netmask $NETMASK up; +route add default gw $GATEWAY eth0 +Or type udhcpc to get ip over dhcp. +Please scp image file to /tmp folder and re-burn main flash with: +/run/initramfs/recovery /tmp/. +----------------"; + +mkdir /run/lock; + +mkdir /dev/mtd; + +ln -s /run/mtd\:u-boot-env /dev/mtd/u-boot-env; + +/usr/bin/mlx-hw-events.sh add reset /sys/devices/platform/ahb/ahb:apb/ahb:apb:i2c@1e78a000/1e78a140.i2c-bus/i2c-4/4-0071/mlxreg-core.1137/hwmon/hwmon*; + +mount /dev/mtdblock5 /run/initramfs/rw -t jffs2 -o remount,ro; +mount tmpfs tmp -t tmpfs -o mode=755,nodev; + +export PS1="(recovery)\u@BMC:\w\$" + +while true; +do + /run/initramfs/ro/sbin/sulogin; +done + diff --git a/meta-mellanox/meta-msn/recipes-phosphor/initfs/files/obmc-init.sh b/meta-mellanox/meta-msn/recipes-phosphor/initfs/files/obmc-init.sh new file mode 100644 index 000000000..55862aac3 --- /dev/null +++ b/meta-mellanox/meta-msn/recipes-phosphor/initfs/files/obmc-init.sh @@ -0,0 +1,430 @@ +#!/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 failsafe recovery shutdown update update_all 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 environemnt 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 "$@" + test -n "$@" && echo Enter password to try to manually fix. + 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 +} + +env=$(findmtd u-boot-env) +if test -n $env +then + ln -s /dev/$env /run/mtd:u-boot-env + cp /run/mtd:u-boot-env /run/fw_env +fi + +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 +failsafe=/run/initramfs/failsafe +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 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 + echo "Saving selected files from read-write overlay filesystem." + $update --no-restore-files + 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 + 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 +ln -s /root/dev/mem /dev/mem +FLASH_CP=`/root/sbin/devmem 0x1e785030` +FLASH_CP=$(($FLASH_CP&0x02)) +rm /dev/mem + +if [ $FLASH_CP == 0 ]; then +# echo "Flash 1 used. Normal boot."; + exec chroot /root $init; +else + exec chroot /root $failsafe; +fi + diff --git a/meta-mellanox/meta-msn/recipes-phosphor/initfs/files/obmc-update_all.sh b/meta-mellanox/meta-msn/recipes-phosphor/initfs/files/obmc-update_all.sh new file mode 100644 index 000000000..fbcf466d6 --- /dev/null +++ b/meta-mellanox/meta-msn/recipes-phosphor/initfs/files/obmc-update_all.sh @@ -0,0 +1,54 @@ +#!/bin/sh +# +# Script to burn entire 32MB of BMC SPI Flash +# +# Usage: +# a) Local: /run/initramfs/update_all +# b) Remote: sshpass -p "" ssh root@ '/run/initramfs/update_all ' +# +# Assumptions: +# is a 32MB file representing all partitions in BMC SPI Flash +# exists on local filesystem +# /dev/mtd0 represents entire BMC SPI Flash device +# /dev/mtd5 is a JFFS2 filesystem (rwfs) partition +# /bsp/reset/bmc_upgrade is symlink pointing to proper sticky bit in CPLD +# + +if [ -f $1 ] +then + echo $0: Update BMC SPI Flash with $1 +else + echo $0: File $1 not found on target, exiting + exit +fi + +echo $0: Stopping system services +systemctl stop mlx_ipmid + +echo $0: Remounting rwfs "(/dev/mtd5)" as read-only +mount /dev/mtdblock5 /run/initramfs/rw -t jffs2 -o remount,ro + +echo $0: Unmounting rofs "(/dev/mtd4)" +umount /dev/mtdblock4 + +MAC=`fw_printenv ethaddr | sed -n "s/^ethaddr=//p"` + +echo $0: Burning SPI Flash "(/dev/mtd0)" with image "$1" +/usr/sbin/flashcp -v $1 /dev/mtd0 + +if [ -v $MAC ]; then + echo "MAC env variable not exist. Set eth0 MAC from eeprom." + MAC=`hexdump -n 6 -s 0xf0 -v -e '/1 "%02x:"' /sys/bus/i2c/devices/6-0055/eeprom`;MAC=${MAC::-1}; +else + echo "MAC env variable exist. Set eth0 MAC from env." +fi; +fw_setenv ethaddr $MAC + +echo $0: Setting bmc_upgrade sticky bit in CPLD +echo 1 > /bsp/reset/bmc_upgrade + +echo $0: Rebooting BMC +echo 0 > /bsp/reset/bmc_reset_soft + + + diff --git a/meta-mellanox/meta-msn/recipes-phosphor/initfs/files/recovery.sh b/meta-mellanox/meta-msn/recipes-phosphor/initfs/files/recovery.sh new file mode 100644 index 000000000..256e18fdb --- /dev/null +++ b/meta-mellanox/meta-msn/recipes-phosphor/initfs/files/recovery.sh @@ -0,0 +1,52 @@ + +#!/bin/sh +# +# Script to burn entire 32MB of BMC SPI Flash 1 +# +# Usage: +# a) Local: /run/initramfs/recovery +# +# Assumptions: +# is a 32MB file representing all partitions in BMC SPI Flash +# exists on local filesystem +# /dev/mtd0 represents entire BMC SPI Flash device +# /dev/mtd5 is a JFFS2 filesystem (rwfs) partition +# /bsp/reset/bmc_upgrade is symlink pointing to proper sticky bit in CPLD +# + +if [ -f $1 ] +then + echo $0: Update BMC SPI Flash with $1 +else + echo $0: File $1 not found on target, exiting + exit +fi + +echo $0: Remounting rwfs "(/dev/mtd5)" as read-only +mount /dev/mtdblock5 /run/initramfs/rw -t jffs2 -o remount,ro + +echo $0: Unmounting rofs "(/dev/mtd4)" +umount /dev/mtdblock4 + +devmem 0x1e785034 l 0x01; + +MAC=`fw_printenv ethaddr | sed -n "s/^ethaddr=//p"` + +echo $0: Burning SPI Flash "(/dev/mtd0)" with image "$1" +/usr/sbin/flashcp -v $1 /dev/mtd0 + +if [ -v $MAC ]; then + echo "MAC env variable not exist. Set eth0 MAC from eeprom." + MAC=`hexdump -n 6 -s 0xf0 -v -e '/1 "%02x:"' /sys/bus/i2c/devices/6-0055/eeprom`;MAC=${MAC::-1}; +else + echo "MAC env variable exist. Set eth0 MAC from env." +fi; + +fw_setenv ethaddr $MAC + +echo $0: Setting bmc_upgrade sticky bit in CPLD +echo 1 > /bsp/reset/bmc_upgrade + +echo $0: Rebooting BMC +echo 0 > /bsp/reset/bmc_reset_soft + diff --git a/meta-mellanox/meta-msn/recipes-phosphor/initfs/obmc-phosphor-initfs.bbappend b/meta-mellanox/meta-msn/recipes-phosphor/initfs/obmc-phosphor-initfs.bbappend new file mode 100644 index 000000000..9ad6bc849 --- /dev/null +++ b/meta-mellanox/meta-msn/recipes-phosphor/initfs/obmc-phosphor-initfs.bbappend @@ -0,0 +1,16 @@ +FILESEXTRAPATHS_prepend := "${THISDIR}/files:" + +SRC_URI += "file://obmc-init.sh" +SRC_URI += "file://obmc-update_all.sh" +SRC_URI += "file://failsafe-boot.sh" +SRC_URI += "file://recovery.sh" + + +do_install_append() { + install -m 0755 ${WORKDIR}/obmc-init.sh ${D}/init + install -m 0755 ${WORKDIR}/failsafe-boot.sh ${D}/failsafe + install -m 0755 ${WORKDIR}/obmc-update_all.sh ${D}/update_all + install -m 0755 ${WORKDIR}/recovery.sh ${D}/recovery +} + +FILES_${PN} += " /update_all /failsafe /recovery" diff --git a/meta-mellanox/meta-msn/recipes.txt b/meta-mellanox/meta-msn/recipes.txt new file mode 100644 index 000000000..c58366847 --- /dev/null +++ b/meta-mellanox/meta-msn/recipes.txt @@ -0,0 +1 @@ +recipes-phosphor - Phosphor OpenBMC applications and configuration -- cgit v1.2.1