Serial bootloader example for MPC5634M

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

Serial bootloader example for MPC5634M

6,587 Views
raphc63
Contributor II

Hi everyone,

I recently bought a MPC563xM StarterTRAK Development Kit. MPC5634M is not supported by RAppID, that's the reason why I want to code my own bootloader for reading, erasing, and writing data on flasH.
Is there a documentation with simple examples of serial bootloader for MPC56xx or MPC55xx which are similar. It will be very helpful for me, this is the first bootloader I have to code.

Labels (1)
27 Replies

3,209 Views
raphc63
Contributor II

Ok thanks Lukas, this terminal works perfectly.


I tried the bootloader that you gave me and it works almost fine. In Codewarrior the baudrate for serial communication seems to be set to 115200baud

2.PNG

Or at this baud I had no communication. I used a logic analyzer and I found the effective baudrate is 80000 and now it works with Terminal. But I don't understand why the baudrate is less than 11500. Maybe my system clock is not set properly ? ( I don't change anything in the code and it supposed to be 80Mhz )

Also I have some random message error as you can see here ( I reset several time to show the random effect ) :

Capture.PNG

0 Kudos

3,208 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

what is the crystal frequency on your board? It looks like you use 8MHz crystal, don't you? My application expects 12MHz crystal. There's note in InitSysclk function:

Sysclk = 80MHz running from PLL with 12 MHz crystal reference.

Change it to:

void initSysclk (void) {

     FMPLL.ESYNCR2.R = 0x00000002;

     FMPLL.ESYNCR1.R = 0xF0000028;

     while (FMPLL.SYNSR.B.LOCK != 1) {}; /* Wait for FMPLL to LOCK  */

     FMPLL.ESYNCR2.R = 0x00000001; /* Fsys =80Mhz */

}

Then it should work.

Lukas

0 Kudos

3,209 Views
raphc63
Contributor II

Thanks it works well :smileywink: Yes I have a 8 Mhz crystal.

This code example will be a good start for me I have just to create a Reading flash function and use CAN instead of serial communication. Do you know if there are existing example project for MPC5634M or other MPC56XX of CAN communication function ?

0 Kudos

3,208 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

basic SW example for CAN communication can be found in application note AN2865:

http://www.freescale.com/files/32bit/doc/app_note/AN2865.pdf

MPC5500 and MPC5600 Simple Cookbook Code

Regards,

Lukas

0 Kudos

3,211 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

take a look at:

https://community.freescale.com/servlet/JiveServlet/download/427962-279359/bootloader.zip

It is written directly for MPC5634M.

Regards,

Lukas

1,464 Views
tobayram
Contributor I
Hello Lukas,
Im working on a MPC5554 serial bootloader. I can not reach this page.Could you give me an example about that.
Have a Nice Day.
Talha Osman BAYRAM
0 Kudos

3,207 Views
bjrajendra
Senior Contributor I

Hi Lukas,

I'm facing problems with the flash boot loading application. Kindly solve this.

1.) Is it possible to download both the user application program and boot loader application without erasing? As I tried programming the boot loader application using the PE Micro USB Multilink, it erases the earlier programmed user application, and vice versa. ( I ensured it by seeing the memory window. It completely erased the earlier programmed memory. including the key. So my user application is not executing the application. So What I need to do? )

2.) I also faced this issue, when executing the __start file, it is not executing after this line lwz    r10,0(r9).

Thanks,

Raju

0 Kudos

3,210 Views
bjrajendra
Senior Contributor I

Thanks Lukas,

It's a kick start for me to start the bootloader module. One thing confirm me.

1) Once the user application deletes the Key, and after reset, bootloader program will execute. During the bootloader project execution, as the key was deleted by the previous user application, Immediately after the completion of program code we need to add key 0xFFFF0000FFFF0000ULL has to be loaded back to address 0x0017FFF8. Is it right?

Because the bootloader project you provided doesn't have this part of the code.

Thanks,

Raju

0 Kudos

3,209 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

this is should be part of project for user application. You can find in main.c:

/* constant in flash used to start the bootloader/user application */
#define BOOT_KEY_ADDRESS     0x0017FFF8UL
#define BOOT_KEY                     0xFFFF0000FFFF0000ULL
#define DESTROY_BOOT_KEY     0x0000000000000000ULL

/* Set a constant in flash - BOOT_KEY for bootloader.
   "key" is added to FORCEACTIVE section in linker file to ensure
   that the constant is not stripped by the linker */
#pragma push
#pragma section all_types ".__key_segment" ".__key_segment"
unsigned long long key = BOOT_KEY;
#pragma pop

And then at the end of *.mot file:

S30D0017FFF8FFFF0000FFFF0000E8

So, the key is programmed to flash by bootloader together with other data...

Regards,

Lukas

3,211 Views
bjrajendra
Senior Contributor I

Hi Lukas,

