Initial commit
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
PR = "r1"
|
||||
PV = "1.0+git${SRCPV}"
|
||||
LICENSE = "Apache-2.0"
|
||||
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
|
||||
|
||||
SRC_URI = "git://github.com/quanta-bmc/read-margin-temp.git;branch=master;protocol=https"
|
||||
SRCREV = "7a9eec77ec9b90eb5ec5de294f3d9a0363193ef8"
|
||||
S = "${WORKDIR}/git"
|
||||
|
||||
inherit autotools pkgconfig
|
||||
inherit meson
|
||||
|
||||
DEPENDS += " nlohmann-json"
|
||||
DEPENDS += " sdbusplus"
|
||||
DEPENDS += " sdeventplus"
|
||||
DEPENDS += " phosphor-dbus-interfaces"
|
||||
RDEPENDS:${PN} += " bash"
|
||||
|
||||
FILES:${PN} = "${bindir}/read-margin-temp"
|
||||
|
||||
do_install() {
|
||||
install -d ${D}${bindir}
|
||||
install -m 0755 read-margin-temp ${D}${bindir}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
LICENSE = "Apache-2.0"
|
||||
LIC_FILES_CHKSUM = "file://LICENSE;md5=86d3f3a95c324c9479bd8986968f4327"
|
||||
|
||||
inherit cmake pkgconfig
|
||||
inherit systemd
|
||||
|
||||
RDEPENDS:${PN} += " bash"
|
||||
|
||||
S = "${WORKDIR}/git"
|
||||
SRC_URI = "git://github.com/quanta-bmc/mac-address.git;protocol=https;branch=master"
|
||||
SRCREV = "93756c78539160a7c15e02c7c3ecf2d6941d56af"
|
||||
DEPENDS += "systemd"
|
||||
|
||||
FILES:${PN} += "${bindir}/mac-address"
|
||||
|
||||
SYSTEMD_PACKAGES = "${PN}"
|
||||
SYSTEMD_SERVICE:${PN} = "mac-address.service"
|
||||
|
||||
EXTRA_OECMAKE:append = " \
|
||||
-DENABLE_TEST=OFF \
|
||||
"
|
||||
@@ -0,0 +1,25 @@
|
||||
LICENSE = "Apache-2.0"
|
||||
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
|
||||
|
||||
FILESEXTRAPATHS:append := "${THISDIR}/${PN}:"
|
||||
SRC_URI:append = " file://usb-network.sh"
|
||||
SRC_URI:append = " file://usb-network.service"
|
||||
|
||||
inherit systemd
|
||||
|
||||
DEPENDS += "systemd"
|
||||
RDEPENDS:${PN} += "libsystemd"
|
||||
RDEPENDS:${PN} += "bash"
|
||||
|
||||
FILES:${PN}:append = " ${sysconfdir_native}/systemd/network/00-bmc-usb0.network"
|
||||
|
||||
do_install() {
|
||||
install -d ${D}/${sbindir}
|
||||
install -m 0755 ${WORKDIR}/usb-network.sh ${D}/${sbindir}
|
||||
|
||||
install -d ${D}${systemd_unitdir}/system/
|
||||
install -m 0644 ${WORKDIR}/usb-network.service \
|
||||
${D}${systemd_unitdir}/system
|
||||
}
|
||||
|
||||
SYSTEMD_SERVICE:${PN}:append = "usb-network.service"
|
||||
@@ -0,0 +1,10 @@
|
||||
[Unit]
|
||||
Description=Enable USB Network
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/sbin/usb-network.sh
|
||||
EnvironmentFile=/usr/share/usb-network/usb-network.conf
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,61 @@
|
||||
#!/bin/bash
|
||||
|
||||
mac_config="/usr/share/mac-address/config.txt"
|
||||
dev_mac_path="/tmp/usb0_dev"
|
||||
host_mac_path="/tmp/usb0_host"
|
||||
|
||||
check_usb_local_administered() {
|
||||
is_enable="$(cat ${mac_config} | grep 'USBLAA')"
|
||||
echo "${is_enable}"
|
||||
}
|
||||
|
||||
# Set the locally administered bit (the second least-significant
|
||||
# bit of the first octet) of the MAC address
|
||||
set_local_administered_bit() {
|
||||
mac="$(tr -d '\0' < "$1")"
|
||||
first_byte="${mac:0:2}"
|
||||
first_byte="$((0x$first_byte|2))"
|
||||
first_byte="$(printf "%02x\n" "$first_byte")"
|
||||
mac="${first_byte}${mac:2}"
|
||||
echo "$mac"
|
||||
}
|
||||
|
||||
cd /sys/kernel/config/usb_gadget || exit 1
|
||||
|
||||
if [ ! -f "g1" ]; then
|
||||
mkdir g1
|
||||
cd g1 || exit 1
|
||||
|
||||
echo 0x1d6b > idVendor # Linux foundation
|
||||
echo 0x0104 > idProduct # Multifunction composite gadget
|
||||
mkdir -p strings/0x409
|
||||
echo "Linux" > strings/0x409/manufacturer
|
||||
echo "Etherned/ECM gadget" > strings/0x409/product
|
||||
|
||||
mkdir -p configs/c.1
|
||||
echo 100 > configs/c.1/MaxPower
|
||||
mkdir -p configs/c.1/strings/0x409
|
||||
echo "ECM" > configs/c.1/strings/0x409/configuration
|
||||
|
||||
|
||||
if [[ $(check_usb_local_administered) == "USBLAA=true" ]]; then
|
||||
dev_mac="$(set_local_administered_bit $dev_mac_path)"
|
||||
host_mac="$(set_local_administered_bit $host_mac_path)"
|
||||
echo "$dev_mac" > $dev_mac_path
|
||||
echo "$host_mac" > $host_mac_path
|
||||
fi
|
||||
|
||||
mkdir -p functions/ecm.usb0
|
||||
cat $dev_mac_path > functions/ecm.usb0/dev_addr # write device mac address
|
||||
cat $host_mac_path > functions/ecm.usb0/host_addr # write usb mac address
|
||||
|
||||
ln -s functions/ecm.usb0 configs/c.1
|
||||
|
||||
echo "$UDC" > UDC
|
||||
|
||||
rm $dev_mac_path
|
||||
rm $host_mac_path
|
||||
|
||||
fi
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user