how could i update bootloader via bootloader?(s12xe)

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

how could i update bootloader via bootloader?(s12xe)

1,300 Views
taofu
Contributor II

I have built one boot loader mc9s12xet256 based on a Serial Bootloader (AN4258). But there is one problem, how could i update boot loader via the boot loader that i have built?

Now, i have merged the user application and bootloader in one *.s19 file.  A "out of range" error was reported when i download the merged s19 file in the mcu via the bootloader. I have found the reason of this error.

When application and boot loader code are merged , the boot loader code is behind of app code in the merged s19 file. The "out of range" error is occurred when the boot loader code is transferring to the mcu via serial port.

In the boot loader, code below restrict the range of bootloader.

if (!((ProgSRec.LoadAddr >= 0x780000UL) && (ProgSRec.LoadAddr <= 0x79FFFFUL)) && \

!((ProgSRec.LoadAddr >= 0x7E0000UL) && (ProgSRec.LoadAddr <= 0x7FEFDFUL)))

return(SRecRangeError);

The boot loader code is placed in

ROM_F000  = READ_ONLY 0xF000 TO   0xFCFF;

 

i want update boot loader code, but i can't erase the boot loader code, is there any method could solve this problem?

Any help would be greatly appreciated.

 

Regards,

taok

Labels (1)
Tags (3)
0 Kudos
Reply
3 Replies

954 Views
lama
NXP TechSupport
NXP TechSupport

Hi,

the task you want to perform is really a new application. There are more approaches.

1) Create a new bootloader which will be able to recognize whether youload application or bootloader upgrade. In the second case the bootloader code (created as PIC - position independent code, the best approach is to use assembler) must be loaded into RAM and executed out of RAM.

2) Another approach could be to load application "bootloader" which copies itself it RAM and continues as described in previous approach.

In all cases you have to keep in mind tat the C coding which uses nonPIC code and/or library functions is not suitable for it. The best approach is to use assembler.

Probably someone could have another idea but I see it this way.

Best regards,

Ladislav

0 Kudos
Reply

954 Views
RadekS
NXP Employee
NXP Employee

Hi tao,

1. Description how to merge application and bootloader is related to situation where we want to load both codes by BDM interface (this allows to skip loading initial version of application trough SCI).

Since bootloader is already in protected flash, you are able to load only updated application trough SCI. AN4258 code is not designed for bootloader code update (only way how to load bootloader is trough BDM interface). If you want update application, please do not follow chapter 8 “How to merge the user application and bootloader”.

2. There is small bug in AN4258SW Bootloader S12X code related to S12XE256 derivatives. I already reported it, but it seems that this was not fixed yet. Function EraseFlash() in main.c file contains command PFlash_EraseBlock(0x7A0000UL) however this memory isn’t implemented.

Please comment out (erase) lines 143 and 144 in original code:

if(Error = PFlash_EraseBlock(0x7A0000UL))

return(Error);

S12XET256 contains just two P-Flash blocks – Block 1S at 0x78_0000..0x79_FFFF and Block 0 at 0x7E_0000..0x7F_FFFF.


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
Reply

954 Views
taofu
Contributor II

Radeks:

Thanks so much for your answer.

The small bug you mentioned above was corrected already.  Now, i have understood the purpose of merge application and bootloader in AN4258.

But how bootloader code update is still confused me. Do you have any advices about this? Or any things what i should know to realize this function?

Thank you once again.

taok

0 Kudos
Reply