USB driver unload/reload

Hi all!

I have a Cypress FX2 board (not the one from OSR, yet). This chip has the posibility to bootload into it’s RAM through USB. I want to control this process and load diffrent firmware
into the chip based on some registry values. But i don’t want to power down/power up my board every time i do that. So i wonder if there’s a way of automatically loading/unloading my USB driver (in that way my device will be disconnected and will be enumerated once again the driver loads). I found a solution using USB_CYCLE_PORT IOCTL but i’m not so happy with it cause it seems like brute force(and sometimes crashes). So, is there any other way to properly unload/reload my driver. I use WIN2K DDK.


Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

If you are changing the identity of the device on the bus (ie the VID and PID) you need to drop off the bus and be reenumerated, there is no other way.


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Marius Cetateanu
Sent: Thursday, June 16, 2005 5:48 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] USB driver unload/reload

Hi all!
?
I have a Cypress FX2 board (not the one from OSR, yet). This chip has the posibility to bootload into it’s RAM through USB. I want to control this process and load diffrent firmware
into the chip based on some registry values. But i don’t want to power down/power up my board every time i do that. So i wonder if there’s a way of automatically loading/unloading my USB driver (in that way my device will be disconnected and will?be enumerated once again the driver loads). I found a solution using USB_CYCLE_PORT IOCTL but i’m not so happy with it cause it seems like brute force(and sometimes crashes). So, is there any other way to properly unload/reload my driver. I use WIN2K DDK.


Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com To unsubscribe send a blank email to xxxxx@lists.osr.com

The FX2 can ReNumerate (their term) at any time, simply by using the
0xA0 vendor request over EP0 to load new firmware.

So, assuming your device has come out of reset and the FX2 hence has no
firmware running (ie. it’s using its “default USB device”), your
driver will match the unprogrammed Cypress (based on either the Cypress
VID, FX2 PID, or your custom VID/PID if you’ve got an EEPROM attached
and using a 0xC0 load). It will then use the 0xA0 VR to load *your* FX2
firmware after which the FX2 will renumerate, which simulates a physical
disconnect/reconnect on the bus. The DO you were working with will be
destroyed (you’ll get an IRP_MJ_PNP/IRP_MN_REMOVE_DEVICE) and you’ll
create a new DO for the renumerated device when you driver’s AddDevice
handler is called.

Now, you’re up and running with your first firmware. Your driver could
support an IOCTL that you define to load different firmware, based on
whatever parameters (ie. registry setting, IOCTL input) you choose. Your
IOCTL will again use 0xA0 VR to reload the new firmware, the DO you’re
using will be destroyed, and your driver will get called at AddDevice
(again assuming your new FX2 firmware specifies a VID/PID that your
driver matches).

Have a look at Ch 3 of the “EZ-USB FX2 Technical Reference Manual” PDF.

Cheers,
Josh

Hi all!

I have a Cypress FX2 board (not the one from OSR, yet). This chip has the posibility to bootload into it’s RAM through USB. I want to control this process and load diffrent firmware
into the chip based on some registry values. But i don’t want to power down/power up my board every time i do that. So i wonder if there’s a way of automatically loading/unloading my USB driver (in that way my device will be disconnected and will be enumerated once again the driver loads). I found a solution using USB_CYCLE_PORT IOCTL but i’m not so happy with it cause it seems like brute force(and sometimes crashes). So, is there any other way to properly unload/reload my driver. I use WIN2K DDK.


Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

If you are going to ship this piece of hardware, you cannot keep the
unprogrammed cypress VID/FX2 PID (think of what would happen if every
vendor did this). You need to have your own VID/PID come up when the
device is unprogrammed. Also, b/c of this design, any client talking to
the device will have to reestablish all settings/data everytime the
machine comes out of lower power. Something to consider if that type of
thing is a showstopper.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Josh S
Sent: Thursday, June 16, 2005 5:52 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] USB driver unload/reload

The FX2 can ReNumerate (their term) at any time, simply by using the
0xA0 vendor request over EP0 to load new firmware.

So, assuming your device has come out of reset and the FX2 hence has no
firmware running (ie. it’s using its “default USB device”), your
driver will match the unprogrammed Cypress (based on either the Cypress
VID, FX2 PID, or your custom VID/PID if you’ve got an EEPROM attached
and using a 0xC0 load). It will then use the 0xA0 VR to load *your* FX2
firmware after which the FX2 will renumerate, which simulates a physical

disconnect/reconnect on the bus. The DO you were working with will be
destroyed (you’ll get an IRP_MJ_PNP/IRP_MN_REMOVE_DEVICE) and you’ll
create a new DO for the renumerated device when you driver’s AddDevice
handler is called.

