MPC5634M Bam problem

cancel
Showing results for 
Search instead for 
Did you mean: 

MPC5634M Bam problem

507 Views
Contributor II

Chip:MPC5634M,Crystal:12M.Through the bam to guide the application in RAM, but the application can not run?

I can run the application download application through TATG.The adaptive baud rate is used250k。Trouble to help me the following, please help me find the reason. thank you all.Lukas ZadrapaDhaval ShahKirk R Humphries

Original Attachment has been moved to: Example-TRK_MPC5634M-FlexCAN-SimpleTX-CW29-(1).zip

0 Kudos
19 Replies

14 Views
NXP TechSupport
NXP TechSupport

Hi,

how did you created binary image? Have you followed all instruction described in this post?

https://community.nxp.com/thread/320166#comment-384300 

Is the BAM sending echo characters for all data you sent?

Regards,

Lukas

0 Kudos

14 Views
Contributor II

Thank you for your reply。I follow your way to build binary image.All my data BAM has to return,but when the data transmission is completed, the microcontroller is not running.

MEMORY
{

init: org = 0x40000000, len = 0x00001000 //4k
exception_handlers: org = 0x40001000, len = 0x00001000
pseudo_rom: org = 0x40002000, len = 0x00001000
internal_ram: org = 0x40003000, len = 0x00001000

heap : org = 0x40004000, len = 0x00001000 // Heap start location
stack : org = 0x40005000, len = 0x00001000 // Start location for Stack

}

If i delete start.c this paragraph

li r16, 0
li r17, 0
li r18, 0
li r19, 0
li r20, 0
li r21, 0
li r22, 0
li r23, 0
li r24, 0
li r25, 0
li r26, 0
li r27, 0
li r28, 0
li r29, 0
li r30, 0
li r31, 0

//init internal_ram,heap,steak
lis r11,0x4000
ori r11,r11,0x3000 //Load strat address 0x4000_3000
li r12,0xc0 //12k/4 bytes/16 GPRs = 192 = 0xc0.
mtctr r12

init_SRAM_loop:
stmw r16,0(r11)
addi r11,r11,0x40 //increment the ram pointer by 64 bytes
bdnz init_SRAM_loop

//init exception_handlers
lis r11,0x4000
ori r11,r11,0x1000 //Load strat address 0x4000_1000
li r12,0x40 //4k/4 bytes/16 GPRs = 64 = 0x40.
mtctr r12

init_excep_loop:
stmw r16,0(r11)
addi r11,r11,0x40 //increment the ram pointer by 64 bytes
bdnz init_excep_loop

The program can be run by JTAG download, but can not be run through BAM download.

If I add this paragraph, through the BAM program can not run properly, through JTAG can not run properly.

I mainly want to FLASH through the RAM to operate。

Save me, i really do not know that.

0 Kudos

14 Views
NXP TechSupport
NXP TechSupport

The code for SRAM initialization seems to be correct.

What does happen if you add only some very simple code to the project? Just toggle GPIO in endless loop or something like that. Is this working? You can add this code at beginning of the main function or directly to __start.

Regards,

Lukas

0 Kudos

14 Views
Contributor II

pastedImage_1.png

0 Kudos

14 Views
NXP TechSupport
NXP TechSupport

Sorry but I'm lost, I do not understand your description. Could you describe it in more detailed way?

Lukas

0 Kudos

14 Views
Contributor II

li r16, 0
li r17, 0
li r18, 0
li r19, 0
li r20, 0
li r21, 0
li r22, 0
li r23, 0
li r24, 0
li r25, 0
li r26, 0
li r27, 0
li r28, 0
li r29, 0
li r30, 0
li r31, 0

//init internal_ram,heap,steak
lis r11,0x4000
ori r11,r11,0x3000 //Load strat address 0x4000_3000
li r12,0xc0 //12k/4 bytes/16 GPRs = 192 = 0xc0.
mtctr r12

init_SRAM_loop:
stmw r16,0(r11)
addi r11,r11,0x40 //increment the ram pointer by 64 bytes
bdnz init_SRAM_loop

//init exception_handlers
lis r11,0x4000
ori r11,r11,0x1000 //Load strat address 0x4000_1000
li r12,0x40 //4k/4 bytes/16 GPRs = 64 = 0x40.
mtctr r12

init_excep_loop:
stmw r16,0(r11)
addi r11,r11,0x40 //increment the ram pointer by 64 bytes
bdnz init_excep_loop

