Debugger won't deposit FLASH contents

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Debugger won't deposit FLASH contents

1,164 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by RolandWOW on Mon Apr 08 00:22:26 MST 2013
I try to maintain an absolute readonly section in FLASH with LPC1111/201.
Using 0X1000 as --section-start=READONLY=... it works after downloading via debugger, with 0X1F00, however, I find the previous contents in FLASH. The hex-files seem to be always correct.

I prepared a minimal program, which listed subsequently. Linker settings are -nostdlib and --section-start=READONLY=0X... .

<<<<<<<<<<<<<<<<<<<<<<<<<<<< almaty.c >>>>>>>>>>>>>>>>>>>>
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]extern
[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]
[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] almaty[4];[/SIZE]
[SIZE=2]

[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]
/* Main Program */
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]

[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]
int
[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]
[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2] [B]main[/B] ([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]
{


[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] almaty[0];[/SIZE]
[SIZE=2]
}


<<<<<<<<<<<<<<<<<<<<<< data.c >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]#include
[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]
[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]<stdint.h>[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]

[/SIZE][SIZE=2][COLOR=#005032][SIZE=2][COLOR=#005032]
uint32_t
[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]__attribute__[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ((section ([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"READONLY"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]))) almaty[4]={ 1, 2, 3, 4,};[/SIZE]
[SIZE=2][/SIZE][/SIZE]
0 Kudos
Reply
5 Replies

1,155 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Wed Apr 10 13:35:02 MST 2013

Quote: RolandWOW
Other than ld, the debugger discards sections althoug they are referenced, a bug which ought to be fixed.
Giving --no-gc-sections explicitly to ld, which shouldn't be necessary as according to the manual this is the default, fortunately the debugger stops dropping sections then.
This is much simpler than what I proposed earlier and first choice for those preferring managed ld-srcipts over the baroque beauty of the succulent syntax for ld-scripts.



Sorry, but it is not a bug. The linker only discards unused sections. If you have not added your file to the linker script, it will be unreferenced and so discarded. Please save yourself  some time and do it the correct way. Do as thefallguy said and search this forum.
0 Kudos
Reply

1,155 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by RolandWOW on Tue Apr 09 22:52:22 MST 2013
Other than ld, the debugger discards sections althoug they are referenced, a bug which ought to be fixed.
Giving --no-gc-sections explicitly to ld, which shouldn't be necessary as according to the manual this is the default, fortunately the debugger stops dropping sections then.
This is much simpler than what I proposed earlier and first choice for those preferring managed ld-srcipts over the baroque beauty of the succulent syntax for ld-scripts.
0 Kudos
Reply

1,155 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Tue Apr 09 00:32:39 MST 2013
You may have told it where to place the section, but you didn't tell the linker what to put in the section - for that you need to change the linker script

As I said, search this forum for how to place data at absolute flash locations. Then you won't need workarounds...
0 Kudos
Reply

1,155 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by RolandWOW on Mon Apr 08 23:46:16 MST 2013
Thank you for your comment.
As can be seen from my post, I did inform ld about section READONLY and where to place it.
Further I did not claim that ld is the problem, as hex-file and symbol table are in order, rather it is the debugger which fails to load section READONLY into FLASH at 0x1F00 and that the debugger is amply confused about symbol almaty.
For reasons beyond my comprehension, the debugger behaves properly once I
designate 0X1000 as start of section READONLY. Unfortunately the program
will be larger than 0X1000 so I need the upper half of LPC1111/201's FLASH also.

Workaround:

In the meantime I resort to IAP-API to erase the FLASH and deposit data from within the program at 0X1F00 and beyond. For use of data after a power cyle or other restart I prepare and use a copy of data in RAM.
0 Kudos
Reply

1,155 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Mon Apr 08 01:04:57 MST 2013
Did you also modify the linker script? If you didn't then the linker will know nothing about how to link your sections, so I guess it will be discarded. Read about GNU linker scripts to understand about this.

However, there are plenty of posts in this forum about how to place data at an absolute location in flash.
0 Kudos
Reply