Skip to content

raspberrypi: stop pulling newlib's time zone code into RP2040 builds - #11379

Merged
dhalbert merged 1 commit into
adafruit:mainfrom
MakerClassCZ:rp2-time-shim
Sep 14, 2026
Merged

dhalbert merged 1 commit into
adafruit:mainfrom
MakerClassCZ:rp2-time-shim

Conversation

@lynt-smitka

Copy link
Copy Markdown

The SDK's pico_localtime_r() and pico_mktime() are weak wrappers around newlib's localtime_r() and mktime(). rtc.RTC uses them through aon_timer on RP2040, and they bring tzset, getenv and the scanf code along.

CircuitPython has the same calendar arithmetic in shared/timeutils, and newlib runs without a TZ here, so both compute UTC.

This PR defines the two SDK hooks on top of timeutils.

Flash on raspberry_pi_pico: 981080 -> 974584, saved 6.5 kB.

The SDK's pico_localtime_r() and pico_mktime() are weak wrappers around newlib's
localtime_r() and mktime(). rtc.RTC uses them through aon_timer on RP2040, and
they bring tzset, getenv and the scanf code along: 6496 bytes of flash on
raspberry_pi_pico.

CircuitPython has the same calendar arithmetic in shared/timeutils, and newlib
runs without a TZ here, so both compute UTC. Define the two SDK hooks on top of
timeutils. RP2350 keeps its time in the powman timer and never called them.

@dhalbert dhalbert left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OH, neat! This is a big savings!

@dhalbert
dhalbert merged commit 13ac3b9 into adafruit:main Sep 14, 2026
173 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants