The XIP SPI flash on Fomu is slow, which results in certain operations
taking a long time. This becomes a problem for time-critical operations
such as USB.
Move various calls into RAM to improve performance.
This includes the call to __modsi3 and __udivsi3 which are used by the
supervisor handler to determine if periodic callbacks need to be run.
This finishes fixing #3841
Signed-off-by: Sean Cross <sean@xobs.io>
This changes lots of files to unify `board.h` across ports. It adds
`board_deinit` when CIRCUITPY_ALARM is set. `main.c` uses it to
deinit the board before deep sleeping (even when pretending.)
Deep sleep is now a two step process for the port. First, the
port should prepare to deep sleep based on the given alarms. It
should set alarms for both deep and pretend sleep. In particular,
the pretend versions should be set immediately so that we don't
miss an alarm as we shutdown. These alarms should also wake from
`port_idle_until_interrupt` which is used when pretending to deep
sleep.
Second, when real deep sleeping, `alarm_enter_deep_sleep` is called.
The port should set any alarms it didn't during prepare based on
data it saved internally during prepare.
ESP32-S2 sleep is a bit reorganized to locate more logic with
TimeAlarm. This will help it scale to more alarm types.
Fixes#3786
Since Actions passed on the previous commit, where this computed value
was checked against the specified value (if any), this is no net change,
except that we no longer need to specify it for particular boards or
ports.
The SPI flash on current Fomu firmware is slow. Circuitpython runs
XIP from SPI flash, and so execution time can also be slow. Ordinarily
this isn't a problem, however certain operations are time-sensitive.
In particular, USB function needs to be handled quickly in order to
prevent the host from re-enumerating the device.
Place several critical TinyUSB structures into RAM, as well as several
hot functions that are frequently called. This reduces execution time
at the expense of system memory, and greatly improves system stability.
Signed-off-by: Sean Cross <sean@xobs.io>