Jump to content
Sign in to follow this  
DTPIC

System.h In Libs?

Recommended Posts

Hi,

I am interested in creating a boostc library for a serial loader (<not> a classic "bootloader", but more of an "on demand" loader, for a specific customer application).

 

To get the serial loader routine to locate at a specific fixed address in memory, I have defined a project which links with the -rb xxxx option; as there is no main() function in the project, I guess this has to be compiled as a library... The routine contains asm instructions, for which it seems the compiler must have system.h included, to be able to interpret the asm.

 

This compiles ok as a library. But when I try to link this into my main project, the linker says

 

failure

Error: Duplicate global var: cmcon

Error: Duplicate global var: eedata

 

...etc.

 

I think the project is seeing 2 copies of system.h (one from the library, one from the main part), both of which call in the _PIC16Fxxx.h header, and this is causing the duplication. But I must have system.h in my library project, or else it doesnt understand the asm instructions...

 

I have tried including boostc.h into the lib instead of system.h, but this seems to be too generalised, ie, also does not allow the library asm commands to be understood...

 

There must be a way of compiling a library a) containing asm commands and :rolleyes: without a duplicate system.h - but I havent found it yet!

 

Any ideas?

Share this post


Link to post
Share on other sites

Think I may have found the answer...

 

The problem is indeed duplication of the "volatile char..." definitions for the CPU registers.

 

1) I copied the PIC16Fxxx.h file from Sourceboost\include to a file in my project directory, (renaming it for safety) and converted all the "volatile char..." definitions to "extern volatile char...".

2) In the library project, I included the above .h file and the compilers own boostc.h file.

 

This now works fine - the loader routine is called from its fixed location at the top of memory, does its stuff (including calls to main program routines) and finally jumps to 0x000 to start the new code...

 

Interestingly, the RAM is unchanged during this load, so you can leave a main program variable set from the loader module (define it as extern...) to indicate that the restart has occurred as a result of a download, etc...

 

 

I'd still be interested if anyone can find a cleaner way of doing it...

 

 

There doesnt seem to be much documentation that I could find on the subject of precompiing libraries, even though the feature is there in BoostC - perhaps someone could write a little something to shed some light on this area?

Share this post


Link to post
Share on other sites
...

This compiles ok as a library. But when I try to link this into my main project, the linker says

 

failure

Error: Duplicate global var: cmcon

Error: Duplicate global var: eedata

 

...etc.

 

I think the project is seeing 2 copies of system.h (one from the library, one from the main part), both of which call in the _PIC16Fxxx.h header, and this is causing the duplication. But I must have system.h in my library project, or else it doesnt understand the asm instructions...

...

Any ideas?

Your are right there must be two copies floating around. Duplicate variable definitions at fixed addresses is allowed under the BoostC compiler as long as the variables have the same fixed addresses.

 

Normally when writing a library it is none target specific and hence won't have any fixed addresses in it. You are right to delare the cpu register variables used as extern, then the project they are linked in to will determine their addresses.

 

Regards

Dave

Share this post


Link to post
Share on other sites

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoticons maximum are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×