This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2340R2: AssertHandler cases not result in calling HAL_ASSERT_SPINLOCK

Expert 3740 points
Part Number: CC2340R2
Other Parts Discussed in Thread: SYSCONFIG, CC2340R5

Tool/software:

Hi team,

My customer started from the demo code for the basic BLE profiles project. (SDK version 8.40)

We are wondering if when an Assert occurs and the stack or some library routine calls AssertHandler, is it expected that the assert handler would return? It seems to me that all the reasons for an Assert to be called are serious and that you'd want to enter into a while(1) loop...

Is there a reason why an assert could occur where everything is okay still? 

The AssertHandler we have been looking at is in the main_freertos.c file and we found that most cases do not call HAL_ASSERT_SPINLOCK.

Best,

Luke

  • Hi Luke,

    Thanks for reaching out! I believe some asserts may be recoverable which is why not all of them spin lock the device. You are correct that if an assert is serious enough it should lock the device for further analysis, but which asserts should lock the device, which should be allowed to attempt a recovery and which should just initiate a reset will depend on the customer's needs. For instance, during development, it may make sense to spin lock all asserts, but during production it may be better to cause a reset on most asserts to allow the device to quickly recover with minimal user impact.

    Best Regards,

    Jan

  • Hi Jan,

    Thanks for the detailed reply, this makes sense! A follow up question based on some further digging...

    After reading through the HAL Assert Handling section in the SDK docs, I made sure they defined EXT_HAL_ASSERT and added hal_assert.c to their project (and double checked they added EXT_HAL_ASSERT and HAL_ASSERT_SPIN to the project's preprocessor symbols).

    When an assert occurs the library code will call their callback function, and then it will execute its callback which will either reset or spin based on one of these being defined: HAL_ASSERT_RESET, HAL_ASSERT_SPIN

    HAL_ASSERT_RESET works, but when they tried the HAL_ASSERT_SPIN option, they got the following compiler error:

    ICall_disableMInt()/ICall_enableMInt() is defined in ICall.h and it is included as part of their project but this didn't work. It's not a compile time issue but rather a linking issue... any ideas on how to resolve this one? Not sure if we are overlooking something simple here.

    Thanks,

    Luke

  • Hi Luke,

    No problem! Glad to hear the HAL_ASSERT_RESET works! Regarding the SPIN macro, I am a bit surprised at this error. Could you confirm that in the include paths, the  ICall.h file is findable? Also, can you double check that the hal_assert.c/h file has an include for the ICall.h file?

    Best Regards,

    Jan

  • Hi Jan, 

    Yes, I checked they had the include for the icall.h file in their hal_assert.c file and confirmed that it is findable. 

    #include "hal_assert.h"
    #include "hal_types.h"
    #include "hal_board.h"
    #include "hal_defs.h"
    #include "onboard.h"
    #include <C:\ti\simplelink_lowpower_f3_sdk_8_20_00_119\source\ti\ble5stack_flash\icall\src\inc\icall.h> OR #include <icall.h> OR #include "icall.h"

    They have tried each of the different methods to include the file and each of these find and open the icall.h file. Not sure why these functions are not being defined properly. 

    Best,

    Luke

  • Hi Luke,

    Can you try using the #include "icall.h" and adding a local copy of the icall.h file to the root of the project? Please ensure that the file is a local copy and not a reference.

    Best Regards,

    Jan

  • Hi Jan,

    No luck... I had them copy icall.h to root of the project and then they added this new file to the project and they still got the same error. Double checked to make sure it is not a reference too. Any other ideas to try?

    Thanks,

    Luke

  • Hi,

    Understood. In the provided screenshot, it looks like they are using IAR. As a quick test, can they try to enable the define in an SDK example on CCS? We may have to file a ticket to get this addressed and if so it will greatly speed up debug if the behavior occurs on an SDK example on CCS.

    Best Regards,

    Jan

  • Jan,

    They don't have CCS installed and weren't able to test this. However, they plan to upgrade to the latest SDK later this week so maybe the new library files will resolve this issue for them... not sure if this is the cause of the problem though.

    I will keep you updated on if the update fixes things.

    Best,

    Luke

  • Hi Luke,

    Understood. Let me know if the new update resolves the issue. :)

    Best Regards,

    Jan

  • Hey Jan,

    We got the Basic BLE Profiles demo code to compile with the latest SDK and IAR versions for them, so I was able to verify that this issue exists in that code too. It is reporting the same link error that we saw with their project for the R2.

    Steps:

    Take the Basic BLE Profiles demo code and get to compile correctly with IAR. With the SysConfig Tool I added only one Profile, glucose.

    Add the hal_assert.c file to the project (C:\ti\simplelink_lowpower_f3_sdk_8_40_00_61\source\ti\ble5stack_flash\hal\src\common)

    Add EXT_HAL_ASSERT, HAL_ASSERT_SPIN to the PreProcessor for the C/C++ Compiler options.

    Build All.

    Here is the whole Build output:

     basic_ble_profiles_LP_EM_CC2340R5_freertos_iar - Release
    Reading project nodes...

    Cleaning... 51 files.
    SysConfig_Generated_Files.ipcf
    Bootstrapping build file...

    app_broadcaster.c
    app_central.c
    app_observer.c
    app_glucose.c
    app_simple_gatt.c
    app_cgm.c
    app_ht.c
    app_dev_info.c
    app_pairing.c
    app_peripheral.c
    app_main.c
    app_data.c
    bleapputil_process.c
    bleapputil_init.c
    icall_user_config.c
    icall_cc23x0.c
    crc.c
    app_connection.c
    bleapputil_task.c
    bleapputil_stack_callbacks.c
    hal_assert.c
    ble_stack_api.c
    ti_freertos_portable_config.c
    ti_ble_config.c
    icall_POSIX.c
    ti_devices_config.c
    ti_drivers_config.c
    util.c
    ti_radio_config.c
    main_freertos.c
    ble_user_config_stack.c
    nvocmp.c
    cgm_server.c
    glucose_server.c
    osal_icall_ble.c
    rom_init.c
    dev_info_service.c
    icall_api_lite.c
    health_thermometer_server.c
    ble_user_config.c
    glucose_db.c
    menu_module.c
    glucose_profile.c
    cgm_db.c
    cgm_profile.c
    health_thermometer_profile.c
    simple_gatt_profile.c
    ti_freertos_config.c
    basic_ble_profiles_LP_EM_CC2340R5_freertos_iar.out
    Error[Li005]: no definition for "ICall_disableMInt" [referenced from C:\BASICBLEPROFILES\Release\Obj\common_4012601122558228827.dir\hal_assert.o]
    Error[Li005]: no definition for "ICall_enableMInt" [referenced from C:\BASICBLEPROFILES\Release\Obj\common_4012601122558228827.dir\hal_assert.o]

    Total number of errors: 2
    Total number of warnings: 0
    Resolving dependencies...
    Build failed  

    So hopefully it should be easy for the team to recreate.  

    I'm guessing one of the libraries should include ICall_disalbeMInt() and ICall_enableMInt() functions, but does not.  

    Thanks,

    Luke

  • Hi Luke,

    I have reached out to R&D to get their thoughts on the support status for this feature.

    Best Regards,

    Jan

  • It is not recommended to use the HAL asserts, but instead adding a custom spin (like using while(1)) to the assert handler. The HAL components are mainly used internally by the stack and shouldn’t be used in the application code unless absolutely required.

    Thanks,
    Luke