AnsweredAssumed Answered

BAM Upload program MPC5644A

Question asked by Alessandro Sirtori on Jul 22, 2019
Latest reply on Jul 29, 2019 by Lukas Zadrapa

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 .

 

 

Outcomes