Power: the main loop never rests and uses a whole core #40
Closed
opened 2026-10-05 23:04:28 +00:00 by twisla
·
3 comments
No Branch/Tag Specified
Labels
Clear labels
area/apps
area/audio
area/build
area/cluster
area/gemini
area/gitea
area/gnss
area/ir
area/irc
area/lora
area/ota-debug
area/power
area/scripting
area/ssh
area/storage
area/ui
area/vpn
area/website
area/wifi
concern/memory
concern/security
Launcher and the apps in src/apps
Microphone, speaker, the codec, recording and playback
PlatformIO, Docker, scripts, partitions, sdkconfig
AtomS3 co-processors on Grove and the link protocol
GeminiService, the Gemini App, Saved Pages
The Gitea client: issues, releases, its TLS and its token
GnssService, the GNSS App, Tracks
The infrared LED and the IR Remote
IrcService and the IRC App
The Cap LoRa-1262 radio and the mesh
Updates, Probation, Safe Mode, Debug Console, crash reports
Battery, PowerService, sleep
Lua Apps from the SD card and their API
The SSH client and its terminal
StorageService, the SD card, Storage page
Canvas, widgets, dialogs, Toasts, fonts, keyboard
The WireGuard tunnel
The project website and its docs
WifiService, Wi-Fi Settings, Wi-Fi Tools
May push the heap towards its floors; measure on the device
TLS, signing, the debug token, trust on first use
kind
bug
Something that doesn't work as it should
kind
chore
Refactors, tooling, CI, scripts
kind
docs
README, CONTEXT, milestones, ADRs
kind
feature
Something new the device can do
priority
high
Next up
priority
low
Some day
priority
medium
Soon
status
blocked
Waiting on something else
status
needs-design
Needs a question round (Qnn) before code
status
ready
Designed; can be started
Milestone
No items
No Milestone
S1 System basics
Assignees
twisla (Clément Martin)
Clear assignees
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: twisla/roro9stack#40
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
What happens
The main loop never rests:
loopTaskuses about 81 % of core 1, averaged since boot, with the device idle on the Launcher and the screen off (tasks, v0.7.0+debug, 2026-10-06):Core 1 is busy four fifths of the time doing nothing visible. That's current the battery pays for, and heat (the chip reads 37 to 39 C at rest).
Why it matters
What's known
loop()insrc/main.cpppolls the keyboard, ticks the Services, runs the console and redraws when needed, then comes straight back.tickIntervalMs()), so the time until the next one due is known; the keyboard has an interrupt line (TCA8418, INT on GPIO 11); the consoles and the radio have their own tasks or interrupts.vTaskDelayfor the simplest version, a task notification from the interrupts for the proper one.To do
Related
#11 (System Monitor, which makes this visible), #20 (radio noise),
src/main.cpp(loop),lib/core/src/service_manager.cpp,docs/milestones/S1.md(Q127).Correction: it's 100 %, not 81 %. The 81 % was an average since boot, and FreeRTOS only adds to a task's run time when the task is switched out, which under-counts a task that has its core to itself. Measured properly (the System App and
tasks, on thes1branch): at rest, core 1's idle task gets 0.0 % andloopTaskhas the whole core.Power: the main loop never rests and uses 81 % of a coreto Power: the main loop never rests and uses a whole coreFixed on the
s1branch (06a5932), not merged yet. After each pass the loop rests: 5 ms with the screen on, 20 ms with it off, and not at all during a serial file transfer. Safe Mode's loop rests too.Checked at the new pace: GNSS, a Gemini fetch, an upload read back by SHA-256, the Sweep, the radio's interrupt.
tasksnow prints the loop's passes; Debug Builds haveloop spin on|offto compare.Not measured
Not done: real sleep. The framework is built without power management (
CONFIG_PM_ENABLEoff), so an idle core only halts until the next interrupt. Automatic light sleep means rebuilding the framework with it, Wi-Fi in modem sleep, and checking what the USB serial port does. A separate issue if battery life calls for it.For #20: the radio's noise floor is the same with the loop spinning or resting. It wasn't the source.
Shipped in v0.8.1 (
s1merged intomain). Typing feel on the real keyboard is still to be judged by hand; reopen if a key ever feels late.