[ros-users] ros on armhf (beagleboard, pandaboard, raspberryPi, gumstix) error/alignment fault/kernel exception - possibly solved

Peter Rudolph semael23 at gmail.com
Sun Mar 3 10:23:05 UTC 2013


He guys!
I tried to solved and it seems solved! First i will explain the problem 
itself: while de-/serializing unaligned pointercasts are done. normally 
this is not a problem! but since newer versions of arm-gcc use float 
support with options -mfloat-abi=hard/softfp, there are many 
possibilities to hit this alignment fault, because NEON instructions 
must be aligned! This is a very big problem... compiling ROS with 
-Wcast-align shows the potential lines! Solving this by setting 
"-mno-unaligned-access" as compiler-flag does NOT work! Every 
prebuilt-compiler i used seemed to ignore this switch.

example from www, demonstrates the error (compile it w/o any 
optimization(-O0), else compiler will re-align the pointercast, but this 
won't work for ROS, since everything is built w/ optimization(-O2)):

#include <stdio.h>

int main(int argc, char* argv[])
{
     char __attribute__ ((aligned(32))) buffer[8] = { 0 };
     float* fval_p;

     fval_p = (float*)&buffer[1];
     *fval_p = 0.1234;

     printf("\nfloat at &buf[1] is %f\n", *fval_p);

     return 0;
}

Build my own example from this, to check what works correctly and serious...

Only possibility was to hack the correct lines in roscpp_serialization. 
I only changed the lines from pointercasts to simple memcpy's and now 
everything seems to work fine! No alignment faults, no bus errors, no 
kernel exceptions! Tried a lightweight openni version, my own robot 
stack, and gmapping! navigation stack will follow!

Due to having no time now, patchfile will follow, too!

Regards,
sem23



More information about the ros-users mailing list