Giovanni Di Sirio
-
2015-10-30
- assigned_to: Giovanni Di Sirio
- Fixed in Repository: False --> True
In usb_lld.c the function usb_pm_alloc calculates the address of the next chunk to be allocated by just adding the size of the current chunk being allocated. As a result, if the size of the current chunk is odd, the address of the next chunk will also be odd, which causes an unhandled exception because TXADDR0 and RXADDR0 must be half-word aligned (see RM: "Bit 0 This bit must always be written as ‘0 since packet memory is half-word wide and all packet buffers must be half-word aligned").
Fix is quite trivial so please forgive me for not going through the trouble of creating a patch. Current code:
usbp->pmnext += size;
Fixed code:
usbp->pmnext += (size + 1) & ~1;