Programming through BAM

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

Programming through BAM

Jump to solution
5,463 Views
dhanaraj_d
Contributor II

HI

This is regarding continuation of https://community.nxp.com/t5/MPC5xxx/Is-there-support-for-IAP-in-MPC5645S/m-p/1190971/highlight/fals...

In MPC5645S, For the usage of Boot Assist Module (BAM) to load a code via UART, we have referred this  AN - https://www.nxp.com/docs/en/application-note/AN4674.pdf

This is having GHS IDE examples. Can i get same for code warrior example that how to generate image output(memory image file) for programming.

Also can you please provide us host machine application like eSL for uploading image file through Linflex in MPC5645S.

Tags (1)
0 Kudos
Reply
1 Solution
5,111 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

I can see this in the linker file MPC5645S_DEBUG.lcf:

MEMORY
{
pseudo_rom: org = 0x40000000, len = 0x00003000
init: org = 0x40003000, len = 0x00001000
exception_handlers: org = 0x40004000, len = 0x00001000
internal_ram: org = 0x40005000, len = 0x00005000
heap : org = 0x4000A000, len = 0x00004000
stack : org = 0x4000E000, len = 0x00002000
}

 

So, the code is compiled to these addresses. It's not position independent code. You can't simply shift it to 0x40000100. The linker file needs to be updated. And important point is that 0x40000100 must be entry point. It's not reset vector. The BAM simply jumps to this address and this code is going to be executed. I described it in https://community.nxp.com/t5/Other-NXP-Products/Boot-Assist-Module-BAM-with-FlexCAN-MPC5604P/m-p/263...

See post from 02-28-2014 12:33 AM, there's step by step guide. 

Function __start must be forced to this address.

Regards,

Lukas

 

 

View solution in original post

0 Kudos
Reply
18 Replies
5,453 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

you can take a look at this thread where I described how to create RAM image which can be loaded by BAM:

https://community.nxp.com/t5/Other-NXP-Products/Boot-Assist-Module-BAM-with-FlexCAN-MPC5604P/m-p/263...

I have no other examples.

Regarding host machine application - we have only Rappid bootloader but it does not support MPC5645S. eSL from AN3953 is only demo application provided as is, unfortunately there are no source codes to share.

Regards,

Lukas

 

 

0 Kudos
Reply
5,444 Views
dhanaraj_d
Contributor II

Hi Lukas,

Thanks for your reply.

We can use elf file also to load into the debugger? Because my PE debugger not loading mot files to sram for copying it as a binary. 

0 Kudos
Reply
5,436 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Yes, elf files are the main files used by debuggers because it contains also debugging information. Each debugger supports elf file.

Regards,

Lukas

 

0 Kudos
Reply
5,431 Views
dhanaraj_d
Contributor II

Ok Lukas.

I have loaded elf file(sram image) and able to see my application running through PE debugger. But Memory window is not allowing to copy the continuous binary file. Is there any way to copy this using other tool and create continuous bin file?

Also prints are not coming in Tera term(115200N1) when running from sram. But Rx of controller seems like working. Same prints are working if I change to flash memory section in linker file and settings.

0 Kudos
Reply
5,408 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

I can see there's one more option - you can generate bin file directly in CodeWarrior. Open project properties (press Alt+F7), go to Linker -> EPPC Linker and herechange Binary File option to One. The build your project and you should find RAM.bin file in bin folder in your project.

 

Regarding the print issues - not really sure what's going on, I have never seen that. Do you have some simple project to reproduce the behavior? Note: I will be out of office, please expect delayed response.

Regards,

Lukas

 

 

 

0 Kudos
Reply
5,395 Views
SathishRaja
Contributor I

Hi Lukas,

Like you mentioned in above message we changed the binary file option from none to one.

After that when we compiled we got error like " link error : can't write in RAM.bin file".

Then we changed the target settings  we compiled as .elf file in that case we didn't get any prints through UART.

As you asked we attached the project file .Please check it and help us with this.

Tags (1)
0 Kudos
Reply
5,373 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

generation of bin file is working on my side. I have CW 2.10, build 3510. Do you have the same version?

And described problem seems to be caused by this piece of code in __ppc_eabi_init.c:

#if defined(ROM_VERSION) || defined(CACHE_VERSION) || defined(CALL_USR_INIT)
mflr r31 /* save off return address in NV reg */
bl usr_init /* init board hardware */
mtlr r31 /* get saved return address */
#endif

 

If usr_init is not called, some initialization is not done (like configuration of IVPR register) and it crashes when calling OutStr. Solution - pres Alt+F7 to open project properties, go to Language Settings -> C/C++ Preprocessor and add this to Prefix Text:

#define CALL_USR_INIT

Then the usr_init will be called also when using RAM target.

Regards,

Lukas

 

 

0 Kudos
Reply
5,364 Views
SathishRaja
Contributor I

Hi Lukas,

Thanks, After we defined the CALL_USR_INIT we are getting prints through UART.

Now we are facing a problem in BAM mode, by using FAB and ABS we turned the controller to BAM mode.

In BAM mode we are trying to enter the 8 byte password as per the reference manual.

For the first 4 bytes only we are getting echo message from BAM to UART .

After that we are not getting any echoes from BAM ,the controller goes to static mode automatically.

Please check it and help us with this issue.

 

0 Kudos
Reply
5,359 Views
SathishRaja
Contributor I

Hi lukas,

With additional to yesterday message ,we tried to debug SSCM , NVPWD0 and NVPWD1 registers for our clarification.

