Hello, I am using a FRDM-K22F and attempting to read and write files to an USB drive. Earlier I used the host_msd_fatfs_bm example program to get a working start. That program worked fine, next I integrated the usbh_sdk_bm_lib into a newly generated project using the KSDK project generator. When I added the files from the host_msd_fatfs_bm project into my generated one I get USB Host Initialization fail!: STATUS: 0x81. This appears to come from the USB host pipe descriptor memory allocation. I'm guessing I missed something before the USB host pointer is allocated here. Checking the memory location for the usb_host_ptr I find that is is allocated properly but its field, namely the pipe descriptor is not, and in turn is freed. Most of this is held in the khci.c source file.
usb_khci_host_state_struct_t* usb_host_ptr = (usb_khci_host_state_struct_t*) OS_Mem_alloc_zero(sizeof(usb_khci_host_state_struct_t));
pipe_struct_t* p;
pipe_struct_t* pp;
int32_t i;
if (NULL != usb_host_ptr)
{
usb_host_ptr->device_attach_phy = 0;
/* Allocate the USB Host Pipe Descriptors */
usb_host_ptr->pipe_descriptor_base_ptr = (pipe_struct_t*)OS_Mem_alloc_zero(sizeof(pipe_struct_t) * USBCFG_HOST_MAX_PIPES);
if (usb_host_ptr->pipe_descriptor_base_ptr == NULL)
{
OS_Mem_free(usb_host_ptr);
return USBERR_ALLOC;
}
I appreciate any and all help,
Thanks.
Solved! Go to Solution.
It turns out that the heap size was too small, quick and easy fix!