Main Site Documentation

Netmf 4.3 Usb host problem with Cerbuinobee


#1

First experiments with the usb-host on the cerbuinobee were not very succesfull:
The examples for usb-mass storage and usb-mouse/keyboard as shown at:
https://www.ghielectronics.com/docs/36/usb-host
did not work properly:

  • plugging in a usb mass storage device ( a memory stick) resulted in an exception
    (Hresult -1) on the mount statement…

  • keyboard/mouse: both devices were recognised, but no data is received

I reinstalled all the software, but had no effect…performed the test on two different boards (rev 1.2).

Also example supplied by Dat GHI did not work:
https://www.ghielectronics.com/community/forum/topic?id=16733&page=5#msg166089


#2

@ freeck - We are still looking into the issue, we will let you know when we find out more.


#3

We can reproduce the issue with one of usb-mass storage we have. But we still can not reproduce with mouse and key board.

Can you please tell use what their manufacture, please?


#4

The keyboard/mouse wireless-combi is from Logitech…
Info driver:
Device USB\VID_046D&PID_C52E&MI_01\


#5

I also want to read an USB Stick:

I just tried the sample code with my new CerbuinoBee
https://www.ghielectronics.com/docs/36/usb-host

After plugging in the USB Stick code jumps to the Controller_DeviceConnectFailed handler without further informations.

I tried with two different USB Sticks (FAT32). 4GB and 512MB without success. Also tried FAT without success

Any suggestions (I’m using the onboard USB Host)?


#6

@ Alex111 - What is the model of the drives you tried?


#7

Here is the output of USB View of one of the devices:

Device Descriptor:
bcdUSB: 0x0200
bDeviceClass: 0x00
bDeviceSubClass: 0x00
bDeviceProtocol: 0x00
bMaxPacketSize0: 0x40 (64)
idVendor: 0x0D7D
idProduct: 0x1600
bcdDevice: 0x0100
iManufacturer: 0x01
0x0409: " "
iProduct: 0x02
0x0409: "USB DISK 20X "
iSerialNumber: 0x03
0x0409: "07511A16027F"
bNumConfigurations: 0x01

ConnectionStatus: DeviceConnected
Current Config Value: 0x01
Device Bus Speed: High
Device Address: 0x02
Open Pipes: 3

Endpoint Descriptor:
bEndpointAddress: 0x81 IN
Transfer Type: Bulk
wMaxPacketSize: 0x0200 (512)
bInterval: 0x00

Endpoint Descriptor:
bEndpointAddress: 0x02 OUT
Transfer Type: Bulk
wMaxPacketSize: 0x0200 (512)
bInterval: 0x00

Endpoint Descriptor:
bEndpointAddress: 0x83 IN
Transfer Type: Interrupt
wMaxPacketSize: 0x0040 (64)
bInterval: 0x04

Configuration Descriptor:
wTotalLength: 0x0027
bNumInterfaces: 0x01
bConfigurationValue: 0x01
iConfiguration: 0x00
bmAttributes: 0x80 (Bus Powered )
MaxPower: 0x64 (200 Ma)

Interface Descriptor:
bInterfaceNumber: 0x00
bAlternateSetting: 0x00
bNumEndpoints: 0x03
bInterfaceClass: 0x08
bInterfaceSubClass: 0x06
bInterfaceProtocol: 0x50
iInterface: 0x00

Endpoint Descriptor:
bEndpointAddress: 0x81 IN
Transfer Type: Bulk
wMaxPacketSize: 0x0200 (512)
bInterval: 0x00

Endpoint Descriptor:
bEndpointAddress: 0x02 OUT
Transfer Type: Bulk
wMaxPacketSize: 0x0200 (512)
bInterval: 0x00

Endpoint Descriptor:
bEndpointAddress: 0x83 IN
Transfer Type: Interrupt
wMaxPacketSize: 0x0040 (64)
bInterval: 0x04


#8

And here the other one:

Device Descriptor:
bcdUSB: 0x0200
bDeviceClass: 0x00
bDeviceSubClass: 0x00
bDeviceProtocol: 0x00
bMaxPacketSize0: 0x40 (64)
idVendor: 0x090C (Feiya Technology Corporation)
idProduct: 0x1000
bcdDevice: 0x1000
iManufacturer: 0x01
0x0409: ""
iProduct: 0x02
0x0409: ""
iSerialNumber: 0x03
0x0409: "11121221000089"
bNumConfigurations: 0x01

ConnectionStatus: DeviceConnected
Current Config Value: 0x01
Device Bus Speed: High
Device Address: 0x02
Open Pipes: 2

