Skip to content

Conversation

@Senape3000
Copy link
Contributor

πŸ“‘ Description

Complete implementation of SRIX4K/SRIX512 NFC tag reader/writer/cloner tool for Bruce Firmware.

✨ Features

  • βœ… Read Tag - Complete 128-block (512 bytes) dump to RAM
  • βœ… Clone Tag - Write buffered data to new tag
  • βœ… Save Dump - Export to .srix file format
  • βœ… Load Dump - Import dumps for cloning
  • βœ… Read UID - Extract 8-byte unique identifier
  • βœ… PN532 Info - Display module firmware and mode
  • βœ… Smart Write - Skip protected blocks with detailed report
  • βœ… Debug Mode - Write simulation via Serial (optional)

πŸ“ Files Added

  • lib/PN532_SRIX/pn532_srix.cpp - Modified SRIX library
  • lib/PN532_SRIX/pn532_srix.h - SRIX library header
  • src/modules/rfid/srix_tool.cpp - Main tool implementation
  • src/modules/rfid/srix_tool.h - Tool header and state machine

πŸ“ Files Modified

  • src/core/menu_items/RFIDMenu.cpp - Added SRIX Tool menu entry

πŸ”Œ Hardware Support

Board Mode Status
CYD-2432S028 I2C Polling βœ… Tested
T-Embed CC1101 Hardware (IRQ+RST) Not Already tested
Custom ESP32 Configurable βœ… Compatible

πŸ§ͺ Testing

  • Compiles without errors
  • Read tag operation verified
  • Write/clone operation verified
  • Save/Load dumps verified
  • Protected block skip tested
  • Works on CYD-2432S028

πŸ“‹ File Format

Filetype: Bruce SRIX Dump
UID: E007000012345678
Blocks: 128
Data size: 512

Data:
FFFFFFFF
00010203
...
[7F] DEADBEEF

🎯 Technical Details

  • Memory organization: 128 blocks Γ— 4 bytes (512 bytes total)
  • Tag types: SRIX4K, SRIX512, ST25TB04K, ST25TB512
  • Protocol: ISO 14443 Type B @ 13.56 MHz
  • UID: 64-bit factory-programmed unique identifier
  • Special areas: OTP zones, binary counters, write-protected blocks

πŸ“š Documentation

Comprehensive technical documentation included in PR files.
SRIX_Technical_Overview.md
SRIX_Tool_README.md

πŸ‘€ Author

Senape3000

πŸ™ Acknowledgments

  • Bruce Firmware community for testing
  • STMicroelectronics for SRIX datasheets

This file implements the Arduino_PN532_SRIX library for I2C communication with the PN532 NFC/RFID breakout board. It includes various functions for initializing the device, sending commands, and reading/writing data to SRIX4K tags.
Implement SRIX4K/SRIX512 Reader/Writer Tool with various functionalities including reading, writing, saving, and loading data. Set up I2C communication and handle user interactions through a menu system.
This header file defines the SRIXTool class for reading and writing SRIX4K/SRIX512 tags.
Added SRIX Tool option to RFID menu if PN532 is set to I2C mode.
Added documentation link to README for SRIX tool.
Added documentation link to SRIX Tool header file
Added a development-focused section to the README and updated the installation instructions. Removed outdated installation details and added acknowledgments.
Removed development-specific to-do list and updated project description.
@bmorcelli
Copy link
Member

This is awesome!

It can share the same base Adafruit_PN532 library functions (and we won't have duplicated functions, which leads to less heap and flash usage), by including it as a resource for this functionality, like:

#include <Adafruit_PN532.h>
class Arduino_PN532_SRIX : public Adafruit_PN532 {
    ...
    ...
}

With it you can remove the duplicated functions from your library (because they look exactly the same), like:

public
    Arduino_PN532_SRIX(uint8_t irq, uint8_t reset); // Hardware I2C
    Arduino_PN532_SRIX();
    bool init(void);

    // Generic PN532 functions
    uint32_t getFirmwareVersion(void);
    bool setPassiveActivationRetries(uint8_t maxRetries);

private:
    uint8_t _irq = 0, _reset = 0;

    // PN532 Init (called by init function)
    bool SAMConfig(void);

    // High level communication functions that handle I2C.
    void readData(uint8_t *buffer, uint8_t n);
    bool readACK();
    bool isReady();
    bool waitReady(uint16_t timeout);

    // Send command to PN532 over I2C
    void writeCommand(uint8_t *command, uint8_t commandLength);
    bool sendCommandCheckAck(uint8_t *command, uint8_t commandLength, uint16_t timeout = 100);

other option is Vendorize the whole Adafruit lib to the./lib folder and add your functions and changes

@Senape3000
Copy link
Contributor Author

@bmorcelli Done my best, tested and retested. when you approve i can continue to implement srix-tool in JS API..

some info:

PN532 SRIX Library Refactoring Report

Overview

This report documents the refactoring of the original arduino-pn532-srix library to create a leaner, more maintainable version that leverages existing Adafruit_PN532 definitions while maintaining full functional compatibility.

Size Comparison

Metric Original Refactored Savings
Header file 3,015 bytes 1,532 bytes -49.2%
Implementation 16,474 bytes 6,527 bytes -60.4%
Total 19,489 bytes 8,059 bytes -58.6%
Flash (estimated) 8,000-9,000 bytes 3,500-4,000 bytes ~5KB (-50%)
RAM usage 78 bytes 78 bytes Identical

Key Changes

Removed

  • 13 duplicate PN532_* constant definitions (reused from Adafruit_PN532.h)
  • Debug infrastructure (#ifdef PN532DEBUG with 15+ messages)
  • Legacy Arduino <1.0 compatibility helpers (i2c_send/i2c_receive)
  • WIRE macro for Arduino Due Wire1 support
  • ESP32-specific I2C timeout configuration

Retained (Critical Dependencies)

  • All SRIX4K-specific command definitions (0x06, 0x0E, 0x08, 0x09, 0x0B)
  • Complete I2C low-level implementation (readData, writeCommand, sendCommandCheckAck)
  • IRQ pin handling and waitReady polling mechanism
  • 64-byte packet buffer (moved from global to class member)
  • All public API methods (100% backward compatible interface)

Technical Improvements

  • Buffer scope: Changed from global static byte to class member uint8_t _packetbuffer[64] (supports multiple instances)
  • Direct Wire API: Removed wrapper functions, uses Wire.write()/Wire.read() directly
  • Cleaner I2C reads: Changed from requestFrom(n+2) to requestFrom(n+1) (correct RDY byte handling)
  • Dependency injection: Reuses Adafruit_PN532.h constants instead of duplicating them

Trade-offs

βœ… Advantages: Smaller footprint, cleaner code, supports multiple NFC instances, production-ready (no debug overhead)
⚠️ Limitations: Requires Adafruit_PN532.h dependency, no Arduino Due support, manual Wire.begin() required, no built-in debug

Validation

Tested on ESP32-S3 with SRIX4K tags. Memory dumps confirmed byte-perfect reads (128 blocks, 0 errors).


Refactored by @Senape3000 β€’ Original by @lilz (GPLv3)

@bmorcelli bmorcelli merged commit eed9029 into BruceDevices:main Jan 4, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants