Post

Tulip Overnight Soak with Wi-Fi File Sharing

Tulip Overnight Soak with Wi-Fi File Sharing

What was tested

Tulip can now serve the photos on its SD card over Wi-Fi, so they can be pulled off while the card stays in the case. In the finished camera a switch will choose between recording and sharing. For testing, the recording firmware (tl_cycle 13) has a !share command instead: it starts a small web server, the test runner on my Mac downloads the newest photos and the log, then tells the server to shut down and the camera goes back to recording.

The overnight run had two questions:

  • Does recording still behave the same with sharing in between?
  • Does starting and stopping the Wi-Fi server over and over leak memory?

It ran on the second perfboard with the first camera module, powered over USB, pointed at the focus test sheet in front of a stone wall. Five jobs ran back to back from 21:29 to 02:25:

JobWhat it did
Memory check 1One boot, 8 share sessions back to back, downloading the same photo each time
Recording a, b, cEach: 4 tests of 25 photos, one per minute, autofocus on. After each test: share, download the 2 newest photos, shut the server down
Memory check 2The same as memory check 1, at the end of the night

Headline numbers

  • Photos: 300 of 300 good at 2592×1944, with no retakes and no camera retries.
  • Resets: only the expected ones: 5 power-ons (one per job) and 288 wakes from deep sleep. No crash or watchdog reset.
  • Sharing: 31 share sessions and 40 photo downloads, none failed.
  • Integrity: all 26 downloaded photo files match, byte for byte, the checksum the camera logged when it saved the photo.
  • Download speed: 459–516 kB/s, about 4.15 s for a 2.1 MB photo. Over the USB serial link the same photo took about 3 minutes.
  • Memory: no leak that matters. Details below.

Contents

Memory

Free heap after each share session, from the two memory checks and from the single share sessions after each recording test.

Free heap after each share session

Table view
Session on the bootMemory check 1, bytesMemory check 2, bytes
1204,928204,780
2204,072203,912
3202,904202,748
4202,020201,880
5201,368201,228
6201,280201,132
7201,156201,008
8201,060200,912

After a recording test, a single share session ended with 203,952–204,316 bytes free.

The first five sessions on a boot lose about 3,500 bytes between them; after that it is about 100 bytes per session. The end-of-night check repeats the start-of-night one to within about 160 bytes, so nothing accumulated across the night. Every photo wakes the board from deep sleep with a fresh heap, which is why the share sessions after recording all end near 204,000 bytes free.

My reading is that the Wi-Fi stack fills its internal pools over the first few start/stop cycles and then levels off. The leftover 100 bytes per session would take about 2,000 share sessions on one boot to matter, and the real camera restarts when the switch changes mode.

Sharing

Download speed

Each dot is one 2.1 MB photo downloaded over the home network, in order over the night, coloured by job.

Download speed per photo

Table view
JobDownloadsSpeed, kB/s (min / median / max)Seconds per photo (min / median / max)
Memory check 18489 / 498 / 5164.08 / 4.23 / 4.30
Recording a8459 / 479 / 5114.06 / 4.27 / 4.46
Recording b8486 / 502 / 5134.05 / 4.10 / 4.28
Recording c8491 / 501 / 5124.04 / 4.14 / 4.23
Memory check 28496 / 504 / 5154.03 / 4.12 / 4.18

The camera reads the card at 16 MHz into one buffer while sending the other, so card reads and Wi-Fi sending overlap. The slower patch in recording a is most likely the home network (an inference).

Wi-Fi start-up

Seconds from the !share command to the camera having an address on the home network.

Seconds from share to Wi-Fi up

Table view
JobSessionsWi-Fi up, s (min / median / max)
Memory check 185.52 / 5.53 / 5.79
Recording a55.34 / 5.53 / 5.76
Recording b55.47 / 5.76 / 5.81
Recording c55.60 / 5.61 / 5.79
Memory check 285.59 / 5.80 / 6.00

A share session with two photo downloads took 15.2–15.95 s from !share to the server shutting down.

Recording

The dashed lines mark the start of recording jobs a, b and c. Each dot is one photo.

Awake time per photo

From power-on to power-off, autofocus on.

Awake time per photo

JPEG size

JPEG size

Camera ready after power-on

Camera ready after power-on

The high dots are the first photo of each test, when the camera starts cold. Every other photo is ready in about 0.85 s.

SD card write time

SD card write time

Written at 8 MHz on the shared bus; it follows the JPEG size.

Battery reading

Battery reading

Table view
MeasureRecording a (min / median / max)Recording bRecording c
Awake, s10.8 / 11.1 / 11.311.1 / 11.2 / 11.711.1 / 11.2 / 11.5
JPEG size, MB2.046 / 2.096 / 2.1582.088 / 2.129 / 2.1532.087 / 2.129 / 2.153
Camera ready, first photo of a test, ms1234, 1240, 1276, 12731300, 1321, 1364, 13771338, 1388, 1369, 1402
Camera ready, other photos, ms835 / 847 / 864835 / 848 / 867834 / 848 / 863
SD card ready, ms582 / 595 / 612583 / 596 / 615582 / 596 / 611
SD write, s4.37 / 4.54 / 4.734.47 / 4.61 / 5.124.47 / 4.56 / 4.71
Camera read, s2.17 / 2.22 / 2.292.21 / 2.26 / 2.282.21 / 2.26 / 2.28
Battery before power-on, mV4242 / 4248 / 42584246 / 4252 / 42584224 / 4238 / 4260
Battery lowest during photo, mV4224 / 4232 / 42344224 / 4234 / 42404178 / 4192 / 4240

Things worth a second look

None of these caused a failed photo, but they are changes over the night that I can’t fully explain yet.

JPEG size stepped up at 22:50. Photos grew by about 0.04 MB from the 7th photo of the fourth test in job a, and awake time and SD write time rose with them by about 0.1 s. From then on, about one photo in five falls back to the lower size. A sharp photo makes a bigger JPEG, so I compared crops from the two sizes. They look equally sharp; the sheet sits a few pixels differently between frames.

Line-pair crops from both size bands

T23_025 (before the step, 2.099 MB), T27_024 (lower band, 2.088 MB) and T27_025 (upper band, 2.127 MB), 100 % crops.

A change in the room light or the paper settling are the likely causes (inference). On this scene the size difference is not a sharpness difference.

The battery reading dropped at 01:11. Before power-on it fell about 10 mV, and its lowest point during a photo fell about 40 mV, between the first and second photo of a test (just after a share session), and it drifted slowly down after that. The board was on USB, so my guess is that the charger finished topping up the battery and the battery then supplied part of each photo’s current. This needs checking with a meter.

The cold first photo got slower. The camera took 1.23 s to be ready on the first photo of the first test and 1.40 s by the last, while every other photo stayed at about 0.85 s.

Numbers come from the serial logs of the five runner jobs and the photos the runner downloaded.

This post is licensed under CC BY 4.0 by the author.