We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi!
I switched to the SiLabs variety of 8051s, and now I can actually flash parts of the memory from inside my application to store some configuration data.
But: I'd like to safeguard my function against overwriting /erasing actual program code. So I need to find a way to determine the end of the code at runtime in order to prevent any accesses to flash below the boundary.
The BL51 pretty much mixxes all the code around in memory - if there was a way to tell him "Put THISVERYOBJECT at the end" I had a way to determine the End-of-Code-address.
Alternatively, is there a way to tell the linker to turn the statistics into runtime-accessable symbols? In "Ye Olden Days" (and on a different platform) I had a linker thet generated symbols like __CODESIZE__ and __DATASIZE__ that could easily be accessed from C.
Are there other paths to determine the code size? I thought about a script gobbling the linker map file and turning the "Program Size:"-line into C source, but this would imply the need for multiple compilation runs (and including a project related tool in the source repository, etc.), which I'd like to avoid.
Help!
Yours, Christian Treczoks
Can you use this? http://www.keil.com/support/man/docs/lx51/lx51_ls_srom.htm
Or simply use fixed data areas for code/data and flash'able configuration data.
-- Joost
Thanks for the info, but this is not what I'm trying to achieve. I want to use all the space "behind" the code for non-voliatile data storage. One day I might think about in-system reprogramming, but at the moment, the available bus speed basically forbids this ;-)
I haven't used SROM myself but I was thinking you might be able to use it to retrieve the end address of a certain section. Hmm, you don't even need this really.
Is it possible to create your linker file such that all sections are linked in a certain order and create a "sentinel" section? Sections (C166) are called segements on C51 I noticed.
The SEGMENTS directive even has a "LAST" parameter.
http://www.keil.com/support/man/docs/lx51/lx51_segments.htm
If you can make sure the classes are ordered in a certain way and you use the LAST parameter on the SEGMENTS directive to put a sentinel segment at the last positition of the last class you can drop a single variable in the segment. &variable should be the end address.
My EUR 0.02...
See also: http://www.keil.com/forum/docs/thread5659.asp http://www.keil.com/forum/docs/thread2200.asp
Thanks for the hint, but somehow, this does not work as intended.
LX51 LINKER/LOCATER V4.09, INVOKED BY: LX51.EXE STARTUP.obj, DELII_Main.obj, [...more Objects...] Flash.obj, Last.obj TO DELII DISABLEWARNING (15, 16) CLASSES (XDATA (X:0X0-X:0XFFF), HDATA (X:0X0-X:0XFFF), ECODE (C:0X0-C:0XFFFF), HCONST (C:0X0-C:0XFFFF)) SEGMENTS (?CO?LAST (LAST))
The way I read the documentation, the "SEGMENTS (?CO?LAST (LAST))" should place the constant from LAST.OBJ at the end of the produced code. Unfortunately, it does not. My constant is placed at C:0x81 (the real end is at about C:0x1600).
Yours, Christian
Did you read the two other threads I posted?
The first one seems to contain (and solve) this very issue: http://www.keil.com/forum/docs/thread5659.asp
-- J
OK, the discussion at http://www.keil.com/forum/docs/thread2200.asp did it.
I switched back to BL51, use "CODE (0X0000-0XFFFF, ?CO*, ?C_*, ?C?*, ?PR*, ?CO?LAST)", and, voila, the constant named __END_OF_CODE__ in Last.c is at the end of the code.
A negative side effect is the decreased quality of code placement, indicated by a bunch of GAPs at the beginning of the code (between the int vectors).
Maybe a working (LAST) in the LX51 might be the better solution for the long term.
Yours, thankfully, Christian Treczoks
I don't know the difference between BL51 or LX51 (using C166 myself).
Can't you use
SEGMENTS(?CO*, ?C_*, ?C?*, ?PR*, ?CO?LAST)
As mentioned in http://www.keil.com/forum/docs/thread5659.asp and still use LX51 that way? Does the "quality of code placement" come from BL51 instead of LX51, or only from the use of the segment ordering?
See also 2: http://www.keil.com/support/docs/2681.htm