Initial commit
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
# 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 += "common-layer"
|
||||
BBFILE_PATTERN_common-layer := "^${LAYERDIR}/"
|
||||
LAYERSERIES_COMPAT_common-layer = "mickledore"
|
||||
@@ -0,0 +1,20 @@
|
||||
SUMMARY = "Enable Host Boot"
|
||||
PR = "r1"
|
||||
LICENSE = "Apache-2.0"
|
||||
LIC_FILES_CHKSUM = "file://${HPEBASE}/COPYING.apache-2.0;md5=34400b68072d710fecd0a2940a0d1658"
|
||||
|
||||
inherit obmc-phosphor-systemd
|
||||
|
||||
HOST_BOOT_SERVICE = "host-boot-enable.service"
|
||||
SYSTEMD_SERVICE:${PN} += "${HOST_BOOT_SERVICE}"
|
||||
|
||||
HOST_BOOT_FMT = "../${HOST_BOOT_SERVICE}:multi-user.target.wants/${HOST_BOOT_SERVICE}"
|
||||
SYSTEMD_LINK_${PN} += "${HOST_BOOT_FMT}"
|
||||
|
||||
SRC_URI += "file://host-boot-enable.service"
|
||||
SRC_URI += "file://host-boot-enable.sh"
|
||||
|
||||
do_install() {
|
||||
install -d ${D}${bindir}
|
||||
install -m 0755 ${WORKDIR}/host-boot-enable.sh ${D}${bindir}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=Enable Host Boot
|
||||
Wants=phosphor-ipmi-host.service
|
||||
After=phosphor-ipmi-host.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/bin/sh -c "host-boot-enable.sh"
|
||||
SyslogIdentifier=host-boot-enable
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
StartLimitInterval=0
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,38 @@
|
||||
#!/bin/sh
|
||||
|
||||
findmtd() {
|
||||
m=$(grep -xl "$1" /sys/class/mtd/*/name)
|
||||
m=${m%/name}
|
||||
m=${m##*/}
|
||||
echo "$m"
|
||||
}
|
||||
|
||||
set -- host-prime host-second vrom-prime vrom-second
|
||||
|
||||
for f in "$@"
|
||||
do
|
||||
image=$(findmtd "${f}")
|
||||
if test -z "$image"
|
||||
then
|
||||
echo "Unable to find mtd partition for ${f}"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
#enable vrom
|
||||
# host-prime to vrom-prime
|
||||
dd if="/dev/$(findmtd host-prime)" of="/dev/$(findmtd vrom-prime)"
|
||||
# host-second to vrom-second
|
||||
dd if="/dev/$(findmtd host-second)" of="/dev/$(findmtd vrom-second)"
|
||||
|
||||
echo 0x1800008a > /sys/class/soc/srom/vromoff
|
||||
|
||||
val=$(( ("$(devmem 0xd1000006 8)" && 0xff) | 0x04 ))
|
||||
devmem 0xd1000006 8 $val
|
||||
devmem 0xd1000018 8 0xff
|
||||
while true
|
||||
do
|
||||
devmem 0xd100000f 8 0x14
|
||||
sleep 1
|
||||
done
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
|
||||
|
||||
# platform configuration files
|
||||
SRC_URI += "file://hpe-publish-uefi-version.sh"
|
||||
|
||||
do_install:append() {
|
||||
install -D ${WORKDIR}/hpe-publish-uefi-version ${D}/usr/bin/hpe-publish-uefi-version
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright (c) 2021 Hewlett-Packard Development Company, L.P.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
# RL300 doesn't support VROM, so we will be reading directly from
|
||||
# SPI-NOR. The whole process is a little bit slow but works
|
||||
|
||||
# Find an MTD /dev file by name
|
||||
findmtd() {
|
||||
echo "parameter $1"
|
||||
m=$(grep -xl "$1" /sys/class/mtd/*/name)
|
||||
m=${m%/name}
|
||||
m=${m##*/}
|
||||
echo "$m"
|
||||
}
|
||||
|
||||
rom=uefi-master
|
||||
echo "Checking for mtd partition ${rom}"
|
||||
image=$(findmtd ${rom})
|
||||
if test -z "$image"
|
||||
then
|
||||
echo "Unable to find mtd partition for ${rom}"
|
||||
exit 1
|
||||
fi
|
||||
rom_mtd=${image}
|
||||
|
||||
uefi_version="hpe-uefi-version /dev/${rom_mtd}"
|
||||
busctl set-property xyz.openbmc_project.Software.BMC.Updater /xyz/openbmc_project/software/bios_active xyz.openbmc_project.Software.Version Version s "$uefi_version"
|
||||
busctl get-property xyz.openbmc_project.Software.BMC.Updater /xyz/openbmc_project/software/bios_active xyz.openbmc_project.Software.Version Version
|
||||
@@ -0,0 +1,44 @@
|
||||
SUMMARY = "GXP EHCI Owner Reset"
|
||||
PR = "r1"
|
||||
LICENSE = "Apache-2.0"
|
||||
LIC_FILES_CHKSUM = "file://${HPEBASE}/COPYING.apache-2.0;md5=34400b68072d710fecd0a2940a0d1658"
|
||||
|
||||
inherit obmc-phosphor-systemd
|
||||
|
||||
DEPENDS += "phosphor-gpio-monitor"
|
||||
RDEPENDS:${PN} += "phosphor-gpio-monitor-monitor"
|
||||
|
||||
SYSTEMD_ENVIRONMENT_FILE:${PN} += "obmc/gpio/port_owner_udc0"
|
||||
SYSTEMD_ENVIRONMENT_FILE:${PN} += "obmc/gpio/port_owner_udc1"
|
||||
SYSTEMD_ENVIRONMENT_FILE:${PN} += "obmc/gpio/port_owner_udc2"
|
||||
|
||||
UDC0_GPIO = "port_owner_udc0"
|
||||
UDC1_GPIO = "port_owner_udc1"
|
||||
UDC2_GPIO = "port_owner_udc2"
|
||||
TMPL_GPIO = "phosphor-gpio-monitor@.service"
|
||||
INSTFMT_GPIO = "phosphor-gpio-monitor@{0}.service"
|
||||
TGT_GPIO = "multi-user.target.requires"
|
||||
FMT_GPIO = "../${TMPL_GPIO}:${TGT_GPIO}/${INSTFMT_GPIO}"
|
||||
SYSTEMD_LINK:${PN} += "${@compose_list(d, 'FMT_GPIO', 'UDC0_GPIO')}"
|
||||
SYSTEMD_LINK:${PN} += "${@compose_list(d, 'FMT_GPIO', 'UDC1_GPIO')}"
|
||||
SYSTEMD_LINK:${PN} += "${@compose_list(d, 'FMT_GPIO', 'UDC2_GPIO')}"
|
||||
|
||||
UDC0_VEHCI = "udc0"
|
||||
UDC1_VEHCI = "udc1"
|
||||
UDC2_VEHCI = "udc2"
|
||||
TMPL_VEHCI = "host-ehci-owner-reset@.service"
|
||||
INSTFMT_VEHCI = "host-ehci-owner-reset@{0}.service"
|
||||
FMT_VEHCI = "${TMPL_VEHCI}:${INSTFMT_VEHCI}"
|
||||
SYSTEMD_LINK:${PN} += "${@compose_list(d, 'FMT_VEHCI', 'UDC0_VEHCI')}"
|
||||
SYSTEMD_LINK:${PN} += "${@compose_list(d, 'FMT_VEHCI', 'UDC1_VEHCI')}"
|
||||
SYSTEMD_LINK:${PN} += "${@compose_list(d, 'FMT_VEHCI', 'UDC2_VEHCI')}"
|
||||
|
||||
SYSTEMD_SERVICE:${PN} += "host-ehci-owner-reset@.service"
|
||||
|
||||
SRC_URI += "file://udc-reconnect.sh"
|
||||
SRC_URI += "file://host-ehci-owner-reset@.service"
|
||||
|
||||
do_install() {
|
||||
install -d ${D}${bindir}
|
||||
install -m 755 ${WORKDIR}/udc-reconnect.sh ${D}${bindir}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
[Unit]
|
||||
Description=GXP EHCI Owner Reset Service
|
||||
Wants=start-ipkvm.service
|
||||
After=start-ipkvm.service
|
||||
StartLimitIntervalSec=0
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/bin/sh -c "udc-reconnect.sh %i"
|
||||
SyslogIdentifier=host-ehci-owner-reset@%i
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
DEVPATH=/dev/input/by-path/platform-ahb@80000000:vuhc-event
|
||||
KEY=200
|
||||
POLARITY=1
|
||||
TARGET=host-ehci-owner-reset@udc0.service
|
||||
EXTRA_ARGS=--continue
|
||||
@@ -0,0 +1,5 @@
|
||||
DEVPATH=/dev/input/by-path/platform-ahb@80000000:vuhc-event
|
||||
KEY=201
|
||||
POLARITY=1
|
||||
TARGET=host-ehci-owner-reset@udc1.service
|
||||
EXTRA_ARGS=--continue
|
||||
@@ -0,0 +1,5 @@
|
||||
DEVPATH=/dev/input/by-path/platform-ahb@80000000:vuhc-event
|
||||
KEY=202
|
||||
POLARITY=1
|
||||
TARGET=host-ehci-owner-reset@udc2.service
|
||||
EXTRA_ARGS=--continue
|
||||
@@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "$1" = "udc0" ]; then
|
||||
function=$(cat /sys/class/udc/80401000.udc/function)
|
||||
if [ "func-$function" != "func-" ]; then
|
||||
echo "UDC0 owner is changed"
|
||||
echo disconnect > /sys/class/udc/80401000.udc/soft_connect
|
||||
sleep 3
|
||||
echo connect > /sys/class/udc/80401000.udc/soft_connect
|
||||
else
|
||||
echo "UDC0 is not attached"
|
||||
fi
|
||||
else
|
||||
if [ "$1" = "udc1" ]; then
|
||||
function=$(cat /sys/class/udc/80402000.udc/function)
|
||||
if [ "func-$function" != "func-" ]; then
|
||||
echo "UDC1 owner is changed"
|
||||
echo disconnect > /sys/class/udc/80402000.udc/soft_connect
|
||||
sleep 3
|
||||
echo connect > /sys/class/udc/80402000.udc/soft_connect
|
||||
else
|
||||
echo "UDC1 is not attached"
|
||||
fi
|
||||
else
|
||||
if [ "$1" = "udc2" ]; then
|
||||
function=$(cat /sys/class/udc/80403000.udc/function)
|
||||
if [ "func-$function" != "func-" ]; then
|
||||
echo "UDC2 owner is changed"
|
||||
echo disconnect > /sys/class/udc/80403000.udc/soft_connect
|
||||
sleep 3
|
||||
echo connect > /sys/class/udc/80403000.udc/soft_connect
|
||||
else
|
||||
echo "UDC2 is not attached"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
@@ -0,0 +1,2 @@
|
||||
SNOOP_DEVICE = "postcode"
|
||||
|
||||
@@ -0,0 +1,214 @@
|
||||
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_HEADER_512 ?= "hpe-uboot-header-512.section"
|
||||
HPE_UBOOT_SIGNING_KEY ?= "hpe-uboot-signing-key.pem"
|
||||
|
||||
# Offsets that are the same for the standard image and secure boot image
|
||||
FLASH_SIZE = "31552"
|
||||
FLASH_UBOOT_OFFSET = "0"
|
||||
UBOOT_IMG_SIZE = "393216"
|
||||
FLASH_KERNEL_OFFSET = "512"
|
||||
FLASH_ROFS_OFFSET = "5376"
|
||||
FLASH_RWFS_OFFSET = "29184"
|
||||
|
||||
# Standard image offsets
|
||||
FLASH_STANDARD_SECTION_OFFSET = "31552"
|
||||
FLASH_STANDARD_SECTION_END = "32768"
|
||||
|
||||
# Secure boot offsets
|
||||
# offset at 0x01f7_0000 / 1024 = 32192
|
||||
FLASH_SECTION_OFFSET = "32192"
|
||||
# end is offset + 576
|
||||
FLASH_SECTION_END = "32768"
|
||||
|
||||
# offset at 0x01ee_0000 / 1024 = 31616
|
||||
FLASH_SECTION2_OFFSET = "31616"
|
||||
FLASH_SECTION2_END = "32192"
|
||||
|
||||
# offset at 0x01c0_0000 / 1024 = 28672
|
||||
FLASH_UBOOT2_OFFSET = "28672"
|
||||
|
||||
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
|
||||
|
||||
if [ -f ${DEPLOY_DIR_IMAGE}/hpe-section2 ]
|
||||
then
|
||||
ln -sf ${DEPLOY_DIR_IMAGE}/hpe-section2 image-section2
|
||||
fi
|
||||
}
|
||||
|
||||
do_mk_static_symlinks:append() {
|
||||
ln -sf hpe-section image-section
|
||||
|
||||
if [ -f ${DEPLOY_DIR_IMAGE}/hpe-section2 ]
|
||||
then
|
||||
ln -sf hpe-section2 image-section2
|
||||
fi
|
||||
}
|
||||
|
||||
do_generate_static:prepend() {
|
||||
bb.build.exec_func("do_generate_hpe_image", d)
|
||||
}
|
||||
|
||||
do_generate_static:append() {
|
||||
# hpe-section2 and u-boot2 only exist in the secure boot image.
|
||||
# If hpe-section2 exists, then this is secure boot.
|
||||
if os.path.exists(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), 'hpe-section2')):
|
||||
_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)))
|
||||
|
||||
_append_image(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), 'hpe-section2'),
|
||||
int(d.getVar('FLASH_SECTION2_OFFSET', True)),
|
||||
int(d.getVar('FLASH_SECTION2_END', True)))
|
||||
|
||||
_append_image(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), 'u-boot.%s' % d.getVar('UBOOT_SUFFIX',True)),
|
||||
int(d.getVar('FLASH_UBOOT2_OFFSET', True)),
|
||||
int(d.getVar('FLASH_RWFS_OFFSET', True)))
|
||||
else:
|
||||
_append_image(os.path.join(d.getVar('DEPLOY_DIR_IMAGE', True), 'hpe-section'),
|
||||
int(d.getVar('FLASH_STANDARD_SECTION_OFFSET', True)),
|
||||
int(d.getVar('FLASH_STANDARD_SECTION_END', True)))
|
||||
}
|
||||
|
||||
# Generate the secure boot image by default
|
||||
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}
|
||||
|
||||
|
||||
# TODO - replace this openssl signing command line with whatever command you need to create a
|
||||
# digital signature of ${DEPLOY_DIR_IMAGE}/u-boot-tmp.${UBOOT_SUFFIX}
|
||||
|
||||
openssl sha384 -sign ${DEPLOY_DIR_IMAGE}/${HPE_UBOOT_SIGNING_KEY} -out ${DEPLOY_DIR_IMAGE}/gxp_tmp.sig \
|
||||
${DEPLOY_DIR_IMAGE}/u-boot-tmp.${UBOOT_SUFFIX}
|
||||
|
||||
# Cat U-Boot header+signature
|
||||
cat ${DEPLOY_DIR_IMAGE}/${HPE_UBOOT_SIGNING_HEADER_512} ${DEPLOY_DIR_IMAGE}/gxp_tmp.sig \
|
||||
> ${DEPLOY_DIR_IMAGE}/gxp-uboot.sig
|
||||
|
||||
|
||||
# Create hpe-section
|
||||
dd if=/dev/zero bs=1k count=576 > ${DEPLOY_DIR_IMAGE}/hpe-section
|
||||
|
||||
# Add U-Boot Header and Signature to hpe-section
|
||||
dd bs=1k conv=notrunc seek=0 \
|
||||
if=${DEPLOY_DIR_IMAGE}/gxp-uboot.sig \
|
||||
of=${DEPLOY_DIR_IMAGE}/hpe-section
|
||||
|
||||
# Add gxp-bootblock to hpe-section
|
||||
dd bs=1k conv=notrunc seek=64 \
|
||||
if=${DEPLOY_DIR_IMAGE}/${HPE_GXP_BOOTBLOCK_IMAGE} \
|
||||
of=${DEPLOY_DIR_IMAGE}/hpe-section
|
||||
|
||||
# hpe-section2 is the same as hpe-section up to this point
|
||||
cp ${DEPLOY_DIR_IMAGE}/hpe-section ${DEPLOY_DIR_IMAGE}/hpe-section2
|
||||
|
||||
|
||||
# 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-uboot.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
|
||||
|
||||
# Create the min tar archive
|
||||
tar -h -cvf ${IMGDEPLOYDIR}/${IMAGE_NAME}.$type.mtd.min.tar \
|
||||
image-kernel image-rofs image-rwfs MANIFEST \
|
||||
image-kernel.sig image-rofs.sig image-rwfs.sig MANIFEST.sig publickey
|
||||
|
||||
cd ${IMGDEPLOYDIR}
|
||||
ln -sf ${IMAGE_NAME}.$type.mtd.tar ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.$type.mtd.tar
|
||||
ln -sf ${IMAGE_NAME}.$type.mtd.min.tar ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.$type.mtd.min.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
|
||||
|
||||
if [ -f image-section2 ]
|
||||
then
|
||||
make_signatures image-u-boot image-kernel image-rofs image-rwfs image-section image-section2 MANIFEST publickey
|
||||
else
|
||||
make_signatures image-u-boot image-kernel image-rofs image-rwfs image-section MANIFEST publickey
|
||||
fi
|
||||
|
||||
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
|
||||
ln -sf ${IMAGE_NAME}.static.mtd.min.tar ${IMGDEPLOYDIR}/${MACHINE}-${DATETIME}.min.tar
|
||||
}
|
||||
@@ -0,0 +1,462 @@
|
||||
#!/bin/sh
|
||||
|
||||
fslist="proc sys dev run"
|
||||
rodir=run/initramfs/ro
|
||||
rwdir=run/initramfs/rw
|
||||
upper=$rwdir/cow
|
||||
work=$rwdir/work
|
||||
|
||||
cd /
|
||||
for f in $fslist
|
||||
do
|
||||
mkdir -p "$f"
|
||||
done
|
||||
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
|
||||
tr '\n\000' '\r\n' < "/dev/$envdev" |
|
||||
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
|
||||
}
|
||||
|
||||
getch() {
|
||||
old=$(stty -g)
|
||||
stty raw -echo min 0 time 50
|
||||
printf '%s' "$(dd bs=1 count=1 2>/dev/null)"
|
||||
stty "$old"
|
||||
}
|
||||
|
||||
debug_takeover() {
|
||||
echo "$@"
|
||||
echo "Press (Y/y) to log in and try to manually fix, force recovery in 5 seconds"
|
||||
answer=$(getch)
|
||||
if [ "$answer" != "y" ] && [ "$answer" != "Y" ] ;
|
||||
then
|
||||
mkdir -p /var/lock
|
||||
envdev=$(findmtd u-boot-env)
|
||||
echo "/dev/${envdev} 0x00000 0x10000" > /etc/fw_env.config
|
||||
echo "/dev/${envdev} 0x10000 0x10000" >> /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 "$consider_download_files" = "y" &&
|
||||
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 "$consider_download_tftp" = "y"
|
||||
then
|
||||
try_tftp "$url"
|
||||
else
|
||||
echo "Download failed."
|
||||
fi
|
||||
elif test "$proto" = http://
|
||||
then
|
||||
if test "$consider_download_http" = "y"
|
||||
then
|
||||
try_wget "$url"
|
||||
else
|
||||
echo "Download failed."
|
||||
fi
|
||||
elif test "$proto" = ftp://
|
||||
then
|
||||
if test "$consider_download_ftp" = "y"
|
||||
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 "$flash_images_before_init" = "y"
|
||||
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 "$force_rwfst_jffs2" = "y" -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
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
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 "
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
KERNEL=="ipmi-kcs1", SYMLINK+="ipmi_kcs1"
|
||||
@@ -0,0 +1,9 @@
|
||||
KCS_DEVICE = "ipmi_kcs1"
|
||||
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
|
||||
|
||||
SRC_URI += "file://99-ipmi-kcs.rules"
|
||||
|
||||
do_install:append() {
|
||||
install -d ${D}${base_libdir}/udev/rules.d
|
||||
install -m 0644 ${WORKDIR}/99-ipmi-kcs.rules ${D}${base_libdir}/udev/rules.d/
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
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 \
|
||||
phosphor-skeleton-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 = " \
|
||||
"
|
||||
|
||||
SUMMARY:${PN}-system = "HPE System"
|
||||
RDEPENDS:${PN}-system = " \
|
||||
bmcweb \
|
||||
webui-vue \
|
||||
phosphor-ipmi-ipmb \
|
||||
dbus-sensors \
|
||||
host-ehci-owner-reset \
|
||||
host-boot-enable \
|
||||
"
|
||||
@@ -0,0 +1,10 @@
|
||||
RDEPENDS:${PN}-logging += "phosphor-logging"
|
||||
RDEPENDS:${PN}-extras += " bmcweb \
|
||||
webui-vue \
|
||||
phosphor-image-signing \
|
||||
phosphor-pid-control \
|
||||
"
|
||||
|
||||
RDEPENDS:${PN}-fan-control = " \
|
||||
${VIRTUAL-RUNTIME_obmc-fan-control} \
|
||||
"
|
||||
@@ -0,0 +1,152 @@
|
||||
#!/bin/sh
|
||||
|
||||
hid_conf_directory="/sys/kernel/config/usb_gadget/obmc_hid"
|
||||
dev_name="80401000.udc"
|
||||
|
||||
create_hid() {
|
||||
# create gadget
|
||||
mkdir "${hid_conf_directory}"
|
||||
cd "${hid_conf_directory}" || exit 1
|
||||
|
||||
# add basic information
|
||||
echo 0x0100 > bcdDevice
|
||||
echo 0x0200 > bcdUSB
|
||||
echo 0x0104 > idProduct # Multifunction Composite Gadget
|
||||
echo 0x1d6b > idVendor # Linux Foundation
|
||||
|
||||
# create English locale
|
||||
mkdir strings/0x409
|
||||
|
||||
echo "OpenBMC" > strings/0x409/manufacturer
|
||||
echo "virtual_input" > strings/0x409/product
|
||||
echo "OBMC0001" > strings/0x409/serialnumber
|
||||
|
||||
# Create HID keyboard function
|
||||
mkdir functions/hid.0
|
||||
|
||||
echo 1 > functions/hid.0/protocol # 1: keyboard
|
||||
echo 8 > functions/hid.0/report_length
|
||||
echo 1 > functions/hid.0/subclass
|
||||
|
||||
# Binary HID keyboard descriptor
|
||||
# 0x05, 0x01, // USAGE_PAGE (Generic Desktop)
|
||||
# 0x09, 0x06, // USAGE (Keyboard)
|
||||
# 0xa1, 0x01, // COLLECTION (Application)
|
||||
# 0x05, 0x07, // USAGE_PAGE (Keyboard)
|
||||
# 0x19, 0xe0, // USAGE_MINIMUM (Keyboard LeftControl)
|
||||
# 0x29, 0xe7, // USAGE_MAXIMUM (Keyboard Right GUI)
|
||||
# 0x15, 0x00, // LOGICAL_MINIMUM (0)
|
||||
# 0x25, 0x01, // LOGICAL_MAXIMUM (1)
|
||||
# 0x75, 0x01, // REPORT_SIZE (1)
|
||||
# 0x95, 0x08, // REPORT_COUNT (8)
|
||||
# 0x81, 0x02, // INPUT (Data,Var,Abs)
|
||||
# 0x95, 0x01, // REPORT_COUNT (1)
|
||||
# 0x75, 0x08, // REPORT_SIZE (8)
|
||||
# 0x81, 0x03, // INPUT (Data,Var,Abs)
|
||||
# 0x95, 0x05, // REPORT_COUNT (5)
|
||||
# 0x75, 0x01, // REPORT_SIZE (1)
|
||||
# 0x05, 0x08, // USAGE_PAGE (LEDs)
|
||||
# 0x19, 0x01, // USAGE_MINIMUM (Num Lock)
|
||||
# 0x29, 0x05, // USAGE_MAXIMUM (Kana)
|
||||
# 0x91, 0x02, // OUTPUT (Data,Var,Abs)
|
||||
# 0x95, 0x01, // REPORT_COUNT (1)
|
||||
# 0x75, 0x03, // REPORT_SIZE (3)
|
||||
# 0x91, 0x03, // OUTPUT (Cnst,Var,Abs)
|
||||
# 0x95, 0x06, // REPORT_COUNT (6)
|
||||
# 0x75, 0x08, // REPORT_SIZE (8)
|
||||
# 0x15, 0x00, // LOGICAL_MINIMUM (0)
|
||||
# 0x25, 0x65, // LOGICAL_MAXIMUM (101)
|
||||
# 0x05, 0x07, // USAGE_PAGE (Keyboard)
|
||||
# 0x19, 0x00, // USAGE_MINIMUM (Reserved (no event indicated))
|
||||
# 0x29, 0x65, // USAGE_MAXIMUM (Keyboard Application)
|
||||
# 0x81, 0x00, // INPUT (Data,Ary,Abs)
|
||||
# 0xc0 // END_COLLECTION
|
||||
printf '\x05\x01\x09\x06\xa1\x01\x05\x07\x19\xe0\x29\xe7\x15\x00\x25\x01\x75\x01\x95\x08\x81\x02\x95\x01\x75\x08\x81\x03\x95\x05\x75\x01\x05\x08\x19\x01\x29\x05\x91\x02\x95\x01\x75\x03\x91\x03\x95\x06\x75\x08\x15\x00\x25\x65\x05\x07\x19\x00\x29\x65\x81\x00\xc0' > functions/hid.0/report_desc
|
||||
|
||||
# Create HID mouse function
|
||||
mkdir functions/hid.1
|
||||
|
||||
echo 2 > functions/hid.1/protocol # 2: mouse
|
||||
echo 6 > functions/hid.1/report_length
|
||||
echo 1 > functions/hid.1/subclass
|
||||
|
||||
# Binary HID mouse descriptor (absolute coordinate)
|
||||
# 0x05, 0x01, // USAGE_PAGE (Generic Desktop)
|
||||
# 0x09, 0x02, // USAGE (Mouse)
|
||||
# 0xa1, 0x01, // COLLECTION (Application)
|
||||
# 0x09, 0x01, // USAGE (Pointer)
|
||||
# 0xa1, 0x00, // COLLECTION (Physical)
|
||||
# 0x05, 0x09, // USAGE_PAGE (Button)
|
||||
# 0x19, 0x01, // USAGE_MINIMUM (Button 1)
|
||||
# 0x29, 0x03, // USAGE_MAXIMUM (Button 3)
|
||||
# 0x15, 0x00, // LOGICAL_MINIMUM (0)
|
||||
# 0x25, 0x01, // LOGICAL_MAXIMUM (1)
|
||||
# 0x95, 0x03, // REPORT_COUNT (3)
|
||||
# 0x75, 0x01, // REPORT_SIZE (1)
|
||||
# 0x81, 0x02, // INPUT (Data,Var,Abs)
|
||||
# 0x95, 0x01, // REPORT_COUNT (1)
|
||||
# 0x75, 0x05, // REPORT_SIZE (5)
|
||||
# 0x81, 0x03, // INPUT (Cnst,Var,Abs)
|
||||
# 0x05, 0x01, // USAGE_PAGE (Generic Desktop)
|
||||
# 0x09, 0x30, // USAGE (X)
|
||||
# 0x09, 0x31, // USAGE (Y)
|
||||
# 0x35, 0x00, // PHYSICAL_MINIMUM (0)
|
||||
# 0x46, 0xff, 0x7f, // PHYSICAL_MAXIMUM (32767)
|
||||
# 0x15, 0x00, // LOGICAL_MINIMUM (0)
|
||||
# 0x26, 0xff, 0x7f, // LOGICAL_MAXIMUM (32767)
|
||||
# 0x65, 0x11, // UNIT (SI Lin:Distance)
|
||||
# 0x55, 0x00, // UNIT_EXPONENT (0)
|
||||
# 0x75, 0x10, // REPORT_SIZE (16)
|
||||
# 0x95, 0x02, // REPORT_COUNT (2)
|
||||
# 0x81, 0x02, // INPUT (Data,Var,Abs)
|
||||
# 0x09, 0x38, // Usage (Wheel)
|
||||
# 0x15, 0xff, // LOGICAL_MINIMUM (-1)
|
||||
# 0x25, 0x01, // LOGICAL_MAXIMUM (1)
|
||||
# 0x35, 0x00, // PHYSICAL_MINIMUM (-127)
|
||||
# 0x45, 0x00, // PHYSICAL_MAXIMUM (127)
|
||||
# 0x75, 0x08, // REPORT_SIZE (8)
|
||||
# 0x95, 0x01, // REPORT_COUNT (1)
|
||||
# 0x81, 0x06, // INPUT (Data,Var,Rel)
|
||||
# 0xc0, // END_COLLECTION
|
||||
# 0xc0 // END_COLLECTION
|
||||
printf '\x05\x01\x09\x02\xa1\x01\x09\x01\xa1\x00\x05\x09\x19\x01\x29\x03\x15\x00\x25\x01\x95\x03\x75\x01\x81\x02\x95\x01\x75\x05\x81\x03\x05\x01\x09\x30\x09\x31\x35\x00\x46\xff\x7f\x15\x00\x26\xff\x7f\x65\x11\x55\x00\x75\x10\x95\x02\x81\x02\x09\x38\x15\xff\x25\x01\x35\x00\x45\x00\x75\x08\x95\x01\x81\x06\xc0\xc0' > functions/hid.1/report_desc
|
||||
|
||||
# Create configuration
|
||||
mkdir configs/c.1
|
||||
mkdir configs/c.1/strings/0x409
|
||||
|
||||
echo 0xe0 > configs/c.1/bmAttributes
|
||||
echo 200 > configs/c.1/MaxPower
|
||||
echo "" > configs/c.1/strings/0x409/configuration
|
||||
|
||||
# Link HID functions to configuration
|
||||
ln -s functions/hid.0 configs/c.1
|
||||
ln -s functions/hid.1 configs/c.1
|
||||
}
|
||||
|
||||
connect_hid() {
|
||||
if ! grep -q "${dev_name}" UDC; then
|
||||
echo "${dev_name}" > UDC
|
||||
fi
|
||||
}
|
||||
|
||||
disconnect_hid() {
|
||||
if grep -q "${dev_name}" UDC; then
|
||||
echo "" > UDC
|
||||
fi
|
||||
}
|
||||
|
||||
if [ ! -e "${hid_conf_directory}" ]; then
|
||||
create_hid
|
||||
else
|
||||
cd "${hid_conf_directory}" || exit 1
|
||||
fi
|
||||
|
||||
if [ "$1" = "connect" ]; then
|
||||
connect_hid
|
||||
elif [ "$1" = "disconnect" ]; then
|
||||
disconnect_hid
|
||||
else
|
||||
echo >&2 "Invalid option: $1. Use 'connect' or 'disconnect'."
|
||||
exit 1
|
||||
fi
|
||||
@@ -0,0 +1,11 @@
|
||||
[Unit]
|
||||
Description=OpenBMC ipKVM daemon
|
||||
ConditionPathIsMountPoint=/sys/kernel/config
|
||||
|
||||
[Service]
|
||||
Restart=always
|
||||
ExecStartPre=/usr/bin/create_usbhid.sh disconnect
|
||||
ExecStart=/usr/bin/obmc-ikvm -v /dev/video0 -k /dev/hidg0 -p /dev/hidg1 -u 80401000.udc
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,13 @@
|
||||
FILESEXTRAPATHS:append := "${THISDIR}/${PN}:"
|
||||
SRC_URI += " file://start-ipkvm.service "
|
||||
SRC_URI += " file://create_usbhid.sh "
|
||||
|
||||
FILES:${PN} += " \
|
||||
${systemd_system_unitdir}/start-ipkvm.service \
|
||||
${bindir}/create_usbhid.sh \
|
||||
"
|
||||
|
||||
do_install:append () {
|
||||
install -D -m 0755 ${WORKDIR}/start-ipkvm.service ${D}${systemd_system_unitdir}
|
||||
install -D -m 0755 ${WORKDIR}/create_usbhid.sh ${D}${bindir}
|
||||
}
|
||||
Reference in New Issue
Block a user