Skip to main content
Associate III
Jun 27, 2026 07:03 UTC
Question

stm32h5 fat12 implemented, using eeprm as msc, issue is i2c is blocking superloop.

 

Hi ,

 

Subject: i need to reduce the log write time what to do 

I have an STM32H503 logging ~20 bytes per line (HH:MM:SS , X.X) to a 24Cxx EEPROM over I2C @ 400 kHz, with FAT12 + USB MSC.

Blocking time = the main loop stalls ~100–200 ms on each append while EEPROM writes finish.

Each line only adds ~20 B of text, but my FAT code does full 512 B sector read-modify-write on the data sector, again on the root directory (file size), plus metadata read/write.

That’s ~1 KB+ programmed per line (many 64 B page programs), so EEPROM ACK/program time dominates — not the 20 B payload or I2C speed alone.

Basic issue: small appends through sector-based FAT on page EEPROM → huge writes per line.

I’m thinking: defer root/meta to session end (back button), RAM cache, write only dirty 64 B pages.

Is that the right fix? Can others get ~20–50 ms/line on 24Cxx without dropping FAT?

2 replies

Andrew Neil
Super User
Jun 27, 2026 08:15 UTC

This seems to be a duplicate of your existing thread:

 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Pavel A.
Jun 27, 2026 10:45 UTC

What to do? Cache the current “block” of the MSC volume, compare and write only changed bytes. If the metadata updates affect the file modification time - drop or delay these updates.