MC9S12XEP100 Bootloader thru CAN

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

MC9S12XEP100 Bootloader thru CAN

1,987 Views
peteyo
Contributor II

Hi,

I am now start to use NXP 16-bit MCU MC9S12XEP100 for a new automotive project,

and it requires a CAN based bootloader to update FW.

 

I summarize some questions below after studying these days and hope can get some tips, thanks.

 

1. There are 3 things I need to do:

bootloader FW, PC-side UI, and also the .prm file of the application FW for address mapping?

 

2. In my application, 2k D-Flash is partitioned to as EEE. Does this will impact my design of bootloader setting?

 

3. The goal of update process in my application will be: With a .s19 file in hand(maybe from other software engineer), user or customer need to do is only execute the GUI, load s19 file and click the update button to upgrade FW of target board.

 

4. Which is more easy way for development to meet my requirement?

     a. User can update FW anytime once MCU receives update command from CAN bus

     b. Reserved some time( for example, 3 sec.) after power on reset to monitor CAN bus for FW update query

 

5. Besides AN4258.pdf, AN4258SW.zip, and bootloaderS12X.zip, do I miss other important documents or example files to start my design?

Labels (1)
Tags (2)
3 Replies

1,304 Views
RadekS
NXP Employee
NXP Employee

Hi Peter,

1.    You need also some hardware, for example: some USB to CAN interface. Additionally you need to know specification of your CAN bus. I suppose that you already have some evaluation/custom board with S12XEP100 and CAN interface. If not, there should be DEVKIT-S12XE board available in near feature (for $39)

2.    In fact, yes, it will impact your design of bootloader settings. You will have to implement flash routines for EEEPROM enable and potentially also for partition D-Flash. The EEE data will be simply copy into buffer RAM instead of loading to flash per phases. Additionally you just need to wait until EEE state machine store all EEE data into D-Flash prior next reset. For example:

while((ETAG > 0) || (FSTAT_MGBUSY == 1));

Do you need any example for EEE, or it is already known technology for you?

3.    OK

4.    I think that ideal way is combination of these approaches. The user can send CAN message – “Hey, I want to talk with bootloader”. The application just store some flag into (RAM)/EEE/Flash and reset MCU. The bootloader just test this flag and answer to PC-side UI “I am ready” or just jump into application (without that flag). In that case you don’t need to take care about write-once registers,…

NOTE: Since content of RAM is random after power-up, using RAM for storing flag might be tricky.

5.    There is also simple bootloader for S12Z - AN4723 S12Z MagniV Bootloader

http://www.nxp.com/files/microcontrollers/doc/app_note/AN4723.pdf

http://www.nxp.com/files/microcontrollers/doc/app_note/AN4723_SW.zip

It was created for different CW IDE, different clock module (CPMU), also the flash routines are slightly different and it has no CAN, but could still work as inspiration – at least from PC client side. This bootloader starts after every MCU reset in case of missing connection with client it de-init MCU register and run application.

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

1,304 Views
peteyo
Contributor II

Hi Radek,

Thanks for your reply.

1. I have an evaluation board and also have a new board for my application with S12XEP100 on it.

2. I think my partition part of source code is from the example of AN3743. It works well and I just need to check some special address to check if the MCU did partition or not.

I will continue to study the documents and examples. If I get some troubles in the future, I will still ask for the help from you guys.

Thanks,

Peter

0 Kudos
Reply

1,304 Views
RadekS
NXP Employee
NXP Employee

Hi Peter,

The testing whether D-Flash was already partitioned or not, could be implemented like here:

MMCCTL1_EEEIFRON = 1; //enable EEEIFR in memory map

  if((*(unsigned int *far)0x120000 != DFPART) || (*(unsigned int *far)0x120004 != ERPART))

  {    

    if((*(unsigned int *far)0x120000 == 0xFFFF) && (*(unsigned int *far)0x120004 == 0xFFFF))  

      err = DFLASH_Partition(DFPART,ERPART);  //first startup of MCU - set the partition

    else

      {    

        //this should never happen

      }    

  }

I would like to recommend also check whether D-Flash was portioned and formatted correctly. You may:

  1. Wait until Partition command ends and writes some flag into P-Flash/signalize and record in production.
  2. Or you may simply test address 0x107F00 during every reset.

The partition command may be interrupted by reset. Since DFPART, ERPART values are programmed prior D-Flash format, the unfinished Partition command may lead to the situation where EEE stops working after some time. Therefore I would like to recommend to test last sector header. For example:

MMCCTL1_EEEIFRON = 1; //enable EEEIFR in memory map

if((*(unsigned int *far)0x120000 != DFPART) || (*(unsigned int *far)0x120004 != ERPART))

  {    

    if((*(unsigned int *far)0x120000 == 0xFFFF) && (*(unsigned int *far)0x120004 == 0xFFFF))

      {    

      err = DFLASH_Partition(DFPART,ERPART);  //first startup of MCU - set the partition

//Partitioning takes approximately 180ms

      //you may signalize (write flag) here that D-Flash was formatted correctly

    }

    else

      {    

        //this should never happen

      }    

  }

  else

  {

  if(*(unsigned int *far)0x107F00 == 0xFFFF) err = FORMAT_ERROR; //Was D-Flash correctly formatted?

//err signalize format error

//partitioning was interrupted

  }

Note: The unfinished partition command may be fixed only by mass erase of the whole device in special single chip mode (simplest way presents Unsecure procedure execution) and by new Partitioning.

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

0 Kudos
Reply