Skip to content
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

[Silabs] Fixing hardfault issue with RS9116 ble manager #36167

Conversation

bhmanda-silabs
Copy link
Contributor

@bhmanda-silabs bhmanda-silabs commented Oct 21, 2024

Problem:
The Ble manager for Rs911x devices code refactored by below PR and in this no where the memory is not allocated for bleEvent.eventData member.
#35522
Due to which hardfault is coming when this struct member is getting defined.

Fix
Fixed the issue by allocating

Testing
Tested commissioning with 917 SoC, RS9116+EFR mg24.

@bhmanda-silabs bhmanda-silabs requested a review from a team as a code owner October 21, 2024 06:21
Copy link

Review changes with SemanticDiff.

Copy link

github-actions bot commented Oct 21, 2024

PR #36167: Size comparison from d7abcbf to 980c798

Full report (65 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink)
platform target config section d7abcbf 980c798 change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1350008 1350008 0 0.0
RAM 104120 104120 0 0.0
bl702 lighting-app bl702+eth FLASH 647788 647788 0 0.0
RAM 25233 25233 0 0.0
bl702+wifi FLASH 825274 825274 0 0.0
RAM 13965 13965 0 0.0
bl706+mfd+rpc+littlefs FLASH 1054200 1054200 0 0.0
RAM 23821 23821 0 0.0
bl702l lighting-app bl702l+mfd+littlefs FLASH 975048 975048 0 0.0
RAM 16468 16468 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 829564 829564 0 0.0
RAM 123452 123452 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 814872 814872 0 0.0
RAM 125332 125332 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 761460 761460 0 0.0
RAM 113824 113824 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 745704 745704 0 0.0
RAM 114016 114016 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 617258 617258 0 0.0
RAM 205908 205908 0 0.0
lock CC3235SF_LAUNCHXL FLASH 657306 657306 0 0.0
RAM 206060 206060 0 0.0
cyw30739 light CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 678589 678589 0 0.0
RAM 78668 78668 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 698433 698433 0 0.0
RAM 81300 81300 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 698433 698433 0 0.0
RAM 81300 81300 0 0.0
CYW930739M2EVB-02 unknown 2040 2040 0 0.0
FLASH 655377 655377 0 0.0
RAM 73736 73736 0 0.0
light-switch CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 614933 614933 0 0.0
RAM 71628 71628 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 634569 634569 0 0.0
RAM 74180 74180 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 634569 634569 0 0.0
RAM 74180 74180 0 0.0
lock CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 634213 634213 0 0.0
RAM 74676 74676 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 653921 653921 0 0.0
RAM 77228 77228 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 653921 653921 0 0.0
RAM 77228 77228 0 0.0
thermostat CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 609525 609525 0 0.0
RAM 68764 68764 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 629385 629385 0 0.0
RAM 71396 71396 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 629385 629385 0 0.0
RAM 71396 71396 0 0.0
efr32 lock-app BRD4187C FLASH 925248 925248 0 0.0
RAM 159708 159708 0 0.0
BRD4338a FLASH 741432 741456 24 0.0
RAM 231008 231008 0 0.0
window-app BRD4187C FLASH 1018236 1018236 0 0.0
RAM 128052 128052 0 0.0
esp32 all-clusters-app c3devkit DRAM 95256 95256 0 0.0
FLASH 1539960 1539960 0 0.0
IRAM 82538 82538 0 0.0
m5stack DRAM 116192 116192 0 0.0
FLASH 1550166 1550166 0 0.0
IRAM 117039 117039 0 0.0
linux air-purifier-app debug unknown 4688 4688 0 0.0
FLASH 2781421 2781421 0 0.0
RAM 129520 129520 0 0.0
all-clusters-app debug unknown 5528 5528 0 0.0
FLASH 6092546 6092546 0 0.0
RAM 524000 524000 0 0.0
all-clusters-minimal-app debug unknown 5424 5424 0 0.0
FLASH 5423122 5423122 0 0.0
RAM 242416 242416 0 0.0
bridge-app debug unknown 5408 5408 0 0.0
FLASH 4752050 4752050 0 0.0
RAM 218384 218384 0 0.0
chip-tool debug unknown 5960 5960 0 0.0
FLASH 13162822 13162822 0 0.0
RAM 584562 584562 0 0.0
chip-tool-ipv6only arm64 unknown 21408 21408 0 0.0
FLASH 11721136 11721136 0 0.0
RAM 635488 635488 0 0.0
fabric-admin debug unknown 5792 5792 0 0.0
FLASH 11390901 11390901 0 0.0
RAM 584954 584954 0 0.0
fabric-bridge-app debug unknown 4632 4632 0 0.0
FLASH 4578446 4578446 0 0.0
RAM 205336 205336 0 0.0
lighting-app debug+rpc+ui unknown 6056 6056 0 0.0
FLASH 5693969 5693969 0 0.0
RAM 228488 228488 0 0.0
lock-app debug unknown 5344 5344 0 0.0
FLASH 4801596 4801596 0 0.0
RAM 204472 204472 0 0.0
ota-provider-app debug unknown 4720 4720 0 0.0
FLASH 4430978 4430978 0 0.0
RAM 198192 198192 0 0.0
ota-requestor-app debug unknown 4656 4656 0 0.0
FLASH 4569750 4569750 0 0.0
RAM 202760 202760 0 0.0
shell debug unknown 4216 4216 0 0.0
FLASH 3116045 3116045 0 0.0
RAM 160368 160368 0 0.0
thermostat-no-ble arm64 unknown 9448 9448 0 0.0
FLASH 4319968 4319968 0 0.0
RAM 242896 242896 0 0.0
tv-app debug unknown 5624 5624 0 0.0
FLASH 6032069 6032069 0 0.0
RAM 596416 596416 0 0.0
tv-casting-app debug unknown 5208 5208 0 0.0
FLASH 11368045 11368045 0 0.0
RAM 675936 675936 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 915528 915528 0 0.0
RAM 143357 143357 0 0.0
nrf7002dk_nrf5340_cpuapp FLASH 885992 885992 0 0.0
RAM 141496 141496 0 0.0
all-clusters-minimal-app nrf52840dk_nrf52840 FLASH 848936 848936 0 0.0
RAM 142265 142265 0 0.0
nxp contact k32w0+release FLASH 582296 582296 0 0.0
RAM 70948 70948 0 0.0
mcxw71+release FLASH 596928 596928 0 0.0
RAM 63184 63184 0 0.0
light k32w0+release FLASH 618932 618932 0 0.0
RAM 70412 70412 0 0.0
k32w1+release FLASH 683160 683160 0 0.0
RAM 48816 48816 0 0.0
lock mcxw71+release FLASH 705552 705552 0 0.0
RAM 67324 67324 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1647604 1647604 0 0.0
RAM 212408 212408 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1553684 1553684 0 0.0
RAM 209208 209208 0 0.0
light cy8ckit_062s2_43012 FLASH 1468004 1468004 0 0.0
RAM 201200 201200 0 0.0
lock cy8ckit_062s2_43012 FLASH 1464980 1464980 0 0.0
RAM 225560 225560 0 0.0
qpg lighting-app qpg6105+debug FLASH 660600 660600 0 0.0
RAM 105396 105396 0 0.0
lock-app qpg6105+debug FLASH 618612 618612 0 0.0
RAM 99864 99864 0 0.0
stm32 light STM32WB5MM-DK FLASH 481936 481936 0 0.0
RAM 144844 144844 0 0.0
telink bridge-app tlsr9258a FLASH 681164 681164 0 0.0
RAM 91304 91304 0 0.0
contact-sensor-app tlsr9528a_retention FLASH 620814 620814 0 0.0
RAM 50600 50600 0 0.0
light-switch-app-ota-shell-factory-data tlsr9528a FLASH 708794 708794 0 0.0
RAM 73940 73940 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 625764 625764 0 0.0
RAM 144468 144468 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 811772 811772 0 0.0
RAM 99100 99100 0 0.0

