USB0 as OTG client

Viewing 6 reply threads
  • Author
    Posts
    • #9155
      Alejandro BertolucciolmoDalco
      Participant

        Hello Octavo System team,

        I am writing this post because I have development a custom board which is practically exact the same that the OSD3358 red board. I have follow the sch and layout reference file,  the bring up process is correct, and the Linux is working. But I am trying to configure the usb0 as a OTG client and I am not able to configure the board as a mass storage device. I have set up the SD card following the same steps that in the tutorial for the beagle-bone black in digikey in this link. 

        My intention is configure the mass storage device with the dwc2 module.  For that, I have added to the /boot/config.txt:

        • dtoverlay=dwc2

        and /etc/modules: dwc2 but when I try to test the usb storage mode with this command:

        • sudo modprobe g_mass_storage file=/piusb.bin stall=0 ro=1

        The response is the following

        • [  577.510832] udc-core: couldn’t find an available UDC – added [g_mass_storage] to list of pending drivers

        I think that it can be caused because the usb0 is configured as a ssh communication because during the boot I can see the following traces:

        • [   18.323564] usb0: HOST MAC 98:5d:ad:2b:3d:4e
          [   18.344093] usb0: MAC 98:5d:ad:2b:3d:4f

        I have removed the ssh over usb in the network/interface file but the response of the ifconfig command is the following:

        eth0: flags=-28669<UP,BROADCAST,MULTICAST,DYNAMIC>  mtu 1500
        ether 98:5d:ad:2b:3d:4d  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 45

        lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 1120  bytes 77280 (75.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1120  bytes 77280 (75.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

        usb1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.6.2  netmask 255.255.255.252  broadcast 192.168.6.3
        inet6 fe80::9a5d:adff:fe2b:3d52  prefixlen 64  scopeid 0x20<link>
        ether 98:5d:ad:2b:3d:52  txqueuelen 1000  (Ethernet)
        RX packets 48  bytes 7425 (7.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 45  bytes 6230 (6.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

        My main doubts are the following:

        1. Is possible configure the OSD3358 red board as a OTG client device in order to detect it as a mass storage device? As far as I read in the OSD3358-SM-RED –User Guide (Rev. 1.09/19/2017), it should be configured automatically.
          • Could you please share with me the main important steps or the document to do it?
        2. Do I need an special kernel image to do it? I mean, it is needed apply some patch or rebuild the dtb file?

        Summarizing, my target is set up this board to detect as usb mass storage device OTG (like a pendrive). Could you please help me to do it?

        Thanks a lot for your help and support,

        Best regards.

        Alejandro

      • #9260
        Neeraj Kumar Reddy DantuNeeraj Dantu
        Moderator

          olmoDalco,

          Apologies for the delayed response here.

          Please take a look at the application note: https://octavosystems.com/app_notes/programming-emmc-with-usb/ which describes the process of programming the on board eMMC by exposing it to a host computer as a mass storage device. The application note takes you through creating the Linux image and the script for exposing the eMMC as a mass storage device is also shown. Note that g_mass_storage module needs to be compiled into the Linux kernel being used in the image.

          Best,

          Neeraj

        • #9323
          Alejandro BertolucciolmoDalco
          Participant

            Dear Neeraj Dantu,

            First of all, I want thank your support, don’t worry about the delay.

            I have read the application note about the programming EMMC, and I have some questions. Really I don’t want programming the EMMC, I need only expose the system as a OPT client in a host computer (the same that a USB pen drive in a PC). My most important doubts are the following:

            • I have followed the Digikey tutorial to setup the SD card to program my OSDboard (it is perfectly working) but I am not able to identify all specific images of the Linux system provided in the project download folder, which should be flashed in the SD card. I want avoid the programming EMMC process because I only need show the system like an OTG client, the most easy way as possible. Can I replace the following files for the showed one (in the Digikey tutorial) in order to flash the SD card with the correct Linux system and configure like as a mass storage system?:
              • u-boot-spl-restore.bin –> ./u-boot/MLO
              • u-boot-restore.img –> ./u-boot/u-boot.img
              • uImage –> 4.14.141-bone27.zImage
              • uinitramfs –> armhf-rootfs-debian-stretch.tar
              • uosd3358-bsm-refdesing.dtb –> 4.14.141-bone27-dtbs.tar.gz
            • Is there any complete image (to write in a SD card) with the g_mass_storage and others necessary
              modules to configure the system like a USB OTG client?

            Based on the above questions, I want mark that the most important point that I need do, is install a complete linux image which will be able to show a USB client OTG in any PC host computer, which use the g_mass_storage module.

            Thanks a  lot Octavo team.
            Regards.

            • This reply was modified 5 years ago by Alejandro BertolucciolmoDalco.
          • #9325
            Neeraj Kumar Reddy DantuNeeraj Dantu
            Moderator

              olmoDalco,

              If you don’t want to program the eMMC, you don’t need to use the resources described in the Application note.

              Please review the following links that describe how to use g_mass_storage to expose part of the storage as a mass storage device:

              1. https://linux-sunxi.org/USB_Gadget/Mass_storage

              2. https://developer.ridgerun.com/wiki/index.php?title=How_to_use_mass_storage_gadget

              If you are using Beagle images, you can look into the Kernel build configuration file located in /boot/ folder to verify if g_mass_storage is built-in/module in the current kernel for the Beagle Image.

              Finally, the page you linked from Digikey(https://www.digikey.com/eewiki/display/linuxonarm/BeagleBone+Black) shows how to build a kernel, build the kernel modules and install the kernel and modules on an SD card if you need to.

              Please let us know if you have further questions.

              Best,

              Neeraj

            • #9519
              Alejandro BertolucciolmoDalco
              Participant

                Neeraj Dantu

                First of all, I want to thank you about your help and support. And sorry for the delay en the answer.
                I dont want to flash de eMMC for MP, I only want configure and use the board as a mass storage device for debugging.

                Lets me try to explain you a bit about my issue. I only wanted use the microusb port of this board as a pen drive in a PC computer. In order to configure the board to do it, I tried with the g_mass_storage module : I have configured the module in /boot/config.txt and /etc/modules files. I have created and format the binary file (with these commands: sudo dd bs=1M if=/dev/zero of=/piusb.bin count=2048 and sudo mkdosfs /piusb.bin -F 32 -I) and mounted the system (sudo mkdir /mnt/usb_share, sudo nano /etc/fstab, adding: “/piusb.bin /mnt/usb_share vfat users,umask=000 0 2”, sudo mount -a). Finally I tested the mass storage devide. Please execute the following commands:
                sudo modprobe gmassstorage file=/piusb.bin stall=0 ro=1
                But it was not correctly configured like a OTG, the dmesg log always showed some errors (I can send you the logs). After search about it, I found that there are some scripts which are executed after boot and are configuring the peripherals according to the OSD reference board , they are causing issues with our design. So that I removed the triggered of these scripts and configure the OTG manually (with the commands mentioned previously) and it works fine.

                So that my recommendation if you find out problems related with OTG, is remove these scripts and after that configure the g_mass_storage module manually.

                Please if you think that I can provide you some information like logs, video or something like that. Lets me know.

                Thanks for the support.
                Best regards.

                Olmo.

              • #9520
                Neeraj Kumar Reddy DantuNeeraj Dantu
                Moderator

                  Olmo,

                   

                  Thank you for getting back to us on the forum! I am glad you got the mass storage utility to work. We would very much appreciate it if you could post the procedure you followed on this thread.

                  Thank you very much for your efforts.

                  Best,

                  Neeraj

                • #10014
                  Alejandro BertolucciolmoDalco
                  Participant

                    Dear Neeraj Dantu,

                    Sorry for the delay in the replay, I have not being working in this project since last year and I have not sign in in the forum. Lets me explain the steps that I followed to bring up the OTG (I know that remove the boot scripts is not the best way, but I have to analyze these scripts in order to avoid the configuration which is causing the difficulty to use the OTG).

                    1. First of all, remove the triggering of these scripts. The fastest way is rename the autoconfigure_usb0.sh file (located in /opt/scripts/boot/), for example, “_autoconfigure_usb0.sh”.
                    2. Configure the g_mass_storage module in boot/config.txt and /etc/modules files.
                    3. Create and format the binary file to share for OTG:
                      • sudo dd bs=1M if=/dev/zero of=/piusb.bin count=2048
                      • sudo mkdosfs /piusb.bin -F 32 -I
                    4. Use the g_mass_storage module: sudo modprobe gmassstorage file=/piusb.bin stall=0 ro=1

                    I hope that these steps work for more people.

                    Thanks a lot,

                    Best regards.

                Viewing 6 reply threads
                • You must be logged in to reply to this topic.