Pointer alignment error

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Pointer alignment error

1,003 Views
PitOn
Contributor III

Alignment error in "serial_port_usb.с"  SDK_2.7.0_FRDMK64
A project was created on the basis of two projects "hello_word_virtual_port" and the project "shell".

Example.png
When the project was launched, the output of non-correct data to the console occurred.

Error.png


The problem is alignment of the pointer to the output.
I solved the problem using an intermediate buffer aligned.

line 862  file serial_port_usb.с

if (needToPrime)
{
if (kStatus_USB_Success !=
USB_DeviceCdcAcmSend(serialUsbCdc->cdcAcmHandle, USB_CDC_VCOM_BULK_IN_ENDPOINT, buffer, length))
{
serialUsbCdc->tx.busy = 0;
return kStatus_SerialManager_Error;
}
}

change to 

if (needToPrime)
 {
 USB_DMA_NONINIT_DATA_ALIGN(USB_DATA_ALIGN_SIZE) static uint8_t s_currSendBuf[DATA_BUFF_SIZE];
 memcpy(s_currSendBuf, buffer, length);
 if (kStatus_USB_Success !=
 USB_DeviceCdcAcmSend(serialUsbCdc->cdcAcmHandle, USB_CDC_VCOM_BULK_IN_ENDPOINT, s_currSendBuf, length))
 {
 serialUsbCdc->tx.busy = 0;
 return kStatus_SerialManager_Error;
 }
 }
0 Kudos
3 Replies

795 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi Konstandin,

The write buffer is transfer from application level and it is not checked by any level. Although there is no word in RM say DMA is word alignment, USB driver defined read buffer as 4 byte alignment. I'll make further test and report this problem. 

Thanks a lot!

Jing

0 Kudos

795 Views
PitOn
Contributor III

Hi Jing !

Here I do not agree with you.

 RM.... Paragraph 46.3.3 Addressing BDT entries.

To compute the entry point into the BDT, the BDT_PAGE registers are concatenated
with the current endpoint and the TX and ODD fields to form a 32-bit address.

Konstfntin/

0 Kudos

795 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi,

But BDT_PAGE register point to the starting location of the BDT, not point to data buffer. ADDR[31:0] field point to the data buffer.

Regards,

Jing

0 Kudos