Light sleep gates the APB clock the I2C peripheral runs on. A transfer in flight stops mid-message and never raises its completion interrupt, so the caller blocks in i2c_sem_waitdone() until ESP32S3_I2CTIMEOTICKS expires and gets -ETIMEDOUT for a bus that was working perfectly. The caller is what causes it. Blocking in i2c_sem_waitdone() is exactly what makes the idle task runnable, and the idle task is what decides to sleep -- so the longer the transfer, the likelier it is to be cut in half by its own wait. Nothing about this is driver-specific. Seen on an esp32s3-xiao reading an LSM6DS3TR-C FIFO: 6000 bytes in one transaction, some 135 ms of bus time at 400 kHz, failing with -110 over and over. A WHO_AM_I probe and the FIFO status read, both short, never failed once in the same runs -- only the long burst did. The consequences went well past one failed read. With the FIFO left undrained the sensor's level-triggered INT1 stayed asserted, the worker was re-entered the moment the IRQ was re-enabled, and that hot loop starved every other task until the board wedged with no console output and no crash dump. pm_stay(PM_IDLE_DOMAIN, PM_IDLE) is the lightest lock that suffices: greedy_governor_checkstate() walks up from PM_NORMAL and stops at the first state holding a wakelock, so a stay at PM_IDLE keeps the domain out of PM_STANDBY and PM_SLEEP while still allowing the plain WFI idle. There is no early return between the stay and the relax. Validated over 3 h 45 of continuous acquisition across two sessions: wakes and drains stayed 1:1 (302/302, then 375/375), zero I2C failures of any kind, and light sleep itself unaffected -- 11.8% of wall time asleep in both, median sleep 2.08 s. Signed-off-by: Felipe Moura <moura.fmo@gmail.com> Assisted-by: Claude:claude-opus-5 |
||
|---|---|---|
| .github | ||
| arch | ||
| audio | ||
| binfmt | ||
| boards | ||
| cmake | ||
| crypto | ||
| Documentation | ||
| drivers | ||
| dummy | ||
| fs | ||
| graphics | ||
| include | ||
| libs | ||
| mm | ||
| net | ||
| openamp | ||
| pass1 | ||
| sched | ||
| syscall | ||
| tools | ||
| video | ||
| wireless | ||
| .asf.yaml | ||
| .codespell-ignore-lines | ||
| .codespellrc | ||
| .editorconfig | ||
| .gitignore | ||
| .gitmessage | ||
| .pre-commit-config.yaml | ||
| .yamllint | ||
| AUTHORS | ||
| CMakeLists.txt | ||
| CONTRIBUTING.md | ||
| INVIOLABLES.md | ||
| Kconfig | ||
| LICENSE | ||
| Makefile | ||
| NOTICE | ||
| README.md | ||
| ReleaseNotes | ||
Apache NuttX is a real-time operating system (RTOS) with an emphasis on standards compliance and small footprint. Scalable from 8-bit to 64-bit microcontroller environments, the primary governing standards in NuttX are POSIX and ANSI standards. Additional standard APIs from Unix and other common RTOSs (such as VxWorks) are adopted for functionality not available under these standards, or for functionality that is not appropriate for deeply-embedded environments (such as fork()).
For brevity, many parts of the documentation will refer to Apache NuttX as simply NuttX.
Getting Started
First time on NuttX? Read the Getting Started guide! If you don't have a board available, NuttX has its own simulator that you can run on terminal.
Documentation
You can find the current NuttX documentation on the Documentation Page.
Alternatively, you can build the documentation yourself by following the Documentation Build Instructions.
The old NuttX documentation is still available in the Apache wiki.
Supported Boards
NuttX supports a wide variety of platforms. See the full list on the Supported Platforms page.
Contributing
If you wish to contribute to the NuttX project, read the Contributing guidelines for information on Git usage, coding standard, workflow and the NuttX principles.
License
The code in this repository is under either the Apache 2 license, or a license compatible with the Apache 2 license. See the License Page for more information.