FM24Cxx: FRAM (I2C) console driver with block read/write/format#24457
Merged
arendst merged 2 commits intoarendst:developmentfrom Feb 16, 2026
Merged
FM24Cxx: FRAM (I2C) console driver with block read/write/format#24457arendst merged 2 commits intoarendst:developmentfrom
arendst merged 2 commits intoarendst:developmentfrom
Conversation
Owner
|
Isn't it wonderful how easy it is to extend Tasmota; only one driver file and two minor updates. |
josef109
pushed a commit
to josef109/Tasmota
that referenced
this pull request
Mar 15, 2026
…dst#24457) * FM24Cxx: FRAM (I2C) console driver with block read/write/format * Fix formatting in license comment section
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
Usecase:
FRAM is particularly suitable for highly volatile, frequently updated data where Flash/EEPROM wear would be a concern:
This driver provides a simple console interface to validate wiring, test read/write behavior, and manage FRAM contents during development and troubleshooting.
Driver Features:
Driver Compatibility:
Short Manual:
Build options and configuration
Optional compile-time configuration macros:
#DEFINE FM24CXX_I2C_ADDFRAM I2C address (default: 0x57)
#DEFINE FM24CXX_CAPACITYTotal FRAM size in bytes (default: 8192)
#DEFINE FM24CXX_BLOCK_SIZEBlock size in bytes. If set to 0, the whole chip is a single block.
#DEFINE FM24CXX_I2C_CHUNKI2C read chunk size (default: 32).
Write payload is automatically limited to FM24CXX_I2C_CHUNK - 2 (because 16-bit address must be sent in the same I2C transaction).
#DEFINE FM24CXX_MAX_WRITE_BYTESHard cap for write payload (default: 4096).
#DEFINE FM24CXX_JSON_MAX_BYTESMaximum bytes returned by FramRead as hex in JSON (default: 4096).
#DEFINE FM24CXX_JSON_MAX_STRINGMaximum bytes returned by FramReadString (default: 4096).
Block model
The FRAM memory is split into blocks:
If FM24CXX_BLOCK_SIZE == 0 → one block spanning the entire chip.
Otherwise → multiple blocks of size FM24CXX_BLOCK_SIZE, with the last block possibly smaller.
All commands that accept operate on the block start address and block length derived from this model.
Command reference
FramInfo
Shows detection and configuration.
Example
FramInfo
FramReadFormat
Reads a block and prints a formatted hex dump to the log (16 bytes per line). Returns a summary JSON.
Example
Reads an entire block and returns the result as a hex string in JSON ("data":"AABBCC...").
This is the recommended command for binary-safe dumps.
Example
Writes bytes parsed from the provided hex payload to the start of the block, then fills the remaining block bytes with 0x00.
Accepts flexible hex formats: AABBCC, AA BB CC, 0xAA,0xBB,0xCC
Example
Writes the provided text bytes directly to FRAM, then fills the remaining block bytes with 0x00 (including a terminating 0x00).
Supports quoted input for spaces:
FramWriteString 0 "Hello World!"
Examples
Reads bytes from the start of the block until the first 0x00 byte (C-string style) or until FM24CXX_JSON_MAX_STRING is reached.
The returned text is JSON-escaped to prevent invalid JSON output.
Example
Fills the target block (or all blocks) with 0x00.
Examples
Console read output example:
Notes and limitations
Binary vs text
Response size
FramRead returns hex, which is 2× the byte count. Large blocks may exceed Tasmota’s response buffer limits even if FM24CXX_JSON_MAX_BYTES allows it.
I2C framing
Low-level access uses 16-bit memory addressing (MSB first), with chunked reads/writes and yield() calls to remain watchdog-friendly.
Related issue (if applicable): fixes #
Checklist:
NOTE: The code change must pass CI tests. Your PR cannot be merged unless tests pass