This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

LESC and FreeRTOS

Does LESC is supported in FreeRTOS?

I init BLE modules in FreeRTOS tasks. After LESC is enabled, system returns error in nrf_crypto_rng_init(). Looks like nrf_stack_info_overflowed() isn't for FreeRTOS. I thought this API check the main stack, not the stack of task. 

I am wondering if there is any example of FreeRTOS with LESC enabled?

Parents
  • You need to try the non interrupt variant of cypto library to make it work with FreeRTOS. There are issues to make crypto interrupt variant work with RTOS environment.

  • Hello -

    I am also trying to get LESC working on FreeRTOS. Based on suggestions here, I am now linking the hard-float/no-interrupts variant of the libnrf_cc310_0.9.12.a library. In my application I am setting the same crypto sdk_config.h options as the ble_app_multirole_lesc app. We are using more RAM than the typical example app, but otherwise I don't believe our compiler/linker settings are different:

    arm_architecture="v7EM"
    arm_core_type="Cortex-M4"
    arm_endian="Little"
    arm_fp_abi="Hard"
    arm_fpu_type="FPv4-SP-D16"
    arm_linker_heap_size="61440"
    arm_linker_process_stack_size="0"
    arm_linker_stack_size="8192"

    With these options I am also getting the stack overflow in nrf_stack_info_overflowed(). We are initializing the BLE modules in our application based on the ble_app_hrs_freertos example.I have tried increasing our linker stack size to 16384, but that doesn't seem to make any difference.

    When I run the ble_app_hrs_freertos app, which also works as expected, I looked at the values being compared here in nrf_stack_info_overflowed:

    if (NRF_STACK_INFO_GET_SP() < NRF_STACK_INFO_BASE)
    

    The values are:

    0x2003e000 < 0x2003fed8
    
    In my app (which fails) the values are:

    0x2003e000 < 0x20009d38
    

    I am using a 20 KB stack size in the FreeRTOS task that initializes BLE. What do I need to change in my configuration/code to get past the stack overflow check successfully?

    Regards,

    Brian

  • Hi, Sorry for late response, but searching for issues made me look into this.

    . The code is for nRF5 which doesn't support threads, so we are just checking against the main stack to see if there is a stack overflow. You can remove the stack check or substitute with a stack check with the current thread stack you are in. The stack limit is just a sanity test to ensure that we don't fly over the stack limit. The crypto doesn't require main stack utilization. It is just testing if there is room on main stack because nRF5 SDK assumes that there is only one. 

    The workaround right now: Remove the stack-check macro (fill it with empty content) and see that you don't blow over your stack or write code that can check per-thread if you have room left in your stack

  • Susheel -

    Thank you for the follow-up. Indeed, removing the stack check macro is the only workaround at this time. FYI - the issue is also covered in this post:

    https://devzone.nordicsemi.com/f/nordic-q-a/54770/lesc-initialization-on-freertos

    Regards,

    Brian

Reply Children
No Data
Related