X-NUCLEO NFC05A1 expansion board

Revision as of 07:36, 12 February 2021 by Registered User

1. Article purpose[edit source]

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



2. Prerequisites[edit source]

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

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

X-NUCLEO-NFC05A1 : 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 Type-micro B USB cable.

• USB Type A to Type-C USB cable.

• USB PD compliant 5V 3A power supply.

The PC/Virtual-machine forms the cross-development platform to build the RFAL library and application code to detect and communicate with NFC devices through the ST25R3911B IC.

3. Hardware setup[edit source]

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

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

NFC05A1
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 Discovery board through the USB Type C port (CN6).

NFC05A1
X-NUCLEO-NFC05A1 plugued to STM32MP157C-DK2

4. Software setup[edit source]

To run the application, the platform configuration needs to be updated by updating the device tree to enable the relevant peripherals. You can do this quickly by using the pre-built images available by referring to Steps for quick evaluation of software using pre-compiled binaries, or you can develop the device tree and build your own kernel images in full-fledged development environment by referring to How to update the platform configuration in the developer package

You can connect to the Discovery Kit 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 source]

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 the X-LINUX-NFC5[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. 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 source]

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 code snippet below to the file: This updates the device tree to enable and configure the SPI4 driver interface.

&pinctrl{
	spi4_pins_a: spi4-0 {
			pins1 {
				pinmux = <STM32_PINMUX('E', 12, AF5)>, /* SPI4_SCK */
				<STM32_PINMUX('E', 14, AF5)>; /* SPI4_MOSI */
				bias-disable;
				drive-push-pull;
				slew-rate = <1>;
			};

			pins2 {
				pinmux = <STM32_PINMUX('E', 13, AF5)>; /* SPI4_MISO */
				bias-disable;
			};
	};
	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 Developer package to get the stm32mp157c-dk2.dtb file. Refer to following link for help: Modify rebuild and reload the Linux kernel

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

Before you begin, the SDK must be downloaded, installed and enabled. Download the application from the link: X-LINUX-NFC5.

Run the commands to below cross-compile the code: These commands will build following files:

  • 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 source]

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.



4.5. Software platform configuration for running the application[edit source]

Before running the application, platform configuration needs to be updated. User needs to download the Developer Package and update device tree for enabling the relevant peripheral configuration.


For quick evaluation of the software, user can refer to section Steps for quick evaluation of software, uses the pre-built images and easily has got the application running on STM32MP157C-DK2 More info green.png.

In case the user wants a full-fledged development environment, detailed description of how to modify the device tree and build updated kernel images is mentioned in section "Updating platform configuration in Developer Package"
Note: In this article, the STM32MP157C-DK2 More info green.png is accessed from host PC via the TCP/IP network (using ssh and scp commands). Another method to access the board could be through serial link (UART / USB) using tools such as ‘minicom’ (on Linux PC) or ‘Tera-term’ (on Windows PC). For more details, please refer to wiki page: How to get Terminal.


4.5.1. Steps for quick evaluation of software[edit source]


In order to speed-up the development process and quickly evaluate the software, please follow below mentioned steps

  • Please follow instructions in the link : STM32MP157C-DK2 Let's start to flash the Starter Package on the SD card.
  • Boot the board with Starter Package.
  • Enable internet connectivity on the board via Ethernet or WiFi. Refer to wiki pages for help.
  • Download the X-LINUX-NFC5 software package [1] and follow below mentioned steps.
  • Use below commands to copy the device tree blob and update the new platform configuration
PC $> cd X-LINUX-NFC5_V1.0.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

Note: In case network connectivity is not available, please refer to section: How to transfer files using ‘Tera Term’(on Windows PC) to Discovery Kit for doing file transfer locally.

  • After the board boots up, copy the application binary and the shared lib to STM32MP157C-DK2 More info green.png
PC $> cd X-LINUX-NFC5_V1.0.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 should start running once the above mentioned commands are executed.


4.5.2. Updating platform configuration in Developer Package[edit source]

In order to set up the development platform, please follow below mentioned steps

&pinctrl{
	spi4_pins_a: spi4-0 {
			pins1 {
				pinmux = <STM32_PINMUX('E', 12, AF5)>, /* SPI4_SCK */
				<STM32_PINMUX('E', 14, AF5)>; /* SPI4_MOSI */
				bias-disable;
				drive-push-pull;
				slew-rate = <1>;
			};

			pins2 {
				pinmux = <STM32_PINMUX('E', 13, AF5)>; /* SPI4_MISO */
				bias-disable;
			};
	};
	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>;
	};
};

4.5.3. Build the RFAL Linux application code[edit source]

  • Download the X-LINUX-NFC5 software package from web : [1]
  • Follow below commands to cross-compile the code
 sudo apt-get install cmake
 cd X-LINUX-NFC5_V1.0.0/NFCPollerApplication/Source/Linux_RFAL_st25r3911_v2.2.0/linux_demo/build
 cmake ..
 make
  • The above mentioned commands would build following files
The example application: "X-LINUX-NFC5_V1.0.0/NFCPollerApplication/Source/Linux_RFAL_st25r3911_v2.2.0/linux_demo/build/nfc_poller/nfc_poller_st25r3911"
The shared library : "X-LINUX-NFC5_V1.0.0/NFCPollerApplication/Source/Linux_RFAL_st25r3911_v2.2.0/linux_demo/build/rfal/st25r3911/librfal_st25r3911.so"

4.5.4. Run the RFAL Linux application on STM32MP157C-DK2[edit source]

Copy generated binaries onto the STM32MP157C-DK2 More info green.png using below commands

 scp X-LINUX-NFC5_V1.0.0/NFCPollerApplication/Source/Linux_RFAL_st25r3911_v2.2.0/linux_demo/build/nfc_poller/nfc_poller_st25r3911 root@<board ip address>:/usr/local
 scp X-LINUX-NFC5_V1.0.0/NFCPollerApplication/Source/Linux_RFAL_st25r3911_v2.2.0/linux_demo/build/rfal/st25r3911/librfal_st25r3911.so root@<board ip address>:/usr/local

Open terminal on the STM32MP157C-DK2 More info green.png or use ssh login and run the application using below commands.

 ssh root@<board ip address>

Export the shared lib to the environment

 export LD_LIBRARY_PATH=/usr/local:$LD_LIBRARY_PATH 

Enter the directory where binaries were copied

 cd /usr/local 

RUN the application

 ./nfc_poller_st25r3911

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 reader antenna, the communication is established between the tag and reader and the UID is displayed on the screen.

5. References[edit source]

Cite error: Invalid parameter in <references> tag


  1. 1.0 1.1 Cite error: Invalid <ref> tag; no text was provided for refs named NFC SW package