Re-Allocate _Startup in PRM file?

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

Re-Allocate _Startup in PRM file?

Jump to solution
1,073 Views
sebasira
Senior Contributor I

Hi!

 

I'm using CW 4.6.

 

I've got and application merged with bootloader using the HEXFILE instruction. Also have PRM pre-process enable, so I define a label __INCLUDE_BOOTLOADER__ to include it.

 

When including the bootloader _Startup cannot be @0xFFFE because the bootloader reset vector is there; and it must be place @0xEFFE... So I try doing this:

#ifndef __INCLUDE_BOOTLOADER__  VECTOR ADDRESS 0xFFFE  _Startup#else  VECTOR ADDRESS 0xEFFE  _Startup#endif

 
And it works.... but I've got some questions:

 

1) First of all... Is that correct? Because I thoguht that it will trow me and error because 0xEFFE is no a "VECTOR ADDRESS"

 

2) And that leads me to wonder... What does VECTOR ADDRESS mean or do?

 

3) And finally... Can I re-locate any function to be wherever I want in .prm file? I mean, can I put my_func at address 0xC582 be doing:VECTOR ADDRESS 0xC582 my_func

 

Thanks for reading, I hope you can "feed" my curiousity!

Labels (1)
Tags (1)
0 Kudos
1 Solution
489 Views
bigmac
Specialist III

Hello Sebastian,

 

The following is an excerpt from the Build Tools Utilities manual, and shows the VECTOR command alternatives available.

 

VECTOR Command

 

This command is specially defined to initialize the vector table.

Use the syntax VECTOR <Number>.  In this case, the linker allocates the vector depending on the target CPU.  The vector number zero is usually the reset vector, but depends on the target.  The Linker knows the default start location of the vector table for each target supported.

 

You can use the syntax VECTOR ADDRESS as well. The size of the entries in the vector table depend on the target processor.

 

Table 3.4  VECTOR Command Syntax and Descriptions

VECTOR ADDRESS 0xFFFE 0x1000

Indicates that the value 0x1000 must be stored at address 0xFFFE

VECTOR ADDRESS 0xFFFE FName

Indicates that the address of the function FName must be stored at address 0xFFFE.

VECTOR ADDRESS 0xFFFE FName OFFSET 2

Indicates that the address of the function FName,incremented by 2, must be stored at address 0xFFFE

The last syntax may be very useful when working with a common interrupt service routine.

.

An alternative method for handling this situation would be to compile and link the code in the normal manner, as if the bootloader were not present.  This will generate a S19 file for the code.  Of course, the code will need to avoid using the area occupied by the bootloader, but the vectors will be at their normal location.

 

Then, for the cases where this file is handled by a bootloader, the bootloader itself can determine when it encounters a vector address, and automatically relocate the vector data to an alternative address location, known to itself.  This would apply whether automatic vector redirection is applicable (for other than the reset vector), or vector redirection is via code within the bootloader.

 

Regards,

Mac

 

View solution in original post

0 Kudos
6 Replies
489 Views
CrasyCat
Specialist III

Hello

 

    The command VECTOR ADDRESS can be used to write a 2 byte value at a specified address.

    It is mainly used to initialize vector table entries. This is the reason the command has been called VECTOR ADDRESS.

 

    You can use it to relocate the vector table to another location.

 

    Do not attempt to use the VECTOR command.

   This command uses a vector number to determine which memory cell to initialize. It works only for the real vector table

   as it expect vector 0 to be at 0xFFFE.

 

  This command cannot be used to allocated a function at a specific address as it initialize on;y 2 bytes (the size of en entry in the vector table).

 

   In order to allocate a function at a specific address, place it in a user defined section and allocate the section at the desired address.

 

CrasyCat

489 Views
sebasira
Senior Contributor I

Hi again crasycat!

 

I've got a doubt about what you said. You said:

>You can use it to relocate the vector table to another location.

 

I don't understand how to do that....Did you mean that I can change the vector location? I mean, let's take reset vector. It address is 0xFFFE, can I change that address so the reset vector is at, for example, 0xFF00?

 

How could I do that?

 

Thanks in advance, and forgive my misunderstanding

 

0 Kudos
489 Views
CrasyCat
Specialist III

Hello

 

What I meant here is that you can use the comamnd VECTOR ADDRESS to initialize a mirror of the vector table.

 

Which is what you are looking for when you are using your bootloader.

 

CrasyCat

0 Kudos
489 Views
sebasira
Senior Contributor I

Oh, ok.... Now I understand! Thanks for your quick reply

0 Kudos
489 Views
sebasira
Senior Contributor I

Thank you both for clarifying that! I'll keep it in mind.

0 Kudos
490 Views
bigmac
Specialist III

Hello Sebastian,

 

The following is an excerpt from the Build Tools Utilities manual, and shows the VECTOR command alternatives available.

 

VECTOR Command

 

This command is specially defined to initialize the vector table.

Use the syntax VECTOR <Number>.  In this case, the linker allocates the vector depending on the target CPU.  The vector number zero is usually the reset vector, but depends on the target.  The Linker knows the default start location of the vector table for each target supported.

 

You can use the syntax VECTOR ADDRESS as well. The size of the entries in the vector table depend on the target processor.

 

Table 3.4  VECTOR Command Syntax and Descriptions

VECTOR ADDRESS 0xFFFE 0x1000

Indicates that the value 0x1000 must be stored at address 0xFFFE

VECTOR ADDRESS 0xFFFE FName

Indicates that the address of the function FName must be stored at address 0xFFFE.

VECTOR ADDRESS 0xFFFE FName OFFSET 2

Indicates that the address of the function FName,incremented by 2, must be stored at address 0xFFFE

The last syntax may be very useful when working with a common interrupt service routine.

.

An alternative method for handling this situation would be to compile and link the code in the normal manner, as if the bootloader were not present.  This will generate a S19 file for the code.  Of course, the code will need to avoid using the area occupied by the bootloader, but the vectors will be at their normal location.

 

Then, for the cases where this file is handled by a bootloader, the bootloader itself can determine when it encounters a vector address, and automatically relocate the vector data to an alternative address location, known to itself.  This would apply whether automatic vector redirection is applicable (for other than the reset vector), or vector redirection is via code within the bootloader.

 

Regards,

Mac

 

0 Kudos