Hi-
Does anyone have ever enabled USB CDC device on a MK20DX128VFM5 with 16KB RAM only? I run into memory allocation failure in MAX 4.1 k20d50m BSP usb\device\source\device\dev_main.c:
USB_STATUS _usb_device_init
(
/* [IN] the USB device controller to initialize */
struct usb_dev_if_struct *usb_if,
/* [OUT] the USB_USB_dev_initialize state structure */
_usb_device_handle *handle,
/* [IN] number of endpoints to initialize */
_mqx_uint endpoints
)
{ /* Body */
...
/* Initialize the USB interface. */
if (dev_if->DEV_PREINIT != NULL)
{
error = dev_if->DEV_PREINIT((_usb_device_handle *) &usb_dev_ptr);
}
...
}
The function call above ends up with a NULL usb_dev_ptr due to a ~3KB memory allocation failure. Since this model of K20 has only 16KB memory, I just want to know if it is feasible to bring up USB CDC stack on this chip.
Thanks
Hui
Added some more details.
The exact failure place is in usb\device\source\device\khci\khci_dev_main.c, where 2432 bytes of memory is allocated:
USB_STATUS _usb_dci_usbfs_preinit
(
/* [IN] the USB device handle */
_usb_device_handle *handle_ptr
)
{
USB_KHCI_DEV_STATE_STRUCT_PTR usb_dev_ptr = (USB_KHCI_DEV_STATE_STRUCT_PTR) USB_mem_alloc_zero(sizeof(USB_KHCI_DEV_STATE_STRUCT));
KHCI_XD_STRUCT_PTR xd_ptr;
SCRATCH_STRUCT_PTR temp_scratch_ptr;
_mqx_uint j;
if (NULL != usb_dev_ptr) {
/* Allocate MAX_XDS_FOR_TR_CALLS */
usb_dev_ptr->G.XD_BASE = (XD_STRUCT_PTR) USB_mem_alloc_zero(sizeof(KHCI_XD_STRUCT) * MAX_XDS_FOR_TR_CALLS);
if (usb_dev_ptr->G.XD_BASE == NULL)
{
#if DEV_DEBUG
printf("2 memalloc failed in _usb_device_init\n");
#endif
...