Skip to main content
Visitor II
September 18, 2025
Solved

Segmentation fault on GPO example

  • September 18, 2025
  • 3 replies
  • 388 views

Hello,

I am running tha example code on RPi 5 on Ubuntu. Everything compiles fine but I get a Segmentation fault. I did configure the hwconfig.h

I added some debug messages to the code:

int main (void)
{
 const ST25DV_PASSWD st25dv_i2c_password = {.MsbPasswd = 0, .LsbPasswd=0};	

 /* Init of the Type Tag 5 component (ST25DV-I2C) */
 (BSP_NFCTAG_Init(0) != NFCTAG_OK);
 printf("ST25DV-I2C init done\r\n");
printf("DEBUG1\n");
 /* Present configuration password */
 BSP_NFCTAG_PresentI2CPassword(0, st25dv_i2c_password );
printf("DEBUG1.5\n");
 /* Set GPO Configuration */
 BSP_NFCTAG_ConfigIT(0,ST25DV_GPO_ENABLE_MASK | ST25DV_GPO_FIELDCHANGE_MASK );
 	
printf("DEBUG2\n");
 while(ST25DV_GPO_Init() != NFCTAG_OK);
 printf("GPO init done\r\n");

This is where it crashes:

./st25dv-i2c_gpo 
ST25DV-I2C init done
DEBUG1
DEBUG1.5
Segmentation fault (core dumped)

 Any help will be appreciated.

 

    This topic has been closed for replies.
    Best answer by myso

    Thank you Cedric,

    defining (uncommenting) USE_LINEEVENT_IOCTL at the top of st25dv-i2c-gpo.c solved the issue. Interestingly, as noted before, the  NDEF_URI sample Project worked without it. 

     

     

    3 replies

    Technical Moderator
    September 18, 2025

    Hi,

    Line 6 of the code snippet: the code does not check the return code of BSP_NFCTAG_Init(0). If the BSP_NFCTAG_Init(0) fails, some internal function pointers may be not initialized.

    Make sure to test each return code in particular the return code of BSP_NFCTAG_Init.

    Rgds

    BT

    mysoAuthor
    Visitor II
    September 19, 2025

    Hi,

    thanks for the reply.

    This is an example project taken directly from your website with no modifications:

    https://www.st.com/en/embedded-software/stsw-st25dv007.html

    So perhaps you could send a request for the example codes to be corrected.

    Best,

    Michael

    Technical Moderator
    September 19, 2025

    Hi,

    Thank you for reporting this issue. It has been forwarded to the development team responsible for this package. This issue is likely related to a merge conflict during the delivery package preparation.

    Regarding the segmentation fault, it is likely caused by a failure during the BSP_NFCTAG_Init function. As suggested, modify line 6 to check the return code of BSP_NFCTAG_Init. When BSP_NFCTAG_Init fails, the structure holding the function pointers is set to NULL. This causes a segmentation fault if a call to BSP_NFCTAG_ConfigIT is made while the initialization has failed.

    Also, if using a ST25DV04KC, ST25DV16KC, and ST25DV64KC, make sure to use STSW-ST25DV009.

    Rgds

    BT

    ST Employee
    September 19, 2025

    Hello Michal,

    DV009 is indeed more appropriate against DV007 which is now in some way obsolete. 

    Thank you for pointing out this missing #endif statement in DV009 resulting from a quick-fix-that-should-have-no-impact-on-overall-demo ;-(

    This will be fixed soon.

     

    Concerning the interrupt pin error you get. It seems as the message states that you are trying to use either an already used or a non existing interrupt pin.

    Could you please double check the GPIO pin you are using on your board (the values preset in the example code were dedicated to our test board -a discovery kit based on STM32MP15-) and set appropriate value in hwconfig.h

     

    Another point, the provided code is intended to address:

    • old linux systems where USE_LINEEVENT_IOCTL is NOT defined at the top of of st25dv-i2c-gpo.c, this the one you are currently using.
    • newer linux systems where USE_LINEEVENT_IOCTL is defined

    If you are using new Linux system please ensure to define USE_LINEEVENT_IOCTL.

     

    Hoping this will help.

    Cedric

    mysoAuthorAnswer
    Visitor II
    September 25, 2025

    Thank you Cedric,

    defining (uncommenting) USE_LINEEVENT_IOCTL at the top of st25dv-i2c-gpo.c solved the issue. Interestingly, as noted before, the  NDEF_URI sample Project worked without it. 

     

     

    ST Employee
    September 25, 2025

    Hello Michal,

    I am happy to see that you now have the demo functioning in your environment.

    Here are a few comments:

    The GPO demo requires setting up the GPIO on your system. This dependency arises from how the interrupt configuration is handled (either through the sysfs or the character device interface) within the function ST25DVxxKC_GPO_Init().

    This also explains why the NDEF_URI demo worked fine out of the box, regardless of the Linux system on which it was running, as it does not require the interrupt configuration feature.

    For your information, the fix for the missing #endif will be available on st.com by next week.

    Best regards,
    Cedric