2025-09-18 7:35 AM
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.
Solved! Go to Solution.
2025-09-25 7:41 AM
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.
2025-09-18 9:20 AM
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
2025-09-19 5:00 AM
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
2025-09-19 5:18 AM - edited 2025-09-19 6:00 AM
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
2025-09-19 6:09 AM
Hi,
there's a missing #endif statement in bsp_nfctag.h in STSW-ST25DV009 which I was able to fix but you could also forward it to the development team.
It runs but I get these two errors constantly (I run it as sudo on Ubuntu, hwconfig.h is defined correctly):
Warning: interrupt pin seems already exported
Error: opening gpio direction file for interrupt pin
Warning: interrupt pin seems already exported
Error: opening gpio direction file for interrupt pin
Warning: interrupt pin seems already exported
Error: opening gpio direction file for interrupt pin
Warning: interrupt pin seems already exported
Error: opening gpio direction file for interrupt pin
Warning: interrupt pin seems already exported
Error: opening gpio direction file for interrupt pin
Warning: interrupt pin seems already exported
Error: opening gpio direction file for interrupt pin
Warning: interrupt pin seems already exported
Error: opening gpio direction file for interrupt pin
Warning: interrupt pin seems already exported
Error: opening gpio direction file for interrupt pin
Warning: interrupt pin seems already exported
Error: opening gpio direction file for interrupt pin
sprintf(buf, "%d", ST25DV_GPO_PIN);
ret = write(fd_exportGPIO, buf, strlen(buf));
if(ret < 0) {
printf("Warning: interrupt pin seems already exported\n");
}
/* set the direction of interrupt pin */
sprintf(buf, "/sys/class/gpio/gpio%d/direction", ST25DV_GPO_PIN);
fd_dirGPIO = open(buf, O_WRONLY);
if (fd_dirGPIO < 0) {
printf("Error: opening gpio direction file for interrupt pin\n");
goto error;
}
2025-09-19 6:17 AM
The NDEF_URI sample Project works fine out of the box on STSW-ST25DV009
2025-09-19 7:58 AM
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:
If you are using new Linux system please ensure to define USE_LINEEVENT_IOCTL.
Hoping this will help.
Cedric
2025-09-25 7:41 AM
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.
2025-09-25 8:30 AM
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