Tutorials
Motion Logger Queue Depth: Size RAM for a Storage Stall
Published · Updated
A drained sensor FIFO can coexist with a full firmware queue. Size the host queue using the bytes that arrive while storage makes no progress.
Use serialized bytes and the longest zero-progress interval

Assume the encoder produces 2,000 bytes/s, usable queue depth is measured in bytes, and storage can stop consuming for 0.75 s. An initially empty queue accumulates 1,500 bytes. If 400 bytes were already pending, a 500-byte drain arrives at once and the long-term 2,000-byte/s estimate excluded that separate burst, reserve at least 2,400 bytes for this scenario before alignment and margin.
Use a consistent burst model. Counting the same 500 bytes both inside and outside the rate interval overstates the bound. If the consumer can write during part of that time, subtract only service that can be guaranteed under those conditions. RAM accounting includes ring implementation overhead, record headers and the queue owner’s full/empty convention.
Check how long recovery takes

If storage resumes at 5,000 B/s and new data still arrives at 2,000 B/s, backlog drains at 3,000 B/s. A 2,400-byte backlog needs 0.8 s to clear under the example assumptions. If another stall occurs earlier, start the next calculation with nonzero occupancy. If sustained consumer service is below the producer rate, increasing RAM only delays overflow.
For acceptance testing, insert a configurable delay in the storage worker and log queue high-water mark, FIFO overrun status, sequence gaps and bytes committed. Test with an almost-full ring and a record that crosses the wrap boundary. Decide whether to stop logging or drop records when capacity is reached, and write an explicit gap event with the affected interval.
If the writer sustains 1800 B/s and the producer sustains 2000 B/s, can a finite ring prevent eventual loss?
Only for a finite interval. Long-term backlog increases at 200 B/s until conditions change.
Show the three-step example

Existing + separately bounded burst: 400 B + 500 B. Arrivals during 0.75 s stall: 1500 B. Peak / clearing time: 2400 B / 0.8 s in this model.
nRF52840 host documentation · Motion logger project and storage worksheet · FIFO watermark and service-time budget · Compare buffer layouts · LSM6DSOX device documentation
Bring encoded record sizes, burst size, longest measured stall, minimum recovery throughput and queue high-water marks. Prepare an engineering review.
References
Back to Tutorials