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

ZedBoard development board.
ZedBoard development board. Bench or board context. Photo by Ordercrazy. Photo source · CC0

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

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
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.

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 exampleExisting + 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

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

ST AN5272 Rev 5, retrieving FIFO data.

Back to Tutorials

Related evidence and next tasks

Continue the task with the relevant source scope. These reading paths do not establish interchangeability or current supply.

Source addresses and citation trail

Full source addresses are retained below. Read each citation with its document revision, page, table and applicability conditions above.

  1. https://commons.wikimedia.org/wiki/File:Embedded_World_2014_Xilinx_ZedBoard_Developer_Board.jpg
  2. http://creativecommons.org/publicdomain/zero/1.0/deed.en
  3. https://www.st.com/resource/en/application_note/an5272-lsm6dsox-alwayson-3d-accelerometer-and-3d-gyroscope-stmicroelectronics.pdf