Also can you tell how to unlock part (entering password) of censorship with Flash boot mode.

CensorshipFlowChart.JPG

Thanks and Regards,

Raju

0 Kudos

3,209 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

It depends which debugger you use...

0 Kudos

3,209 Views
bjrajendra
Senior Contributor I

Hi Lukas,

In Flash boot mode, I want to uncensor the device. I got an idea, suggest whether I'm in right track or not?

1. Initially my user application will censor the device

         a.)    Erasing the shadow flash, programming the NVPWD registers with the right password and then programming the NCSCI registers.

2. Once the user application receives CAN id for flash boot mode with the right password, The user application will uncensor the device.(0x55AAxxxx,0x55AAxxxx)

         b.)    Erasing the shadow flash, programming the default NVPWD registers and then programming the NCSCI registers for uncensor (0x55AA55AA,0x55AA55AA).

3. The user application will delete the key and resets it to start the bootloading application.

Thanks and Regards,

Raju.

0 Kudos

3,210 Views
bjrajendra
Senior Contributor I

Hi Lukas,

Thanks for your swift response.

So the SRECCONV file wont generate .mot file with last line S30D0017FFF8FFFF0000FFFF0000E8. We need to add that line at the end of the .mot file, before downloading the code. Is it right?

Thanks and regards,

Raju

0 Kudos

3,211 Views
bjrajendra
Senior Contributor I

Yes, I got it.

Thanks for your valuable information

Raju

0 Kudos

3,210 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

if the key is present in the application *.mot file, it will be also in converted *.mot file. You can try to convert the mot file of user application which is included in the zip file and you will see...

Lukas

3,211 Views
buraksoner
Contributor II

Hello Lukas,

Although this project seems to be written for MPC5634M (which contains the C90LC, right?), the SSD seems to be for the C90FL flash module. I've concluded this after I saw the EraseFlash function was trying to "enable" (I guess that means select-for-erase?) blocks which are signified by bits 22-23 of the LMSR.

unsigned char EraseFlash(void)

{

  shadowFlag = FALSE;

  /* Erase all blocks (except area occupied by bootloader) in low and mid addr space of flash array 0 */

  lowEnabledBlocks = 0x000003F8;

0x000003F8 -> bits 22->28 are set.

Screenshot from ref manual below:

c90fl_c90lc.png

Also, of course, there are some other differences between the C90FL and the C90LC.

Am I correct in this analysis?

I've downloaded the "MPC56xx C90LC Flash Standard Software Driver (REV 1.0.3)" from NXP software center but inside it the user manual states that the document is prepared for C90FL devices! Is the API for C90FL and C90LC really the same?!

If not, where can I find the SSD explicitly for C90LC?

0 Kudos

3,210 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

API of SSD drivers is the same for C90LC and C90FL.

There's C90LC flash on MPC5634M. C90FL was used on first revisions (prototypes) of chip. Regarding appendix, there's note in Table A-2:

pastedImage_0.png

"MPC56xx C90LC Flash Standard Software Driver (REV 1.0.3)" - Yes, this one should be used.

To find correct SSD drivers for a device, find the web page of device, for example:

MPC563xM|32-bit MCU|Powertrain|NXP

or

MPC564xL|32-bit MCU|Chassis-Safety|NXP


Then go to "Software & Tools" tab:

pastedImage_3.png

Then search for "Middleware - Device Drivers":

pastedImage_4.png

And here you can find the drivers for the device:

pastedImage_5.png

Regards,

Lukas

3,211 Views
buraksoner
Contributor II

Lukas,

Thanks for the explanation.

One humble suggestion: Perhaps, the fact that the SSDs are the same for C90LC and C90FL can be stated somewhere accesible. As the SSDs are just a bunch of hex numbers in c-files or srecords, no conclusion can be made by just comparing drivers obtained from two different sources -> I've compared the API c-files (which contain just arrays made up of some hex numbers which respresent the API functions) under the "SSD_driver" folder in the serial bootloader example to all of the "c-array_driver" files provided under all (cw, diab, ghs) and (BookE and vle) combinations in the SSD v1.0.3 provided from the NXP website and none are matching..

Regarding your answer, I assume there would only be some cosmetic changes which result in different hex numbers in those c-files but nothing functional is different. Am I correct?

Thanks for the help,

Burak

0 Kudos

3,210 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

It is mentioned in document which I attached to the bootloader:

pastedImage_0.png

When you download the drivers, the package always contains user guide and release notes, so I think it's enough.

Instead of comparing the c-arrays, it is much better way to download appropriate drivers and use them in your project.

Lukas

3,211 Views
alexvinchev
Contributor V

Hi lukaszadrapa,

is there any chance to find such example project for MPC5748G (for GHS if possible)?

In which way it should differ from boorloader for MPC5634M?

Regards,

Aleksandar

0 Kudos