nrfxlib Softdevice Controller crashes (hardfault) on nRF52832 but not on nRF52840 without Zephyr (baremetal)

Hi, We are trying to work with nrfxlib directly baremetal without Zephyr.  Were able to do advertising with it.  On nRF52832 the SDC crashes when we tried to set new advertising data by calling

sdc_hci_cmd_le_set_adv_data

On the nRF52840, everything works smoothly. 

We saw the debug symbols that the libsoftdevice_controller_multirole.a was compiled for S140.  Could this be the issue.  Can Nordic provide a version for the S132 ?

I aslo suspect other issue.  it could be that some how when compiling for the nRF52832 it cause some global variable inside the lib to be unaligned causing the crash (hardfault).

Please review the library code to make sure proper variable alignment or enable unaligned access for the gcc compiler when compiling the lib.

crash location : sym_OC5GPSERLPE7TKXSCU3QAZ62H3OM4MWFYV7WX2I() at 0x2f5f8

UPDATE : Sorry I was talking to fast about the the nRF52840.  It also crashes but I can confirm this.  The crash was cause by unaligned access within either the mpsl or the sec lib.

Compile my code by disabling all optimization works but not when optimization is enable.  The different is that when no optimization all global vars are word aligned while optimization will pack all global on a byte align. 

Thanks. 

Parents Reply
  • We are not using SES.  We use GCC 10.3.  It is not compiler version or IDE issue.  This is in your code.  

    You can fix this by forcing alignment on all variable that are not unit8_t or char type or you can also enable the compiler option to allow unaligned access.  By default unaligned access is not allow.  That why it causes the hardfault. The draw back is that generating unaligned access the code will be slow.   

Children
Related