E2 Debugger not writing ROM _mdata section

Please note:

I originally thought linker script was the cause of this issue, further debugging indicates it is actually a case of the debugger not writing the _mdata region of Flash under some circumstances.

I am trying to locate some variables in the Data Flash region of my Rx processor.

I have added the following section to linker script for GNU compiler.



RAM : ORIGIN = 0x4, LENGTH = 524284

RAMSB : ORIGIN = 0x000A4000, LENGTH = 8192

DFLASH : ORIGIN = 0x00100000, LENGTH = 32768

RAM2 : ORIGIN = 0x00800000, LENGTH = 524288

OFS : ORIGIN = 0xFE7F5D00, LENGTH = 128

ROM : ORIGIN = 0xFFE00000, LENGTH = 2097512


.dflash (NOLOAD) :


__DFlash_Start = .;




















__DFlash_End = .;


Then the variables are allocation to each section as follows:

const Type_t dfType __attribute__((section(".dflash.01"))) __attribute__ ((aligned (64))); // 64 bytes allocated

This all works fine and the map file shows my variables as being located at the correct address.

The problem is that when I try to debug with the E2 debugger, the ROM location _mdata is not updated if the linker contains this dflash section.

This means that ram initialises with garbage and the application wont run.

If I comment out this section from the linker file, the mdata is correctly written to the mcu and my code will run.

Uncomment the section and compile, code will once again load and run as the _mdata section is now correct in the mcu.

Change the code so it is bigger or smaller, compile and debug and the _mdata in the mcu (as viewd through debugger) remains at the last running compile location, not wherever it now is located.

I have investigated the elf file and the correct data for the _mdata section is located at the correct address according to the map file.

However, when I try and debug, the code is loaded correctly and initialisation tries to read the data from the correct _mdata address but the data at this address is not correct as the debugger doesn't seem to have changed it from the last run.

If I add an expression which points to the last compiles _mdata location, I can see the correct data, so I know the old location values are being used. However, the elf file definitely contains the correct data at the correct new _mdata location.

I tried deleting the elf file to ensure no caching, setting the elf file location to absolute path. No matter what I do, the symptoms are that the code won't initialise the RAM correctly because the _mdata area in ROM is not matching the compiled _mdata location.