Help booting  MPC5606B microcontroller via CAN

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Help booting  MPC5606B microcontroller via CAN

3,517件の閲覧回数
anegoiko
Contributor III

Hi,

 

I'm new with the MPC5606B microcontroller, and I have read in its user guide that there is a possibility to boot the microcontroller via FlexCAN or LINFlex. I have been searching for more information, as I'm a bit confused after reading the user guide. Does somebody know where I should look to get more information?

 

Any help would be appreciated.

ラベル(1)
0 件の賞賛
返信
18 返答(返信)

2,860件の閲覧回数
lukaszadrapa
NXP TechSupport
NXP TechSupport

2,860件の閲覧回数
anegoiko
Contributor III

Hi Lukas,

Thank you for your answer, it has been very helpfull to clear my ideas. I've realized that in my case it would be a better solution having a resident bootloader in flash, in order to avoid generating the necessary signals for ABS and FAB pins.

I have downloaded the zip file that you have attached and while I was reading the AN_qorriva bootloader.pdf file to get more information ( I am really new with creating a specific bootloader for a microcontroller) I just realize that the pdf it is not finished. Do you have the final document?

Regards,

Ane

0 件の賞賛
返信

2,860件の閲覧回数
lukaszadrapa
NXP TechSupport
NXP TechSupport

No, I didn't find time to finish it in the past... But only the last chapter is missing. It is the same like chapter "5.3 Bootloader Guide" in:

http://www.freescale.com/files/microcontrollers/doc/app_note/AN4258.pdf

Lukas

0 件の賞賛
返信

2,860件の閲覧回数
anegoiko
Contributor III

Hi again,

I'm sorry for making so many questions (that maybe I should know) and wasting your time, but I'm a bit lost about this topic and I really need help to focus in the correct way, as I am reading a lot of different documents, and I do not get a clear idea.

I'm not sure how do I have to download the bootloader and the user application together. Do I have to attach them with Code Warrior an build a unique .mot file? Or do I have to download first the bootloader and then the user application to the microcontroller? If the answer is that I have to download first the bootloader and then the user application, how do I ensure that I don't erase the bootloader memory area while I am downloading the user application?

Thanks again,

0 件の賞賛
返信

2,862件の閲覧回数
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

the bootloader and user application can be developed separately. If you follow the steps from application note, both projects (bootloader and user application) will work in "standalone mode" without any modification. For production purposes, it is good idea to merge both .mot files together, so you can program the flash in one step.

Regards.

Lukas

2,867件の閲覧回数
anegoiko
Contributor III

Thanks for your answer, it has been very helpfull.

However I'm not still able to edit the content of a variable that is stored in the flash memory, as I mentioned in my last answer. Do you know why I the memory is bloked?

0 件の賞賛
返信

2,867件の閲覧回数
lukaszadrapa
NXP TechSupport
NXP TechSupport

Could you share piece of code that doesn't work? Or tell me exactly which block you want to erase and what data at which address you want to program and I can write simple SW example for you...

Lukas

0 件の賞賛
返信

2,867件の閲覧回数
anegoiko
Contributor III

As I wrote some post before...

I'm using the MPC5606B in a development board, and this is my code to first erase and then program the value of key. (This value is stored in the address 0x000FFFF8- 0x000FFFF). I realized that the value of HBE bit is 0, and the HLK bits are always 0xFF. (So I think that here is the mistake, as this memory area will be locked in the erase and program instants).

Do you know why I can not get HBL bit = 1, and HLK = 0x00 ?

asm("wrteei 0");
/////////// ERASE
/* unlock high address space in flash array 2 */
CFLASH.HBL.R = 0xB2B22222;
CFLASH.HBL.B.HLK = 0x00; /* unlock flash array 2 */
status= CFLASH.HBL.B.HBE;
status= CFLASH.HBL.B.HLK;
/* execute programming sequence */
CFLASH.MCR.B.ERS = 1;
CFLASH.HBS.B.HSL = 0x08;
*(_SOFT_U32BITS *)BOOT_KEY_ADDRESS_UP = 0xFFFFFFFF;
*(_SOFT_U32BITS *)BOOT_KEY_ADDRESS_DOWN = 0xFFFFFFFF;
CFLASH.MCR.B.EHV = 1;
while(CFLASH.MCR.B.DONE == 0){};
CFLASH.MCR.B.EHV = 0;
CFLASH.MCR.B.ERS = 0;
////////// PROGRAM
/* unlock high address space in flash array 2 */
CFLASH.HBL.R = 0xB2B22222;
CFLASH.HBL.R = 0x00000000; /* unlock flash array 2 */
status= CFLASH.HBL.B.HBE;
status= CFLASH.HBL.B.HLK;
/* execute programming sequence */
CFLASH.MCR.B.PGM = 1;
*(_SOFT_U32BITS *)BOOT_KEY_ADDRESS_UP = DESTROY_BOOT_KEY_UP;
*(_SOFT_U32BITS *)BOOT_KEY_ADDRESS_DOWN = DESTROY_BOOT_KEY_DOWN;
CFLASH.MCR.B.EHV = 1;
while(CFLASH.MCR.B.DONE == 0){};
status = CFLASH.MCR.B.PEG;
CFLASH.MCR.B.EHV = 0;
CFLASH.MCR.B.PGM = 0;
/* reset the device */
//ME.MCTL.R = 0x00005AF0;

