X-NUCLEO-NFC05A1 expansion board

Revision as of 12:41, 4 November 2020 by Registered User (→‎Steps for quick evaluation of software)

1. Article purpose[edit source]

The purpose of this article is to explain how to integrate the NFC05A1 expansion board with STM32MP157C-DK2. Software runs on Linux on Cortex®-A7. NFC05A1 board is an NFC card reader expansion board based on ST25R3911B for STM32 and STM8 Nucleos.

2. Prerequisites[edit source]

STM32MP157C-DK2
File:X-nucleo-nfc05a1.jpg
X-NUCLEO-NFC05A1 board


3. Hardware setup - connections explained[edit source]

The X-NUCLEO-NFC005A1 is docked on to the Arduino connector present on the bottom side of the STM32MP157C-DK2 board as shown in below figure -

File:NFC05A1 and DiscoveryKit showingArduinoConnectors.png
Location of Arduino Connectors on both boards
File:NFC05A1 and STM32MP157C-DK2 dock.png
NFC05A1 docks over STM32MP157C-DK2


4. Software setup, build and run[edit source]

4.1. Booting STM32MP157C-DK2 with Starter Package[edit source]

Instructions for Booting the board using Starter Package are available for reference on wiki page: Getting_started/STM32MP1_boards/STM32MP157x-DK2/Let's_start/Populate_the_target_and_boot_the_image

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

Before running the application, platform configuration needs to be updated. User needs to download Developer Package and update device tree for enabling the relevant peripheral configuration. For quick evaluation of the software, user can refer to section 4.2.1 and use the pre-built images and easily have the application running on discovery kit.

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 document, we will access the Discovery Kit from host PC via 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.2.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’: Windows PC to Discovery Kit' for doing file transfer locally.

  • After the board boots up, copy the application binary and the shared lib to discovery board –
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 will start running once the above mentioned commands are executed.


4.2.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.2.3. Build the RFAL Linux application code[edit source]

  • Download the X-LINUX-NFC5 software package from web : [2]
  • 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.2.4. RUN the RFAL Linux application on STM32MP157C-DK2[edit source]

Copy generated binaries onto the Discovery Kit 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 Discovery Kit board 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]