X-NUCLEO NFC05A1 expansion board

1 Article purpose[edit]

The purpose of this article is to explain how to integrate the X-NUCLEO-NFC05A1[1] expansion board with STM32MP157C-DK2 Discovery kit More info green.png . An OpenSTLinux software expansion package is provided (X-LINUX-NFC5), it runs on the ARM® Cortex® A7-based core of the STM32MP1 microprocessor. The application demonstrates Radio Frequency Abstraction Library (RFAL)-based NFC driver.

2 Prerequisites[edit]

• Ubuntu version 18.04 or higher installed in PC/Virtual-machine.

• STM32MP157C-DK2 Discovery kit More info green.png.

X-NUCLEO-NFC05A1[1]: NFC card reader expansion board based on ST25R3911B

• micro SD card (minimum 8 GB ) to boot the STM32MP157C-DK2 Discovery kit More info green.png.

SD card reader / LAN connectivity.

USB Type-A to micro USB Type B cable.

USB Type-A to USB Type C cable.

• USB PD compliant 5V 3A power supply.

The PC/Virtual-machine forms the cross-development platform to build the RFAL library and the application code.

3 Hardware setup[edit]

The X-NUCLEO-NFC05A1[1] is docked onto the Arduino connector present on the back side of the STM32MP157C-DK2 More info green.png board as explained in below steps.

Step 1: Plug the X-NUCLEO-NFC05A1[1] expansion board onto the Arduino connectors on the back-side of the STM32MP157C-DK2 Discovery board.

Location of Arduino connectors on both boards

Step 2: Connect the ST-LINK programmer/debugger embedded on the Discovery board to your host PC via the USB micro B type port (CN11).

Step 3: Power the STM32MP157C-DK2 Discovery kit More info green.png. through the USB Type C port (CN6).

X-NUCLEO-NFC05A1 plugued to STM32MP157C-DK2

4 Software setup[edit]

To run the application, the platform configuration needs to be updated by modifying the device tree to enable SPI4 on SPI32MP1. For that  :

You can connect to the STM32MP157C-DK2 Discovery kit More info green.png. from the host PC via TCP/IP network using ssh and scp commands, or through serial UART using tools like minicom for Linux or Tera Term for Windows.

4.1 Steps for quick evaluation of software using pre-compiled binaries[edit]

Step 1: Flash the Starter Package on the SD Card and boot the board. Please refer: Populate the target and boot the image.

Step 3: Enable internet connectivity on the board via Ethernet or Wi-Fi. Please refer to wiki page to connect via WiFi :How to setup wifi connection.

Step 4: Download theX-NUCLEO-NFC05A1[1] software package.

Step 5: Use the following commands to copy the device tree blob and update the new platform configuration:
If network connectivity is not available, you can transfer the files locally from your Windows PC to the Discovery Kit using Tera Term. For that, please refer to How_to_transfer_files_using_‘Tera_Term’(on_Windows_PC)_to_Discovery_Kit

PC $> cd RFAL_STMPU_release_v1.0/STM32MP157C-DK2_DeviceTree/Binaries
PC $> scp stm32mp157c-dk2.dtb root@<ip address of board>:/boot/
PC $> ssh root@<ip address of board>
Board $> /sbin/depmod –a
Board $> sync
Board $> reboot

Step 6: After the board boots up, copy the application binary and the shared lib to discovery board.

PC $> cd RFAL_STMPU_release_v1.0/NFCPollerApplication/Binaries
PC $> scp ./* root@<ip address of board>:/usr/local
PC $> ssh root@<ip address of board>
Board $> cd /usr/local
Board $> export LD_LIBRARY_PATH=/usr/local/:$LD_LIBRARY_PATH
Board $> chmod +x nfc_poller_st25r3911
Board $> ./nfc_poller_st25r3911

The application will start running once these commands are executed.

4.2 How to update the platform configuration in the developer package[edit]

The following steps will allow you to set up the development environment.

Step 1: Download STM32MP1 Developer Package and install the SDK on your Ubuntu machine.

Step 2: Open the device tree file ‘stm32mp157c-dk2.dts’ in the Developer Package source code and add the below mentioned code snippet to the file:This updates the device tree to enable and configure the SPI4 driver interface.

	spi4_pins_a: spi4-0 {
			pins1 {
				pinmux = <STM32_PINMUX('E', 12, AF5)>, /* SPI4_SCK */
				<STM32_PINMUX('E', 14, AF5)>; /* SPI4_MOSI */
				slew-rate = <1>;

			pins2 {
				pinmux = <STM32_PINMUX('E', 13, AF5)>; /* SPI4_MISO */
	spi4_sleep_pins_a: spi4-sleep-0 {
			pins {
				pinmux = <STM32_PINMUX('E', 12, ANALOG)>, /* SPI4_SCK */
				<STM32_PINMUX('E', 13, ANALOG)>, /* SPI4_MISO */
				<STM32_PINMUX('E', 14, ANALOG)>; /* SPI4_MOSI */
&spi4 {
	pinctrl-names = "default", "sleep";
	pinctrl-0 = <&spi4_pins_a>;
	pinctrl-1 = <&spi4_sleep_pins_a>;
	/*status = "disabled";*/
	cs-gpios = <&gpioe 11 0>;
	status = "okay";

	spidev@0 {
		compatible = "semtech,sx1301";
		spi-max-frequency = <5000000>;		
		reg = <0>;

Step 3: Compile the Device Tree to get the stm32mp157c-dk2.dtb file. Refer to following link for help: How to compile the device tree with the Developer Package

4.3 How to build the RFAL Linux application code[edit]

Step 1: prerequisites: the SDK for OpenSTLinux distribution must be downloaded, installed and enabled.
Step 2: Download the X-LINUX-NFC5 software package.
Step 3: Run below commands on your Ubuntu machine to cross-compile the code. Once all commands are executed successfuly, below files are generated -

  • The example application: nfc_poller_st25r3911
  • shared lib for running the example application: librfal_st25r3911.so
PC $> sudo apt-get install cmake
PC $> cd RFAL_STMPU_release_v1.0/NFCPollerApplication/Source/Linux_RFAL_st25r3911_v2.1.0/linux_demo/build
PC $> cmake ..
PC $> make

4.4 How to run the RFAL Linux application on STM32MP157C-DK2[edit]

Step 1: Copy generated binaries onto the Discovery Kit using below commands

PC $> scp RFAL_STMPU_release_v1.0/NFCPollerApplication/Source/Linux_RFAL_st25r3911_v2.1.0/linux_demo/build/nfc_poller/nfc_poller_st25r3911 root@<board ip address>:/usr/local
PC $> scp RFAL_STMPU_release_v1.0/NFCPollerApplication/Source/
Linux_RFAL_st25r3911_v2.1.0/linux_demo/build/rfal/st25r3911/librfal_st25r3911.so root@<board ip address>:/usr/local

Step 2: Open terminal on the Discovery Kit board or use ssh login and run the application using the following commands.

PC $> ssh root@<board ip address>
Board $> export LD_LIBRARY_PATH=/usr/local/:$LD_LIBRARY_PATH #export the shared lib to the environment
Board $> cd /usr/local/ #enter directory where binaries were copied
Board $> ./nfc_poller_st25r3911 # Run the application

The user will see the below message on the screen:

Welcome to the ST25R3911B NFC Poller Demo on Linux. 
Scanning for NFC Technologies ......

When an NFC tag is brought near the NFC receiver, the UID and NFC tag type is displayed on the screen.

5 References[edit]