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

Extra flash when emulating 52810 (to allow debugging with Optimization=none)

I compiled and debugged the PCA10040e ANCS example (ie emulating the 52810 using the 52832) from SDK 15.3 - successfully. But I wanted to turn off code optimization to facilitate debugging. That seems to bring the solution over the flash size limit of the 52810.

How can I cheat and allow emulating the 52810 which (temporarily, for debugging) taking advantage of the 52832's larger flash ?

So after adding a debug configuration in the .emProject file via

<configuration Name="Debug"
c_preprocessor_definitions="DEBUG; DEBUG_NRF"
gcc_optimization_level="None"/>

I get ".text too large to fit in FLASH memory segment" during linking. So I tried to modify the 

linker_section_placement_macros="FLASH_PH_START=0x0;FLASH_PH_SIZE=0x38000;

and bumped the FLASH_PH_SIZE a little (from 0x30000). It will link now, but the J-Link reports a "Error reported. Failed to download application. Generic error." 

Any ideas ? How could I temporarily use more flash while emulating the 52810 ?

Thanks !

  • Your optimization level is set to "Level 3", which also works for me. What happens on your end if you set it to "None". It fails here.

  • Sorry for the back and forth on this, I really thought I tested it without optimization, but it's not working now. I guess the debugger reports the error because the image exceeds the address range defined for the 52810. However, it still didn't work after I changed the target device in the debug settings. I need to spend some more time on this to figure out what is going on. Can you use the "pca10040" project for debugging in the meantime?

  • Vidar, ok. I had found the following interesting, but wouldn't know how to incorporate the results into SES, and whether this makes debugging possible now:

    If I run the JLink executable in the install folder, and issue the following commands ...

    >erase

    >device nrf52810_xxAA

    >loadfile <outputfile>.hex

    Response: Unspecified error -1

    >erase

    >device nrf52832_xxAB

    >loadfile <outputfile>.hex

    Result:No errors.

  • This is what ended up working for me ...

    Create a file "SetupTarget.JLinkScript" in the project folder, with the following content:

    int SetupTarget(void) {
    JLINK_SetDevice("nrf52832_xxAB");
    return 0;
    }

    JLink will call this function just before writing the flash, making it realize that the actual target is a nRF52832.

    (I tried changing the target via Project Options -> Debug -> Debugger, but that wreaked havoc with my .emProject file requiring manual cleanup. Apart from causing compile time errors with respect to use of the FPU.)

    The .emProject file then looks like this towards the file end:

    <configuration Name="Release"
    linker_section_placement_macros="FLASH_PH_START=0x0;FLASH_PH_SIZE=0x30000;RAM_PH_START=0x20000000;RAM_PH_SIZE=0x6000;FLASH_START=0x19000;FLASH_SIZE=0x17000;RAM_START=0x20001c18;RAM_SIZE=0x43e8"
    linker_section_placements_segments="FLASH RX 0x0 0x30000;RAM RWX 0x20000000 0x6000"
    c_preprocessor_definitions="NDEBUG"
    gcc_optimization_level="Optimize For Size" />
    <configuration Name="Debug"
    JLinkScriptFileName="$(ProjectDir)/SetupTarget.JLinkScript"
    linker_section_placement_macros="FLASH_PH_START=0x0;FLASH_PH_SIZE=0x80000;RAM_PH_START=0x20000000;RAM_PH_SIZE=0x6000;FLASH_START=0x19000;FLASH_SIZE=0x67000;RAM_START=0x20001c18;RAM_SIZE=0x43e8"
    linker_section_placements_segments="FLASH RX 0x0 0x80000;RAM RWX 0x20000000 0x6000"
    c_preprocessor_definitions="DEBUG; DEBUG_NRF"
    gcc_optimization_level="None"/>

    This gives you 512k of flash while emulating the nRF52810 allowing to debug without code optimization.

Related