S12ZVMC128 Bootloader

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

S12ZVMC128 Bootloader

Jump to solution
1,359 Views
chojunghun
Contributor II

Hello
Now I am trying to make a code for bootloader of S12ZVMC128 MCU.
Flash Start Address = 0xFE0000, Application Start Address = 0xFE0000,
Vector Sector Address = 0xFFFE00 etc. The address is set according to the memory map, but the bootloader does not work. I do not know the cause of the problem.
Please help me
I attached the code and the Application SX file.

Original Attachment has been moved to: S12ZVMC_Bootloader.zip

Original Attachment has been moved to: UserApp.sx.zip

Labels (1)
Tags (3)
1 Solution
781 Views
RadekS
NXP Employee
NXP Employee

Hi Cho,

  1. Yes, you can have two interrupt vectors for CAN. The relocation is managed by IVBR register.
  2. The last two S record lines in your App.sx file are formatted strange way. I supposed, that it is your own modification. Correct? Currently, I do not see any obvious reason for that behavior.
  3. Unfortunately, your implementation of relocated vector table contains error. But it is my error from an older version of my example code. The IVBR line should be:

IVBR=(dfINT_VECTOR_TABLE_ADDR_IN_FLASH>>8) & 0xFFFE;

For selected vector table address, it is a rather formal error- it will not have any effect on the result.

  1. Your prm file in bootloader is quite confusing since you filled it also by information related to application (APP_ROM_ENTRY, APP_ISR_SEG, APP_SEG,…). But I do not see any obvious issue there.

 

However, I found one issue in define.h file. You increased Bootloader size. So, the flash size for Application will be smaller. Please update also dfFLASH_SECTORS_TO_ERASE value.

Since your Bootloader code starts at address 0xFFF400, the higher 6 sectors are occupied by the bootloader. The dfFLASH_SECTORS_TO_ERASE value should be in this case just 250.

It is possible that the bootloader erased his code during Flash preparation and he cannot finish his operation correctly.

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

4 Replies
781 Views
RadekS
NXP Employee
NXP Employee

Hi CHO JUNG HUN,

Bootloader:

The define.h file contains

#define dfFLASH_START_ADD 0xFE0000

#define dfAPPLICATION_START_ADD                    0xFE0000

#define dfBOOTLOADER_START_ADD    0xFE0000

 

This is obvious issue – your bootloader erases 252 sectors from address 0xFE0000 for application use.

So, the bootloader must be placed at highest 4 sectors in Flash.

 

Please update bootloader prm linker file. The ROM segment should start at address 0xFFF800.

Also, SHADOW_ROM_S must not overlap ROM segment and the same is valid for SHADOW_RAM_S and RAM segments.

 

Application:

Your UserApp S-record file contains 6 interrupt and 1 reset vectors at the area which is already occupied by bootloader (0xFFFE00.. 0xFFFFFF).

You must create vector table somewhere else in Flash or RAM and modify IVBR register at application start.

See attached simple example code with relocated vector table into Flash/RAM for your inspiration.

 

Since the UserApp will be called from Bootloader, please comment out default reset vector in UserApp linker file:

//VECTOR 0 _Startup

 

From UserApp S-record file is not clear linker settings. Please do not forget on trim Flash size in UserApp linker file for avoiding any UserApp/Bootloader overlap – up to 0xFFF7FF. This typically doesn’t problem for RAM.

 

Please be aware, that there may be an issue with default starts12z.c file – the linker typically place DoZeroOut() function as first into Flash. This leads into the situation, that _Startup() position in flash depends on number and sizes of used initialized variables.

There are at least two workarounds. Please select one of them:

1. You may change order of DoZeroOut(), DoCopyDown() and _Startup() functions in starts12z.c file for manage that _Startup() will be the first function placed into flash.

See attached starts12z.c file.

2. You may place jump instruction and vector to _Startup() function as first in UserApp linker file.

See attached example linker file.

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!
-----------------------------------------------------------------------------------------------------------------------

781 Views
chojunghun
Contributor II

HI Radek

1. I am using can interrupt in the boot loader code, and I want to know if it is possible to use the same CAN Interrupt in the application code.

2. When the application sx file is downloaded after loading the boot loader code on the target board. Last S2 10 FFF1F0 FF FE 0E D9 FF FE 0E D9 FF FE 0E D9 63 The value does not wirte memory.

3. I want to know if the application's vector table relocation is correct.
Now the interrupts I use in my application
VECTOR 13 TIMch1_ISR
VECTOR 14 TIMch2_ISR
VECTOR 15 TIMch3_ISR
VECTOR 28 ADC0error_ISR
VECTOR 30 ADC0done_ISR
VECTOR 42 CAN_ISR

4. I want to know if each memory address setting in the boot loader and application prm file is correct.

Attachment: Application sx, prm, Vector_Relocation
                    Bootloader Code

Have a great day,

CHO JUNG HUN

0 Kudos
781 Views
chojunghun
Contributor II

HI Radek

Vector table Relocation and dfFLASH_SECTORS_TO_ERASE Size have been modified.

Thank you very much for your help.

Have a great day,

 

CHO JUNG HUN

0 Kudos
782 Views
RadekS
NXP Employee
NXP Employee

Hi Cho,

  1. Yes, you can have two interrupt vectors for CAN. The relocation is managed by IVBR register.
  2. The last two S record lines in your App.sx file are formatted strange way. I supposed, that it is your own modification. Correct? Currently, I do not see any obvious reason for that behavior.
  3. Unfortunately, your implementation of relocated vector table contains error. But it is my error from an older version of my example code. The IVBR line should be:

IVBR=(dfINT_VECTOR_TABLE_ADDR_IN_FLASH>>8) & 0xFFFE;

For selected vector table address, it is a rather formal error- it will not have any effect on the result.

  1. Your prm file in bootloader is quite confusing since you filled it also by information related to application (APP_ROM_ENTRY, APP_ISR_SEG, APP_SEG,…). But I do not see any obvious issue there.

 

However, I found one issue in define.h file. You increased Bootloader size. So, the flash size for Application will be smaller. Please update also dfFLASH_SECTORS_TO_ERASE value.

Since your Bootloader code starts at address 0xFFF400, the higher 6 sectors are occupied by the bootloader. The dfFLASH_SECTORS_TO_ERASE value should be in this case just 250.

It is possible that the bootloader erased his code during Flash preparation and he cannot finish his operation correctly.

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!
-----------------------------------------------------------------------------------------------------------------------