-
Notifications
You must be signed in to change notification settings - Fork 0
Fix hard fault in Dmod_EnterCritical caused by corrupt .dmod.inputs startup initialization #88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a6320a9
Initial plan
Copilot a188510
Fix hard fault: move .dmod.inputs/.dmod.outputs inside .data to fix s…
Copilot 01b896d
Add explicit stm32f746g-disco Renode CI test with better diagnostics …
Copilot 16772ce
Fix CI to explicitly show BOARD=stm32f746g-disco in cmake steps
Copilot eda6751
Fix VFS pre-RTOS mutex fallback, revert timeouts, improve CI test
Copilot 04f0ac6
Add pre-RTOS Dmod_Mutex_New guard via --wrap to fix VFS mounts
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,29 @@ | ||
| # Expected log messages from DMOD-Boot firmware running in Renode | ||
| # Each line is a pattern that must appear in the monitor-gdb output | ||
| # Lines starting with # are comments and empty lines are ignored | ||
| # on the stm32f746g-disco board configuration. | ||
| # | ||
| # This test catches the hard-fault that occurred when .dmod.inputs was not | ||
| # correctly copied to RAM during startup. A corrupt .dmod.inputs caused | ||
| # Dmod_ConnectApi to write garbage function pointers into loaded modules' | ||
| # .dmod.outputs sections, leading to an immediate hard-fault whenever a | ||
| # loaded driver (e.g. dmgpio via dmdevfs) tried to log a message. | ||
| # | ||
| # With the fix applied the boot sequence is: | ||
| # 1. Heap initialised | ||
| # 2. modules.dmp loaded, dmell enabled | ||
| # 3. Filesystems mounted (/configs, /dev) -- requires the dmvfs pre-RTOS | ||
| # mutex fallback fix so that mounts succeed before vTaskStartScheduler | ||
| # 4. FreeRTOS scheduler starts | ||
| # 5. dmell loads and configures board drivers (dmgpio, dmclk, etc.) | ||
| # -- this is where the hard-fault used to occur with the corrupt | ||
| # .dmod.inputs linker bug | ||
| # | ||
| # Lines starting with ! must NOT appear in the log (crash guard). | ||
| # The pattern matched is everything after the leading '!'. | ||
| # All other non-empty, non-comment lines must appear in the log. | ||
|
|
||
| DMOD-Boot started | ||
| # --- crash guard: a hard-fault means something is still broken --- | ||
| !HardFault_Handler invoked! | ||
|
|
||
| # --- positive checks: firmware must reach these milestones --- | ||
| Heap initialized | ||
| DMOD-Boot started |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /** | ||
| * @brief Pre-RTOS guard for Dmod_Mutex_New (ARMv7-M) | ||
| * | ||
| * The dmosi bridge library provides a strong Dmod_Mutex_New that calls | ||
| * dmosi_mutex_create(), which in turn calls pvPortMalloc() + | ||
| * xSemaphoreCreateRecursiveMutex(). Both succeed before vTaskStartScheduler() | ||
| * because FreeRTOS heap allocation does not require the scheduler. However, | ||
| * dmosi_mutex_lock() returns -ENOTSUP when !dmosi_is_started(), so any caller | ||
| * that obtains a non-NULL mutex handle before the scheduler starts and then | ||
| * tries to lock it will fail. | ||
| * | ||
| * This wrapper (enabled via -Wl,--wrap=Dmod_Mutex_New) returns NULL when the | ||
| * scheduler has not yet been started. NULL causes callers such as dmvfs to | ||
| * fall back to Dmod_EnterCritical / Dmod_ExitCritical (interrupt-disable | ||
| * critical sections), which work correctly both before and after RTOS start. | ||
| * | ||
| * After vTaskStartScheduler() the wrapper forwards to the real implementation | ||
| * so proper recursive RTOS mutexes are created as usual. | ||
| */ | ||
|
|
||
| #include <stdbool.h> | ||
|
|
||
| /* Resolved at link time from dmosi_freertos */ | ||
| extern bool dmosi_is_started(void); | ||
|
|
||
| /* The real (unwrapped) symbol comes from the dmosi bridge library */ | ||
| extern void* __real_Dmod_Mutex_New(bool Recursive); | ||
|
|
||
| void* __wrap_Dmod_Mutex_New(bool Recursive) | ||
| { | ||
| if (!dmosi_is_started()) | ||
| { | ||
| return NULL; | ||
| } | ||
| return __real_Dmod_Mutex_New(Recursive); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jeśli tutaj już była obsługa board, to czemu nie dodałeś odpowiedniego parametru?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The board parameter was already handled elsewhere; the real issue was that the VFS mounts failed pre-RTOS (see the
Dmod_Mutex_Newwrap fix in04f0ac6), which is what prevented board modules from loading.