Copy link
Contributor

@mkardous-silabs mkardous-silabs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a general comment, do we need to use a global variable for the bleEvent?
osMessageQueuePut copies the the buffer to the queue to not require the user of the API to maintain the initial event data.

We can just create a local variable each time we want to pass an event to the message queue.

@@ -294,6 +294,7 @@ void SilabsBleWrapper::rsi_ble_add_char_val_att(void * serv_handler, uint16_t ha

uint32_t SilabsBleWrapper::rsi_ble_add_matter_service(void)
{
bleEvent.eventData = new SilabsBleWrapper::sl_wfx_msg_t();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using dynamic allocation, we could just change the structure type to avoid using a pointer for the eventData. From i can tell, there doesn't seem to be an explicitly requirement and the variable is global.

@chirag-silabs
Copy link
Contributor

chirag-silabs commented Oct 21, 2024

As a general comment, do we need to use a global variable for the bleEvent?

@mkardous-silabs The reason it can't be saved as a local variable and passed through the queue is that we need the data which is saved in the same struct during the init/previous event data during the some of events. So instead of having multiple global variables it is better to have a single struct.

@mkardous-silabs
Copy link
Contributor

mkardous-silabs commented Oct 21, 2024

As a general comment, do we need to use a global variable for the bleEvent?

@mkardous-silabs The reason it can't be saved as a local variable and passed through the queue is that we need the data which is saved in the same struct during the init/previous event data during the some of events. So instead of having multiple global variables it is better to have a single struct.

@chirag-silabs From what i can see from the code, the only spot where the ble event is used differently is rsi_ble_add_matter_service. In that function, we set two values that don't change other and set at init making them the equivalent to "constants".

I'm not sure why this would require a global variable. Am i missing something?

@bhmanda-silabs
Copy link
Contributor Author

This change is not required

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants