diff options
author | Thang Q. Nguyen <thang@os.amperecomputing.com> | 2021-10-15 17:04:44 +0300 |
---|---|---|
committer | Thang Q. Nguyen <thang@os.amperecomputing.com> | 2021-11-05 05:30:27 +0300 |
commit | ff38979bf9dbc8bc02ee6852d707140ca97b80aa (patch) | |
tree | cafc0f898abe1fa617a2fbbc30a2f0e0612e9d55 /meta-ampere/meta-common/recipes-ac01 | |
parent | cb3197635912c1f49357838d9cd59f927b1af23b (diff) | |
download | openbmc-ff38979bf9dbc8bc02ee6852d707140ca97b80aa.tar.xz |
meta-ampere: usbnet: implement using usb-ctrl
Change to implement virtual USB Ethernet using phosphor-misc's usb-ctrl.
Tested:
1. Boot BMC to Linux. Login and check if usb0 ethernet interface exists.
2. Power ON the Host. Check if usb0 automatically sets its IP to
192.168.0.10
3. Restart the ampere-usbnet.service service. Check if no error happens.
Signed-off-by: Thang Q. Nguyen <thang@os.amperecomputing.com>
Change-Id: I4de722a691a112db851b6dda0a7821b9f78b4d72
Diffstat (limited to 'meta-ampere/meta-common/recipes-ac01')
4 files changed, 0 insertions, 143 deletions
diff --git a/meta-ampere/meta-common/recipes-ac01/usbnet/ampere-usbnet.bb b/meta-ampere/meta-common/recipes-ac01/usbnet/ampere-usbnet.bb deleted file mode 100644 index 3045fa557..000000000 --- a/meta-ampere/meta-common/recipes-ac01/usbnet/ampere-usbnet.bb +++ /dev/null @@ -1,30 +0,0 @@ -SUMMARY = "Ampere Computing LLC Add Ethernet over USB gadget device" -DESCRIPTION = "Add Ethernet over USB gadget device for Ampere systems" -PR = "r1" - -LICENSE = "Apache-2.0" -S = "${WORKDIR}" - -LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" - -inherit systemd -inherit obmc-phosphor-systemd - -DEPENDS = "systemd" -RDEPENDS:${PN} = "bash" - -SYSTEMD_PACKAGES = "${PN}" -SYSTEMD_SERVICE:${PN} = " \ - ampere_add_usbnet_gadget.service \ - " - -SRC_URI += "file://00-bmc-usb0.network" -SRC_URI += "file://ampere_add_usbnet_gadget.sh" - -do_install:append() { - install -d ${D}${sbindir} - install -d ${D}/etc/systemd/network - install -m 744 ${WORKDIR}/ampere_add_usbnet_gadget.sh ${D}${sbindir}/ - install -m 644 ${WORKDIR}/00-bmc-usb0.network \ - ${D}/etc/systemd/network/ -} diff --git a/meta-ampere/meta-common/recipes-ac01/usbnet/ampere-usbnet/00-bmc-usb0.network b/meta-ampere/meta-common/recipes-ac01/usbnet/ampere-usbnet/00-bmc-usb0.network deleted file mode 100644 index 640fe04b9..000000000 --- a/meta-ampere/meta-common/recipes-ac01/usbnet/ampere-usbnet/00-bmc-usb0.network +++ /dev/null @@ -1,7 +0,0 @@ -[Match] -Name=usb0 -[Address] -Address=192.168.0.10/16 -[Network] -LinkLocalAddressing=no -IPv6AcceptRA=no diff --git a/meta-ampere/meta-common/recipes-ac01/usbnet/ampere-usbnet/ampere_add_usbnet_gadget.service b/meta-ampere/meta-common/recipes-ac01/usbnet/ampere-usbnet/ampere_add_usbnet_gadget.service deleted file mode 100644 index 428263a89..000000000 --- a/meta-ampere/meta-common/recipes-ac01/usbnet/ampere-usbnet/ampere_add_usbnet_gadget.service +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=Ampere adds Ethernet over USB gadget device -Wants=systemd-networkd.service -Before=systemd-networkd.service -After=phosphor-ipmi-host.service - -[Service] -ExecStart=/usr/bin/env ampere_add_usbnet_gadget.sh -SyslogIdentifier=ampere_add_usbnet_gadget.sh -Type=oneshot - -[Install] -WantedBy=systemd-networkd.service diff --git a/meta-ampere/meta-common/recipes-ac01/usbnet/ampere-usbnet/ampere_add_usbnet_gadget.sh b/meta-ampere/meta-common/recipes-ac01/usbnet/ampere-usbnet/ampere_add_usbnet_gadget.sh deleted file mode 100644 index c4c2c273f..000000000 --- a/meta-ampere/meta-common/recipes-ac01/usbnet/ampere-usbnet/ampere_add_usbnet_gadget.sh +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/sh - -# Add an Ethernet over USB gadget device and connect to a port of Aspeed USB -# virtual hub. If can't find any free port on virtual hub, exit with failure. -# If can't find the virtual hub, exit with failure. - -# Author: Thinh Hung Pham <thinh.pham@amperecomputing.com> -# Signed-off-by: Chanh Nguyen <chnguyen@amperecomputing.com> - -UDC_SYSPATH=/sys/class/udc -VHUB_DEVICE=1e6a0000.usb-vhub:p -GADGET_CONFIG_SYSPATH=/sys/kernel/config/usb_gadget -USBNET=usbnet -# The number of port on AST2500 USB virtual hub -NUM_PORT_USB_HUB=5 -# idVendor = 0x1d6b: Linux Foundation -VENDORID=0x1d6b -# idProduct = 0x0103: NCM (Ethernet) Gadget -PRODUCTID=0x0103 -# Language code = 0x409: English – United States -LANGUAGEID=0x409 -SERIALNUMBER=cafecafe -MANUFACTURER=Aspeed -FUNCTION=ecm.usb0 - -if [ ! -d ${GADGET_CONFIG_SYSPATH} ]; then - # GADGET_CONFIG_SYSPATH is not exist - # Return 1 so that systemd knows the service failed to start - echo "ERROR: ${GADGET_CONFIG_SYSPATH} : doesn't exist!" - exit 1 -fi - -find_free_vhub_port(){ - for ((i=1;i<=${NUM_PORT_USB_HUB};i++)) - do - state=$(cat ${UDC_SYSPATH}/${VHUB_DEVICE}${i}/state) - func=$(cat ${UDC_SYSPATH}/${VHUB_DEVICE}${i}/function) - if [ "${state}" == "not attached" -a "${func}" == "" ]; then - FREEUDC=${VHUB_DEVICE}${i} - break - fi - done - if [ ${i} -eq 6 ]; then - # Can't find a free port - # Return 1 so that systemd knows the service failed to start - echo "ERROR: Can't find a free port !" - exit 1 - fi -} - -if [ -d ${GADGET_CONFIG_SYSPATH}/${USBNET} ]; then - cd ${GADGET_CONFIG_SYSPATH}/${USBNET} -else - # Create the gadget - mkdir ${GADGET_CONFIG_SYSPATH}/${USBNET} - cd ${GADGET_CONFIG_SYSPATH}/${USBNET} - - # Configure the gadget - echo ${VENDORID} > idVendor - echo ${PRODUCTID} > idProduct - mkdir strings/${LANGUAGEID} - echo ${SERIALNUMBER} > strings/${LANGUAGEID}/serialnumber - echo ${MANUFACTURER} > strings/${LANGUAGEID}/manufacturer - echo ${USBNET} > strings/${LANGUAGEID}/product - - # Create the configuration - mkdir configs/c.1 - mkdir configs/c.1/strings/${LANGUAGEID} - - # Create the function - mkdir functions/${FUNCTION} - - # Associate the function with its configuration - ln -s functions/${FUNCTION} configs/c.1 -fi - -# Find an available virtual hub port -find_free_vhub_port - -# Enable the gadget -echo ${FREEUDC} > UDC - -if [[ $? -ne 0 ]]; then - # End - cd - > /dev/null - # Virtual HUB is not available - # Return 1 so that systemd knows the service failed to start - exit 1 -fi - -# End -cd - > /dev/null - |