Out of Memory with USB UFN driver

I found this issue investigating strange behaviors related to this topic and this one.

It’s quite easy to reproduce this “Out of Memory” situation following these steps:

  • set the USB port as permament USB client as described here (remove SODIMM 137 jumper and set that pin as GPIO output and 1; set the registry as
    [HKEY_LOCAL_MACHINE\Drivers\BuiltIn\UFN]
    "Dll"="usbfn.dll"
    [HKEY_LOCAL_MACHINE\Drivers\BuiltIn\USBOTG]
    "Dll"="_otg_vybrid.dll"

  • open Start >> Settings >> Control Panel >> System and switch to “Memory” tab

  • wait for 3 hours (more or less). You see that the Memory “In Use” arises a little bit (less than 500 kB in 3 hours) but WinCE is somehow crashed

  • as a matter of fact, if you try to connect the USB cable to X29 connector you see the following error

If you wait for a longer time before plugging the USB cable, the “Out of memory” popup is not shown and the OS is completely unresponsive.

As far as I know, based on my tests, this behavior doens’t happen if you don’t reconfigure the OS as permanent USB Client as described above.

This issue is quite important for my application and I hope you can investigate and fix it as soon as possible.
I can help doing additional tests and/or testing a beta release.

Hello @raja.tx

feel free to come back to me if I can help in some way.

Dear @vix,

Thank you for your patience.
Could you please log debug message during this test case and share with us.

Did you run an automatic script to keep toggle Gpio 137 pin to simulate USB cable detections?

Is USB client cable connected to Colibri and PC during the test? or Did you connect USB client after out of memory warning?

Hi @raja.tx

I’m going to save and share debug messages but I need some hours (at least).

In the meanwhile, let me clarify some points:

  • during the test the USB cable is not connected and nothing runs on the Colibri (apart from the Desktop and the System Properties application)
  • I plug the USB cable asfter some hours to demonstrate that the module has problems (the popup demonstrates this). If you dont’ plug the cable and you wait for 5 or 6 hours the module is completely unresponsive to mouse, touch screen, … (without any popup)

The test is quite easy: reconfigure the module as permanent USB client, boot it and wait (without USB cable plugged). I suspect the problem is in usbfn.dll (my two cents).

See attached the debug messages

Dear @vix,

Thank you for the details.

Did you set SODIMM_137 as GPIO, output through application or boot config settings.

By default, it is set to Alt 2 mode(RCON27). Please confirm, let me make similar setup and try the reproduce the issue on our side.

Hi @raja.tx
I confirm that I set SODIMM_137 as GPIO through boot config settings.

Dear @vix,

Could you please share exact details of what did you set on boot gpio config settings.

Goto bootloader command mode and enter set gpio command and please share the output of that command. Thank you.

Initiating image launch in 1 seconds.

BootLoader Configuration:

C) Clear Flash Registry X) Enter
CommandPrompt Mode D) Download image
to RAM now F) Download image to FLASH
now L) Launch existing flash resident
image now

Enter your selection: x

set gpio

Here is what I set:

set gpio.bootconf "[gpio_52]altfn=-1 dir=in pull=none [gpio_102]altfn=-1 dir=out lvl=1 pull=none"
save gpio

I use GPIO_52 for the LCD backlight.

Dear @vix,

Unfortunately, we are not able to reproduce the similar issue with your inputs and using the following setup here.

Colibri VF61, 256MB IT V1.2A,

Colibri Evaluation board 3.2A

Windows CE 6.0 1.5 for Vybrid Built Dec 18 2017.

Most probably, there would be different hardware behavior that could cause the issue on your side.

Is there any malfunction on gpio_102? Could you please probe gpio_102 and verify the gpio is the stable state in all the times?

Could you please export ConfigBlock, registry, filesystem using UpdateTool, BackUp and share with us. Let me program v1.5 release image and import all your config block, registry, and filesystem and let’s see whether we are able to reproduce the issue on our side.

Note: Please use standard release image inbuilt update tool( v 7.5.0) do not use the OS image inbuilt update tool ( Start → Programs → ColibriTools → UpdateTool, v 7.3.0).

Could you please try to do the same testing on different Colibri VF SOMs or Eval board and let us know your results.

Hi @raja.tx

I can confirm that gpio_102 works as expected (set to high level).

My configuration is exactly like yours (Colibri VF61, 256MB IT V1.2A - Colibri Evaluation board 3.2A - Windows CE 6.0 1.5 for Vybrid Built Dec 18 2017).

I can see the issue on all the VF61 modules I have, both with Evaluation Board and our custom carrier board.

On Evaluation Board I removed jumper on X11 corresponding to SODIMM_137.

I attach the backup that you requested.

From my tests, the issue happens only if you disable otg_vybrid.dll and enable usbfn.dll as it is described in the first message of this topic.

