fix(LPBAM): initialize Request in LPBAM_LPTIM_FillStructInfo#74
Open
94xhn wants to merge 1 commit into
Open
Conversation
For the LPBAM_LPTIM_CONFIG_ID node, LPBAM_LPTIM_FillStructInfo() only sets pDescInfo->Request when Config.State == ENABLE, or when Config.State != ENABLE and Config.Mode == LPBAM_LPTIM_UE_MODE. The remaining case (State != ENABLE, Mode != LPBAM_LPTIM_UE_MODE, i.e. LPBAM_LPTIM_NO_UE_MODE) leaves pDescInfo->Request untouched. The caller, LPBAM_LPTIM_FillNodeConfig() in stm32_lpbam_lptim.c, declares its LPBAM_InfoDesc_t on the stack without initializing it, so in this case pDMANodeConfig->Init.Request ends up with whatever garbage was already on the stack. That value also decides pDMANodeConfig->Init.Direction (set to DMA_MEMORY_TO_PERIPH whenever Request != DMA_REQUEST_SW), so two otherwise-identical LPTIM stop nodes can end up with different DMA node configurations depending on unrelated stack contents - reported independently by two users, one of whom confirmed setting Request explicitly fixed their queue. Set Request to DMA_REQUEST_SW for this case, matching the same choice already made in the State == ENABLE branch above (also a case with no specific hardware DMA request tied to it). Fixes STMicroelectronics#65 Signed-off-by: yi chen <94xhn1@gmail.com>
Contributor
|
Hello @94xhn, Thank you for this report. This point is already being tracked internally. I will keep you informed about our decision. Best Regards, |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Resubmission of #73, closed because the CLA wasn't signed yet at the time — signed now.
Fixes #65.
Root cause
For the
LPBAM_LPTIM_CONFIG_IDnode,LPBAM_LPTIM_FillStructInfo()(Utilities/lpbam/STM32U5/stm32_ll_lpbam.c) only setspDescInfo->Requestin two cases:Config.State == ENABLE→DMA_REQUEST_SWConfig.State != ENABLEandConfig.Mode == LPBAM_LPTIM_UE_MODE→LPDMA1_REQUEST_LPTIM1_UE/LPDMA1_REQUEST_LPTIM3_UEThe remaining combination —
Config.State != ENABLEandConfig.Mode == LPBAM_LPTIM_NO_UE_MODE— falls through without ever assigningpDescInfo->Request.The caller,
LPBAM_LPTIM_FillNodeConfig()(Utilities/lpbam/stm32_lpbam_lptim.c), declares itsLPBAM_InfoDesc_t desc_info;on the stack without initializing it, so in this casepDMANodeConfig->Init.Requestends up with whatever garbage happened to be on the stack. That value also decidespDMANodeConfig->Init.Direction(set toDMA_MEMORY_TO_PERIPHwheneverRequest != DMA_REQUEST_SW), so two otherwise-identical LPTIM "stop" nodes built the same way can end up with different DMA node configurations purely depending on unrelated stack contents at the time — this is exactly what @elektrojupp's report shows: two stop nodes built with the same code, one working and one not, traced down to differingRequestbits in the resulting descriptors.Fix
Set
Request = DMA_REQUEST_SWfor the missing case, matching the same choice already made in theConfig.State == ENABLEbranch just above it — both are cases where there's no specific hardware DMA request line tied to the transfer, so software-triggered is the consistent choice.Testing
I don't have the affected hardware or STM32CubeMX/IDE set up to build the full LPBAM example project, so I can't provide a board-level test. What I did instead: extracted the exact branch structure of
LPBAM_LPTIM_FillStructInfo()'sLPBAM_LPTIM_CONFIG_IDcase into a standalone host-C reproduction (stand-in enums for the STM32U5-specific constants), compiled and ran with plaingcc:State=DISABLE, Mode=NO_UE_MODEleavesRequestas an uninitialized sentinel value.Request = DMA_REQUEST_SW(0), consistently.This matches @elektrojupp's own account that "the suggested fix at least worked in my case. Both stop nodes working and no difference in descriptors."
Generative AI
I used generative AI tools when creating this PR, but a human has checked the code and is responsible for the code and the description above.