This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DSPLink: Memory alignment issue with MSGQ messages

We are having a problem with sending the long data type over MSGQ. It seems to cause a misalignment and results in garbage data. I have included a working and not working example of our packet. We would highly appreciate it If someone could shed some light on this problem.

 Note: We are using BIOS 5.33.05 / DSPLink 1.65.00.03

 

Thank you very much,

Arya B.

example.h
  • Arya,

    First thing that comes to mind would be that the data types might be different on either side of the architecture cores.  One that always seems to hit people are enum(s) and bool(s) but others may also differ.  For this reason, we typically recommend using the types defined by DspLink and DSP/BIOS (Uint16, Uint32, Int16, Int32, Char8, etc) to guarantee that the size is the same on both cores.  You can take a look at the dsplink/gpp/inc/usr/gpptypes.h file to see the different types defined.

    Some compiler options may pack structures which can also lead to incompatible sizes as well.  To verify the size of your structure, you could print out the sizeof your struct to ensure that both sides agree.

  • You must be using a C6X DSP. The "long" data type is 40-bits on the DSP and 32 bits on the ARM. As Arnie Reynoso suggests, using the TI defines can help. On the ARM side, gpptypes.h and on the DSP side, tistddefs.h. Would have been nice if TI uses the same header file name or used the ANSI standard stdint.h. Note that the two header files don't define the same set of types. For example, one side uses Char and the other uses Char8.

    DSPLink by its very nature assumes identical endian and packing on both sides. It would not work otherwise. To avoid packing issues, you could try to always to use "Int" which is this case is "int" on the ARM and DSP. Arrays of chars are trickier. Rounding up the allocation to the nearest sizeof(int) usually avoid packing issues.

  • Thank you both very much for the quick response, I had forgotten that the "long" data type is 40-bits on the DSP and 32 bits on the ARM. Which explains the alignment issue. I guess for keeping proper alignment we will send over our data as the TI Int data type and recast them once they are needed.


    Thanks,

    Arya B.