dfu: protect USB_DFU_STATE_DFU_MANIFEST by a critical section
In the MANIFEST state, the IRQ won't move the state, but to prevent incosistency between dfu_manifestation_complete & dfu_state, use a critical section.
dfu: download: flash the first block in manifest phase
To prevent half flashed applications, erase the first page when dfu downloading starts and save the first block for later. In manifest stage, flash the first block. If the first 4 byte are 0xffffffff, the board won't boot into application and go into the dfu bootloader.
In theory USB_DFU_ATTRIBUTES_WILL_DETACH is nice, in practice not so much, because usb uses control transfers and "waiting" for status response completion after finishing flashing is cumbersome. There is basically no advantage if the device resets itself, and just waiting for the host to do it like most DFU devices (and what the BL used to do in the beginning) works around the status issue.
Right now dfu-utils is unhappy because the final get status never is answered because the response is submitted by the device, but the self reset immediately afterwards is faster, so it never arrives at the host.