By debugging SSCM registers we got 0x08 50 values which means SSCM.SEC =0 ,SSCM.PUB=0 and BOOTMODE =010 i.e BAM is in UART boot mode.

By reading reference manual ,we understood if SEC=0 and PUB=0 means flash is unsecured and serial boot mode with private flash password is allowed.

So we tried using default password available in NVPWD0 and NVPWD1 registers .

The default password we read in NVPWD registers is FEEDFACECAFEBEEF.

In NVSCIO registers we got this value 55AA55AA.After that we tried to enter the password FEEDFACECAFEBEEF through UART at BAM .

In that for the first bytes values only we got echoed from BAM ie. FEEDFACE .

Once the 4 byte is echoed means the controller goes to static mode automatically. Because of this we are not able to run our application code in BAM mode.

Please check it ,and provide us some way to solve this issue.

 

Regards,

Sathish Raja D 

 

0 Kudos
Reply
5,278 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

I'm sorry for delay, fighting with a lot of queries after vacation.

I have only one idea - do you use correct baud rate? What is your crystal frequency and what is your baud rate?

The reference manual says:

"The system clock is driven by an external oscillator.

The LINFlex controller is configured to operate at a baud rate = system clock frequency/833, using an 8-bit
data frame without parity bit and 1 stop bit."

For example, if you use 16MHz crystal, the baud rate should be 19200. Could you double check?

Regards,

Lukas

 

 

0 Kudos
Reply
5,272 Views
dhanaraj_d
Contributor II

Thanks Lukas.

We configuring baud rate to 9600 and 8Mhz external crystal.

Since I have seen in application note doc, BAM is using 9600, I have set to that value. 

I think baud rate is correct so that am getting first 4 byte echoed correctly on the terminal and then it stops. I am doubting on the header i have added on top of original ram.bin file. Can you please confirm all my header bytes are correctly provided or need any other change? I attached the bin here.

0 Kudos
Reply
5,259 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Ok, the baud rate is correct.

I can see two issues in the bin file.

First, the start address needs to be 0x4000_0100 or higher. There’s a note in BAM chapter (easy to miss):

“The RAM location where to download the code can be any 4 byte aligned location starting from the

address 0x4000_0100.”

Second, the number of bytes seems to be too high.

But this does not solve the problem with password anyway.

When sending the password, are you waiting for echo character before next byte is transmitted?

Regards,

Lukas

 

0 Kudos
Reply
5,249 Views
dhanaraj_d
Contributor II

Hi Lukas,

I have changed to 40000100 as starting location. How much the max bytes allowed in BAM?

Actually am sending the bin file using tera term - send file option. I tried manually typing in tera term and its accepting 8 bytes since 'f' is 1 byte, 'e' is 2nd byte and so on, like that I got "feedface" and then it terminates the transaction. 

So is there any way or other tool to transmit bin file by checking the echo message properly received or not and then send the next byte?

0 Kudos
Reply
5,238 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

There's 64KB of SRAM, so you can use up to 64KB - 0x100.

Ok, tera term is the reason. It is mandatory to follow the procedure:

lukaszadrapa_0-1610019626987.png

The best way is to write simple PC application which will manage that or it is possible to use another microcontroller.

For testing purposes, tera term supports configuration of delay after each transmitted character. This could work too if the delay is long enough.

Regards,

Lukas

 

 

0 Kudos
Reply
5,127 Views
dhanaraj_d
Contributor II

Hi Lukas,

Thanks for the input.

I made simple python script PC application and able to transmit whole binary data now(python3 usb_data.py - all echoed back). After transferring whole binary, BAM should go to starting address(40000100) and execute my application from there. But application contains prints which is not coming in my console. Any clue to fix this issue(simply if I load binary file through debugger and execute form RAM then am getting prints)?

One difference is through debugger i loaded ram application from 40000000 but through BAM I uploaded in 40000100. I have doubt that code is booted or not itself.

I attached my python script, RAM project folder and binary. 

0 Kudos
Reply
5,112 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

I can see this in the linker file MPC5645S_DEBUG.lcf:

MEMORY
{
pseudo_rom: org = 0x40000000, len = 0x00003000
init: org = 0x40003000, len = 0x00001000
exception_handlers: org = 0x40004000, len = 0x00001000
internal_ram: org = 0x40005000, len = 0x00005000
heap : org = 0x4000A000, len = 0x00004000
stack : org = 0x4000E000, len = 0x00002000
}

 

So, the code is compiled to these addresses. It's not position independent code. You can't simply shift it to 0x40000100. The linker file needs to be updated. And important point is that 0x40000100 must be entry point. It's not reset vector. The BAM simply jumps to this address and this code is going to be executed. I described it in https://community.nxp.com/t5/Other-NXP-Products/Boot-Assist-Module-BAM-with-FlexCAN-MPC5604P/m-p/263...

See post from 02-28-2014 12:33 AM, there's step by step guide. 

Function __start must be forced to this address.

Regards,

Lukas

 

 

0 Kudos
Reply
5,108 Views
dhanaraj_d
Contributor II

Thanks Lukas. 

Now BAM feature is working !!!

I changed linker file and link order so that __start function is coming at 40000100 address.

0 Kudos
Reply
5,295 Views
dhanaraj_d
Contributor II

Hi Lukas,

Any solution or clue to fix this issue that BAM is echoing only 4 bytes and then stuck in that?

Tags (1)
0 Kudos
Reply