This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Linking Functions at Specific addresses

I need to Link Functions at Specific address

I have 5 functions that i want to go into 0xFA00 ONWARDS

I am using uvision2 and 0xFAOO onwards is a part of flash that will not be erased

I can fix one function using...

?PR?_LOADER?LOADER(0FA00h) command in the (BL51 Locate) TAB

Do I have to specifically locate ever function this way or can i just specify the first function in a file.

All functions are in the same file..

  • I don't work with the '51 chips, but to link a group of functions to a specific memory area, you normally place the functions in a separate source file, and then configure the linker to place that code segment in the required memory area.

    A different issue here is how you are going to find the entry point to these functions. For more general-purpose processors, you would normally use function pointers, i.e. start the code region with a pointer table to the individual functions. However, function pointers and the '51 architecture is not a good combination...

    An alternative is to always link your application with this absolutely located segment, but make sure that you don't erase/download this memory region.

  • Thanks...surely the linker will know the functions start addresses and anything calling these functions will be resolved at link time

  • "surely the linker will know the functions start addresses and anything calling these functions will be resolved at link time"

    Absolutely - so why the need to locate them to an absolute location?!

    The usual reason is that the functions will not be linked-in, so a hard-coded address has to be used...

  • Since these functions should be in a segment that is not erased, I was of the impression that they where part of a boot loader, or a resident library.

    The next step will then be if it should be possible to update these resident functions without having to update all applications that makes use of them. This requires that the function entry points can be retrieved.

    For the linker to be able to locate the application so that it knows the addresses of these functions, each individual function must start at a know address, or you must link the application with the resident functions.

    If you just link your application without access to the resident functions, the linker will complain about missing external symbols - unless you have mapped them - one by one - to fixed addresses yourself.

  • Yes you are right my bootloader function is located at 0xFA00, it uses spi to read external serial flash and load processor flash filling all below 0xFA00

    Very first load is done JTAG after that the bootloader reads the full hex file BUT only loads UPTO 0xFA00, thus ignoring bootloader and all above.

    So if I change application code the bootloader will get re-Linked so the app code will know where to find the bootloader, I have told linker where to start bootloader at 0xFA00 but the functions that the bootloader calls i want to sit above the bootloader....if i leave it to the linker it puts these other functions anywhere.

    Do i have to fix the location of these other functions or is there a way of getting the linker to automatically put them after the loader???

    The Loader at 0xFA00 is the only location used by the app code

  • if I change application code the bootloader will get re-Linked so the app code will know where to find the bootloader

    If both the bootloader and the app is in C there is the risk that when they are linked together the "support functions" e.g. switch support will be linked in the app area and on the next release the bootloader will blow.

    You need to do one of two: code the bootloader in assembler OR link the two iondependently.

    Erik

  • thats exactly wot is to does, unable to use your options. if i link separately how do i load the bootloader and app code first time with JTAG.

    the way i get round this is to specify start address of all loader functions...

    0xFA00 Loader
    0xFCA0 function A
    0xFCB0 function B
    0xFCC0 function C...etc

    This is very messy

    I have seen the following on Keil site would this work??

    In the µVision IDE, go to Project -> 'Options for Target' -> 'BL51 Misc', and in the 'Misc controls' section, enter:

    CODE (?pr?*?myfile (0x100))

    where all functions are in myfile.obj