cancel
Showing results for 
Search instead for 
Did you mean: 

STSW-ST25R021 Linux sample not working with X-NUCLEO-NFC09A1 (ST25R100)

myso
Associate II

Hi,

I am using this library on Rpi5:
https://www.st.com/en/embedded-software/stsw-st25r021.html#overview

I modified the gpio_init thusly

stError gpio_init(void)
{
    int ret = 0;
    char gpiochip_file[SIZE];

    if (isGPIOInit) {
        return ERR_NONE;
    }

    sprintf(gpiochip_file, "/dev/gpiochip4"); /* Open /dev/gpiochip0 */
    int fd = open(gpiochip_file, O_RDONLY);

I modified the rfal_platform.h to correspond to my interrupt pin

/* Set the GPIO pin number used as interrupt line to receive interrupts from ST25R */
#define ST25R_INT_PIN               12                     /*!< GPIO pin used for ST25R External Interrupt         */
#define ST25R_INT_PORT              (fd_GPIOs[0])         /*!< 

But the demoIni function fails (I added some debug statements)

    bool ok = demoIni();
printf("debug1, demoIni result %d\n", ok);    
    while ((!ok) || (ok && i--))
    {
        platformLedOn(PLATFORM_LED_FIELD_PORT, PLATFORM_LED_FIELD_PIN);
        platformLedOn(PLATFORM_LED_A_PORT, PLATFORM_LED_A_PIN);
        platformLedOn(PLATFORM_LED_B_PORT, PLATFORM_LED_B_PIN);
        platformLedOn(PLATFORM_LED_F_PORT, PLATFORM_LED_F_PIN);
        platformLedOn(PLATFORM_LED_V_PORT, PLATFORM_LED_V_PIN);
        platformLedOn(PLATFORM_LED_AP2P_PORT, PLATFORM_LED_AP2P_PIN);
        platformDelay(ok ? 200U : 100U);
        platformLedOff(PLATFORM_LED_FIELD_PORT, PLATFORM_LED_FIELD_PIN);
        platformLedOff(PLATFORM_LED_A_PORT, PLATFORM_LED_A_PIN);
        platformLedOff(PLATFORM_LED_B_PORT, PLATFORM_LED_B_PIN);
        platformLedOff(PLATFORM_LED_F_PORT, PLATFORM_LED_F_PIN);
        platformLedOff(PLATFORM_LED_V_PORT, PLATFORM_LED_V_PIN);
        platformLedOff(PLATFORM_LED_AP2P_PORT, PLATFORM_LED_AP2P_PIN);
        platformDelay(ok ? 200U : 100U);
    }
printf("debug2\n");

 

It obviously hangs within the while cycle as seen in the output:

sudo ./nfc_demo_st25r200 
Welcome to the ST25R NFC Demo on Linux.
debug1, demoIni result 0

I checked my wiring three times, I use the SPI0 which should be the default in the demo.

 Any ideas why it's not working?

All the best,

Michael

This discussion is locked. Please start a new topic to ask your question.
1 ACCEPTED SOLUTION

Accepted Solutions

Thanks Brian,

the final problem was that the 5V pin from rpi5 was insufficient to power tha 09A1. An external 5V power supply solved the issue. Thanks for all the suggestions!

Best regards,

Michael

View solution in original post

5 REPLIES 5
Brian TIDAL
ST Employee

Hi,

Could describe your hardware setup? e.g. X-NUCLEO-NFC09A1 + interposer (ARPI600) or flying wires? Could you check that the ST25R100 reset pin is tied to Gnd. 

Make sure to follow the various recommendations from  User Manual UM3559.

Could you enable the ST25R_SELFTEST compilation switch to check the communication interface and the interrupt handling? Also I suggest to set a breakpoint in st25r200Initialize and step in.

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Could describe your hardware setup? e.g. X-NUCLEO-NFC09A1 + interposer (ARPI600) or flying wires?

X-NUCLEO-NFC09A1 + flying wires 

Could you check that the ST25R100 reset pin is tied to Gnd.

I did.

Make sure to follow the various recommendations from  User Manual UM3559.

I did. There's actually a mistake in the manual - "the platform specific code (in
file pltf_gpio.h) must be modified to change the definition of macro ST25R_INT_PIN from 7 to the new GPIO pin,"

The correct file is rfal_platform.h, not pltf_gpio.h.

Could you enable the ST25R_SELFTEST compilation switch to check the communication interface and the interrupt handling?

I did: cmake -DBUILD_SELFTEST=ON ..
But it dies here, even before it gets to the SELFTEST section:

    if( !st25r200CheckChipID( NULL ) )
    {
        platformErrorHandle();       
        return RFAL_ERR_HW_MISMATCH;
    }

EDIT: it always gives me ID == 0 inside st25r200CheckChipID().
 I checked my spi communication by connecting MISO to MOSI and I get correct results:

sudo ./spidev_test -D /dev/spidev0.0 -s 500000 -v
spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 kHz)
TX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F0 0D  |......@.........................|
RX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F0 0D  |......@.........................|

 

Hi,

"It always gives me ID == 0 inside st25r200CheckChipID()." This indicates that no data has been received on the MISO line, which the SPI controller interprets as zeroes. Several potential causes include:

  1. The device is not properly powered:

    • Verify that VDDIO is correctly supplied with 3.3 V.
    • Ensure that VDD and VDD_DR are properly supplied with 5 V.
    • Confirm that the GND pins are connected.
    • Ensure your board or power supply can deliver sufficient power to the X-NUCLEO-NFC09A1.
  2. Reset pin issues:

    • Although you have already checked this, ensure the reset pin is functioning correctly.
  3. Inverted SPI MISO and MOSI:

    • Verify the wiring of your SPI connections.
  4. Missing or incorrectly driven SPI BSS:

    • Ensure the BSS is properly connected.
    • Confirm that the firmware is configured to use this pin.

I recommend connecting a logic analyzer to the SPI lines (CLK, MISO, MOSI, BSS) and the ST25R_INT pin. You can share the raw file from your logic analyzer for further analysis.

Regards,

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Thanks Brian,

the final problem was that the 5V pin from rpi5 was insufficient to power tha 09A1. An external 5V power supply solved the issue. Thanks for all the suggestions!

Best regards,

Michael

Brian TIDAL
ST Employee

Hi Michael,

thanks for your feedback. Good to know that some RPi5 may have insufficient supply for some add-on expansion board.

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.