I'm working on a project using the MKL27Z128/256. The project uses the "usb_device_hid_generic" project in KSDK 2.0 as a starting point.
On power cycle or hardware reset, my code runs just fine.
The problem is with using the KBOOT bootloader in the ROM to perform SW updates in the field via USB HID.
I can programmatically jump to the bootloader and perform the update, but when blhost attempts to reset the device, it doesn't come up. I don't see my debug messages on LPUART0, and it doesn't enumerate on USB.
blhost -u 0x15a2,0x0073 flash-erase-all
blhost -u 0x15a2,0x0073 flash-image code.s19
blhost -u 0x15a2,0x0073 reset
Another developer asked a similar question about their MKL27Z128 design using SDK 1.3: KL27z getting crash on program booting from ROM(bootloader) using blhost reset command , but I'm not sure if the solution there still applies, or how to implement it.
TIA,
Jeremy
I ran into the same issue yesterday. None of the suggestions here worked for me. The problem I found is that the bootloader changed the default clock source from LIRC to HIRC. This led to random crashes during startup of the application code. To workaround, I preset the MCG_C1 to its default value before any initialization code. This seems to fix the issue.
int main(void) {
MCG->C1 = 0x40;
BOARD_InitBootPins();
Hi Jeremy,
I had the same problem 6 months ago, this bug is caused by the USB, on reboot from KBOOT, the code crash and go to HardFault, I tryed all, the solution was implement a pushbutton to physical reset on firmware updates.
Regards!
Rafael Toledo
The problem is in KBoot in the KL27 ROM, there is no place to put the above USB Clock disable as it has nothing to do with the users code.
The command "blhost -u 0x15a2,0x0073 reset" does not work when issued via USB.
On the USB bus analyzer it shows repeated enumeration failures, after programming and requires a board reset, what exactly happens depends on what FOPT got programmed to with the update just programmed.
What I, and I expect other users of the KL27, want is to get the source code for the KL27 KBoot ROM implementation, then we could fix the issue and customize the code without having to reinvent the wheel, with each of us doing our own KL27 KBoot implementation.
Is that equivalent to:
SIM->SCGC4 = SIM->SCGC4 & (~SIM_SCGC4_USBFS_MASK);
I couldn't figure out how to refer to SIM_SCGC4, and used the somewhat similar register fiddling in pin_mux.c as an example.
If that is equivalent, it didn't seem to make a difference, in which case I'll dig deeper.
Thank you!
Any comment as to whether what I've done is correct? So far I have been unable to resolve this problem.
Thank you,
Jeremy Wood
Hi Jeremy,
Your code above is equivalent. It should be placed before any USB configurations in the application code.
Did you follow my suggestion of connecting to the running target? What did you find?
Regards!
Jorge Gonzalez