S12XEQ384 - Placing Software in Paged ROM only

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

S12XEQ384 - Placing Software in Paged ROM only

Jump to solution
553 Views
saschapfengler
Contributor II

Hi there, I'm trying to figure out if and how it is possible, to place Bootloader SW in an address area without using Direct Flash pages FD and FF.

 

If I manipulate Project.prm to not use ROM_C000 or ROM_4000 ("direct Flash Pages"), but to use a paged Flash Area (PPAGE_FA for example) for StartUp-Code and such, linker throws errors left and right. (See attached file)

 

My goal is to place App- and Boot-SW - Code each in a consecutive way.

 

Lets say:

Bootloader: "Flash Page" E0 ... F4

AppSW: "Flash Page" FA ... FF

 

Is there a way to do this?


Reason: Our (Standard-)Bootloader is written in a way that it clears the APP-SW-Area from Start to Finish and then writes AppSW from Start to Finish. (In this Case "Flash Pages" FA to FF)

Original Attachment has been moved to: ProjectBootSW.prm.zip

Labels (1)
1 Solution
406 Views
RadekS
NXP Employee
NXP Employee

Hi Sascha.

The first problem is with the reset and interrupt vectors.

The interrupt and reset vectors are just 16bit pointers, therefore they cannot point to banked memory.

So, you have to use at least some part of FF or FD page for bootloader if bootloader will use any interrupt. The next option is a definition of interrupt routines in non-banked RAM.

From this point of view, it is logical that _Startup function will be also automatically placed in non_banked memory.

The next problem is with default startup code. By default, these functions are in the non-banked area. You may at least define “__BANKED_COPY_DOWN” and move variables initialization into banked memory.

Note: I have no experience with that.

In fact, I am not sure whether is somehow possible to bend CW project to do not use non-banked memory. I suppose that in that case, the banked modes doesn’t have sense and you should use large mode.

You may also use your own init functions for bootloader instead of standard Start12.c file.

Anyway, keep whole page FF for the application may be dangerous. When you want to modify the last sector, you have to erase them and any power down prior reprogramming this sector may cause complete lock MCU due to missing reset vectors. I would like to recommend keep reset vectors with default interrupt vectors under bootloader control (it suppose, that we will never need to update the bootloader).

For code placement you may also use standard pragmas:

#pragma CODE_SEG MY_BANKED_SEG

//my code

#pragma CODE_SEG DEFAULT

I hope it helps you.

Have a great day,
Radek

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

View solution in original post

2 Replies
407 Views
RadekS
NXP Employee
NXP Employee

Hi Sascha.

The first problem is with the reset and interrupt vectors.

The interrupt and reset vectors are just 16bit pointers, therefore they cannot point to banked memory.

So, you have to use at least some part of FF or FD page for bootloader if bootloader will use any interrupt. The next option is a definition of interrupt routines in non-banked RAM.

From this point of view, it is logical that _Startup function will be also automatically placed in non_banked memory.

The next problem is with default startup code. By default, these functions are in the non-banked area. You may at least define “__BANKED_COPY_DOWN” and move variables initialization into banked memory.

Note: I have no experience with that.

In fact, I am not sure whether is somehow possible to bend CW project to do not use non-banked memory. I suppose that in that case, the banked modes doesn’t have sense and you should use large mode.

You may also use your own init functions for bootloader instead of standard Start12.c file.

Anyway, keep whole page FF for the application may be dangerous. When you want to modify the last sector, you have to erase them and any power down prior reprogramming this sector may cause complete lock MCU due to missing reset vectors. I would like to recommend keep reset vectors with default interrupt vectors under bootloader control (it suppose, that we will never need to update the bootloader).

For code placement you may also use standard pragmas:

#pragma CODE_SEG MY_BANKED_SEG

//my code

#pragma CODE_SEG DEFAULT

I hope it helps you.

Have a great day,
Radek

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

406 Views
saschapfengler
Contributor II

Hi Radek,

this information is very valuable. Thanks!

0 Kudos