AnsweredAssumed Answered

Problems Using USB Host MSD with KDS + PEx + FatFs in OSA BareMetal Mode

Question asked by Alessandro Vagniluca on Jan 26, 2016
Latest reply on May 23, 2016 by isaacavila

On my custom board based on K66F180 cpu I have successfully developed an application that handles memory sticks on USB Host.

I have developed my application with KDS 3.1.0 and KSDK 1.3.0 + PEx. My application is based on MQX RTOS Standard and I created my project following the tutorial How To: Create an MQX RTOS for KSDK project with Processor Expert in Kinetis Design Studio IDE .

Following the tutorial FRDM K64F Data Logger using FatFs with KSDK 1.2.0 | Centaurian  and the host_msd_fatfs_mqx_twrk65f180m demo project provided with KSDK 1.3.0, I chose FatFs file system for the USB mass storage devices.

 

Now, on the same board I am developing another application that handles memory sticks on USB Host. This second application is more simple than the first one (it's a custom USB Host MSD bootloader), so I chose the OSA BareMetal mode provided with PEx. I use the same USB Host and FatFs source files of my first application.

 

In my application based on the OSA BareMetal mode I defined two task: the main Boot_task and the USB_task. Like in my first application, the USB_task waits for attach/detach events and mounts the FatFs file system on a successfully attached mass storage device.

 

I run into the following issues:

  1. If the watchdog is enabled (WDOG_DRV_Init()), the application crashes after few seconds. I still don't know why; I chose to not use the watchdog.
  2. When I inserted a memory stick, on the debug console I got the "3TR Timeout!" error message from the USB Host core. Following the post Kinetis Design Studio  USB "3TR Timeout!" in khci.c , I solved the issue disabling MPU on the main startup. But I still don't understand why.
  3. Attach/Detach events now are properly detected, but when mounting the FatFs file system on an attached memory stick, the msd_disk_ioctl() function in the msd_diskio.c source file (used to send the first SCSI commands to the device) never ends, because the end command call-back function is never called by the USB Host core.

 

I know USB Host core creates some internal OS_tasks, OS_events, OS_MessageQueues and OS_Mutex: for this, there is an adapter interface to the current SDK OS abstraction.

Issue 3. looks like some internal task or event related to the control-pipe transactions is not running properly in my OSA BareMetal system.

I have the macro OS_ADAPTER_ACTIVE_OS = OS_ADAPTER_SDK in the adapter_cfg.h header file. The macro USE_RTOS = 0 (no RTOS is used). In this condition msd_disk_ioctl(), msd_disk_read() and msd_disk_write() functions call the OSA_PollAllOtherTasks() function while waiting the command end. So the internal USB tasks should run and process the command transaction

 

OSA BareMetal mode is a possible choise also in the host_msd_fatfs_mqx_twrk65f180m demo project provided with KSDK 1.3.0.

What is the right configuration for the USB Host stack working in OSA BareMetal mode?

 

Thanks.

Outcomes