HCS08 linker INIT function disregards assembly relocatable sections

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

HCS08 linker INIT function disregards assembly relocatable sections

704件の閲覧回数
scottm
Senior Contributor II


I just ran into a weird problem that caused me some serious bootloader headaches.  I recently ported an HCS08 project from CW6.2 to CW10.6 and did quite a bit of cleanup, partly to make use of PE functions.

 

The problem I discovered is that if I use the INIT command in the linker configuration file to designate my bootloader_main assembly function as the program entry point, the linker apparently disregards the SECTION specifier in the .asm file.  The start of the bootloader looks like this:

BOOTSTRAP_ROM:SECTION
XDEFbootloader_main

bootloader_main:

; code here

 

The LCF places BOOTSTRAP_ROM into section BROM at 0xFE00.  The reset vector points to bootloader_main and all is well - unless I set INIT bootloader_main.

 

The only reason I did this was for the sake of having the debugger start there while I was doing some troubleshooting.  As far as I can tell from the documentation, it shouldn't have any effect on placement.

 

Without the INIT command, everything is fine, bootloader_main gets placed at 0xFE00 and calls PE's _EntryPoint when it's done.  With INIT set, it gets placed at the start of DEFAULT_ROM, along with its constants that were also declared in BOOTSTRAP_ROM.

 

If I use ORG $FE00 to place bootloader_main in an absolute section, the linker honors it.  It's only the relocatable section that's ignored.

 

I got it working again by removing the INIT command, but I'd like to know why this happens.  Does INIT have some other significance that's not covered in the manual?  Why would it ignore the defined sections?  Particularly for the constants, which have their own BOOTSTRAP_ROM: SECTION placement and aren't directly named by INIT.

 

Thanks,

 

Scott

ラベル(1)
0 件の賞賛
返信
3 返答(返信)

536件の閲覧回数
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi,

INIT command in the prm file specifies the function as application entry point.

in prm, the code

INIT bootloader_main

means "bootloader_main" is  application entry point.

CW for HCS08 has some predefined segments.

Predefined segment can be grouped into segments according to the runtime routines:

segment "_PRESTART" is for application entry point is stored in the segment _PRESTART. This segment must also be associated with a READ_ONLY section.  that's to say, bootloader_main must be defined in "_PRESTART".

Let's take an example:

2016-07-25_14-07-30.jpg

in above prm file, _PRESTART is defined in ROM1(0xC000 to 0xFF9B), thus with code

INIT bootloader_main

bootloader_main is defined in ROM1 section.

if you want to relocate bootloader_main to other section, we just need change _PRESTART placement in prm file.

does this answer your question?


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛
返信

536件の閲覧回数
scottm
Senior Contributor II

That seems to have fixed it, thanks.  Is there any reason other than having the debugger start there that you'd want to use INIT to set the entry point?  It doesn't affect the reset vector.  I can't see that it has any other effect.

The bootloader in question was forked from the example in app note AN2295 more than 10 years ago.  I went back and looked at AN2295 (circa 2008) and it has INIT pointing to main().

BTW, if you check DOC-93391, the link given for the latest version of AN2295SW says it covers HCS08, Coldfire, and Kinetis.  The ZIP file only appears to contain the Kinetis version, though.

Scott

0 件の賞賛
返信

536件の閲覧回数
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Scott,

INIT defines the initialization entry point for the application. the specific function defined by INIT is specified as application entry point. and the debugger will also start from this function.

in 8bit MCU, the reset vector address is 0XFFFE, this address will store the application initialization entry point address. in an2295sw for hcs08,  address 0xFFFE stores start-address of main function.

to get an2295 full version, please download it from NXP web site by searching AN2295SW on NXP web site.

http://cache.nxp.com/files/microcontrollers/doc/app_note/AN2295SW.zip

pastedImage_1.png

does this answer your questions?


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛
返信