Main Site Documentation

USB Host without using GHIElectronics.NETMF.USBHost dll


Has anybody succeeded with USB host without using the GHIElectronics.NETMF.USBHost library.
Because i want to know the basic communication details with Mass Storage Class (MSC).
How the Controller handshake and read the VID and PID from the Mass Storage…

Regards YuvaRaja…


Thank you for your reply andre.m.
ya am read the USB…rg ,jan axelson’s blog and some sources…
i need to know , how the basic communication done in the NETMF…

Regards YuvaRaja…


Download Microsoft Porting Kit for NETMF from codeplex.

It will show you how it is implemented.


ya i will try it now…


There is no support for USB Host in standard NETMF.


@ Cuno - You are right. My mistake


oh…Then where can i get the details…
Any one can help me…?

Regards YuvaRaja…


User manual for particular MCU and example code from the manufacturer would be my first stop.


There is no support for USB Host in standard NETMF.

So in the NETMF, we are unable to make a USB Host Without using the GHI library…?
and the USB device (Client) only available in the NETMF…?
i cant understand what do u mean…?


What GHI board are you using?


Am not using the GHI Board…
Am use STM32f407ZG from ST
with a own PCB Board…
That has the USB Host port also…

please Answer my last Question also…


I figured out Something…The NETMF doesn’t Support for the USB HOST functionality.
If we need the HOST functionality means, we want to write our own LOW LEVEL (or REGISTER LEVEL ) code.
I think that the GHI done it in the GHIElectronics.NETMF.USBHost library.
Is it correct…?
Or something else in it…?

Regards YuvaRaja…


oh, Thank you andre.m.


Am trying to use the low level code and initialize the USB host Full speed but the problem is when upload the program,the program upload successfully. After that movement the USB not detected in my system.So i need to upload the firmware for every time. But my board use the USB host High speed port for deployment.Still i cant figure out the problem why the Full speed registers affect the High speed registers…?


lets get this straight.

you’re not using a GHI board.
you’re not using the .Net Micro framework.

And you expect someone here to be able to help? Hmmm, sorry, I don’t think you’re going to find anyone who can actually help, even if it was relevant to anyone here - which it isn’t.


Hi Brett…first of all am not using the GHI board, but am using the ghi firmware in a NETMF device…
did u know the GHI provides the low level code i mean register level code in the OSHW.Hardware, so am trying it in the low level code only.k
thanks for reply…


Hi andre.m
The low level code means IC’s Register level code

using GHI.OSHW.Hardware.LowLevel;
namespace USBtest
    public static class Program
        private const UInt32 HPRT_ADDRESS = 0x50000440;    //Host port control and status register
        private const UInt32 GINTSTS_ADDRESS = 0x50000014; //Global core interrupt register
        private const UInt32 GUSBCFG_ADDRESS = 0x5000000C; //Global USB configuration register
        private const UInt32 GINTMSK_ADDRESS = 0x50000018;   // interrupt mask register 
        private const UInt32 HCFG_ADDRESS = 0x50000400; //Host configuration register
        private const UInt32 GRXFSIZ_ADDRESS = 0x50000024; //Receive FIFO size register
        private const UInt32 HNPTXFSIZ_ADDRESS = 0x50000028;//Host non-periodic transmit FIFO size register
        private const UInt32 HPTXFSIZ_ADDRESS = 0x50000100; //Host periodic transmit FIFO size register
        private const UInt32 HAINTMSK_ADDRESS = 0x50000418; //Host all channels interrupt mask register
        private const UInt32 HAINT_ADDRESS = 0x50000414; //Host all channels interrupt register
        private const UInt32 HCTSIZ1_ADDRESS = 0x50000530;  //Host channel-1 transfer size register
        private const UInt32 HCCHAR1_ADDRESS = 0x50000520; //Host channel-1 characteristics register
        public static bool FullSpeedDevice = false, LowSpeedDevice = false;
        public static void Main()
            UsbController[] controllers = UsbController.GetControllers();
            Debug.Print("HPRT Reset value: " + HPRT.Read().ToString());
            Debug.Print("GUSBCFG Reset value: " + GUSBCFG.Read().ToString());
            Debug.Print("GINTSTS Reset value: " + GINTSTS.Read().ToString());

        public static void ChannelInit()
        public static bool DeviceInit()

            HAINT.SetBits(1);  //Channel 1 Selected
            HAINTMSK.SetBits(1);  //Channel 1 Selected
            while (true)
                UInt32 t = HPRT.Read();
                bool t1 = IsClear(t, 1);
                if (t1)
                    Debug.Print("Device Connected");
                    HPRT.SetBits(10);  //
                    Thread.Sleep(10);  //Reset Process  

                    HPRT.SetBits(2); //Set Port Enable bit
                    t = HPRT.Read();
                    bool t2 = IsClear(t, 3); //Port enable/disable change detection bit
                    if (t2)
                        t = HPRT.Read();
                        bool Speed1 = IsSet(t, 18);
                        bool Speed2 = IsSet(t, 17);
                        if (Speed1 == false && Speed2 == true) { FullSpeedDevice = true; Debug.Print("FULL SPEED DEVICE CONNECTED"); }
                        if (Speed1 == true && Speed2 == false) { LowSpeedDevice = true; Debug.Print("LOW  SPEED DEVICE CONNECTED"); }
                        if (Speed1 == false && Speed2 == false || Speed1 == true && Speed2 == true) Debug.Print("UNKNOWN SPEED DEVICE CONNECTED");
                        return true;
                        //Init Complete
                        //Next to do Channel initialization
                    return false;
        public static void RegisterInit()

            GUSBCFG = new Register(GUSBCFG_ADDRESS);
            HPRT = new Register(HPRT_ADDRESS);
            GINTSTS = new Register(GINTSTS_ADDRESS);
            GINTMSK = new Register(GINTMSK_ADDRESS);
            HCFG = new Register(HCFG_ADDRESS);
            GRXFSIZ = new Register(GRXFSIZ_ADDRESS);
            HNPTXFSIZ = new Register(HNPTXFSIZ_ADDRESS);
            HPTXFSIZ = new Register(HPTXFSIZ_ADDRESS);
            HAINTMSK = new Register(HAINTMSK_ADDRESS);
            HAINT = new Register(HAINT_ADDRESS);
            HCTSIZ1 = new Register(HCTSIZ1_ADDRESS);
            HCCHAR1 = new Register(HCCHAR1_ADDRESS);
            //Debug.Print("HPRT Reset value: "+HPRT.Read().ToString());
            //Debug.Print("GUSBCFG Reset value: " + GUSBCFG.Read().ToString());
            //Debug.Print("GINTSTS Reset value: " + GINTSTS.Read().ToString());
        public static bool IsSet(UInt32 Byte, int BitPos)
            //This working properly only when apply HEX values
            //But the Register.Read() returns Decimal numbers.

            string hexNumber = Byte.ToString("X");
            UInt32 mask = 1U << BitPos;
            return (Byte & mask) != 0;

        public static bool IsClear(UInt32 ba, int bit)
            UInt32 mask = 1U << bit;
            return (ba & mask) != 0;


This is my example code for the USB host full speed…
Am already states that this code only crash the USB debug port…


Hi patc
Still am not find USB host code,So i will try to write my own driver…


GHI USB Host is a premium feature. So I assume this is not OpenSource.


Yes it is not a open source, But it is possible to write our own Host functionality through the GHI.OSHW.Hardware.LowLevel…