I am working on TWR-K22F120M board. I am just working on the existing code and I have selected target device as “MK22F51212” and I have problem in USB detection.
Able to compile and download bootloader and LED Demo application code to target board.
Able to use KinetisFlashTool and download the application.
I have UART and USB peripherals enabled in Bootloader Configuration area. I am able to work with UART. Able to send command from blhost and do all the stuff with UART.
In bootloader_config.h I have ensured that
BL_CONFIG_USB_HID and BL_CONFIG_USB_MSC are enabled.
On the hardware side, I have ensured that jumpers J26 and J28 are mounted. Pin 1 and 2 of J27 is shorted and J34 is mounted.
After inserting USB, USB is not being detected.
Upon debugging, I have found that bootloader reads the configuration data, USB is enabled (enabledPeripherals = 0xF9, //!< Enabled Peripheral: UART CAN USB-HID), USB registration is success and handle is returned successfully.
Futher in bl_main.c, it polls for active peripherals, it is able to find UART but not USB.
// Wait for a peripheral to become active
while (activePeripheral == NULL)
Going further, below line invokes
if (peripheral->controlInterface->pollForActivity(peripheral)) (line 403 of bl_main.c)
calls below function in "usb_hid_msc_peripheral_interface.c"
bool usb_hid_poll_for_activity(const peripheral_descriptor_t *self)
// uint32_t hidInfoIndex = self->instance / 2;
bool hid_active = false;
bool msc_active = false;
hid_active = g_device_composite.hid_generic.hid_packet.didReceiveFirstReport;
#endif // USB_DEVICE_CONFIG_HID
msc_active = g_device_composite.msc_disk.msc_state.isActive;
#endif // USB_DEVICE_CONFIG_HID
s_dHidMscActivity = hid_active;
s_dHidMscActivity = msc_active;
return (g_device_composite.attach && (hid_active || msc_active));
variables hid_active and msc_active is never SET
Why? What is that I am missing? Am i getting interrupts? Am i registered with interrupts?
What is missing?
KBOOT doesn't support Host USB and there is not example available for your specific device, but you could check the following links:
I recommend to create this USB Host bootloader by using Kinetis Bootloader as reference, and because AN4368 uses USB BareMetal stack (4.1.1)
Sorry for all inconvenience it may cause.
My understanding was wrong and it was as below:
In bootloader mode, I can use the target as host and can connect mass storage device (eg. Pendrive) to the USB port and it will be able to detect the USB. But it is not so.
But implementation in Bootloader is as below:
The target is implemented USB MSC (Mass Storage Class) composite device classes. Plugging in Mass Storage Device to the target board will not help because our target itself is acting as mass storage device. (It is not implemented as host).
As explained in Section 6.6 of the user manual (Kinetis Bootloader v2.0.0 Reference Manual), I am able to connect the target as mass storage device and device drive letter appears in the file manager of the operating system.
But my aim is to make target as host in the Bootloader mode. How do we do it?
How do I make my target device as Host in Bootloader mode? By doing so I should be able to connect USB mass storage device to the target and read the files from the pen drive.
What are the options available? Is there any support from NXP towards this?
Any hint towards this direction is highly appreciated.