Hi,
I have fixed a first problem with USB_HID_SET_REPORT_REQUEST (see USB_HID_SET_REPORT_REQUEST does not work correctly )
I have another issue where after 10 "Set Report" requests (sent from host), kboot stops answering requests.
It looks like there is a credit set at startup and each "Set Report" request consumes a credit. When there is no more credit, no more answers are sent to the host.
Also, trying to program the target using Windows KinetisUpdater, makes the target reboot.
Any fix to these issues ?
Best regards,
Nicolas
Hi Nicolas,
Would you please provide more details for your issue? for example, the platform information, the modification you applied for the boot loader, and something like that. I will try to reproduce the same issue here and investigate it. Thanks for your patience!
Have a great day,
Kan
Freescale Technical Support
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Kan,
I use a custom hardware very close to FRDM-K22F. I need to modify KBOOT to manage additional hardware present on my hardware.
I created a new workspace with KDS3.0.
In this workspace, I copied "src" and "target" folders from KBOOT 1.2.0.
In KDS3.0 I then imported "targets\MK22F51212\kds\freedom_bootloader" project.
Compile runs with success.
I added support for console on uart1.
I added support for I2C0 since I need it for some peripherals.
I can now manage all my hardware and get debug messages on UART1.
Everything works correctly except what I described in my first message.
1) USB_HID_SET_REPORT_REQUEST requests are received, response are sent, acknowledge of sent response (USB_DEV_EVENT_SEND_COMPLETE) are transmitted to application untill it blocks on a send response (or acknowledge, not sure which one)
2) In "usb_hs_hid_peripheral_interface.c" file, "usb_hid_app_param_callback()" function, how does "USB_DEV_EVENT_DATA_RECEIVED" treatment works since "event" is not used (except for length) ?
Regards,
Nicolas
Hi Nicolas,
Thanks for the information! From what you mentioned above, I guess you just used USB HID as the downloading interface, right? You know, this bootloader supports UART, I2C as well, and since you use UART1 and I2C0 for other purpose, you may disable them in the bootloader_config.h. like below:
That would help you avoid any possible conflicts, and I have tried to open the KDS project in a new work space, it works as expected. so I think the cause might be the software modification you added for UART1 and I2C0 support, if there is no more changes. Please only enable USB HID and see if it makes any difference.
The USB HID uses 3 endpoints:
• Control (0)
• Interrupt IN (1)
• Interrupt OUT (2)
so there is event of "USB_DEV_EVENT_DATA_RECEIVED" used for any IN transfer, please kindly refer to 6.5 USB HID Peripheral of Kinetis Bootloader v1.2.0 Reference Manual.pdf for details, and you may refer to Chapter 10 Kinetis bootloader porting for more details on the porting guide.
Hope that helps,
Have a great day,
Kan
Freescale Technical Support
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Kan,
I restarted from the begginning. Just added the fix for USB_HID_SET_REPORT_REQUEST as stated in my first message.
I get the same behaviour.
- USB_HID_SET_REPORT_REQUEST hangs after 10 requests
- Windows flash loader does not its job correctly (application is not running after flashing)
Best regards,
Nicolas
I fixed the USB_HID_SET_REPORT_REQUEST issue. I was searching on the TX side while the problem was on the RX side.
The problem is located in module "usb_hs_hid_peripheral_interface.c", function "usb_hid_packet_read()" :
This code is faulty :
if (s_hidInfo[hidInfoIndex].isReceiveDataRequestRequired) | |
{ | |
// Initiate receive on interrupt out pipe. | |
USB_Class_HID_Recv_Data(s_hidInfo[hidInfoIndex].app_handle, | |
HID_OUT_ENDPOINT, | |
(uint8_t *)&s_hidInfo[hidInfoIndex].report.header, | |
sizeof(s_hidInfo[hidInfoIndex].report)); | |
} | |
s_hidInfo[hidInfoIndex].isReceiveDataRequestRequired = true; |
Each time this code is executed, a new Interrupt OUT packet is requested. When using report request, this code is excuted while it should not.
I modified the module to fix this bug.
Now, I still have an issue where FlashEraseRegion either hangs the device or resets it.
Nicolas
I finally got it !
The hang problem is due to a strange compiler behaviour.
In /src/drivers/flash/flash_command_sequence.c, function copy_flash_run_command().
In the follwing line :
memcpy((void *)flashRunCommand, (void *)((uint32_t)flash_run_command - 1), funcLength);
For an unknown reason, (void *)((uint32_t)flash_run_command - 1) decrements flash_run_command by 2, not 1.
I replaced it with :
memcpy((void *)flashRunCommand, (void *)((uint32_t)flash_run_command & ~1), funcLength);
Also replaced next line by :
callFlashRunCommand = (void (*)(FTFx_REG_ACCESS_TYPE))((uint32_t)flashRunCommand | 1);
The same problem exists in /src/drivers/flash/flash_cache_clear.c, function copy_flash_cache_clear_command().
Nicolas
Forgot to say in my last message that I tested on FRDM-K22F board.
Hi Kan,
I already disabled all peripherals except USB HID.
1) Have you tried to send USB_HID_SET_REPORT_REQUEST repeatedly ?
My test program use set report to get KBOOT features. This was working prefectly with KBOOT V1.1.0 on a FRDM-k22F. Now, it hangs after 10 requests.
2) You have not answered my question : How does "USB_DEV_EVENT_DATA_RECEIVED" treatment works since "event" pointer is not used (except for length) ?
In USB_HID_SET_REPORT_REQUEST treatment, received data is copied to local buffer. There is no such thing in "USB_DEV_EVENT_DATA_RECEIVED treatment.
Best regards,
Nicolas
Nicolas
In case you continue having difficulties in solving loader issues, note that there is also a compatible solution at µTasker Kinetis FRDM-K22F support
It includes UART console and I2C in parallel with KBOOT HID functionaility - with a small OS included to allow easy additional functions being added without risk of breaking loader modules. Optionally you can enable SD card loading, USB-MSD (as composite together with KBOOT HID) or KBOOT (or SREC) UART.
The operation can be simulated with VisualStudio based K22 simulator so any further developments can be made, tested and debugged without usual HW restrictions for highest efficiency and shortest time-to-market.
Works on all K, KV, KL, KE, KEA, KW parts with almost any IDE.
Regards
Mark
Kinetis: µTasker Kinetis support
K22: µTasker Kinetis FRDM-K22F support / µTasker Kinetis TWR-K22F120M support
For the complete "out-of-the-box" Kinetis experience and faster time to market
Hello Mark,
I know µTasker. Very interesting product. But I need a free bootloader.
Regards,
Nicolas