Community
cancel
Showing results for 
Search instead for 
Did you mean: 
NNath7
Beginner
1,115 Views

MCU program segfault -- Unhandled exception/interrupt occurred!

I'm trying to find out the cause of my MCU project crashing, I assume, it's ViperOS task, but I'm unable to find any help with the documentation provided by the MCU SDK as to how to determine what the source of the problem is.

Pretty much what I have right now is my MCU project waits on receiving a "go" command from Linux side and then setups up GPIO pins direction and just acks any further "go" commands:

# include "mcu_api.h"

# include "mcu_errno.h"

# include

# include

typedef enum eGPIOs

{

GPIO_15 = 15, //

GPIO_44 = 44, // IR sensor

GPIO_45 = 45, // button

GPIO_46 = 46, //

GPIO_47 = 47, //

GPIO_48 = 48, //

GPIO_49 = 49 //

} eGPIOs;

// GPIOs to be configured for interrupts

typedef struct tGPIOInt

{

int gpio;

int mode;

uint32_t timestamp; // time since last interrupt, non-zero when pending

} tGPIOInt;

tGPIOInt GPIOs_Int[] =

{

// { GPIO_15, 0, 0 }, //

{ GPIO_44, 0, 0 }, // IR sensor

{ GPIO_45, 0, 0 }, // button

{ GPIO_46, 0, 0 }, //

{ GPIO_47, 0, 0 }, //

{ GPIO_48, 0, 0 }, //

{ GPIO_49, 0, 0 } //

};

# define GPIO_INT_COUNT (sizeof(GPIOs_Int) / sizeof(GPIOs_Int[0]))

uint8_t buffer[8];

void mcu_main()

{

int size;

debug_print(DBG_INFO, "waiting on go...\n");

// wait for host processor to be ready for us to run

while (1)

{

size = host_receive(buffer, sizeof(buffer));

if((size > 0) && memmem(buffer, size, "go\n", 3))

break;

// check again in 1 second

mcu_sleep(100);

}

debug_print(DBG_INFO, "go command received! Setting up GPIOs.\n");

mcu_sleep(50); // 500ms wait

// setup GPIO interrupts

for(size_t i=0; i

{

gpio_setup(GPIOs_Int[i].gpio, 0);

}

debug_print(DBG_INFO, "GPIOs setup, registering ISRs.\n");

mcu_sleep(50); // 500ms wait

// do nothing for now

// loop forever

while (1)

{

// wake-up every 100ms and check if any interrupts fired

mcu_sleep(10 /* X 10ms */);

// do nothing for now

// see if host processor is wanting our attention

size = host_receive(buffer, sizeof(buffer));

if((size > 0) && memmem(buffer, size, "go\n", 3))

{

debug_print(DBG_INFO, "acknowledging go command.\n");

mcu_sleep(50); // 500ms wait

}

}

}

The problem is that as soon as I give the go command:

# echo "go" > /dev/ttymcu0

I get this dumped into the USB serial console (Note: Neither the faulting address nor context ID ever changes between program code changes):

***** Unhandled exception/interrupt occurred! *****

Current context ID = 0xff10fb34

Faulting instruction address = 0x00000023

Fatal task error! Aborting task.

And all I get is this from the debug serial:

# cat /dev/ttymcu1

( INFO): waiting on go...

So it appears to crash before the second debug_print() is reached. I put a mcu_sleep() for half a second after each debug_print() just in case that pipe was buffered and didn't get flushed to Linux side until after a couple of ViperOS task context switches.

Anybody from Intel have any ideas as to how to fix this crashing issue?

2 Replies
idata
Community Manager
40 Views

Hi,

 

 

I looked through the MCU API documentation section and I believe the error is in the host_receive function. Can you put a print_debug inside the while() loop to see if it provides additional information?

 

 

Is your issue similar to this /message/369567# 369567 https://communities.intel.com/message/369567# 369567 ?

 

 

Sergio

 

idata
Community Manager
40 Views

Do you still need assistance with this thread, were you able to fix the crashing issue?

-Sergio

 

Reply