cancel
Showing results for 
Search instead for 
Did you mean: 

Where is Code for DFU_Detach request in runtime HID driver w/DeFuse?

davem2
Associate II
Posted on September 11, 2009 at 15:13

Where is Code for DFU_Detach request in runtime HID driver w/DeFuse?

8 REPLIES 8
davem2
Associate II
Posted on May 17, 2011 at 13:17

Defuse documentation talks about using a Runtime HID driver that supports the DFU_Detatch command, but Defuse ''Detatch'' button is greyed out.

Is there any sample code for how to setup the USB HID device descriptors so that it supports the DFU_Detatch command?

Thanks,

Dave

16-32micros
Associate III
Posted on May 17, 2011 at 13:17

Dear Dave,

Please refer to UM0412 ( User Manual) To be able to have a DFU Aware device while it is a HID device not composite, we have implemented a special protocol to be able to launch a Detach for HID class device providing the special HID detach feature :

(USAGE_PAGE 0xFF00 and USAGE_DETACH 0x0055) in its report descriptor.

Example:

0xa1, 0x00, // Collection(Physical)

0x06, 0x00, 0xFF, // Vendor defined usage page - 0xFF00

0x85, 0x80, // REPORT_ID (128)

0x09, 0x55, // USAGE (HID Detach)

0x15, 0x00, // LOGICAL_MINIMUM (0)

0x26, 0xFF, 0x00, // LOGICAL_MAXIMUM (255)

0x75, 0x08, // REPORT_SIZE (8 bits)

0x95, 0x01, // REPORT_COUNT (1)

0xB1, 0x82, // FEATURE (Data,Var,Abs,Vol)

0xC0, // END_COLLECTION (Vendor defined)

Once you receive your such Command by HID protocol, you should implement a mechanism to reset for example using internal watchdog and to re-enumerate as DFU device and not HID Device ( this for example adding a variable in RAM to detect the switch), Do not hesitate and let me know if it is not clear 🙂

Cheers,

STOne-32.

aherson
Associate II
Posted on May 17, 2011 at 13:17

Thank you for your help on this issue. I am a crossover from this posting:

http://www.st.com/mcu/forums-cat-8634-23.html

I am a little confused about the HID Descriptor posting as a solution for the failure to complete the erasure while in DFU mode. Are the two related? I suppose that an endpoint that can talk to the ST application software could be convenient to instantiate a reset and then return to DFU mode. Maybe I'll get to that later. I'm not that sophisticated yet.

In the meantime, can you please help me with the basics of DFU mode? Like I said in the other post, I hang at the 14% erase point.

16-32micros
Associate III
Posted on May 17, 2011 at 13:17

Quote:

I am a little confused about the HID Descriptor posting as a solution for the failure to complete the erasure while in DFU mode. Are the two related?

In the meantime, can you please help me with the basics of DFU mode? Like I said in the other post, I hang at the 14% erase point.

This failure is due to the fact that the DFU Software is erasing itself in the first pages of the Flash, that should be protected against write as we did in our demonstration inside the string descriptor where all first pages 12Kbytes of the flash) are only Read-able. For more details you can refer to set of documentation included with the DFU software

Cheers,

STOne-32.

brianh
Associate II
Posted on May 17, 2011 at 13:17

Hi,

I'm currently working with davem1 on the HID/DFU application. I've implemented the HID report suggested below in our main code. The DfuSe Demo application (v2.2.1) now recognizes our board in HID mode and enables the ''Enter DFU mode/HID detach'' button. It appears as if the button sends a set report command with two bytes of data (0x80 0x55) with the 0x80 being the report ID. I've traced the incoming command to the function CustomHID_Data_Setup and added a section of code to handle a SET_REPORT. Other than verifying that this was a SET_REPORT command, how do we additionally verify that the report ID was 0x80 and the data is 0x55?

Code snippet from usb_prop.c (v2.2.1)

RESULT CustomHID_Data_Setup(u8 RequestNo)

{

.

.

.

/*** GET_PROTOCOL ***/

else if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT))

{

if (RequestNo == GET_PROTOCOL)

{

CopyRoutine = CustomHID_GetProtocolValue;

}

else if (RequestNo == SET_REPORT)

{

CopyRoutine = CustomHID_GetProtocolValue;

// verify this is report id 128 with payload of 0x55

// not sure how to do this...

// set flag for main code to reset into DFU mode

// not implemented yet

}

}

.

.

.

sivakumar431
Associate II
Posted on May 17, 2011 at 13:17

Hi ,

I am New to this and need some info on Dfuse(i am using 3.0.0)

I am trying to run the joystick demo application, in order to switch from this HID mode to DFU mode i have added the following code in my report descriptor i.e(i commented REPORT_ID line in the descriptor, with which it doesnt work)

0xa1, 0x00, // Collection(Physical)

0x06, 0x00, 0xFF, // Vendor defined usage page - 0xFF00

//0x85, 0x80, // REPORT_ID (128)

0x09, 0x55, // USAGE (HID Detach)

0x15, 0x00, // LOGICAL_MINIMUM (0)

0x26, 0xFF, 0x00, // LOGICAL_MAXIMUM (255)

0x75, 0x08, // REPORT_SIZE (8 bits)

0x95, 0x01, // REPORT_COUNT (1)

0xB1, 0x82, // FEATURE (Data,Var,Abs,Vol)

0xC0, // END_COLLECTION (Vendor defined)

with this i am able see the joystick functionality but not able to see this in the devices list of the Dfuse utility on the Host PC and even the ''Enter DFU Mode/HID Detach'' button is not enabled.

In one of the mail thread i have seen changing the VID PID to that of Device Firmware Demo code i.e VID_0483 and PID_DF11, i tried this then i am able to see the device in the list but still the button is not enabled.

Can some one help on this to proceed i am stuck with it

Thanks in Advance

Siva

aherson
Associate II
Posted on May 17, 2011 at 13:17

All, thanks for any support provided to date on the DFUSE issue.

I have made slight progress since I last visited. I have:

* Demonstrated that my firmware upgrade project works by successfully upgrading my DFU enabled device from just a DFU enabled device to a mouse/speaker/joystick

* Demonstrated that I am pressing the right buttons between the hex->dfu conversion by rebuilding the sample application and making my own DFU file for download

However, I can not convert my project to a DFU ready project. I really think that I have done all of these things to ready my project. They are listed here:

http://data.versiontracker.com/drivers/autoExtract/analog/pub/MicroConverter/Keil_362c/MDK_ext/extract/ARM/Boards/ST/CQ-STARM2/readme.txt

Am I missing something? After I upgrade, my device does not function correctly.

Any help is greatly appreciated.

aherson
Associate II
Posted on May 17, 2011 at 13:17

I finally did it! Credit is due to the ST and Keil team for putting together a good USB upgrade solution.

Root cause of my problem: Well, I have been integrating example code into my project and one of the examples made a call to

void NVIC_Configuration(void)

which reset my memory map to 0x08000000! So, my code was running, but returning to zero because of this bug.

All is well! Thanks for listening.