If I delete the above code, I joined the FLASH operation of the program can be downloaded to the RAM through the JTAG to run, and complete the FLASH operation, but can not be added through the BAM FLASH operation code to boot into RAM. If I do not delete the above code, I can not join the FLASH code through the JTAG boot to the normal operation of the RAM, BAM can not boot to the normal operation of RAM.

What would be the reason for this ?

0 Kudos

14 Views
NXP TechSupport
NXP TechSupport

I can see you have commented out the __init_data() function:

pastedImage_1.png

So, global variables are not initialized - including pointers to SSD flash functions:

extern unsigned int FlashInit_C[];
extern unsigned int FlashErase_C[];
extern unsigned int BlankCheck_C[];
extern unsigned int FlashProgram_C[];
extern unsigned int ProgramVerify_C[];
extern unsigned int CheckSum_C[];
extern unsigned int GetLock_C[];
extern unsigned int SetLock_C[];

When you call the FlashInit:

returnCode = pFlashInit( &ssdConfig );

... it will crash...

Regards,

Lukas

0 Kudos

14 Views
Contributor II

Thank you for your reply.I added your prompt code, code but I will not run through the guidance of BAM into RAM. Examples of this is my revised, and bam recorded data transmission, would you please help me, thank you!!!!!What would be the reason for this ?

0 Kudos

14 Views
NXP TechSupport
NXP TechSupport

I can see that the initial values of the global variables are loaded to RAM memory together with elf file. So, the initial values are already part of your binary image and there are some data at 0x40003000. This seems to be a feature of linker when creating RAM target for debugging. Function __init_data does not re-init these values (but I can see it copies some different data anyway).

So, I can see two solutions:

- initialize global variables manually at beginning of main function. In your example, initialize pointers to SSD functions and ssd_config structures. This is the easiest workaround.

- second option would be to get the last init address from linker file and initialize the RAM memory only behind this address.

Regards,

Lukas

0 Kudos

14 Views
Contributor II

Thank you for your advice.If i adopt the first suggestion, what should i do? Can you give an example?
If I adopt the second suggestion, do I get last init address?
Thank you very much for your help, but I am confused about your suggestion. Do not know what to do

0 Kudos

14 Views
NXP TechSupport
NXP TechSupport

I have to run away in a few minutes, so here is just quick example for the first solution:

pointers are defined in this way in the project:

/* Assign function pointers */
pFLASHINIT     pFlashInit     = (pFLASHINIT)     FlashInit_C;
pFLASHERASE    pFlashErase    = (pFLASHERASE)    FlashErase_C;
pBLANKCHECK    pBlankCheck    = (pBLANKCHECK)    BlankCheck_C;
pFLASHPROGRAM  pFlashProgram  = (pFLASHPROGRAM)  FlashProgram_C;
pPROGRAMVERIFY pProgramVerify = (pPROGRAMVERIFY) ProgramVerify_C;
pCHECKSUM      pCheckSum      = (pCHECKSUM)      CheckSum_C;
pGETLOCK       pGetLock       = (pGETLOCK)       GetLock_C;
pSETLOCK       pSetLock       = (pSETLOCK)       SetLock_C;

Because the pointers are not initialized (cleared by your init code) initialize them like this:

