Menu

#656 STM32 USBv1 wrong buffer alignment

3.0.3
closed
None
High
3.0.2
True
2015-11-08
2015-10-29
No

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;

Discussion

  • Giovanni Di Sirio

    • assigned_to: Giovanni Di Sirio
    • Fixed in Repository: False --> True
     
  • Giovanni Di Sirio

    • status: open --> closed
     

Log in to post a comment.