Discussion Forum

USERCLASS issue

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Read-Only
Author
Leon de Wit
Posted
8-Apr-2009 20:34 GMT
Toolset
C51
New! USERCLASS issue

Hi all

I'm hoping someone can help me locate my code the way I need to. I want to put a portion of my code in a specific address range, and exclude all other code from this region. Following http://www.keil.com/support/docs/2670.htm I included this in the .c source file:

#pragma userclass(code=ldr)

and when linking I specify

CLASSES(CODE_LDR(C:80h-C:1DFFh),CODE(C:1E00h-C:7FFFh))

I thought this would do the trick, but now I get

*** WARNING L47: NO SEGMENTS ASSIGNED TO USER CLASS CLASS: CODE_LDR

when linking. Looking at the map file confirms that no code was assigned to the address space C:80h-C:1DFFh.

I am using CX51 and LX51.

What am I overlooking? Any help would be sincerely appreciated.

Read-Only
Author
Per Westermark
Posted
8-Apr-2009 20:45 GMT
Toolset
C51
New! RE: USERCLASS issue

Unless you are writing your code in assembler, I think you should consider using two targets. One to generate the loader and one for the application.

If you write in C and just relocate different parts of the code, you get the problem that you either have to place all RTL functions with the loader, or your loader may require init functions or self call (possibly even indirect helper functions called by the compiler) code that isn't in the loader region.

Read-Only
Author
Leon de Wit
Posted
8-Apr-2009 21:16 GMT
Toolset
C51
New! RE: USERCLASS issue

Hi Per

Thanks for the reply.

I have specific reasons for wishing to locate the code I explained above, most of which have to do with this being a legacy project I'm trying to add GSM bootloading to without rewriting too much of the (tried&tested) firmware.

The loader code I'm trying to specifically locate does little more than copy verified new firmware to flash, and thus it is completely self contained.

It makes sense to have this in the main target, as it will run each time the unit is reset. (It checks a CRC on the RAM and FLASH, and makes a decision to reload or to continue with the current FLASH) I also need to be able to call this at will from the standard firmware.

My only concern is not overwriting the piece of code actually doing the copying while copying, which is why I need the absolute address location.

Do you know why the USERCLASS I employed is not locating the code as I expected?

Thanks again

Read-Only
Author
Ole Saether
Posted
23-Apr-2009 07:36 GMT
Toolset
C51
New! RE: USERCLASS issue

Hi Leon,

This is the syntax I am using:

#pragma userclass(code = LDR)

and then in the "User classes" box in the LX51 tab:

CODE_LDR(C:0x0080)

Regards,
Ole

Next Thread | Thread List | Previous Thread Start a Thread | Settings