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

Correct setting for CC310 in NRF52840

Hello everyone.

I made my own board with nrf2840 and wanted to use the CC310 module for encryption.

I uploaded an example from the SDK to my board and in the debug I see that all tests are going well and the module is working. But when I wanted to add the library libnrf_cc310_0.9.13.a to my project, then I ran into problems. I wanted to use AES in CBC mode. The module initialization functions SaSi_AesInit, SaSi_AesSetIv and SaSi_AesSetKey from example pass successfully and output is SA_SILIB_RET_OK. But when I want to use SaSi_AesBlock or SaSi_AesFinish for encryption, I catch a hard fault in debug. My project uses a S140 softdevice and works with a smartphone via NUS. I tried disabling everything and dont upload softdevice and running only the code with encryption tests that I copied from the example, but they don't work and program goes to hard fault handler. What could I have forgotten while adding this library to the project? I use SDK17, softdevice get clock from internal source. This is my first experience with this MCU and cryptocell unit.

Thanks! 

Parents
  • I tried disabling everything and dont upload softdevice and running only the code with encryption tests that I copied from the example, but they don't work and program goes to hard fault handler.

     Is your main() function reached at all when you try this? Can you show me what the hardfault looks like?

    Best Regards,

    Edvin

  • Thanks for the answer, I'm still trying to figure out what's wrong with my project config. If I create a new empty project and add encryption libraty to it then everything works in debug. If I remove everything except encryption files from my project and add main file from the CC310 encryption example in SDK, then an error is still caught. It seems to me that the matter is in the Segger settings. It takes a long time to create my project from scratch and add files there, but in the end I still get the same errors.I cannot understand at what stage I am breaking the project, since everything works until the last moment Slight smile. In the pictures, I go through the debugging of the first test of that function and it crashes. The only difference in the picture is that I commented functions for the output to the debug console.

  • Hello,

    In the project where this hardfault occurs. Perhaps you can try to add the hardfault handler. It is found in SDK\libraries\hardfault\

    Add hardfault_implementation.c, hardfault.h, nrf52\handler\hardfault_handler_gcc.c, and make sure that the HARDFAULT_HANDLER is enabled in sdk_config.h in your project. (I believe it is HARDFAULT_HANDLER_ENABLED set to 1)

    Then the hardfault handler from these files should trigger instead of the weak implementation in ses_startup_nrf52.s.

    If it is hit, try to replace:

    /*lint -save -e14 */
    __WEAK void HardFault_process(HardFault_stack_t * p_stack)
    {
        // Restart the system by default
        NVIC_SystemReset();
    }

    with 

    /*lint -save -e14 */
    __WEAK void HardFault_process(HardFault_stack_t * p_stack)
    {
        // Restart the system by default
        //NVIC_SystemReset();
        while (true)
        {
            NRF_LOG_PROCESS();
        }
    }

    and see what the log says.

    Best regards,

    Edvin

  • Thanks for the tip, I added hardfault debugging and corrected  a bit the code in hardfault_implementation.c, since NRF_LOG_ERROR does not work, I replaced it with SEGGER_RTT_printf. Thus, I got the following. I still do not understand which part of the code from HAL breaks the project. There are many modules in the project that work through HAL, I will look what exactly breaks it  when adding.Although it breaks in a project that has removed everything except encryption, which confuses me.

  • Is there some way for me to reproduce this?

    Is the hardfault happening inside one of the NRF_LOG_...() calls? What are your log settings? What is your log backend set in sdk_config.h? What is the NRF_LOG_DEFERRED set to? Do you use an RTOS (FreeRTOS)? Do you have multiple instances to NRF_LOG_PROCESS() or NRF_LOG_FLUSH()?

Reply Children
No Data
Related