S12XEP100: Jump from Bootloader to Applikation

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

S12XEP100: Jump from Bootloader to Applikation

Jump to solution
1,022 Views
bastih84
Contributor I

Hi together,

 

I have a problem with my Bootloader for S12XEP100.

 

Everything works fine (flashing...), but I can's jump to Applikation.

 

Sometimes jump-function works, but only sometimes

 

My jump function looks like (runs well on S12G):

 

__asm{

              ldx #0xBFFE;

              ldx D, x;

              jmp 0, x

             };

 

Reset vector of applications is on 0x7F_BFFE.

 

I think i have a problem with local and global addressing... Can somebody help me?

 

Thanks

Labels (1)
0 Kudos
1 Solution
657 Views
RadekS
NXP Employee
NXP Employee

Hi Bastian,

You are right. Address 0x7F_BFFE is global address and your code works only with lower 16 bits = 0xBFFE.

So, loading address will work only in case when PPAGE register will be set to value 0xFE.

Despite of fact, that S12XE core contains instruction for work with global addresses, the core still works in default 16bit address space (program counter is 16bit).

So, you have three basic options:

1. Typically we place application starting point into unbanked memory. For example:

AppResetVect:  equ $effe ; here is stored reset vector of user application

ldx AppResetVect

jmp 0,x              ; jump to the application

2. We could leave application reset vector in paged memory, but we have to ensure that PPAGE register will be correctly set for reading right value. In case when bootloader code is executed from non-banked area, we could simply write 0xFE into PPAGE register prior we read from address #0xBFFE. If bootloader code is executed from paged memory, situation is slightly more complicated and you should use routine for safe reading from far address (see datapage.c file).

3. We could leave application reset vector in paged memory, but we will use global address and global instructions for reading vector value. In that case we should (optionally save GPAGE register), set GPAGE to 0x7F value, use GLDX instruction for reading vector value (optionally , restore GPAGE register value) and jump to application.

I am just curious, why you use instruction ldx D, x;?

Do you have more application reset vectors than one and you use offset in D accumulator for distinguish between applications?


I hope it helps you.

Have a great day,
RadekS

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

View solution in original post

0 Kudos
3 Replies
657 Views
bastih84
Contributor I

Thanks a lot :smileygrin:

It's not so easy to place reset vector of application in paged flash.

According datasheet you have to place reset vectors in higher unpaged flash region.

I changed my vector table of my application to another place (unpaged higher region) and it work's fine :smileycool:

Have a great day,

Bastian

0 Kudos
658 Views
RadekS
NXP Employee
NXP Employee

Hi Bastian,

You are right. Address 0x7F_BFFE is global address and your code works only with lower 16 bits = 0xBFFE.

So, loading address will work only in case when PPAGE register will be set to value 0xFE.

Despite of fact, that S12XE core contains instruction for work with global addresses, the core still works in default 16bit address space (program counter is 16bit).

So, you have three basic options:

1. Typically we place application starting point into unbanked memory. For example:

AppResetVect:  equ $effe ; here is stored reset vector of user application

ldx AppResetVect

jmp 0,x              ; jump to the application

2. We could leave application reset vector in paged memory, but we have to ensure that PPAGE register will be correctly set for reading right value. In case when bootloader code is executed from non-banked area, we could simply write 0xFE into PPAGE register prior we read from address #0xBFFE. If bootloader code is executed from paged memory, situation is slightly more complicated and you should use routine for safe reading from far address (see datapage.c file).

3. We could leave application reset vector in paged memory, but we will use global address and global instructions for reading vector value. In that case we should (optionally save GPAGE register), set GPAGE to 0x7F value, use GLDX instruction for reading vector value (optionally , restore GPAGE register value) and jump to application.

I am just curious, why you use instruction ldx D, x;?

Do you have more application reset vectors than one and you use offset in D accumulator for distinguish between applications?


I hope it helps you.

Have a great day,
RadekS

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

0 Kudos
657 Views
iggi
NXP Employee
NXP Employee

In case you don't know about and appnote, it would be good for you to check  the AN4258 Serial Bootloader for S12(X) Microcontrollers Based on 180 nm Technology.

The SW is here AN4258SW

The global address is OK. but the s-record file must be converted in order to have global (linear) addresses. For this purpose SRecCvt utility is used (included in AN4258SW zip package).

Regards,

iggi

0 Kudos