David
OK - I now understand that you "are" the keyboard device that is returning a stall when the host sends the SET_IDLE to its interface 1.
I don't know why the host is repeating the same SET_IDLE (which I would expect to be simply stalled again) but I understand that the basic issue is that this 'following' transaction from the host is showing the problem (and not which transaction it actually is).
I have also attached a recording of a typical HID case which does this. In this case the following transaction is not a repeat of the SET_IDLE but a GET DESCRIPTOR (also a SETUP transaction) so it should be equivalent. It just shows that this is normal activity and the following transaction continues normally.
In your recording I see that there are "ERROR" blocks shown in the host's transmission which led me to initially think that it may be a host problem (and you were using a host interface in your project) but after a bit of reflection (I don't know the analyser view) I now am assuming that it is not actually signalling that the host transmission was bad but instead that the host transmission was probably never acked by the device (I can't see any other thing that it could be representing because the data content looks OK). I also see that the SETUP is in fact repeated a number of times, which the host controller (very low level) will do when there is a transmission problem - like a CRC error causing the device to not ack.
Therefore my conclusion would now be that the USB device is sort or disabled (dead) at this point, which would be more serious than the software crashing etc. since malfunctioning SW wouldn't stop the controller itself from at least responding to a SETUP with an ACK, since this takes place in the HW. My presumption is therefore that the stall has deactivated endpoint 0 (or blocking its ping-pong buffers for further reception), in which case you will need to investigate the handling of the stall transmission to find out why it has done this and correct it accordingly.
As reference, a stall is performed simply by setting the STALL flag in the endpoint's buffer descriptors (both). At the same time the buffer descriptors need to be freed (the OWN bit set).
ptEndpointBD->usb_bd_tx_even.ulUSB_BDControl = (OWN | BDT_STALL);
ptEndpointBD->usb_bd_tx_odd.ulUSB_BDControl = (OWN | BDT_STALL);
check that the OWN bit is not being forgotten....
I can't comment of the 4.1.1 USB stack since I never really used it - it was very complicated to understand due to its many registered callbacks that made it almost impossible to follow. Probably the advice will be to move to the V5.0 stack but I also don't know what is better and what new problems it may bring?
If you can't find it and need a solution I can offer a resolution [debugging/identification/correction] (based on 8 years of intensive USB development experience) or could offer the uTasker USB stack which has been industrially proven in many intensive products and of course includes USB keyboard support (that can be mixted with a number of other composite classes with no effort). It also allows Kinetis USB controller simulation and complete project simulation to aid in general development efficiency and product quality.
Regards
Mark