DFU Upload only working when MAX_BLOCK_SIZE is not a multiple of CONTROL_MAX_PACKET_SIZE

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

DFU Upload only working when MAX_BLOCK_SIZE is not a multiple of CONTROL_MAX_PACKET_SIZE

跳至解决方案
1,097 次查看
gabrielharrison
Contributor III

Hi,

We are using the DFU class in USB 4.1.1 library successfully to update our device but have had to create a work-around for this issue.

The device is a MK60F15. We have used the bare-metal example code to initialize the USB-FS module.

I have found that if the DFU packet size (MAX_BLOCK_SIZE in usb_descriptor.h) is a multiple of USB packet size the upload hangs at the end of the first block. I've created a temporary work-around by setting MAX_BLOCK_SIZE to 499 but this then causes a bit of a headache within the code that burns each block to flash.

I think the issue is probably that a Zero Length Packet is not sent at the end of the final block but haven't managed to find the relevant bit of code in the stack. I'm also not entirely sure if the issue is at the Windows App end of the Kinetis MCU end.

Any help would be much appreciated,

Gabriel

Message was edited by: Gabriel Harrison

标签 (2)
0 项奖励
1 解答
882 次查看
gabrielharrison
Contributor III

Hi,

I have managed to get to the bottom of this issue but would appreciate a little more advice. The cause of the issue is the Windows DFU Demo not the firmware.

If the block size is a multiple of the USB packet size, after the last block packet, a zero length packet is expected (as set up in USB_Bus_Token_Cpl_Handler() [lines 1608 - 1645]) but is never sent

I have proved this by temporarily changing the 'flag' parameter of the call to _usb_device_init_endpoint() to FALSE.

I am not a C# developer but think that the Demo app needs to configure the use of ZLP with WinUsb_SetPipePolicy() has anyone done this?

Is there a more up-to-date version the the demo app?

Thank you,

Gabriel

在原帖中查看解决方案

0 项奖励
7 回复数
883 次查看
gabrielharrison
Contributor III

Hi,

I have managed to get to the bottom of this issue but would appreciate a little more advice. The cause of the issue is the Windows DFU Demo not the firmware.

If the block size is a multiple of the USB packet size, after the last block packet, a zero length packet is expected (as set up in USB_Bus_Token_Cpl_Handler() [lines 1608 - 1645]) but is never sent

I have proved this by temporarily changing the 'flag' parameter of the call to _usb_device_init_endpoint() to FALSE.

I am not a C# developer but think that the Demo app needs to configure the use of ZLP with WinUsb_SetPipePolicy() has anyone done this?

Is there a more up-to-date version the the demo app?

Thank you,

Gabriel

0 项奖励
882 次查看
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Gabriel,

Which device did you run the USB stack 4.1.1 on? Would you please help to clarify? Thanks for your patience!


Have a great day,
Kan

Freescale Technical Support
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
882 次查看
gabrielharrison
Contributor III

Hi,

Sorry, yes that would be useful!

I'm running it on a MK60F15 by using the MK60F15 bare-metal example code to initialize the USB-FS module.

Gabriel

0 项奖励
882 次查看
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Gabriel,

Thanks for  the information! Would you please tell us if there is any other changes you applied to the USB stack 4.1.1 besides MAX_BLOCK_SIZE? It would be better  if you pass your project for a review, and Thanks for your patience!


Have a great day,
Kan

Freescale Technical Support
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
882 次查看
gabrielharrison
Contributor III

Hi,

The change I have made to the stack are:

- Global upgrade of wBlockNum & Final_Block from uint_8 to uint_16 to allow block sizes > 255 (usb_descriptior.c, usb_descriptior.h, usb_dfu.c)

- Upgraded wTransferSize to use both bytes (usb_descriptior.c)

- Increase USB_OUT_PKT_SIZE to 4096 (user_config.h)

- Change MAX_BLOCK_SIZE to 499 (usb_descriptior.h)

Regards,

Gabriel

0 项奖励
882 次查看
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Gabriel,

I have checked with an expert for DFU application, and he told me USB_OUT_PKT_SIZE can be 64 bytes at max according to the USB spec. so maybe you can try reduce it and see  if it makes any difference.

Hope that helps,


Have a great day,
Kan

Freescale Technical Support
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
882 次查看
gabrielharrison
Contributor III

Thanks,

I've updated USB_OUT_PKT_SIZE although something is still not happy as it's getting stuck in USB_DFU_DNBUSY.

I'm on vacation for a week and will pick this up again when I get back. It could be that this was the fix for this question but I can't tell quick yet.

Regards,

Gabriel

0 项奖励