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

nrf_modem_lib_shutdown need 48 seconds bug report

void main(void)
int main(int argc, char* argv[])
{
uint32_t lasttick;

nrf_modem_lib_init(NORMAL_MODE);

lte_lc_power_off()

nrf_modem_lib_shutdown();

}

////////////////////////

assembly code to simple C
<nrf_modem_shutdown>
4B0C ldr r3, =0x20019441
B510 push {r4, lr}
781A ldrb r2, [r3]
B18A cbz r2, 0x00031464
2400 movs r4, #0
701C strb r4, [r3]
4B0A ldr r3, =0x20019442 <operation_mode>
781B ldrb r3, [r3]
B12B cbz r3, 0x00031456
2B01 cmp r3, #1
D007 beq 0x0003145E
F7FFFFB1 bl 0x000313B4 <modem_off>
4620 mov r0, r4
BD10 pop {r4, pc}
F000F80D bl 0x00031474 <nrf_modem_platform_shutdown>
4604 mov r4, r0
E7F7 b 0x0003144E
F7FBFC87 bl 0x0002CD70 <nrfx_ipc_uninit>
E7F4 b 0x0003144E
F04F34FF mov.w r4, #0xFFFFFFFF
E7F3 b 0x00031452
BF00 nop
20019441 .word 0x20019441
20019442 .word 0x20019442

void nrf_modem_shutdown(void)
{
if ( operation_mode )
{
if ( operation_mode == 1 )
nrfx_ipc_uninit();
}
else
{
v0 = nrf_modem_platform_shutdown();
}
modem_off();
}

<nrf_modem_platform_shutdown>
B5F7 push {r0-r2, r4-r7, lr}
F7FFF9E7 bl 0x00030848 <gnss_interface_deinit>
2800 cmp r0, #0
BF14 ite ne
2416 movne r4, #22
2400 moveq r4, #0
F7FDF877 bl 0x0002E574 <ip_interface_deinit>
2800 cmp r0, #0
BF18 it ne
2416 movne r4, #22
F7FEFC74 bl 0x0002FD78 <mfu_interface_deinit>
2800 cmp r0, #0
BF18 it ne
2416 movne r4, #22
F7FFFB6F bl 0x00030B78 <pdn_interface_deinit>
2800 cmp r0, #0
BF18 it ne
2416 movne r4, #22
F7FEF816 bl 0x0002F4D0 <tls_interface_deinit>
2800 cmp r0, #0
BF18 it ne
2416 movne r4, #22
F7FEFB9F bl 0x0002FBEC <at_interface_deinit>
2800 cmp r0, #0
BF18 it ne
2416 movne r4, #22
F2475530 movw r5, #0x7530
F7FCFFDE bl 0x0002E478 <interface_shutdown>
2664 movs r6, #0x64
F012FAFA bl 0x00043AB6 <rpc_transport_request_shutdown>
F012FAFA bl 0x00043ABA <rpc_transport_shutdown_done>
B908 cbnz r0, 0x000314CC
2D00 cmp r5, #0
DC16 bgt 0x000314FA
F012FAF7 bl 0x00043ABE <rpc_transport_shutdown>
F64B3580 movw r5, #0xBB80
2764 movs r7, #0x64
4E0D ldr r6, =0x40005000

//////////wait in this loop 48 seconds
//Do
F8D63440 ldr.w r3, [r6, #0x0440]
2B01 cmp r3, #1 ///if ( MEMORY[0x40005440] != 1 )
D109 bne 0x000314F4 ///break;
2000 movs r0, #0
A901 add r1, sp, #4
9701 str r7, [sp, #4]
//nrf_modem_os_timedwait(uint32_t context, int32_t *timeout)
F00FFE87 bl 0x000411F8 <nrf_modem_os_timedwait>
9B01 ldr r3, [sp, #4]
3B64 subs r3, #0x64
441D add r5, r3
2D00 cmp r5, #0
DCF1 bgt 0x000314D8
///while ( v7 > 0 ) //normal leave is v7 <= 0
//////////wait in this loop 48 seconds

4620 mov r0, r4
B003 add sp, sp, #12
BDF0 pop {r4-r7, pc}
A901 add r1, sp, #4
9601 str r6, [sp, #4]
F00FFE7B bl 0x000411F8 <nrf_modem_os_timedwait>
9B01 ldr r3, [sp, #4]
3B64 subs r3, #0x64
441D add r5, r3
E7DB b 0x000314C2
BF00 nop
40005000 .word 0x40005000

nrf_modem_platform_shutdown(int a1, int a2, int a3)
{
signed int v3; // r4
signed int v4; // r5
int v5; // r0
int v6; // r0
signed int v7; // r5
int v9; //
int v10; //

v9 = a2;
v10 = a3;
if ( gnss_interface_deinit(a1, a2, a3) )
v3 = 22;
else
v3 = 0;
if ( ip_interface_deinit() )
v3 = 22;
if ( mfu_interface_deinit() )
v3 = 22;
if ( pdn_interface_deinit() )
v3 = 22;
if ( tls_interface_deinit() )
v3 = 22;
if ( at_interface_deinit() )
v3 = 22;
v4 = 30000;
v5 = interface_shutdown();
v6 = rpc_transport_request_shutdown(v5);
while ( !rpc_transport_shutdown_done(v6) && v4 > 0 )
{
v9 = 100;
v6 = ((int (*)(void))nrf_modem_os_timedwait)();
v4 += v9 - 100;
}
rpc_transport_shutdown();
v7 = 48000;

//////////wait in this loop 48 seconds
do
{
if ( MEMORY[0x40005440] != 1 )
break;
v9 = 100;
nrf_modem_os_timedwait(0, &v9);
v7 += v9 - 100;
} while ( v7 > 0 );
//////////wait in this loop 48 seconds

return v3;
}

~/ncs/modules/hal/nordic/nrfx/mdk/nrf9160.h
#define NRF_POWER_NS_BASE 0x40005000UL
uint32_t POWERSTATUS; /*!< (@ 0x00000440) Modem domain power status

/////////////////////////////////////////////////////////////////////////////
when watchpoing at 0x40005440 no one write it, only read it
MEMORY[0x40005440] is alway 1 so the loop wait long long time

/////////////////////////////////////////////////////////////////////////////
when do this is failed in memory
*((volatile uint32_t *)((uint8_t *)NRF_POWER + (uint32_t)0x440)) = 0x0UL


but this successful  in memory
*((volatile uint32_t *)((uint8_t *)NRF_POWER + (uint32_t)0x614)) = 0x1UL;
k_usleep(500);
*((volatile uint32_t *)((uint8_t *)NRF_POWER + (uint32_t)0x614)) = 0x0UL;
*((volatile uint32_t *)((uint8_t *)NRF_POWER + (uint32_t)0x610)) = 0x1UL;

Parents Reply Children
No Data
Related