Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor II
952 Views

mraa initialization causes segmentation fault

I have

  • A custom breakout board whose pins appropriate to the mini breakout board
  • My own image based on the official intel image
  • My own C++ application which has been integrated into the image by writing a recipe.

My C++ application uses different libraries such as boost or mraa. I am linking statically except mraa (since no static lib exists). Therefore the recipe includes RDEPENDS = "mraa".

The Problem:

After bitbaking and flashing my application crashes with "segmentation fault" when trying to execute. I figured out that this is definitely caused by mraa, more specific by sth. in "mraa_init" because my application does not even reach the first "cout<<"Hello"<<endl;"-statement which is the first statement in "int main".

Additional information:

journalctl | grep libmraa

shows:

Version:

cat /sys/devices/virtual/dmi/id/board_name shows "BODEGA BAY"

cat /etc/version shows "Custom Edison build by xxx"

Any help is appreciated!

// Edit:

Using the big Arduino breakout board my software runs fine. My my custom board is also being recognized as a Arduino breakout board (instead of the smaller mini breakout board). The actual board check is performed in intel_edison_fab_c.c:

mraa_board_t*

mraa_intel_edison_fab_c()

{

mraa_board_t* b = (mraa_board_t*) calloc(1, sizeof(mraa_board_t));

if (b == NULL) {

return NULL;

}

b->platform_name = PLATFORM_NAME;

// This seciton will also check if the arduino board is there

tristate = mraa_gpio_init_raw(214);

if (tristate == NULL) {

syslog(LOG_INFO, "edison: Failed to initialise Arduino board TriState,\

assuming Intel Edison Miniboard\n");

if (mraa_intel_edison_miniboard(b) != MRAA_SUCCESS) {

goto error;

}

return b;

}

...

To which pin does pin 214 exactly correspond to? It seems that tristate can be allocated in my case causing executing a false code branch.

7 Replies
Highlighted
Employee
14 Views

Hello IntelAnonymous,

Does your application runs fine if you run it directly from Linux? I mean, if don't bitbake it into the image, if you flash the stock image and try to run application, does it work?

I just want to make sure that the issue is not with the application itself.

Peter.

0 Kudos
Highlighted
New Contributor II
14 Views

Hello Peter,

I just tried the following:

putting the edison with my custom image and my c++ application on the arduino breakout board (big one):

My applications runs fine!

putting the same edison on my custom breakout board:

Crash in libmraa because the code piece above decides that my custom board is an "arduino breakout board" what is not true. libmraa then tries to initialize the pins in mraa_intel_edison_misc_spi() what fails as shown in my screenshot from the start post. When trying further initializations with those pins in the same function libmraa crashes because of this.

I changed the following piece

  1. // This seciton will also check if the arduino board is there
  2. tristate = mraa_gpio_init_raw(214);
  3. if (tristate == NULL) {

to

  1. // This seciton will also check if the arduino board is there
  2. tristate = mraa_gpio_init_raw(214);
  3. if (tristate == NULL || 1) { // Hack

and my application also runs on the custom board.

What's the magic behind pin 214? How could I fix this in a nice way?

0 Kudos
Highlighted
Employee
14 Views

Pin 214, is the one MRAA uses to detect if the Edison is either using the Arduino Expansion Board or the Mini breakout board. So, I believe the issue is caused when MRAA detects that the Arduino Expansion Board is present because of pin 214, but when it looks for the rest of the Arduino Expansion Board Muxing and finds that they are missing because as you mentioned you are using a custom board. That's when the library crashes, so you may have to make deep changes within the library to adapt it to your custom board.

Peter.

0 Kudos
Highlighted
New Contributor II
14 Views

Maybe my question was unclear. I would like to contribute a fix to libmraa, if possible. Currently, Pin 214 is used to detect whether a mini breakout board or an arduino breakout board is being used. In my case, this check delivers the wrong result. So what does Pin 214 exactly do? Maybe an additional check would be an option?

0 Kudos
Highlighted
Employee
14 Views

Yep, sorry, I misunderstood you.

Then I think you can contact them from their github: https://github.com/intel-iot-devkit/mraa intel-iot-devkit/mraa · GitHub. Or you could reach out to arfoll, he may be able to provide you a more accurate approach.

Peter.

0 Kudos
Highlighted
14 Views

Hi there - file a bug on github, we can try find a solution for you, on top of looking for pin214 we could check how many gpios are available to the kernel and actually detect the presence of the gpio mux.

0 Kudos
Highlighted
New Contributor II
14 Views

0 Kudos