2018-02-08 04:51 PM
How can I force a char array to align 4 ?
//align 4;
char LoRaTxFrames[8][64]; char LoRaRxFrames[8][64];is this a correct method ?
char LoRaTxFrames[8][64]; __attribute__((packed, aligned(4))) char LoRaRxFrames[8][64]; __attribute__((packed, aligned(4)))#alignment2018-02-08 05:08 PM
Most compilers on ARM align structures and elements on 32-bit boundaries unless you change the packing
#pragma pack(1) // tight packing, ie file structures, or third party data
#pragma pack(4) // normal
2018-02-08 05:13 PM
There should be USB examples for 32 bit aligned 8 bit arrays needs.
Usually, if I need 32 bit aligned, why not creating a type with union of u8[4] and u32 ?
This maybe enough for the linker to get a clue of the 32 bit alignment need.
A quick check with MAP file to find out.
2018-02-08 08:52 PM
My purpose is to validate a packet by hash algorithm.
actually, the array was already aligned, but I wanted to force the alignment to be sure future compilations still work.
I am running a 32bit hash over the buffer, rather than doing the 8bit shuffle.
2018-02-08 11:44 PM
Things like memory alignment are core and toolchain specific, so there is no solution that fits for every environment.
Just to mention that.