8 Replies Latest reply on Sep 2, 2020 3:54 PM by anven

    Ultra96 V2 USB OTG/Device port


      I am trying to connect Ultra96 to a PC through the USB OTG port (J7 - mini a/b) using the RnDIS driver... however the usb port seems unresponsive. It does not enumerate on either my Windows or Linux PC. Is there anything that needs to be done to enable that port as a device?


      Thank you

        • Re: Ultra96 V2 USB OTG/Device port

          Hi Anton,


          It sounds like you might be missing the g_ether RNDIS USB Gadget Ethernet driver in your kernel.  Are you using PetaLinux?  You might want to try using a known-good PetaLinux BSP for the Ultra96-V2Ultra96-V2 that has has USB gadget Ethernet enabled.



          This Xilinx forums post provides more detail of what is needed to enable USB gadget Ethernet:





            • Re: Ultra96 V2 USB OTG/Device port

              Thanks Tom,

              I am using petalinux and the 2019.2 BSP and I thought I added all the USB Gadgets and RNDIS options under the kernel configurator... Obviously I must have missed something.

              I know the Pynq image works and enumerates to seamlessly... now I just need to get my own build to do the same (I have some PL gpio tweaks that need to be baked in).


              This may be a noobie question, but Is there a way to compare the kernel settings file between pynq for example and my custom one? Pynq is ubuntu based I think, but likely petalinux was still involved in kernel configuration...





            • Re: Ultra96 V2 USB OTG/Device port

              I got it to work - the secret was in the usb gadget driver configuration. I was under impression that it should work out of the box, as long as the kernel rndis module was selected, but I guess the below sequence is also required. This was copied from the PYNQ project:


              # Script Adapted from http://irq5.io/2016/12/22/raspberry-pi-zero-as-multiple-usb-gadgets/
              cd /sys/kernel/config/usb_gadget/
              mkdir -p g
              cd g
              echo 0x1d6b > idVendor  # Linux Foundation
              echo 0x0104 > idProduct # Multifunction Composite Gadget
              echo 0x0100 > bcdDevice # v1.0.0
              echo 0x0200 > bcdUSB  # USB 2.0
              echo 0xEF > bDeviceClass
              echo 0x02 > bDeviceSubClass
              echo 0x01 > bDeviceProtocol
              mkdir -p strings/0x409
              echo "0000" > strings/0x409/serialnumber
              echo "Xilinx Inc."   > strings/0x409/manufacturer
              echo "PYNQ-USB"   > strings/0x409/product
              echo> os_desc/use
              echo 0xcd  > os_desc/b_vendor_code
              echo MSFT100 > os_desc/qw_sign
              mkdir -p functions/acm.usb0  # serial
              mkdir -p functions/rndis.usb0  # network
              mkdir -p functions/mass_storage.ms0
              echo RNDIS  > functions/rndis.usb0/os_desc/interface.rndis/compatible_id
              echo 5162001 > functions/rndis.usb0/os_desc/interface.rndis/sub_compatible_id
              echo /usr/local/share/fatfs > functions/mass_storage.ms0/lun.0/file
              echo 1 > functions/mass_storage.ms0/lun.0/removable
              mkdir -p configs/c.1
              echo 250 > configs/c.1/MaxPower
              if [ ! -e os_desc/c.1 ]; then
              ln -s configs/c.1 os_desc/
              if [ ! -e configs/c.1/rndis.usb0 ]; then
              ln -s functions/rndis.usb0 configs/c.1/
              if [ ! -e configs/c.1/acm.usb0 ]; then
              ln -s functions/acm.usb0 configs/c.1/
              if [ ! -e configs/c.1/mass_storage.ms0 ]; then
              ln -s functions/mass_storage.ms0 configs/c.1/
              udevadm settle -t 5 || :
              ls /sys/class/udc/ > UDC
              echo "" > /sys/kernel/config/usb_gadget/g/UDC
              ls /sys/class/udc/ > UDC
              ifconfig usb0


              Once executed, Windows 10 detected the RNDIS device

              1 of 1 people found this helpful
                • Re: Ultra96 V2 USB OTG/Device port

                  Thank you for sharing your success!  Like you, I would have expected this to work out of the box, too.  I knew it worked the Pynq image, but did not know this script was required.  Perhaps this enhancement can be built into a future Ultra96-V2 PetaLinux BSP release.




                  • Re: Ultra96 V2 USB OTG/Device port

                    When I run this script on my Ultra96-V2 I get an error at the line "echo /usr/local/share/fatfs > functions/mass_storage.ms0/lun.0/file".


                    mass_storage.ms0/lun.0: unable to open backing file: /usr/local/share/fatfs

                    ./usb_gadget_ethernet.sh: line 25: echo: write error: No such file or directory


                    Is there a fix or workaround for this?  I don't believe it is required for using the USB as an Ethernet device.  I believe this is needed to use the USB as mass storage.