|
Some checks are pending
MemBrowse Memory Report / changes-filter (push) Waiting to run
MemBrowse Memory Report / load-targets (push) Waiting to run
MemBrowse Memory Report / identical (push) Blocked by required conditions
MemBrowse Memory Report / analyze (push) Blocked by required conditions
CONFIG_ESP32S3_TICKLESS hangs forever the first time a task calls a sleep/timeout with a fractional-second component of roughly 134ms or more (e.g. usleep(500000)) while another task is also pending a timeout. Root cause: NSEC_2_CTICK() computes ((nsec) * CTICK_PER_USEC) / NSEC_PER_USEC. `nsec` (struct timespec's tv_nsec) is a 32-bit `long`, and CTICK_PER_USEC is 16 (the S3's systimer runs at 16MHz), so the multiplication overflows a 32-bit signed int for any tv_nsec at or above INT32_MAX / 16 (~134,217,728 ns). The overflowed (negative) result then gets added into up_timer_start()'s `uint64_t cpu_ticks`, wrapping around to a value near UINT64_MAX. tickless_setcounter() then programs the systimer alarm that many ticks in the future -- effectively never -- so nxsched_process_timer() is never called and the waiting task sleeps forever. Reproduced on real esp32s3-xiao hardware: apps/testing/ostest hung indefinitely right after starting user_main(), whose first statement is usleep(500000). Instrumented up_timer_start() to print its inputs and observed exactly the described overflow (cpu_ticks close to UINT64_MAX for tv_nsec=510000000). Confirmed root cause is the concurrent-timeout case specifically: user_main's usleep() alone works, and ostest_main's own usleep() alone works, but the two together (matching ostest's actual task_create() + concurrent usleep() pattern) reproduce the hang every time. Fix: cast to uint64_t before multiplying in all three *_2_CTICK macros, forcing 64-bit arithmetic throughout, matching how the CTICK_2_* (division) macros are already overflow-safe. Validated on esp32s3-xiao: with the fix, the full ostest suite (built with CONFIG_ESP32S3_TICKLESS=y) runs past the point it used to hang and completes end to end. Note: while testing, ostest's own round-robin test (rr_test) failed near the end of the run -- the two same-priority SCHED_RR threads did not appear to interleave under tickless. That looks like a separate, likely more architectural issue (time-slice preemption needs its own periodic re-arm, independent of one-shot sleep timeouts) and is not addressed by this fix; filing separately. Signed-off-by: Felipe Moura <moura.fmo@gmail.com> |
||
|---|---|---|
| .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.