Endpoint Descriptor:
bEndpointAddress: 0x81 IN
Transfer Type: Bulk
wMaxPacketSize: 0x0200 (512)
bInterval: 0xFF

Endpoint Descriptor:
bEndpointAddress: 0x02 OUT
Transfer Type: Bulk
wMaxPacketSize: 0x0200 (512)
bInterval: 0xFF

Configuration Descriptor:
wTotalLength: 0x0020
bNumInterfaces: 0x01
bConfigurationValue: 0x01
iConfiguration: 0x00
bmAttributes: 0x80 (Bus Powered )
MaxPower: 0xFA (500 Ma)

Interface Descriptor:
bInterfaceNumber: 0x00
bAlternateSetting: 0x00
bNumEndpoints: 0x02
bInterfaceClass: 0x08
bInterfaceSubClass: 0x06
bInterfaceProtocol: 0x50
iInterface: 0x00

Endpoint Descriptor:
bEndpointAddress: 0x81 IN
Transfer Type: Bulk
wMaxPacketSize: 0x0200 (512)
bInterval: 0xFF

Endpoint Descriptor:
bEndpointAddress: 0x02 OUT
Transfer Type: Bulk
wMaxPacketSize: 0x0200 (512)
bInterval: 0xFF


#9

Hope this is the information you need?

I’m just evaluating your platform and will report back my experience in my team. This will considered what technology we will use for further projects in our company. I cannot do anything myself to get this working at the moment, so I would be very happy, if you can give my feedback what to do, or if this is a known problem…

Thanks!


#10

@ Alex111 - What about the name like Fujifilm 4GB MicroSD HC, class 4? We can see if we have one that is failing for you so we can quickly try to reproduce the error. Otherwise your best bet is to send us the ones that fail for us to test.


#11

Sorry but the USB Sticks are not labeled like this. I got one as gift which is not labeled at all. And on the other one is labeled witth Feiya. Nothing else… I used them over years in WinCe Windows and Linux systems without issues.

Unfortunately I connot send it from Germany easyly… Any other information, which could help you to find the issue?

Can you confirm, that Usb Sticks are supported in cerb?


#12

@ Alex111 - USB Sticks are supported in Cerb. We have used them internally numerous times. None of the sticks we have tried have ever given any issue like you’re describing. Just to be sure, can you post the code you are using?


#13

