Skip to content

Add ENOTSUP fallback in mutex lock/unlock for pre-RTOS operation#52

Merged
JohnAmadis merged 2 commits into
developfrom
copilot/add-fallback-for-enotsup-mutexes
Mar 5, 2026
Merged

Add ENOTSUP fallback in mutex lock/unlock for pre-RTOS operation#52
JohnAmadis merged 2 commits into
developfrom
copilot/add-fallback-for-enotsup-mutexes

Conversation

Copilot AI commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

Dmod_Mutex_Lock returns -ENOTSUP when the RTOS scheduler hasn't started yet, causing all DMVFS operations (including filesystem mounting) to fail with "Failed to lock DMVFS mutex".

Changes

  • src/dmvfs.c
    • Add #include <errno.h>
    • lock_mutex(): on -ENOTSUP from Dmod_Mutex_Lock, fall back to Dmod_EnterCritical() instead of returning failure
    • unlock_mutex(): on -ENOTSUP from Dmod_Mutex_Unlock, call Dmod_ExitCritical() to match the lock-side fallback
// Before: any non-zero return from Dmod_Mutex_Lock was a hard failure
return (Dmod_Mutex_Lock(g_mutex) == 0);

// After: ENOTSUP means RTOS not started — transparently use critical sections
int ret = Dmod_Mutex_Lock(g_mutex);
if (ret == 0)        { return true; }
if (ret == -ENOTSUP) { Dmod_EnterCritical(); return true; }
return false;

The same symmetry is applied in unlock_mutex — if Dmod_Mutex_Unlock returns -ENOTSUP, Dmod_ExitCritical() is called to pair with the critical section entered during lock.

Original prompt

This section details on the original issue you should resolve

<issue_title>Dodać fallback mutexów dla ENOTSUP</issue_title>
<issue_description>Ostatnio do mutexów zostało dodane sprawdzanie czy system już wystartował. Niestety przez to, jeśli próbujemy zamontować jakiś system plików przed startem RTOSa, to mutexy zwracają errno -ENOTSUP, co powoduje problem z montowaniem systemów plików:

[INFO] To debug module 'dmell' in gdb: add-symbol-file <MODULE_ELF_FILE> 0x200186f8
[ERROR] Failed to lock DMVFS mutex
[INFO] Config filesystem found in ROM: addr=0x8046B3B, size=774 bytes
[ERROR] Failed to lock DMVFS mutex
[ERROR] Failed to mount config filesystem at /configs/
[ERROR] Failed to lock DMVFS mutex

Trzeba dodać sprawdzenie, czy to jest taki kod błędu i w takim przypadku założyć, że RTOS nie wystartował i że sekcje krytyczne wystarczą</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
Copilot AI changed the title [WIP] Add fallback mutex handling for ENOTSUP error Add ENOTSUP fallback in mutex lock/unlock for pre-RTOS operation Mar 5, 2026
@JohnAmadis JohnAmadis marked this pull request as ready for review March 5, 2026 20:30
@JohnAmadis JohnAmadis merged commit f03a29b into develop Mar 5, 2026
1 check 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.

Dodać fallback mutexów dla ENOTSUP

2 participants