//ME.MCTL.R = 0x0000A50F;
asm("wrteei 1");

Thank you for your help and attention,

2,867件の閲覧回数
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

here it is:

/* unlock HLK3 block */

CFLASH.HBL.R = 0xB2B22222; /* write password */

CFLASH.HBL.R = 0x000000F7; /* unlock HLK3 only */

/* erase block HLK3 (0x000E_0000 - 0x000F_FFFF) */

CFLASH.MCR.B.ERS = 1;

CFLASH.HBS.R = 0x00000008; /* select HLK3 */

*(unsigned int *)0x000E0000 = 0xFFFFFFFF; /* interlock write - write to any address in selected

memory */

CFLASH.MCR.B.EHV = 1;

while(CFLASH.MCR.B.DONE == 0);

CFLASH.MCR.B.EHV = 0;

CFLASH.MCR.B.ERS = 0;

/* program double word to HLK3 */

CFLASH.MCR.B.PGM = 1;

*(unsigned int *)0x000FFFF8 = 0xAABBCCDD; /* interlock write */

*(unsigned int *)0x000FFFFC = 0x11223344; /* program data write */

CFLASH.MCR.B.EHV = 1;

while(CFLASH.MCR.B.DONE == 0);

CFLASH.MCR.B.EHV = 0;

CFLASH.MCR.B.PGM = 0;

I didn't test it because I'm traveling now but this should work. Please give this a try.

Regards,

Lukas

0 件の賞賛
返信

2,867件の閲覧回数
anegoiko
Contributor III

Thanks for your help. The answer is right.

However, now I am trying to modify the values of another memory area, and I am getting the same problem, the LME bit is always 0. In addition, when the code gets to  "CFLASH.MCR.B.ERS = 1;" line, it jumps to an address that there is nothing and it gets stuck there. This is the new code:

CFLASH.LML.R = 0xA1A11111; /* write password */

        CFLASH.LML.R = 0x0011003F; /* unlock MLK1 only */

        status= CFLASH.LML.B.LME;

        status= CFLASH.LML.B.MLK;

            /* erase block MLK1 (0x0006_0000 - 0x0007_FFFF) */

            CFLASH.MCR.B.ERS = 1;

            CFLASH.LMS.R = 0x00020000; /* select MLK1 */

            *(unsigned int *)0x0007FFF0 = 0xFFFFFFFF; /* interlock write - write to any address in selected memory */

            CFLASH.MCR.B.EHV = 1;

            while(CFLASH.MCR.B.DONE == 0);

            CFLASH.MCR.B.EHV = 0;

            CFLASH.MCR.B.ERS = 0;            

            /* program double word to MLK1*/

            CFLASH.MCR.B.PGM = 1;

            *(unsigned int *)0x0007FFF8 = 0xFFFF2222; /* interlock write */

            *(unsigned int *)0x0007FFFC = 0xFFFF0000; /* program data write */

            CFLASH.MCR.B.EHV = 1;

            while(CFLASH.MCR.B.DONE == 0);

            CFLASH.MCR.B.EHV = 0;

            CFLASH.MCR.B.PGM = 0;

Do you have any clue why I am getting so many problems?

Thanks in advance,

0 件の賞賛
返信

2,867件の閲覧回数
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

low and mid address space have two locking registers - primary (LML) and secondary (SLL). It is necessary to unlock the block in both of them. That means:

CFLASH.LML.R = 0xA1A11111; /* write password */

CFLASH.LML.R = 0x0011003F; /* unlock MLK1 only */

and then also

CFLASH.SLL.R =...

CFLASH.SLL.R =...

High address space has only single locking register.

This should solve the problem.

Regards,

Lukas

0 件の賞賛
返信

2,868件の閲覧回数
anegoiko
Contributor III

Finally I got it! After that I moved to a MPC5602C (64 pin) microcontroller and after solving other problems, I got it again. Now I'm working in 100 pin MPC5602C. I am using the same code but when the programme tries to erase, it stops in

    .align SIXTEEN_BYTES

IVOR3trap:  b    IVOR3trap /* Instruction Storage interrupt handler */

