The image turning green previously was caused by the rgb stats not being
sampled continously (only every 100 frames) coupled with only happening
on snapshot. As such, any algorithm causing the fps to slow down would
lower the update freq. The new average solution ensures that the rgb
average is smoothed over many frames and only keeps the last 250ms of
history.
Addresses review feedback from PR #2870:
- Fix NULL pointer dereference when finalisers run on unopened files
- Prevent infinite recursion in error handlers during buffered I/O
- Add explicit validation for FA_READ|FA_WRITE flag combinations
- Switch to mp_vfs_open for consistency with VFS abstraction
- Add NULL checks to file_buffer_on/off public APIs
The recursion fix ensures both file_buffer_off() and file_close()
clear their state before risky operations, making re-entry safe.
Replace lookup table with bit-by-bit polynomial calculation for
the remaining 1-3 bytes. Direct calculation is faster than table
lookup for such small amounts due to avoiding cache misses and
memory indirection overhead that dominates when processing only
1-3 bytes.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This reverts commit bb52288561.
Event though this fixes a deadlock in the new protocol, it
actually breaks fair locking as one side could lock multiple
times in a row.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Clear the thread ID to 0 when unlocking the mutex to prevent deadlock.
If the thread holding never reacquire it, other threads would be
permanently blocked with a stale thread ID.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
The removal of unused USB commands that are still sent by the IDE
causes tinyusb boards to crash on connect currently. Flushing the
excess received bytes for unknown commands solves this issue.
This adds a simple code profiler that leverages both SysTick and
the Performance Monitoring Unit (PMU) available on Armv8.1-M cores.
SysTick provides a simple high-resolution timer source, while the PMU
offers a cycle counter and multiple configurable event counters that
can track low-level performance metrics such as cache misses, pipeline
stalls, etc... See the Armv8.1-M Performance Monitoring User Guide
for additional details.
Function-level instrumentation is enabled using -finstrument-functions
on select files to automatically record statistics on entry/exit.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This commit refactors the TinyUSB debug interface with the following changes:
- Handle disabled IRQs.
- Replace global variables with centralized state.
- Add timeout, and validation for more robust transfers (as much as possible
given the protocol limits).
- Remove obsolete/unsupported commands (attr read/write, script save etc..)
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This allows drivers to override standard resolutions,
or use custom ones, without affecting other CSIs.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
- Abort if synchronization takes too long.
- Reinit SPI on transfer restart (fixes an issue on N6).
- Clean up vospi code.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Check if VOSPI_SYNC_MS has elapsed since the last abort instead
of delaying on every call. This avoids blocking other CSIs on
back-to-back resync's.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Use C11 atomic operations to implement the mutex instead
of hard-coded intrinsics. This generates more efficient
assembly on newer ARM architectures by taking advantage
of the new LDA/STL instructions (and their exclusive variants),
which avoid full memory barriers while still providing
memory ordering guarantees.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>