1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-18 08:54:15 +01:00

f4 usb: ensure that we NAK on unused OUT endpoints

The ST USB code will automatically receive on any
endpoint that is opened but not in the NAK state.
Make sure we set OUT endpoints to NAK initially.

It also happily writes via a NULL pointer in ep->xfer_buff
which writes to address 0x0000_0000.  Since address
0x0 is aliased onto the internal flash by the BOOT0/1 pins
and the internal flash is (normally) in the LOCKED state,
this write puts the internal flash into an errored state.

This errored state means that writes to internal flash
are no longer allowed and all further writes fail.
This commit is contained in:
Stacey Sheldon 2013-03-24 20:41:05 -04:00 committed by Alessio Morale
parent 07af6b5c80
commit 280f537644

View File

@ -168,6 +168,20 @@ void PIOS_USBHOOK_RegisterEpOutCallback(uint8_t epnum, uint16_t max_len, pios_us
/*
* FIXME do not hardcode endpoint type
*/
/*
* Make sure we refuse OUT transactions until we explicitly
* connect a receive buffer with PIOS_USBHOOK_EndpointRx().
*
* Without this, the ST USB code will receive on this endpoint
* and blindly write the data to a NULL pointer which will
* have the side effect of placing the internal flash into an
* errored state. Address 0x0000_0000 is aliased into internal
* flash via the "Section 2.4 Boot configuration" BOOT0/1 pins.
*/
DCD_SetEPStatus(&pios_usb_otg_core_handle,
epnum,
USB_OTG_EP_RX_NAK);
}
extern void PIOS_USBHOOK_DeRegisterEpOutCallback(uint8_t epnum)