Skip to content

v1.1.0 - real light sleep on the Badger

Choose a tag to compare

@stanelie stanelie released this 05 Sep 21:32
· 9 commits to main since this release

Measured power work on the Badger 2040, plus EPUB and jump-to fixes for
all three boards.

Badger 2040: 18 mA -> 5 mA

Stock CircuitPython's alarm.light_sleep_until_alarms() barely sleeps on
RP2040. Measured on a PPK2, one page every 10 s:

state stock patched
awake, 125 MHz 25 mA 25 mA
light sleep 16 mA 2 mA
reader average, 1 page / 10 s 18 mA 5 mA

1 mA of the remaining 2 mA is the board itself - regulator, panel, divider -
so the chip's own share went from ~15 mA to ~1 mA. The Badger now draws less
than the E290's 8 mA.

Two causes, both needed fixing: the port's sleep_en masks gate clock
distribution and leave clk_sys and both PLLs running, and the 1024 Hz
supervisor tick drags the core out of WFI every 977 us regardless. Upstream
notes the first itself - this only saves about 2mA right now.

badger2040-circuitpython-real-light-sleep.uf2 is CircuitPython 10.1.0-beta
for the Badger 2040 with that patch. Hold BOOTSEL, plug in, copy the .uf2 to
the RPI-RP2 drive. Back up CIRCUITPY first - flashing can reformat it,
and it holds your books and reading positions. Source:
firmware/patches/0002-rp2-real-light-sleep.patch.

Fixes (all boards)

  • EPUB chapters converted out of order. Calibre splits long chapters into
    numbered fragments, and the converter sorted by fragment index while
    ignoring which chapter it belonged to - so any book with more than one
    multi-fragment chapter came out with every chapter's opening bunched
    together, then every chapter's body. Now reads the EPUB's own spine.
  • A crash that only appeared on hardware: chapters decompressed through
    the pure-Python fallback inflater come back bytearray-backed, and a
    bytearray is not hashable. Invisible in host tests, where CPython's zlib
    always returns bytes.
  • Battery-only EPUB conversion hung after converting on E213/E290 and
    needed a manual reset. The post-conversion restart chose a soft reload
    whenever off USB - a rule that only exists to protect the Badger's power
    latch, which those boards do not have.
  • Jump-to-percent could land on the wrong offset: a hold-to-confirm
    arriving quickly after a tap was swallowed as a double-tap.

Assets

  • badger-1.1.0.zip - precompiled, ready-to-copy Badger 2040 reader
  • badger2040-circuitpython-real-light-sleep.uf2 - patched CircuitPython
  • heltec_vision_master_e213.bin / heltec_vision_master_e290_lightsleep.bin
    • unchanged since v1.0.0, flash at 0x0
  • SHA256SUMS - covers every asset here

For the E213/E290 reader itself, copy the contents of device/ from the
repository; those boards have no precompiled package.