USB Stack 4.0 problems running out of flash

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

USB Stack 4.0 problems running out of flash

跳至解决方案
1,165 次查看
GregLoucks
Contributor II

I'm trying to get my application using the USB Stack 4.0 CDC device driver to run out of flash on my K60F120 board. It works fine if I load and run it from RAM, but not if I download and start from flash. The rest of the code, including interrupts and a flexbus device, works fine in both cases. The problem is that the host will not correctly enumerate the CDC device when running out of flash. I haven't delved into the details yet, I was hoping someone had some ideas?

 

Greg

0 项奖励
1 解答
709 次查看
GregLoucks
Contributor II

My problem was actually that the descriptors were marked const and put in the flash, however they are supposed to be in RAM for USB access. I had somewhere along the way mangled the the __MK_xxx_H__ #define (usb_descriptors.c) and that ended up putting the descriptors in flash.

 

BlackNight: I've had to make some changes to the USB Stack 4.0 already to allow large packet sizes. In a few places a size parameter is a uint_8 and not a USB_PACKET_SIZE type. I've also ported the k70 high-speed code into the k60 (as I'm using USBHS).

 

--Greg

在原帖中查看解决方案

0 项奖励
6 回复数
710 次查看
BlackNight
NXP Employee
NXP Employee

Hard to guess. Would be good to know what is not working. Is it just not enumerating? or the application does not run at all?

 

I don't have the K60F, but I'm running a Processor Expert component based on 4.0 USB Stack (see http://mcuoneclipse.wordpress.com/category/processor-expert/embedded-components/usb/, http://www.steinerberg.com/EmbeddedComponents/FSL_USB_Stack and http://www.steinerberg.com/EmbeddedComponents/Examples/Example_PE_CDC_V1JM128).

I think you should be able to run it on the K60F as well (as the difference is just the added floating point unit).

I have attached the MCU10.2 project, and it runs out of flash for me.

 

Hope this helps,

BK

0 项奖励
710 次查看
GregLoucks
Contributor II

My problem was actually that the descriptors were marked const and put in the flash, however they are supposed to be in RAM for USB access. I had somewhere along the way mangled the the __MK_xxx_H__ #define (usb_descriptors.c) and that ended up putting the descriptors in flash.

 

BlackNight: I've had to make some changes to the USB Stack 4.0 already to allow large packet sizes. In a few places a size parameter is a uint_8 and not a USB_PACKET_SIZE type. I've also ported the k70 high-speed code into the k60 (as I'm using USBHS).

 

--Greg

0 项奖励
710 次查看
BlackNight
NXP Employee
NXP Employee

Hi Greg,

I would be interested in those changes you have made to support larger packet sizes.

 

BK

0 项奖励
710 次查看
GregLoucks
Contributor II

Here is what I've done so far:

 

* In Source/Device/app/common added:
MK60DZ10.h
MK60F12.h
MK60F15.h

 

* Everywhere there was:
#ifdef MCU_MK70F12
there is now
#if defined(MCU_MK70F12) || defined(MCU_MK60F12)
or
#ifndef MCU_MK70F12
becomes:
#if !defined(MCU_MK70F12) && !defined(MCU_MK60F12)

 

Everywhere there is a naked printf I put put an ifdef:
#ifdef SERIAL_DEBUG
printf(...);
#endif

 

Lots of changes to register names in Source/Device/app/common/main_kinetis.c (attached).

 

Additional changes to code described in attached file.

0 项奖励
710 次查看
MVa
NXP Employee
NXP Employee

Hi,

  Maybe this could help.

  After reset USB DMA (bus master) has no access to the FLASH memory (if descriptors are placed  in RAM everithing is OK). See description of the M3AP (M6AP for USBHS) bits in the FMC_PFAPR register.

Next possible probelm can appear if there is a never ending loop in your code and the loop code is placed in FLASH. By default Core bus master has higher priority then USB DMA bus master -> USB DMA will wait until CPU release bus but this will never happed and USB enumeration will be unsuccessfull (see AXBS_PRSn register). I have attached picture of CPU componet  with required setings in the Processor Expert.

 

Best Regards

MVa

0 项奖励
710 次查看
eli_hughes
Contributor V

*THANK YOU* for pointing out this #if....    I was trying to migrate the CDC files from the library to a stand alone project (without all the ridiculous soft links).

 

Been fighting with this for awhile now...

0 项奖励