How to specify a startup file with CodeWarrior

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

How to specify a startup file with CodeWarrior

Jump to solution
2,284 Views
powerNZ
Contributor III

Hello all,

Slowly working through the issues of migrating a HiCross project to CodeWarrior and the Metrowerks compiler.

 

The original HiCross application has it's own startup file which is based on the HiCross library version but has some additions.

 

I have two questions:

1) The CodeWarrior makes use of E68K_startup.c as supplied in the Metrowerks library. How does CodeWarrior know to use this specific file?

 

2) How free am I to modify this file?

 

In particular I would like to manipulate the MCU speed prior to the memory initalisation.

 

Comments and suggestions welcome.

Graham

Labels (1)
0 Kudos
1 Solution
649 Views
powerNZ
Contributor III

Hi there,

Thanks for clearing that point up - as to be expected HiCross and Metrowerks do somethings quite differently. 

 

I have begun an examination of the E68K_startup.c file and will need to upskill in how the .bss, etc, are defined. HiCross have a struct that contains all the details regarding initialisation while Metrowerks pass them through constants (such as _SP_INIT).

 

Thanks,

Graham

View solution in original post

0 Kudos
4 Replies
649 Views
CrasyCat
Specialist III

Hello

 

In CodeWarrior "Embedded  68K Linker" panel, you specify the application entry point.

This entry point is function __start per default, which uses function _start from module E68K_startup as entry point.

 

If you want to use your own startup function, you can specify your own function name here.

If the function is implemented in an ANSI C source file, make sure to use a _prefix as the compiler internally adds a leading _ to symbol names.

 

As compiler requires some CPU registers to be initialized a certain way I would recommend you to take the code delivered with CodeWarrior and extend it to your needs.

 

CrasyCat

0 Kudos
649 Views
powerNZ
Contributor III

Hello CrassyCat,

Thanks for the response.

 

Your comments seem to imply that the function name __start and E68K_startup.c are linked internally tied by the compiler/CodeWarrior environment. Correct?

 

Therefore, as long as my entry point function uses a name different from the default it can reside in our custom file.

 

I will take a deeper look into the CodeWarrior startup code and the implications it brings to our application.

 

Hope the trip progresses well,

Graham

0 Kudos
649 Views
CrasyCat
Specialist III

Hello

 

In fact I forget one important step in my answer.

When you create a project for CodeWarrior, there are some run time libraries linked to the application

*.Runtime.a.

 

This runtime library includes the object code for E68K_startup.c. So indicating function _start as application entry point will automatically take the function from run time library as entry point.

 

You are right specifying another function name there will make the linker use a custom startup code.

 

If you write your own code keep in mind that some registers needs to be initialized in the startup code for code to work properly.

Here I think about A5 that is used to access variable allocated in .sdata or .sbss.

 

CrasyCat

0 Kudos
650 Views
powerNZ
Contributor III

Hi there,

Thanks for clearing that point up - as to be expected HiCross and Metrowerks do somethings quite differently. 

 

I have begun an examination of the E68K_startup.c file and will need to upskill in how the .bss, etc, are defined. HiCross have a struct that contains all the details regarding initialisation while Metrowerks pass them through constants (such as _SP_INIT).

 

Thanks,

Graham

0 Kudos