586 views
in System Integration by

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
by
 
Best answer
Hello,

difficult to say....

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

Best regards,

Manfred.
by

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.

 

by
Can you send your modified DeviceDriver.c file? I will have a look on that.
by

https://ask.embedded-wizard.de/?qa=blob&qa_blobid=614896531816490184 //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.

https://ask.embedded-wizard.de/?qa=blob&qa_blobid=6536290395998010090    //ads1256test.c

https://ask.embedded-wizard.de/?qa=blob&qa_blobid=5383896756556811157    //bcm2835.c

https://ask.embedded-wizard.de/?qa=blob&qa_blobid=12596710160883662912 //bcm2835.h

by

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 )
{
  EwPrint("A\n");
    if (!bcm2835_init())
        return 1;
  EwPrint("B\n");
    bcm2835_spi_begin();
  EwPrint("C\n");
    bcm2835_spi_setBitOrder(BCM2835_SPI_BIT_ORDER_MSBFIRST);   //default
  EwPrint("D\n");
    bcm2835_spi_setDataMode(BCM2835_SPI_MODE1);                //default
  EwPrint("E\n");
    bcm2835_spi_setClockDivider(BCM2835_SPI_CLOCK_DIVIDER_256);//default
  EwPrint("F\n");
    bcm2835_gpio_fsel(SPICS, BCM2835_GPIO_FSEL_OUTP);//
  EwPrint("G\n");
    bcm2835_gpio_write(SPICS, HIGH);
  EwPrint("H\n");
    bcm2835_gpio_fsel(DRDY, BCM2835_GPIO_FSEL_INPT);
  EwPrint("I\n");
    bcm2835_gpio_set_pud(DRDY, BCM2835_GPIO_PUD_UP);    	
...

 

by

Thanks a lot Manfred

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

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...