BAM Upload program MPC5644A

cancel
Showing results for 
Search instead for 
Did you mean: 

BAM Upload program MPC5644A

519 Views
alessandrosirto
Contributor II

Hi All, 

I have an huge problem about BAM on My MPC5644A  . I 'm using boot via CAN interface with baud rate detection. I respect all the CAN protocol and If I download  only a simple "hello world "program like led blink It's works fine. But If I try to download something coplex it dosen't works. I'm pretty sure that is not a problem about program because It works in RAM downloaded by j-link .

I fallows all the steps that you will find here  : https://community.nxp.com/thread/320166

So I have done these :

1)

"Find file __start.c in installation directory of CodeWarrior and copy it into your project. Add this files to source files in the project. Change the link order – set this file as a first one.

You will get some warnings because we overloaded the __start function

Then it is necessary to change the linker file – place “init” section at the start of memory and place init_vle at the start of “init” GROUP:"

2)

My linker file is  :

init: org = 0x40000000, len = 0x00001000
pseudo_rom: org = 0x40001000, len = 0x00003000
exception_handlers: org = 0x40004000, len = 0x00001000
internal_ram: org = 0x40005000, len = 0x0001B000
heap : org = 0x40020000, len = 0x00008000
stack : org = 0x40028000, len = 0x00008000

SECTIONS

{

    GROUP : {     

.init_vle (VLECODE) : {

*(.init)

*(.init_vle)

      }

      .init : {}

    } > init

….

 

Then the entry point (function __start() ) will be at 0x4000_0000. You can check it in .map file.

3) I have created an utility that load all the .bin file after the program build because :

"The RAM.mot cannot be downloaded by BAM directly. It must be continuous image without gaps. You can either write some program on PC that will create continuous binary file or you can download the project into RAM by debugger, then save the content of RAM memory to binary file."

4) Disable core wDog as the first instruction of mian function :


__asm static void dis_core_wdog (void)
{
//** Core WDOG*****//
li r6,0x00
mtspr 340,r6


blr
}

 

5) I don't understand the RAM Init : 

"Notice that downloading of code also initializes ECC. Area that is not written by BAM will contain ECC errors. If your application wants to use uninitialized RAM, it must be explicitly initialized by your SW."

I don 't do this or I don't understand where and the function to do this . I know that the code pass through the MPC5644A_HwInit.c in user init function , because in prefix file i have defined

#define VLE_IS_ON 0
#define CALL_USR_INIT 1

In this way once i have setted = 1 the initi derivative the code pass from the INIT_Derivative function that I have modified like this:

/*************************************************************************/
__asm void INIT_Derivative(void)
{
nofralloc

/* Disable the software watch dog. */
mflr r26
bl cfg_WATCHDOG
mtlr r26

lis r11,L2SRAM_LOCATION@h
ori r11,r11,L2SRAM_LOCATION@l

/* Loops to cover L2SRAM, stmw allows 128 bytes (32 GPRS x 4 bytes) writes */
lis r12,L2SRAM_CNT@h
ori r12,r12,L2SRAM_CNT@l
mtctr r12

init_l2sram_loop:
stmw r0, 0(r11) /* Write 32 GPRs to SRAM */
addi r11,r11,128 /* Inc the ram ptr; 32 GPRs * 4 bytes = 128B */
bdnz init_l2sram_loop /* Loop for L2SRAM_CNT */
blr
}

where:

L2SRAM_CNT = 0x30000 / 128;

START_EXTERNAL_RAM = 0x20000000;

 

this function should do the ram init loop but if my code pass from here I have an exception on IVOR1trap :

IVOR1trap: b IVOR1trap // Machine check / (NMI) interrupt handler
// ISI, ITLB Error on first instruction fetch for an exception handler
// Parity Error signaled on cache access
// External bus error

I have tryed also to initialize only ram after the end of ram address of the RAM code loaded via BAM without any result. 

I know that i lost something or I 'm doing something wrong , about this, and  any help or advice is greatly appreciated .