Now, you’re up and running with your first firmware. Your driver could
support an IOCTL that you define to load different firmware, based on
whatever parameters (ie. registry setting, IOCTL input) you choose. Your

IOCTL will again use 0xA0 VR to reload the new firmware, the DO you’re
using will be destroyed, and your driver will get called at AddDevice
(again assuming your new FX2 firmware specifies a VID/PID that your
driver matches).

Have a look at Ch 3 of the “EZ-USB FX2 Technical Reference Manual” PDF.

Cheers,
Josh

Hi all!

I have a Cypress FX2 board (not the one from OSR, yet). This chip has
the posibility to bootload into it’s RAM through USB. I want to control
this process and load diffrent firmware
into the chip based on some registry values. But i don’t want to power
down/power up my board every time i do that. So i wonder if there’s a
way of automatically loading/unloading my USB driver (in that way my
device will be disconnected and will be enumerated once again the driver
loads). I found a solution using USB_CYCLE_PORT IOCTL but i’m not so
happy with it cause it seems like brute force(and sometimes crashes).
So, is there any other way to properly unload/reload my driver. I use
WIN2K DDK.


Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com — Questions? First check the Kernel Driver FAQ
at http://www.osronline.com/article.cfm?id=256 You are currently
subscribed to ntdev as: xxxxx@windows.microsoft.com To unsubscribe send
a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag
argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

> If you are going to ship this piece of hardware, you cannot keep the

unprogrammed cypress VID/FX2 PID (think of what would happen if every
vendor did this). You need to have your own VID/PID come up when the
device is unprogrammed.

Yeah, the FX2 supports this behaviour when it has an EEPROM connected
and the first byte of the EEPROM is 0xC0. It then treats the first few
bytes of the EEPROM as the VID/PID. You can also have it load its
firmware from the EEPROM if you want instead of loading at enumeration time.

Cheers,
Josh

I have custom PID/VID values and i’m performing a C0 Load from an EEPROM.
I guess the solution Josh outlined is the best giving the situation. Unfortunately i have to
do the Renumeration process twice for every change cause i have an external RAM chip that has to be loaded also and that requiers implementing a vendor specific command: Load External RAM.

Many tahnks!

Josh S wrote:

> If you are going to ship this piece of hardware, you cannot keep the
> unprogrammed cypress VID/FX2 PID (think of what would happen if every
> vendor did this). You need to have your own VID/PID come up when the
> device is unprogrammed.

Yeah, the FX2 supports this behaviour when it has an EEPROM connected
and the first byte of the EEPROM is 0xC0. It then treats the first few
bytes of the EEPROM as the VID/PID. You can also have it load its
firmware from the EEPROM if you want instead of loading at enumeration time.

Cheers,
Josh


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@yahoo.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

---------------------------------
Yahoo! Sports
Rekindle the Rivalries. Sign up for Fantasy Football

Marius Cetateanu wrote:

I have custom PID/VID values and i’m performing a C0 Load from an EEPROM.
I guess the solution Josh outlined is the best giving the situation.
Unfortunately i have to
do the Renumeration process twice for every change cause i have an
external RAM chip that has to be loaded also and that requiers
implementing a vendor specific command: Load External RAM.

The sample Cypress “ezloader” driver handles the firmware and external
RAM loading in one driver. You don’t have to re-enumerate twice.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Search the MS’s newsgroups for “schizophrenic devices”. You will find a good article by Eliyas Yakub (dated around Mon-Feb 2002) with detailed explanation of this issue.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
----- Original Message -----
From: Marius Cetateanu
To: Windows System Software Devs Interest List
Sent: Thursday, June 16, 2005 4:47 PM
Subject: [ntdev] USB driver unload/reload

Hi all!

I have a Cypress FX2 board (not the one from OSR, yet). This chip has the posibility to bootload into it’s RAM through USB. I want to control this process and load diffrent firmware
into the chip based on some registry values. But i don’t want to power down/power up my board every time i do that. So i wonder if there’s a way of automatically loading/unloading my USB driver (in that way my device will be disconnected and will be enumerated once again the driver loads). I found a solution using USB_CYCLE_PORT IOCTL but i’m not so happy with it cause it seems like brute force(and sometimes crashes). So, is there any other way to properly unload/reload my driver. I use WIN2K DDK.


Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 You are currently subscribed to ntdev as: xxxxx@storagecraft.com To unsubscribe send a blank email to xxxxx@lists.osr.com