Please let me know if this should work?

 public class Program
    {
        private static RawDevice raw;

        public static void Main()
        {
            Controller.DeviceConnectFailed += Controller_DeviceConnectFailed;
            Controller.JoystickConnected += Controller_JoystickConnected;
            Controller.KeyboardConnected += Controller_KeyboardConnected;
            Controller.MassStorageConnected += Controller_MassStorageConnected;
            Controller.MouseConnected += Controller_MouseConnected;
            Controller.UnknownDeviceConnected += Controller_UnknownDeviceConnected;
            Controller.UsbSerialConnected += Controller_UsbSerialConnected;
            Controller.WebcamConnected += Controller_WebcamConnected;

            Controller.Start();

            BaseDevice[] allDevs = Controller.GetConnectedDevices();
            foreach (BaseDevice usbDev in allDevs)
            {
                Debug.Print("VID:" + usbDev.VendorId.ToString("X4"));
                Debug.Print("PID:" + usbDev.ProductId.ToString("X4"));
            }

            Thread.Sleep(Timeout.Infinite);
        }

        static void Controller_WebcamConnected(object sender, Webcam webcam)
        {
            Debug.Print("Webcam connected.");

            webcam.Disconnected += webcam_Disconnected;
        }

        static void webcam_Disconnected(BaseDevice sender, EventArgs e)
        {
            Debug.Print("Webcam disconnected.");
        }

        static void Controller_MouseConnected(object sender, Mouse mouse)
        {
            Debug.Print("Mouse connected.");

            mouse.Disconnected += mouse_Disconnected;
        }

        static void mouse_Disconnected(BaseDevice sender, EventArgs e)
        {
            Debug.Print("Mouse disconnected.");
        }

        static void Controller_MassStorageConnected(object sender, MassStorage storage)
        {
            Debug.Print("Mass storage connected.");

            storage.Disconnected += storage_Disconnected;
        }

        static void storage_Disconnected(BaseDevice sender, EventArgs e)
        {
            Debug.Print("Mass storage disconnected.");
        }

        static void Controller_JoystickConnected(object sender, Joystick joystick)
        {
            Debug.Print("Joystick connected.");

            joystick.Disconnected += joystick_Disconnected;
        }

        static void joystick_Disconnected(BaseDevice sender, EventArgs e)
        {
            Debug.Print("Joystick connected.");
        }

        static void Controller_UsbSerialConnected(object sender, UsbSerial usbserial)
        {
            Debug.Print("Usb Serial connected.");

            usbserial.Disconnected += usbserial_Disconnected;
        }

        static void usbserial_Disconnected(BaseDevice sender, EventArgs e)
        {
            Debug.Print("Usb serial disconnected.");
        }

        static void Controller_UnknownDeviceConnected(object sender, Controller.UnknownDeviceConnectedEventArgs unknowndevice)
        {

            Debug.Print("Unknown Device connected.");
            Debug.Print("   ID   = " + unknowndevice.Id.ToString("X4"));
            Debug.Print("   Port = " + unknowndevice.PortNumber);
            Debug.Print("   VID  = " + unknowndevice.VendorId.ToString("X4"));
            Debug.Print("   PID  = " + unknowndevice.ProductId.ToString("X4"));
            Debug.Print("   Type = " + (BaseDevice.DeviceType)unknowndevice.Type);

            raw = new RawDevice(unknowndevice.Id,
                                    unknowndevice.InterfaceIndex,
                                    unknowndevice.VendorId,
                                    unknowndevice.ProductId,
                                    unknowndevice.PortNumber,
                                    BaseDevice.DeviceType.HID);

            raw.Disconnected += raw_Disconnected;
            GHI.Usb.Descriptors.Device devdesc = raw.GetDeviceDescriptor();

            Debug.Print(devdesc.ToString());

        }

        static void raw_Disconnected(BaseDevice sender, EventArgs e)
        {
            Debug.Print("Raw device disconnected");
        }

        private static void Controller_DeviceConnectFailed(object sender, EventArgs e)
        {
            Debug.Print("Failed.");
        }

        private static void Controller_KeyboardConnected(object sender, Keyboard keyboard)
        {
            Debug.Print("Keyboard connected.");

            keyboard.Disconnected += keyboard_Disconnected;
        }

        private static void keyboard_Disconnected(BaseDevice sender, EventArgs e)
        {
            Debug.Print("Keyboard disconnected.");
        }
    }

#14

@ Alex111 - That code should work, yes. So you run that code, plug in your USB drive, and you get the device connect failed event?


#15

Yes, exactly. Any things I can do to get more debug informations?

I just found a third USB device - a sd card reader.

If I start the device and then plug in the card reader (with an SDCard inside) no event is fired.

But if I plug in the card reader and then start the debug session, then the event is fired one single time. I also get the Disconnected event one time. Any subsequent plug in/out do not fire any further events…

Any suggestions?


#16

I have news about this: I found out that my two USB Sticks seems to not fire error events anymore, if I unplug the Enc28 module…

But the issue with the card reader stays the same (no events)…

[quote]If I start the device and then plug in the card reader (with an SDCard inside) no event is fired.

But if I plug in the card reader and then start the debug session, then the event is fired one single time. I also get the Disconnected event one time. Any subsequent plug in/out do not fire any further events…
[/quote]

I added an issue on the task tracker: https://www.ghielectronics.com/community/forum/topic?id=18076


#17

@ Alex111 - After you remove the ENC28, do the two USB drives fire the Connected event and function normally?

Do you have any other board you can try these tests on?


#18

Yes, I can confirm this behaviour? After each try I disconnected USB cable from cerbuino to my computer and connected it again.

i.e. it works without the Enc28 module, but

I also have another one (without anything connected to the cerbuino except USB for debugging):

if I uncomment the two lines of “COM3” code, the USB Memory Sticks again fails with connect fail event. Can you confirm this, too?

           GHI.Usb.Host.Controller.UnknownDeviceConnected += Controller_UnknownDeviceConnected;
            GHI.Usb.Host.Controller.MassStorageConnected += Controller_MassStorageConnected;
            GHI.Usb.Host.Controller.DeviceConnectFailed += Controller_DeviceConnectFailed;
            GHI.Usb.Host.Controller.Start();


            //SerialPort com = new SerialPort("COM3", 115200);

            //com.Open();

Unfortunately I only purchased one cerbuino for evaluation. So far I must say that at the moment there are really many issues with this product…


#19

@ Alex111 - All of the USB drives we tried worked with or without the ENC28 connected. But I was able to reproduce the connect failed event when I added the two com port lines to the code. We will investigate that for the next SDK release.


#20

When do you think will a hotfix be available?