Payodhi Sharma
Published © GPL3+

NFC-Based Secure Memory

A specific NFC tag, when brought near the reader, authenticates via UID match and unlocks a secret message stored in the Data Flash memory.

IntermediateFull instructions provided8 hours60
NFC-Based Secure Memory

Things used in this project

Hardware components

Renesas EK-RA2E1 Evaluation Kit
×1
Renesas PTX105R NFC Reader Board
×1
NFC Type A Tags (UID readable)
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1

Software apps and online services

Renesas e2 studio
Segger J-link RTT Viewer

Story

Read more

Code

NFC-Based Secure Memory

C/C++
Step-1:
1. Download the Project
Click this Google Drive link: https://drive.google.com/file/d/1pTSojMjo9dO0MEmjAkEQCeh1l_84K_no/view
Download the ZIP file named RA2E1_nfc_dataFlash.zip.
2. Extract the ZIP
Right-click on the ZIP file → Extract All (Windows) or Unzip (macOS/Linux).
You should now see a folder named RA2E1_nfc_dataFlash.
3. Launch e² studio
Open e² studio.
Wait for the workspace to load.
4. Import the Project
In the top menu, go to File → Import...
In the Import Wizard:
Expand General
Select Existing Projects into Workspace → Click Next
Click Browse… and select the folder you just extracted.
Ensure the project RA2E1_nfc_dataFlash is checked → Click Finish.
5. Replace the Static UID
By default, the project authenticates one specific NFC tag using a static UID.
You must replace that UID with your own NFC tag’s UID.

-How to find your tag’s UID:
Run the project as-is by following the rest of this step.
Open SEGGER RTT Viewer (we’ll guide you in Step 2).
When you bring any NFC tag close to the reader, its UID will be printed on the RTT console like this:
eg- NFCID1: A1B2C3D4
Copy this 4-byte UID.
-How to update your UID in code:
In Project Explorer, navigate to:
src → STACK → EXAMPLE → IOT_APP → ptx_IOT_RD_Main.c
Find this block of code:
if (memcmp(cardRegistry->ActiveCard->TechParams.CardAParams.NFCID1,
(uint8_t[]){ 0xA8, 0x94, 0x6A, 0x12 }, 4) == 0)
Replace the 4-byte array with your own UID
Save the file.
You’ve now authenticated your own tag!

6. Generate Project Content
Double-click on configuration.xml to open the FSP Configuration GUI.
Click the Generate Project Content button (top-right corner).
7. Build the Project
Right-click the project RA2E1_nfc_dataFlash → Select Build Project.
Let the build finish; confirm it completes with 0 errors.
8. Connect and Debug
Connect the RA2E1 board to your PC using a USB cable.
Once connected:
Right-click the project → Select Debug As → Renesas GDB Hardware Debugging
The firmware will be flashed to the board, and execution will start.
Once done, your project is now running and ready to detect your authenticated NFC tag.

Step 2:
View NFC Tag Output Via SEGGER RTT Viewer
To verify if your NFC tag is being correctly detected and authenticated, you’ll use SEGGER RTT Viewer, a powerful debugging console that prints real-time logs from the RA2E1 board.

How to Setup SEGGER RTT Viewer
Follow these steps carefully:

1. Locate the SEGGER Address
After building the project, go to the Debug folder inside your project.
RA2E1_nfc_dataFlash → Debug
Open the file named:
RA2E1_nfc_dataFlash.map
Press Ctrl + F and search for _SEGGER_RTT.
Copy the address listed beside _SEGGER_RTT.
It will look like:
_SEGGER_RTT 0x20005570
2. Launch SEGGER RTT Viewer
Open the SEGGER RTT Viewer application.
Select the correct device part number(You can verify the part number in configuration.xml → BSP tab → Device Name).
In the setup window:
Select J-Link Device as your RA2E1 board.
Choose Interface = SWD
In the RTT Control Block section, paste the address you copied from .map file (e.g., 0x20000400).
Click OK.
3. Monitor Output
Once connected:

You’ll start seeing real-time logs in SEGGER RTT Viewer.
Bring an NFC tag close to the reader.
If the UID matches the one you hardcoded earlier, you’ll see:
AUTHENTICATED: UID matched A1B2C3D4
DataFlash Read: Hello Renesas!
If the UID does not match, you’ll see:

UNAUTHENTICATED: UID did NOT match


Note: Only tags with static UIDs (not randomly generated each time) can be reliably authenticated in this setup.

We recommend you use tags with fixed UID, these are often labeled as “NTAG213,” “NTAG215,” etc.
No preview (download only).

Credits

Payodhi Sharma
1 project • 0 followers

Comments