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 !

Parents
  • I think the easiest way might be to just use the pca10040 (without the 'e') configuration with the same source code. That said, I think you were pretty close to achieve this with your pca10040e project. In addition to increasing the FLASH_PH_SIZE you need to change the total flash size in your "linker_section_placements_segments" macro.

    The original setting from ble_app_ancs_c_pca10040e_112.emProject file

          linker_section_placements_segments="FLASH RX 0x0 0x30000;RAM RWX 0x20000000 0x6000"

    must be changed to:

          linker_section_placements_segments="FLASH RX 0x0 0x38000;RAM RWX 0x20000000 0x6000"

  • Vidar, I am still getting the "Error reported. Failed to download application. Generic error." when launching the debugger in SES.

  • It worked here, but I had to increase the address to 0x3A000 to be able to build without optimization. 

    linker_section_placement_macros="FLASH_PH_START=0x0;

    FLASH_PH_SIZE=0x3A000;

    RAM_PH_START=0x20000000;

    RAM_PH_SIZE=0x6000;

    FLASH_START=0x19000;

    FLASH_SIZE=0x26000;

    RAM_START=0x20001c18;

    RAM_SIZE=0x43e8"


    linker_section_placements_segments="FLASH RX 0x0 0x3A000;RAM RWX 0x20000000 0x6000"

    But the linker settings should not lead to  debugger errors. Can you try to do a chip erase with nrfjprog first and see if you get the same result? 

    > nrfjprog --erase 

  • Vidar, so first of all: Thank you for the original input to also adjust linker_section_placements_segments. Presumably that is a fix. And it sounds like you were able to flash it.

    As to my specific case, it appears that it turns into a JLink / Segger issue ?!

    I repeated my setup with a JLink-Lite and a different target board, and same result: I cannot flash the "emulated with extra flash" version to either target board due to the generic error.

    I upgraded JLink to the latest 6.52e version and also upgraded SES to 4.22 .

    Above, I assume I was to issue a "nrfjprog --eraseall". It did not help. I was able to program the softdevice and the hex file using "nrgprog --program <>.hex", if that tells you something.

    * if you don't mind, could I send you my .emProject file and you give it a quick try, just to make sure there is no hidden incorrect setting.

    * Otherwise, I presume, this is more a Segger issue ?

  • Attached is my modified example. I tested it with SDK 15.3.0. 

    4087.ses.zip

Reply Children
  • 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