Segmentation Fault- is the error while running the executable.Kindly suggest the possible cause

asked Jan 31 in System Integration by rpi3usr

The only changes done by me are to the device driver .c file while using the generated code from the Device Integration example of Raspberry Pi.

1 Answer

+1 vote
answered Jan 31 by Manfred Schweyer
Best answer

difficult to say....

What happens if you take the original DeviceDriver.c file - does it work without segmentation fault?

Best regards,

commented Feb 1 by rpi3usr

Hello Manfred

I followed your suggestion. And pin-pointed the location where the error is occuring. 

The fault occurs before the DeviceDriver_Initialize() function is even called. Since devicedriver.c was the file which was modified , I am not able to draw any conclusions from this.


commented Feb 1 by Manfred Schweyer
Can you send your modified DeviceDriver.c file? I will have a look on that.
commented Feb 1 by rpi3usr //devicedriver,c

Here, I have attached the device driver.c file. 

Just FYI, I am using an ADC chip ADS1256 . An example file(namely ADS1256test.c- which is also attached below) was available online which uses bcm2835.h as the base functionality file. I had tested the file independently , also I tested the Deviceintegeration project independently. This is my attempt to basically include the ADC functions into the Devicedriver.    //ads1256test.c    //bcm2835.c //bcm2835.h

commented Feb 2 by Manfred Schweyer

I still believe the segmentation fault happens somewhere within the DeviceDriver_Intialize() function - your EwPrint() messages are maybe not transferred because of the missing "\n".

Try to find the erroneous location e.g. by putting a lot of simple but unique messages within your code, e.g.:

void DeviceDriver_Initialize( void )
    if (!bcm2835_init())
        return 1;
    bcm2835_spi_setBitOrder(BCM2835_SPI_BIT_ORDER_MSBFIRST);   //default
    bcm2835_spi_setDataMode(BCM2835_SPI_MODE1);                //default
    bcm2835_gpio_fsel(SPICS, BCM2835_GPIO_FSEL_OUTP);//
    bcm2835_gpio_write(SPICS, HIGH);
    bcm2835_gpio_fsel(DRDY, BCM2835_GPIO_FSEL_INPT);
    bcm2835_gpio_set_pud(DRDY, BCM2835_GPIO_PUD_UP);    	


commented Feb 2 by rpi3usr

Thanks a lot Manfred

You were right. The error was due the bcm2835.h library. It required root access to run

Embedded Wizard Website | Privacy Policy | Imprint