thanks in advance 

Alessandro Sirtori .

Labels (1)
0 Kudos
7 Replies

236 Views
alessandrosirto
Contributor II

Yep.... First mistake... It was faulty value of L2SRAM_LOCATION and L2SRAM_CNT :

Now the value are :

/* How many writes with stmw, 128 bytes each, are needed to cover
the whole L2SRAM (used for L2 SRAM initialization) */
L2SRAM_CNT = 0x28190 / 128 ;                  /*      previous one   0x30000 / 128;

/* L2 SRAM Location (used for L2 SRAM initialization) */

L2SRAM_LOCATION = 0x40007E70;           /*    previous one    0x40000000;

I get this value L2SRAM_LOCATION  ,  that would be the next value of last address present in the .bin file 

L2SRAM_CNT  would be = 0x30000  (ram size ) - 0x7E70 (size that I wrote) .

The section are  always : 

init: org = 0x40000000, len = 0x00001000
pseudo_rom: org = 0x40001000, len = 0x00003000
exception_handlers: org = 0x40004000, len = 0x00001000
internal_ram: org = 0x40005000, len = 0x0001B000
heap : org = 0x40020000, len = 0x00008000
stack : org = 0x40028000, len = 0x00008000

Now I have not IVOR6 exception , I can send the program with j_link and works ,  but after the code download with BAM the application does not run . Do you have any Idea?  attched you will find the first start CAN handshaking , the protocol works and the file I'm pretty sure is continuos...

thanks in advance.

CAN Sniff.png 

0 Kudos

236 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

L2SRAM_LOCATION = 0x40007E70;

- the address must be aligned to 128 bytes when using stmw and writing 128 bytes.

Then you can simply dump the SRAM before and after execution of this init code and you can compare the results.

Lukas

0 Kudos

236 Views
alessandrosirto
Contributor II

Correct... changed the parameters like :

L2SRAM_CNT = 0x28180 / 128 ; 

L2SRAM_LOCATION = 0x40007E80; 

and I add in program loaded via BAM all the value in address from  0x40007E70; to 0x40007E80 not included as 0 .

The result is the same the program after the download doesn't start. 

So , I have loaded the program with j-link and i dump RAM of the program , after save it on file . I compare it with .mot build file . These are the same exept for the address that are not present in mot file due to build. After I have compared the RAM file that i used to load the program with the dump file and are the same.. exept for the address that are not present in mot file due to build , I fill it with 0  value (like bin file) and the dump file have other I think due to the RAM initialization.

No idea..

0 Kudos

236 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

I think I know what's going on now.

When using RAM target in CodeWarrior, initialized data (like .sdata section) are not copied to RAM memory in startup files. It's part of the image which is loaded to RAM memory by debugger. Only non-initialized variables (like .sbss) are cleared by startup files.

So, when you load image to RAM, you should include also mentioned segments. If you don't do that, the program may crash because it probably relies on the init values. Or other option which comes into my mind - do not use initialized variables.

Regards,

Lukas

0 Kudos

236 Views
alessandrosirto
Contributor II

Hi Lukas , 

First thanks for you help , I was a bit confused was not the IVOR1 but the IVOR6 , sorry. 

As you can see in the attached image sram_init.png the code pass through the sram init but if I suspend program is in IVOR6 . Do you have any Idea ? 

thanks, sram_init.pngIVOR6.png

0 Kudos

236 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Are you sure you are not overwriting own code in RAM? What is the value of L2SRAM_LOCATION? If IVOR6 is triggered, this could be the reason. As I wrote before, check SRR0 register and then corresponding address in RAM memory. You will see if it is overwritten or not.

Regards,

Lukas

0 Kudos

236 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

this would require some debugging... First step - if IVOR1 is triggered, what is the content of MCSRR0 and MCSR registers? MCSRR0 contains address of instruction which caused the exception and MCSR reflects source of the exception.

Regards,

Lukas

0 Kudos