AN4258 bootloader on S12XET256

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

AN4258 bootloader on S12XET256

Jump to solution
1,099 Views
kthomas
Contributor I

Hi,

 

I'm using the example code provided with AN4258 to learn how to implement a serial bootloader on an MC9S12XET256.  The question I have is about a discrepancy in the memory layout between the datasheet and what's in the code.

 

The datasheet indicates that the S12XET256 (mask xM53J) has two PFlash blocks: one beginning at global address 0x78_000 and the other beginning at 0x7E_0000, both 128K. The datasheet says there is no PFlash from 0x7A_0000 to 0x7D_FFFF.

 

The example firmware from AN4258, in the EraseFlash() function in main.c, proceeds to erase a portion of the block starting at 0x7E_0000, the entire block starting at 0x7A0000 and the entire block at 0x780000. To me, that erase at 0x7A0000 shouldn't happen.

 

Is this an error in the code? If not, what am I missing in the datasheet or why is it being done? I've copied the block of code below, but you can download the project here.

 

Thanks.

 

 

static UINT8 EraseFlash(void)

{

  UINT8 Error;

 

  switch (PARTID)

  {

    //S12XS 256k flash

    case MASK_0M05M:

          //erase whole P-Flash memory except bootloader area

          return(PFlash_EraseSectorBySector(0x7C0000UL, 0x7FEFDFUL));

   

    //S12XS 128k flash

    case MASK_0M04M:  //Falling to next case

    case MASK_1M04M:

          //erase whole P-Flash memory except bootloader area

          return(PFlash_EraseSectorBySector(0x7E0000UL, 0x7FEFDFUL));

   

    //S12XE 1024k flash

    case MASK_0M48H:  //Falling to next case

    case MASK_1M48H:  //Falling to next case

    case MASK_2M48H:  //Falling to next case

    case MASK_3M48H:  //Falling to next case

    case MASK_4M48H_5M48H:

          //erase whole P-Flash block 0 except bootloader area

          if(Error = PFlash_EraseSectorBySector(0x7C0000UL, 0x7FEFDFUL))

            return(Error);

          //and erase all remaining blocks

          if(Error = PFlash_EraseBlock(0x7A0000UL))

            return(Error);

          if(Error = PFlash_EraseBlock(0x780000UL))

            return(Error);

          if(Error = PFlash_EraseBlock(0x740000UL))

            return(Error);

          if(Error = PFlash_EraseBlock(0x700000UL))

            return(Error);

          return(noErr);

   

    //S12XE, S12XF 512k flash

    case MASK_0M25J:  //Falling to next case

    case MASK_1M25J:  //Falling to next case

    case MASK_2M25J_3M25J:  //Falling to next case

    case MASK_1M64J_2M64J:

          //erase whole P-Flash block 0 except bootloader area

          if(Error = PFlash_EraseSectorBySector(0x7C0000UL, 0x7FEFDFUL))

            return(Error);

          //and erase all remaining blocks

          if(Error = PFlash_EraseBlock(0x7A0000UL))

            return(Error);

          if(Error = PFlash_EraseBlock(0x780000UL))

            return(Error);

          return(noErr);

   

    //S12XE 256k flash

    case MASK_0M53J:  //Falling to next case

    case MASK_1M53J_2M53J:

          //erase whole P-Flash block 0 except bootloader area

          if(Error = PFlash_EraseSectorBySector(0x7E0000UL, 0x7FEFDFUL))

            return(Error);

          //and erase all remaining blocks

          if(Error = PFlash_EraseBlock(0x7A0000UL))

            return(Error);

          if(Error = PFlash_EraseBlock(0x780000UL))

            return(Error);

          return(noErr);

   

    default:

          //break;

          return(UnknownPartID);

  }     

}



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

Yes, it is error in code.

In case S12XET256 there is missing block 0x7A_0000 – 0x7D_FFFF.

Please delete this code:

“if(Error = PFlash_EraseBlock(0x7A0000UL))

return(Error);“


View solution in original post

0 Kudos
1 Reply
527 Views
RadekS
NXP Employee
NXP Employee

Yes, it is error in code.

In case S12XET256 there is missing block 0x7A_0000 – 0x7D_FFFF.

Please delete this code:

“if(Error = PFlash_EraseBlock(0x7A0000UL))

return(Error);“


0 Kudos