This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

nRF52832 loop while calling sd_softdevice_enable

FIXED (see below)
Hi!
I'm developing software for nRF52 on nRF52 preview DK, which I got on the Global Tech Tour. LED blinking (blinky) example is running OK, so I moved on to beacon example. The problem is when I'm calling sd_softdevice_enable function. Then it hangs on 0x7C0 address forever.
I'm compiling using IAR 7.4.
Here's my ICF file (WRONG):

 /*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x0001F000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x0001F000;
define symbol __ICFEDIT_region_ROM_end__   = 0x0007FFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__   = 0x2000FFFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 0x2000;
define symbol __ICFEDIT_size_heap__   = 0x2000;

define memory mem with size = 4G;
define region ROM_region   = mem:[from __ICFEDIT_region_ROM_start__   to __ICFEDIT_region_ROM_end__];
define region RAM_region   = mem:[from __ICFEDIT_region_RAM_start__   to __ICFEDIT_region_RAM_end__];

define block CSTACK    with alignment = 8, size = __ICFEDIT_size_cstack__   { };
define block HEAP      with alignment = 8, size = __ICFEDIT_size_heap__     { };

initialize by copy { readwrite };
do not initialize  { section .noinit };

place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region   { readonly };
place in RAM_region   { readwrite,
                        block CSTACK, block HEAP };

Program starts correctly. it goes through SystemInit, then through __iar_program_start as it supposed to. Next is my main function:

int main(void)
{
    uint32_t err_code;
    // Initialize.
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false);
    err_code = bsp_init(BSP_INIT_LED, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), NULL);
    APP_ERROR_CHECK(err_code);
    ble_stack_init();
    advertising_init();

    // Start execution.
    advertising_start();

    // Enter main loop.
    for (;; )
    {
        power_manage();
    }
}

In the ble_stack_init the sd_softdevice_enable is called. Here's disassembly of call:

0x219AC: 0x4914    LDR.N    R1, [PC, #0x50]
0x219AE: 0x0020    MOVS     R0, R4
0x219B0: 0xDF10    SVC      #0x10

After that program jumps to address 0x7BC, goes to 0x7C0 and stays there:

0x7BC: 0x4B01    LDR.N    R3, [PC, #0x4]
0x7BE: 0x681B    LDR      R3, [R3]
0x7C0: 0x68DB    LDR      R3, [R4, #0xC]

I have SoftDevice 1.0.0-3.alpha flashed. I'm using SDK 0.9.2. Target is set to nRF52832_xxAA, VFPv4 is set.
Anyone have any ideas what am I doing wrong?

EDIT:
FIXED!
The ICF file was wrong. You have to move RAM_start by 0x2800. So the final and working ICF looks like this:

/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x0001F000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x0001F000;
define symbol __ICFEDIT_region_ROM_end__   = 0x0007FFFF;
define symbol __ICFEDIT_region_RAM_start__ = 0x20002800;
define symbol __ICFEDIT_region_RAM_end__   = 0x2000FFFF;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 0x2000;
define symbol __ICFEDIT_size_heap__   = 0x2000;

define memory mem with size = 4G;
define region ROM_region   = mem:[from __ICFEDIT_region_ROM_start__   to __ICFEDIT_region_ROM_end__];
define region RAM_region   = mem:[from __ICFEDIT_region_RAM_start__   to __ICFEDIT_region_RAM_end__];

define block CSTACK    with alignment = 8, size = __ICFEDIT_size_cstack__   { };
define block HEAP      with alignment = 8, size = __ICFEDIT_size_heap__     { };

initialize by copy { readwrite };
do not initialize  { section .noinit };

place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region   { readonly };
place in RAM_region   { readwrite,
                        block CSTACK, block HEAP };

Hope it will help someone :)

Related