Does somebody know why I can not even erase the flash or why does the programme go to that interruption?

Thanks in advance,

0 件の賞賛
返信

2,866件の閲覧回数
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

it looks like you erased the flash where the code was running from. Could you check that?

Have you changed the default platform flash controller setting? Default settings is enabling the stall-while-write/erase and disabling the abort and notifications interrupt. So, the read operation will be stalled until on-going program/erase operation to complete. That means it is not necessary to run the command from SRAM or from another flash block. (notice that this is valid only on devices like MPC5602C which has C90LC flash).

Regards,

Lukas

0 件の賞賛
返信

2,866件の閲覧回数
anegoiko
Contributor III

Thanks for your answer. The truth is that I did not change the default settings, at least not in purpose. How can I know if I have changed thouse settings?

Regards,

0 件の賞賛
返信

2,867件の閲覧回数
lukaszadrapa
NXP TechSupport
NXP TechSupport

Run your initialization and then check the registers PFCR0 and PFCR1, bit fields BKn_RWWC. All mentioned bits should be '1' (default state).

pastedImage_0.png

Regards,

Lukas

2,867件の閲覧回数
anegoiko
Contributor III

Hi Lukas,

I'm trying to do a simple example of a user application that waits until an integer reaches a value, and then the value of the key that is used by bootloader should be modified, but I'm not able to change the value of that key variable.

I've follow your pdf and I've asigned a specific memory area to that key variable in the user application. Moreover, when I debug the user aplication I can see that in the specified memory area the value of the key is stored correctly. However, when the integer value reaches the maximum value the new value is not stored. Do you know why can be that?

In order to asign the new key value I'm using the folllowing code that it can be found in your zip file:

*(unsigned long long *)BOOT_KEY_ADDRESS = DESTROY_BOOT_KEY;

Thanks in advance,

0 件の賞賛
返信

2,867件の閲覧回数
anegoiko
Contributor III

Hi,

It is not necessary to answer this question, as I have already solved it.The problem was that before editing the key variable, I was not unlocking the flash memory. :smileyconfused:

0 件の賞賛
返信

2,867件の閲覧回数
anegoiko
Contributor III

Hi,

I'm sorry asking so many times but I can not get any of two questions that I made. I thought that at least I was able to modify the key variable but I realized that I am not able.

I'm using the MPC5606B in a development board, and this is my code to first erase and then program the value of key. (This value is stored in the address 0x000FFFF8- 0x000FFFF). I realized that the value of HBE bit is 0, and the HLK bits are always 0xFF. (So I think that here is the mistake, as this memory area will be locked in the erase and program instants).

Do you know why I can not get HBL bit = 1, and HLK = 0x00 ?

asm("wrteei 0");
/////////// ERASE
/* unlock high address space in flash array 2 */
CFLASH.HBL.R = 0xB2B22222;
CFLASH.HBL.B.HLK = 0x00; /* unlock flash array 2 */
status= CFLASH.HBL.B.HBE;
status= CFLASH.HBL.B.HLK;
/* execute programming sequence */
CFLASH.MCR.B.ERS = 1;
CFLASH.HBS.B.HSL = 0x08;
*(_SOFT_U32BITS *)BOOT_KEY_ADDRESS_UP = 0xFFFFFFFF;
*(_SOFT_U32BITS *)BOOT_KEY_ADDRESS_DOWN = 0xFFFFFFFF;
CFLASH.MCR.B.EHV = 1;
while(CFLASH.MCR.B.DONE == 0){};
CFLASH.MCR.B.EHV = 0;
CFLASH.MCR.B.ERS = 0;
////////// PROGRAM
/* unlock high address space in flash array 2 */
CFLASH.HBL.R = 0xB2B22222;
CFLASH.HBL.R = 0x00000000; /* unlock flash array 2 */
status= CFLASH.HBL.B.HBE;
status= CFLASH.HBL.B.HLK;
/* execute programming sequence */
CFLASH.MCR.B.PGM = 1;
*(_SOFT_U32BITS *)BOOT_KEY_ADDRESS_UP = DESTROY_BOOT_KEY_UP;
*(_SOFT_U32BITS *)BOOT_KEY_ADDRESS_DOWN = DESTROY_BOOT_KEY_DOWN;
CFLASH.MCR.B.EHV = 1;
while(CFLASH.MCR.B.DONE == 0){};
status = CFLASH.MCR.B.PEG;
CFLASH.MCR.B.EHV = 0;
CFLASH.MCR.B.PGM = 0;
/* reset the device */
//ME.MCTL.R = 0x00005AF0;

//ME.MCTL.R = 0x0000A50F;
asm("wrteei 1");

Thank you for your help and attention,

0 件の賞賛
返信