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

peer manager initialization stucked

I had a BLE central application and need to migrate now to peer_manager to have the LESC security. 

I am using as a reference the Experimental: LE Secure Connections Multirole Example  example.

Application compiles ok, but it gets stucked in peer manager initialization, in pm_init() fcn, specifically in nrf_crypto_rng_backend_init() inside inside sm_init() .

This event just happens when LESC is enabled. If PM_LESC_ENABLED is disabled, then application at least starts.

When i try the original examples it works properly. Any idea what would be the reason for this? 

I am using the nrf52840, thus s140.

Parents
  • I don't think I have seen problems with the program getting stuck inside sm_init() before. Can you post a screenshot of the CPU registers when it's stuck? Also, which SDK version and IDE/toolchain is it that you are working with?

  • i use a gcc project with Eclipse IDE. SDKI 15.3

    SEGGER J-Link GDB Server V6.72 Command Line Version
    
    JLinkARM.dll V6.72 (DLL compiled Apr 28 2020 10:55:34)
    
    Command line: -if swd -device nrf52840_XXAA -endian little -speed 1000 -port 2331 -swoport 2332 -telnetport 2333 -vd -ir -localhostonly 1 -singlerun -strict -timeout 0
    -----GDB Server start settings-----
    GDBInit file:                  none
    GDB Server Listening port:     2331
    SWO raw output listening port: 2332
    Terminal I/O port:             2333
    Accept remote connection:      localhost only
    Generate logfile:              off
    Verify download:               on
    Init regs on start:            on
    Silent mode:                   off
    Single run mode:               on
    Target connection timeout:     0 ms
    ------J-Link related settings------
    J-Link Host interface:         USB
    J-Link script:                 none
    J-Link settings file:          none
    ------Target related settings------
    Target device:                 nrf52840_XXAA
    Target interface:              SWD
    Target interface speed:        1000kHz
    Target endian:                 little
    
    Connecting to J-Link...
    J-Link is connected.
    Firmware: J-Link OB-SAM3U128-V2-NordicSemi compiled Mar 17 2020 14:43:00
    Hardware: V1.00
    S/N: 682190433
    Feature(s): RDI, FlashBP, FlashDL, JFlash, GDB
    Checking target voltage...
    Target voltage: 3.30 V
    Listening on TCP/IP port 2331
    Connecting to target...
    Connected to target
    Waiting for GDB connection...Connected to 127.0.0.1
    Reading all registers
    Read 4 bytes @ address 0x00000000 (Data = 0x20000400)
    Read 2 bytes @ address 0x00000000 (Data = 0x0400)
    Received monitor command: speed 1000
    Target interface speed set to 1000 kHz
    Received monitor command: clrbp
    Received monitor command: reset
    Resetting target
    Received monitor command: halt
    Halting target CPU...
    ...Target halted (PC = 0x00000A80)
    Received monitor command: regs
    R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000
    R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000
    R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000
    R12= 00000000, R13= 20000400, MSP= 20000400, PSP= 00000000
    R14(LR) = FFFFFFFF, R15(PC) = 00000A80
    XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000
    CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00
    Reading all registers
    Received monitor command: speed auto
    Select auto target interface speed (1000 kHz)
    Received monitor command: flash breakpoints 0
    Flash breakpoints disabled
    Read 4 bytes @ address 0x00000A80 (Data = 0x47184B06)
    Read 2 bytes @ address 0x00000A80 (Data = 0x4B06)
    Downloading 16080 bytes @ address 0x00026000 - Verified OK
    Downloading 16064 bytes @ address 0x00029ED0 - Verified OK
    Downloading 16032 bytes @ address 0x0002DD90 - Verified OK
    Downloading 16080 bytes @ address 0x00031C30 - Verified OK
    Downloading 15984 bytes @ address 0x00035B00 - Verified OK
    Downloading 16016 bytes @ address 0x00039970 - Verified OK
    Downloading 15984 bytes @ address 0x0003D800 - Verified OK
    Downloading 15984 bytes @ address 0x00041670 - Verified OK
    Downloading 16128 bytes @ address 0x000454E0 - Verified OK
    Downloading 16064 bytes @ address 0x000493E0 - Verified OK
    Downloading 16112 bytes @ address 0x0004D2A0 - Verified OK
    Downloading 16304 bytes @ address 0x00051190 - Verified OK
    Downloading 9676 bytes @ address 0x00055140 - Verified OK
    Downloading 192 bytes @ address 0x0005770C - Verified OK
    Downloading 40 bytes @ address 0x000577CC - Verified OK
    Downloading 8 bytes @ address 0x000577F4 - Verified OK
    Downloading 24 bytes @ address 0x000577FC - Verified OK
    Downloading 16 bytes @ address 0x00057814 - Verified OK
    Downloading 60 bytes @ address 0x00057824 - Verified OK
    Downloading 40 bytes @ address 0x00057860 - Verified OK
    Downloading 8 bytes @ address 0x00057888 - Verified OK
    Downloading 416 bytes @ address 0x00057890 - Verified OK
    Downloading 16 bytes @ address 0x00057A30 - Verified OK
    Downloading 8 bytes @ address 0x00057A40 - Verified OK
    Downloading 3836 bytes @ address 0x00057A48 - Verified OK
    Downloading 20 bytes @ address 0x00058944 - Verified OK
    Writing register (PC = 0x   3a7dc)
    Read 4 bytes @ address 0x0003A7DC (Data = 0x4A074906)
    Read 2 bytes @ address 0x0003A7DC (Data = 0x4906)
    Read 2 bytes @ address 0x00026490 (Data = 0xE92D)
    Reading 64 bytes @ address 0x00026480
    Read 2 bytes @ address 0x00026670 (Data = 0xF004)
    Reading 64 bytes @ address 0x0002BE00
    Read 2 bytes @ address 0x0002C098 (Data = 0x2C00)
    Read 2 bytes @ address 0x0002BEC8 (Data = 0x4A9B)
    Read 2 bytes @ address 0x0002BEC0 (Data = 0x2113)
    Read 2 bytes @ address 0x0002BEC0 (Data = 0x2113)
    Received monitor command: clrbp
    Received monitor command: reset
    Resetting target
    Received monitor command: halt
    Halting target CPU...
    ...Target halted (PC = 0x00000A80)
    Read 2 bytes @ address 0x00026490 (Data = 0xE92D)
    Received monitor command: regs
    R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000
    R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000
    R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000
    R12= 00000000, R13= 20000400, MSP= 20000400, PSP= 00000000
    R14(LR) = FFFFFFFF, R15(PC) = 00000A80
    XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000
    CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00
    Reading all registers
    Setting breakpoint @ address 0x00026490, Size = 2, BPHandle = 0x0001
    Setting breakpoint @ address 0x0002BEC0, Size = 2, BPHandle = 0x0002
    Setting breakpoint @ address 0x0002BEC8, Size = 2, BPHandle = 0x0003
    Setting breakpoint @ address 0x0002C098, Size = 2, BPHandle = 0x0004
    Starting target CPU...
    ...Breakpoint reached @ address 0x00026490
    Reading all registers
    Removing breakpoint @ address 0x00026490, Size = 2
    Removing breakpoint @ address 0x0002BEC0, Size = 2
    Removing breakpoint @ address 0x0002BEC8, Size = 2
    Removing breakpoint @ address 0x0002C098, Size = 2
    Read 4 bytes @ address 0x00026490 (Data = 0x4FF0E92D)
    Setting breakpoint @ address 0x0002BEC0, Size = 2, BPHandle = 0x0005
    Setting breakpoint @ address 0x0002BEC8, Size = 2, BPHandle = 0x0006
    Setting breakpoint @ address 0x0002C098, Size = 2, BPHandle = 0x0007
    Starting target CPU...
    Debugger requested to halt target...
    ...Target halted (PC = 0x0004A552)
    Reading all registers
    Removing breakpoint @ address 0x0002BEC0, Size = 2
    Removing breakpoint @ address 0x0002BEC8, Size = 2
    Removing breakpoint @ address 0x0002C098, Size = 2
    Read 4 bytes @ address 0x0004A552 (Data = 0x8F5BF3BF)
    Read 2 bytes @ address 0x0004A552 (Data = 0xF3BF)
    Read 2 bytes @ address 0x0004A554 (Data = 0x8F5B)
    Reading 64 bytes @ address 0x0004A500
    Reading 64 bytes @ address 0x2003FE00
    Read 4 bytes @ address 0x000491D8 (Data = 0x48064D05)
    Reading 64 bytes @ address 0x000491C0
    Read 4 bytes @ address 0x00049C4C (Data = 0x07D89B05)
    Reading 64 bytes @ address 0x00049B00
    Reading 64 bytes @ address 0x00049B40
    Reading 64 bytes @ address 0x2003FE80
    Read 4 bytes @ address 0x000486F4 (Data = 0xD14E2800)
    Reading 64 bytes @ address 0x00048600
    Reading 64 bytes @ address 0x00048640
    Reading 64 bytes @ address 0x2003FEC0
    Read 4 bytes @ address 0x00047DC8 (Data = 0xFF2EF7FF)
    Reading 64 bytes @ address 0x2003FF00
    Read 4 bytes @ address 0x00047756 (Data = 0xD1EA2800)
    Read 4 bytes @ address 0x000476C8 (Data = 0x28003401)
    Read 4 bytes @ address 0x00044266 (Data = 0xB9384604)
    Reading 64 bytes @ address 0x2003FF40
    Read 4 bytes @ address 0x000472B6 (Data = 0xB9784604)
    Read 4 bytes @ address 0x000456CC (Data = 0xF000BB50)
    Read 4 bytes @ address 0x0002D044 (Data = 0x2205B9E8)
    Read 4 bytes @ address 0x0002656E (Data = 0xFF07F004)
    

  • The log does not show the CPU register content when the program is stuck inside sm_init(). Do you have a CPU register view in Eclipse? Also, does Eclipse build with our SDK makefiles and linker scripts?

  • I don't have a CPU register in Eclipse. 

    And yes, Eclipse does build with the SDK makefiles and linker scripts, otherwise i believe the program will not compile.

    And this stucking part only appears when i have LESC enabled in the peer:manager_init().

    Without that the system can bond properly and application starts correctly. 

    Any other idea of what could be causing this stopping or never returning function?

    Basically what i did was integrating the peer_manager to the NUS central example. Then i enabled the LESC to have encrypted communications and MITM protection. 

  • Are you able to share your project so I can try to debug it here? I think it will be difficult for me to find out what the problem is otherwise.  I will of course make this thread private if neccessary.

Reply Children
Related