A comprehensive Flipper Zero application for managing NFC data on Xiaomi Mi Band devices with advanced features including automatic backups, detailed logging, and progress tracking.
This application provides a complete toolkit for reading, writing, emulating, and verifying NFC data on Mi Band smart bands. It supports the full workflow from preparing a blank Mi Band to writing custom NFC dumps with real-time progress feedback and automatic verification.
- Quick UID Check: Instantly read card UID and scan disk for matching dumps
- Load NFC Dumps: Browse and load Mifare Classic dumps from
/ext/nfcfolder - Magic Card Emulation: Create blank template with 0xFF keys for Mi Band initialization
- Write Original Data: Write dump data to Mi Band with intelligent key detection
- Automatic Backup: Optional pre-write backup with timestamp
- Verify Write: Read and compare written data with original dump
- Difference Viewer: Detailed hex comparison of mismatched blocks
- Save Magic Dumps: Convert dumps to magic format with 0xFF keys
- Settings System: Persistent configuration storage
- Auto-backup before write
- Automatic verification after write
- Detailed progress display
- Enable/disable logging
- Logging System: Complete operation logging with export capability
- Timestamped log entries
- Exportable to text files
- Up to 500 entries stored
- Debug, Info, Warning, Error levels
- Progress Tracking: Real-time feedback with ASCII progress bars
- Sector-by-sector progress
- Percentage completion
- Authentication statistics
- Operation status messages
miband_nfc_writer/
├── miband_nfc.c # Main entry point and lifecycle
├── miband_nfc.h # Public header (opaque type)
├── miband_nfc_i.h # Internal header (structures)
├── miband_logger.c # Logging system implementation
├── miband_logger.h # Logging system interface
├── progress_tracker.c # Progress tracking utilities
├── progress_tracker.h # Progress tracker interface
├── miband_nfc_scene.c # Scene handler arrays
├── miband_nfc_scene.h # Scene declarations
├── miband_nfc_scene_config.h # Scene configuration (X-Macro)
├── miband_nfc_scene_main_menu.c # Main menu
├── miband_nfc_scene_file_select.c # File browser
├── miband_nfc_scene_magic_emulator.c # Magic card emulation with stats
├── miband_nfc_scene_writer.c # Data writing with progress
├── miband_nfc_scene_backup.c # Automatic backup system
├── miband_nfc_scene_verify.c # Data verification
├── miband_nfc_scene_diff_viewer.c # Detailed difference display
├── miband_nfc_scene_magic_saver.c # Magic dump converter
├── miband_nfc_scene_uid_check.c # Quick UID reader and scanner
├── miband_nfc_scene_settings.c # Settings configuration
├── miband_nfc_scene_about.c # Help/documentation
└── miband_nfc_icons.c # Icon assets
Uses Flipper's scene manager with X-Macro pattern for scalable scene handling:
- Each scene has three handlers:
on_enter,on_event,on_exit - Scenes defined once in
miband_nfc_scene_config.h - Automatic generation of handler arrays and enumerations
- Scanner: Detects and identifies NFC cards
- Poller: Reads data from physical cards
- Listener: Emulates NFC cards with real-time statistics
- Uses synchronous polling API for reliable read/write operations
- Circular buffer with 500 entry capacity
- Automatic log rotation (keeps newest 75% when full)
- Timestamped entries with log levels
- Export to
/ext/apps_data/miband_nfc/logs/ - Enable/disable via settings
- Persistent storage in
/ext/apps_data/miband_nfc/settings.bin - Magic number validation
- Auto-load on startup
- Configurable options:
- Auto backup enabled
- Verify after write
- Show detailed progress
- Enable logging
Purpose: Rapidly identify a card and find matching dumps on disk.
Process:
- Reads Block 0 from placed card
- Displays UID, BCC, SAK, ATQA
- Scans
/ext/nfcdirectory (non-recursive) - Lists all matching dump files
- Shows manufacturer data
Use Case: Quick identification before operations, find which dumps match your Mi Band.
Purpose: Prepare a new Mi Band for writing by emulating a blank template.
Process:
- Loads selected dump file
- Preserves original UID from dump
- Zeros all data blocks
- Sets all keys to
FF FF FF FF FF FF - Configures magic access bits
- Emulates the template via NFC
- Shows real-time statistics:
- Authentication attempts and successes
- Connection count
- Last activity status
Use Case: Use this BEFORE first write to initialize a blank Mi Band with magic keys.
UI Features:
- Real-time auth counter
- Success/fail statistics
- Status messages
- Animated dolphin icon
- Back button to stop
Purpose: Write actual dump data to Mi Band NFC chip.
Process:
- Optional automatic backup (if enabled in settings)
- Detects card and determines current key state
- Preserves Block 0 UID (read-only)
- Writes all data blocks (1-15 for each sector)
- Writes sector trailers with keys and access bits
- Uses intelligent authentication:
- First write scenario: tries 0xFF keys first
- Rewrite scenario: tries dump keys first
- Real-time progress display:
- ASCII progress bar
- Percentage completion
- Current sector number
- Optional automatic verification (if enabled)
Key Features:
- Automatic pre-write backup with timestamp
- Automatic key detection (magic vs original)
- Block 0 UID preservation
- Retry logic for reliability
- Progress bar updates every sector
- Logged to system if enabled
Purpose: Convert dump file to magic format for easy handling.
Process:
- Loads original dump
- Shows conversion progress per sector
- Modifies all sector trailers:
- Key A:
FF FF FF FF FF FF - Key B:
FF FF FF FF FF FF - Access bits:
FF 07 80 69
- Key A:
- Saves with
_magic.nfcsuffix - Progress bar during conversion
Use Case: Create magic-compatible versions of dumps for testing or simplified writing.
Purpose: Confirm data was written correctly to Mi Band.
Process:
- Reads all sectors from Mi Band
- Shows detailed progress:
- Sector-by-sector reading
- Authentication statistics
- Progress bar and percentage
- Tries dump keys first, falls back to 0xFF keys
- Compares data intelligently:
- Block 0: SKIPPED (UID is preserved, not compared)
- Sector trailers: SKIPPED (keys are expected to differ)
- Data blocks: Full comparison (16 bytes)
- Reports differences if found
- Can show detailed difference viewer
Key Fix: The verify operation now:
- Skips Block 0 completely (UID preservation)
- Skips all sector trailers (key differences expected)
- Only compares actual data blocks
- Handles both key scenarios gracefully
Purpose: Show detailed hex comparison of mismatched blocks.
Features:
- Lists all differing blocks
- Shows expected vs found data in hex
- Highlights different bytes with
[XX]notation - Displays block types (Data/Trailer/UID)
- Shows byte-level differences
- Scrollable text view
Purpose: Create timestamped backups before write operations.
Process:
- Triggered automatically if enabled in settings
- Reads current Mi Band data
- Creates backup in
/ext/nfc/backups/ - Filename:
backup_YYYYMMDD_HHMMSS.nfc - Shows progress during backup
- Proceeds to write after successful backup
Safety: Ensures you can always restore original data.
Configurable Options:
- Auto Backup: Create backup before each write
- Verify After Write: Automatically verify after writing
- Detailed Progress: Show progress bars and percentages
- Enable Logging: Log all operations to file
- Export Logs: Export current logs with timestamp
- Clear Logs: Reset log buffer
Persistence: Settings saved to persistent storage and loaded on app start.
The writer implements a three-tier authentication strategy:
// Priority order for authentication:
1. Try 0xFF keys (if pre-check indicates magic state)
2. Try dump Key A
3. Try dump Key B
4. Try 0xFF keys as last resort (if not already tried)Block 0 is special because it contains the UID which is typically read-only:
// Block 0 structure:
// [0-3] UID (4 bytes)
// [4] BCC (1 byte) = UID[0] ^ UID[1] ^ UID[2] ^ UID[3]
// [5] SAK
// [6-7] ATQA
// [8-15] Manufacturer dataThe writer:
- Reads current Block 0
- Preserves existing UID
- Writes only blocks 1-2 in sector 0
- Writes sector 0 trailer
- NEVER compares Block 0 during verification
Magic card format:
Bytes 0-5: Key A = FF FF FF FF FF FF
Bytes 6-9: Access bits = FF 07 80 69
Bytes 10-15: Key B = FF FF FF FF FF FF
These access bits allow read/write with any key, perfect for magic cards.
if (block_index == 0) {
// SKIP - UID block is preserved, not compared
continue;
} else if (is_sector_trailer(block_index)) {
// SKIP - keys are expected to differ
continue;
} else {
// Full comparison for data blocks only
compare(original[0:16], read[0:16]);
}This ensures only actual data is compared, avoiding false mismatches from UID preservation or key changes.
All long operations show real-time progress:
Writing sector 12/16
[============> ]
75%
ASCII progress bar with:
- Current/total items
- Visual progress bar (20 characters)
- Percentage completion
// Log levels
LogLevelDebug - Detailed debugging information
LogLevelInfo - General information messages
LogLevelWarning - Warning conditions
LogLevelError - Error conditions
// Log format
YYYY-MM-DD HH:MM:SS [LEVEL] Message
// Example
2024-12-27 14:32:15 [INFO] Write started: /ext/nfc/miband.nfc
2024-12-27 14:32:45 [INFO] Write completed successfullyLogs are:
- Circular buffer (500 entries)
- Auto-rotating when full
- Exportable with timestamp
- Enable/disable in settings
Problem: "All authentication methods FAILED"
Solutions:
- Ensure Mi Band is a magic card type
- Check card positioning (hold steady)
- Run "Emulate Magic Card" first
- Verify dump file is valid Mifare Classic
- Check logs if enabled
Problem: "Data mismatch found"
Check Logs/Difference Viewer:
- Use difference viewer to see exactly what differs
- Check if only specific sectors differ
- Verify original dump is correct
- Try rewriting the affected sectors
Note: Verify now skips Block 0 and trailers, so any reported differences are real data mismatches.
Problem: "Cannot create backup"
Solutions:
- Check SD card has free space
- Ensure
/ext/nfc/backups/directory exists - Verify card can be read
- Check file permissions
Problem: "Too many auth attempts" (stops at 100)
Cause: Reader continuously authenticating without reading
Solution:
- Check that dump file is valid
- Verify UID is correct
- Try with different dump file
- Check emulation statistics for patterns
Problem: Settings reset after closing app
Solutions:
- Check
/ext/apps_data/miband_nfc/exists - Verify SD card is not write-protected
- Check logs for save errors
- Reinstall app if structure corrupted
- Prepare: Load your dump file
- Main Menu → "Write Original Data" → Select file
- Initialize: Emulate magic template
- Main Menu → "Emulate Magic Card"
- Place Mi Band near Flipper
- Watch auth counter reach ~16-32
- Remove Mi Band, press Back
- Write: Write actual data
- Main Menu → "Write Original Data"
- (Automatic backup if enabled)
- Place Mi Band near Flipper
- Watch progress bar complete
- Wait for "Success" message
- Verify: Confirm write
- (Automatic if enabled in settings)
- Or manually: "Verify Write"
- Check for any differences
- Choose "Write Original Data"
- Select dump file
- Auto-backup runs (if enabled)
- Place Mi Band near Flipper
- Write automatically detects existing keys
- Auto-verify runs (if enabled)
- Check results
- Choose "Quick UID Check"
- Place any NFC card near Flipper
- View UID and card information
- See list of matching dumps on SD card
- Press Back to return
- Choose "Save Magic Dump"
- Select source dump file
- Watch conversion progress
- New file created with
_magic.nfcsuffix - Use this file for easier magic card operations
- Settings → "Enable Logging" (ON)
- Perform operations
- Settings → "Export Logs"
- Find in
/ext/apps_data/miband_nfc/logs/log_YYYYMMDD_HHMMSS.txt - Settings → "Clear Logs" to reset
/ext/nfc/ - NFC dump files
/ext/nfc/backups/ - Automatic backups
/ext/apps_data/miband_nfc/ - App data directory
/ext/apps_data/miband_nfc/logs/ - Exported log files
/ext/apps_data/miband_nfc/settings.bin - Settings file
-
Add scene entry to
miband_nfc_scene_config.h:ADD_SCENE(miband_nfc, my_new_scene, MyNewScene)
-
Create
miband_nfc_scene_my_new_scene.cwith handlers:void miband_nfc_scene_my_new_scene_on_enter(void* context); bool miband_nfc_scene_my_new_scene_on_event(void* context, SceneManagerEvent event); void miband_nfc_scene_my_new_scene_on_exit(void* context);
-
Handlers are automatically registered via X-Macro pattern
For long operations, update UI frequently:
// Update text every iteration
popup_set_text(app->popup, progress_text, 64, 18, AlignCenter, AlignTop);
// Use delays to allow GUI updates
furi_delay_ms(100);
// Don't call popup_reset() during progress
// Set header/icon once at start, update text only- All allocations in
miband_nfc_app_alloc() - All deallocations in
miband_nfc_app_free() - Scene-specific resources allocated in
on_enter - Scene-specific resources freed in
on_exit - Logger allocated before settings load
// Log important operations
miband_logger_log(app->logger, LogLevelInfo, "Operation started");
// Log errors with details
miband_logger_log(app->logger, LogLevelError, "Failed: sector %zu", sector);
// Check if logging enabled before expensive operations
if(app->enable_logging) {
// Prepare detailed message
}- Progress updates every 50-100ms for smooth display
- Maximum 20 tool calls for file operations
- Circular log buffer prevents memory exhaustion
- Non-recursive directory scanning for speed
- Settings cached in memory, saved on change
Developed for Flipper Zero by LucasMac.
Based on official Flipper NFC APIs and extensive testing with Mi Band devices.
Check Flipper Zero application license requirements.
Version: 1.0
Last Updated: 20251002
Compatibility: Flipper Zero Official Firmware