User Tools

Site Tools



C cast to 32-bits Boundary (Customer Contribution)

After investigation, we discovered the issue we had and the LCD is currently working in our embedded environment.

Thanks to the source code you provided, we think we have discovered an issue in your code (see attached ProtoBuffer.c). Our ARM processor (CPU - Marvell 88F6281), it is known that the cast MUST be aligned to a 32-bits boundary. Then, when casting your buffer in ProtoBuffer.c, there is an effect on the data sent or received (which generates some data corruption). I suggest to review this part of code to have a good behaviour for any ARM architecture.

I give you the source code we modified to get the 1RU tutorial working. The toolchain used is gcc-arm-linux-gnueabi (default package provided by ubuntu package).

Original source code

*((RdUWord*) (buffer->ptr + buffer->size)) = input;
      ^^  This cast is not necessarily aligned to a 32-bits boundary and generates some corruption

Replaced by:

 memcpy(buffer->ptr + buffer->size, &input, sizeof(RdUWord));

Here are some link about this known ARM cast-align issue:

Customer Credit: Enensy


Last modified: 2016/04/18 23:10

Page Tools