int main(void) {

   pFlashInit     = (pFLASHINIT)     FlashInit_C;

   pFlashErase    = (pFLASHERASE)    FlashErase_C;

   .... and so on...

Regards,

Lukas

0 Kudos

14 Views
Contributor II

pFlashInit = (pFLASHINIT) FlashInit_C;
pFlashErase = (pFLASHERASE) FlashErase_C;
pBlankCheck = (pBLANKCHECK) BlankCheck_C;
pFlashProgram = (pFLASHPROGRAM) FlashProgram_C;
pProgramVerify = (pPROGRAMVERIFY) ProgramVerify_C;
pCheckSum = (pCHECKSUM) CheckSum_C;
pGetLock = (pGETLOCK) GetLock_C;
pSetLock = (pSETLOCK) SetLock_C;
//

A.BDMEnable=0xC3F88000;
A.c90flRegBase=0x00000000;
A.highBlockNum=0;
A.lowBlockNum=0;
A.mainArrayBase=0;
A.mainArraySize=0;
A.pageSize=0x08;
A.shadowRowBase=0;
A.shadowRowSize=0;
A.midBlockNum=0;

I have changed as you suggest, but I met a problem, and not just erase FLASH when they go wrong in low and mid addr space of flash array 0。

CFLASH0.LMLR.R=0xA1A11111; /
CFLASH0.LMLR.B.LLOCK=0;
CFLASH0.SLMLR.R=0xC3C33333; 
CFLASH0.SLMLR.B.SLLOCK=0; 
CFLASH1.HLR.R=0xB2B22222;
CFLASH1.HLR.B.HBLOCK=0;
CFLASH2.HLR.R=0xB2B22222;
CFLASH2.HLR.B.HBLOCK=0;
//Erase Bank0, Array0
CFLASH0.MCR.B.ERS=1;
//step2:
//CFLASH0.LMSR.B.LSEL=0b11111111; //Select the block, or blocks, Two low address space blocks are selected for erase
//CFLASH0.LMSR.B.MSEL=0b1;
//CFLASH0.LMSR.R = 0x00000080;
//step3:
sp_FlashPageAddr32=(vuint32_t *)MAS_MED0_ADDR_128KB;
*sp_FlashPageAddr32=0xFFFFFFFF; //program data write
*((unsigned int*) 0x00048928) = 0xFFFFFFFF;
CFLASH0.MCR.B.EHV=1 ;
while(CFLASH0.MCR.B.DONE==0){ }//Wait until the FLASH_MCR[DONE] bit goes high
//step5:
while(CFLASH0.MCR.B.PEG==0){ }//Confirm FLASH_MCR[PEG] = 1.
//step6:
CFLASH0.MCR.B.EHV=0; //Write a logic 0 to the FLASH_MCR[EHV] bit.
//step7:If more blocks are to be erased, return to step 2
//step8:
CFLASH0.MCR.B.ERS=0;

I erase this so can't erase x40000 0-0 x80000 segment。

What would be the reason for this ?Where is my wrong?Thank you for your answer。

0 Kudos

14 Views
NXP TechSupport
NXP TechSupport

Hi,

why do you waiting for PEG bit in this piece of code for erase?

See the sample code below how to do erase and program:

    /* Unlock all blocks in CFLASH0 except shadow block */
  CFLASH0.LMLR.R = 0xA1A11111;
  CFLASH0.LMLR.R = 0x00100000;
 
  CFLASH0.SLMLR.R = 0xC3C33333;
  CFLASH0.SLMLR.R = 0x00100000;      
 
  /* Erase all blocks in CFLASH0 */
    CFLASH0.MCR.B.ERS = 1;
    CFLASH0.LMSR.R = 0x000300FF; /* Select blocks */    
    *(unsigned int *)0x00010000 = 0xFFFFFFFF; /* Interlock write - write to any address in selected memory */
    CFLASH0.MCR.B.EHV = 1;
    while(CFLASH0.MCR.B.DONE == 0);
    CFLASH0.MCR.B.EHV = 0;
    CFLASH0.MCR.B.ERS = 0;
    
    /* Program double word */
    CFLASH0.MCR.B.PGM = 1;
    *(unsigned int *)0x00001000 = 0xAABBCCDD; /* interlock write */
    *(unsigned int *)0x00001004 = 0x11223344; /* program data write */
    CFLASH0.MCR.B.EHV = 1;
    while(CFLASH0.MCR.B.DONE == 0);
    CFLASH0.MCR.B.EHV = 0;
    CFLASH0.MCR.B.PGM = 0;

Regards,

Lukas

0 Kudos

14 Views
Contributor II

Thank you for your answer and advice

0 Kudos

14 Views
Contributor II

pastedImage_1.png

I look at the data provided in the manual。

0 Kudos

14 Views
NXP TechSupport
NXP TechSupport

Oops, sorry, I mixed up PEG and PGM. My fault.

0 Kudos

14 Views
Contributor II

Thank you very much, I need to initialize ssd_config structures? If you need any good advice? Can you tell me what the meaning of “Boot can be performed from any block in the Low Address Space except blocks 1b and 2b. ”is?What does boot mean?

0 Kudos

14 Views
Contributor II

I'm sorry, my English is very bad.If my program is just open CAN, my program is able to boot through BAM to RAM in the normal operation. If I add c-array_driver in the program, my program through BAM boot to RAN is not working properly.I joined the c-array_driver program through the JTAG download to RAM as shown above, I click the source go button program can not run, has been stuck in the starting position does not move.Thank you for your answer, i do not know how to do it?

0 Kudos

14 Views
Contributor II

Thank you for your answer.If you open the CAN, you can download and run through BAM.

After loading the FLASH can not run, through the emulator download, found after loading

FLASH program has been at START.C Department.

0 Kudos