Hi @raja.tx
reproducing the problem is always the first step towards a fix.

Let me know

Hi,

We check this pins. This is connected also to VBUS on module and when you set it to 1 it start triggering USB IRQ that will lead to memory leak on long term.

The only solution is not to use this pin as GPIO but pull it down. We will document this in the next release of datasheet.

I am sorry for your trouble.

Hi @luka.tx

now I’m a little bit confused about the situation and I need your help to clarify it.

As you can read on my first message in this topic, I set the pin to 1 as suggested in this other topic.

You can read on that topic that the original issue was related to the boot of VF61 while an external +5 V is present on USB0_VBUS_DETECT (because the PC is already connected when the power supply to VF61 is enabled).

Since I don’t need USB Host, I followed the suggestions and modified the setup of the pin and the USB driver loaded.

Now you say that I can’t use this pin as GPIO, but I must pull it down.

Do you mean I should use an external pull-down resistor?

And how should I configure the pin?

Moreover, does the device works as Mass Storage Device if I hold this pin low?
In another topic @andy.tx redirect me to this page if I want to set the module as Mass Storage Device.

It seems to me that we have a puzzle and we can’t insert the last piece without having to move the others.

hi Vix,

I did not really follow this questions from beginning. I only did debugging today to figure out why this happens and I see on module we connect it also to VBUS. Now if this pins is 1 then also VBUS is one and this makes issues for USB detection.

Now if you only want host, you can just leave this PIN as is and add registry as you already have →

[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\UFN] 
"Dll"="usbfn.dll"
[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\USBOTG] 
"Dll"="_otg_vybrid.dll"

If you leave PIN 137 in default configuration this is going to work.
I hope you understand this. I think there was some confusion between answers and questions.

hi @luka.tx

for sure I appreciate your help and I’m going to do other tests, but I need to be sure that we talk abou the same configuration.

And so I think we need the help @raja.tx and @andy.tx (who suggested different approaches).

Now if you only want host

I don’t need USB Host; I need USB Client only.

you can just leave this PIN as is

Do you mean configuration only?
Or do you mean that the pin must be connected to VCC_USB5 on the Evaluation Board (i.e. jumper # 49 of X11 must stay plugged)?

if you want client sorry i mixed client and host.

So if you want client only you can use that registry settings and not change the pin.

You can remove jumper from EVB and it should work.

@luka.tx

I removed the configuration of the pin as OUTPUT high and I modified the registry to load usbfn.dll.

In this way should the module work as USB client (i.e. seen as mass storage device when it is connect to my laptop)?

This doesn’t happen, unfortunately.
I connect X29 of EVB to my laptop.

I modified the registry as described here (following @andy.tx suggestion) but the behavior is the same:
the laptop doesn’t see the SD Card plugged into EVB when I connect the EVB to the laptop itself.

Ok I did some more testing on this and it seems that there is no way to currently connect without connecting PIN 137.

Now my question is can you design hardware to comply with this? I am sorry for all the confusion but looking at this again its not clear why it cant work.

Hi @luka.tx

I designed my hardware so that I can either connect or disconnect PIN 137; if I disconnect it, I can pull it high or low.

I took this decision because I started having issue with this pin more than one year ago (see this topic - the issue with On/Off button is generated by PIN 137).

This topic too is related to USB, and I don’t know if it is somehow involved. I decided not to use this pin as GPIO and so I didn’t disable the driver HCD_HSH1.

More in general, if the module is OFF but you supply an external voltage on some pins.
For your convenience, I quote from the original topic:

First of all, the issue happens when
the evaluation board is powered off
but some power supply is applied to
some pins of the VF61. This can
happen, as an example, when USB cable
is connected from the PC to X29
connector (signal USB0_VBUS_DETECT).
Another example on the Evalution Board
is if I apply a DC value of +3.3 V
(driven with high impedence) to pin
SODIMM_30. This simulates an output. I
measured that when the Evaluation
board is powered off, a current of
more or less 16 mA is driven into VF61
through this pins (USB0_VBUS_DETECT or
SODIMM_30).

My guess is that this current gives
some problem to the VF61 when it boots
(not 100% of the times, but more
frequently if you push and hold down
the button SW7 for a couple of
seconds). Some months ago I was wrong:
the VF61 boots (I can see from the
extended debug messages), but the RGB
interface which drives my EDT display
doesn’t work as expected. Most of the
times the display is completely white,
but sometimes I can see images with
some missing colors. I don’t know if
some other peripherals are affected
somehow.

And so if I leave PIN 137 connected, sometimes the VF61 canot boot if USB cable is connected to the PC before the module itself is powered on.

To summarize:

  • I need USB client only
  • module should boot even if USB cable is connect to the PC before powering on

Could you clarify the hardware and software configuration necessary?