Programming to RAM through BAM

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

Programming to RAM through BAM

Jump to solution
1,178 Views
jasonhd
Contributor III

Hello everyone, the microcontroller I use is mpc5634m. Now I want to write the test program to RAM by using esci in BAM mode. The test program sends out a few characters, but the program is not executed in RAM. As a test comparison, I use OSBDM to brush the RAM program to the microcontroller. The program can be executed. I don't know why. Can someone help me? The following is the source program, and I use my own upper computer program to write RAM.mot data of the whole process.

I follow this step, modify the start address, and use 0xff to fill the discontinuous memory address in the upper computer program, but the result is still unsuccessful.

 
 
 
0 Kudos
1 Solution
1,142 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Here you can find the reason why it is necessary to initialize the SRAM:

lukaszadrapa_0-1611326686145.png

It's necessary to initialize SRAM in startup files before you read or write the SRAM. Easiest way: search for MPC55xx_init_debug.c file and change

#define INIT_DERIVATIVE_INTERNAL_SETUP 0

to

#define INIT_DERIVATIVE_INTERNAL_SETUP 1

Then function INIT_Derivative will be called in startup files.

It is necessary to change the base address and size. In the original code, base address is 0x4000_0000. You need to change it to end of your RAM image. Align the address to 128 bytes. And then change also the size.

stmw instruction is used for initialization - it writes all 32 general purpose core registers to SRAM.

 

When reading the description, I guess that it's really caused by the ECC.

And also be aware that core watchdog is enabled:

lukaszadrapa_1-1611327085854.png

It's necessary to refresh it or disable it.

Regards,

Lukas

 

View solution in original post

0 Kudos
6 Replies
1,176 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

typical issues are:

- did you double check if the __start function is at 0x4000_0000?

- are you waiting for echo bytes before sending next byte? Are all echo bytes correct?

- are you sure the image is continuous?

Regards,

Lukas

 

0 Kudos
1,173 Views
jasonhd
Contributor III

Thank you Lukas

1.  I set the address to 0x40000100.

RAM.map is shown in the table below:

jasonhd_0-1611104791670.png

When using OSBDM to debug ram target, the program counter (PC) points to:

jasonhd_1-1611104979513.png

When the host computer sends, the address is the same:

jasonhd_2-1611105214642.png

2. Yes, I check each echo byte in the host computer, and continue to send the next byte after confirming the consistency.

jasonhd_3-1611105512925.png

3. RAM.mot is not continuous, but I set it to be filled with 0xff in the sending program of upper computer.

jasonhd_4-1611105648086.png

jasonhd_5-1611105747576.png

 

 

 
 
0 Kudos
1,157 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

OK, this seems to be correct.

Then I mentioned in the procedure (https://community.nxp.com/thread/320166#comment-384300

"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. "

In the linker file, stack is usually placed at the end of RAM memory. Do you load the image up to end of RAM / stack? If not, the RAM is not initialized. Second option is to initialize the rest of RAM by your startup files. This option is better, it's much faster than loading via BAM. See INIT_Derivative function. This can be used. It's not called in case of RAM project but you can reuse the code.

Regards,

Lukas

 

0 Kudos
1,147 Views
jasonhd
Contributor III

Sorry, I don't know how to use that function to initialize RAM? Call in __start or in main function? Initialize all ram or unused ram of my image, because the image is divided into several areas intermittently. By the way, in today's experiment, it happened that the program could work several times after using BAM to swipe into RAM, but it stopped automatically after a few minutes, and it didn't work every time without any change, but sometimes it didn't work. I don't know if it was the reason of ECC.

 
 
 
0 Kudos
1,143 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Here you can find the reason why it is necessary to initialize the SRAM:

lukaszadrapa_0-1611326686145.png

It's necessary to initialize SRAM in startup files before you read or write the SRAM. Easiest way: search for MPC55xx_init_debug.c file and change

#define INIT_DERIVATIVE_INTERNAL_SETUP 0

to

#define INIT_DERIVATIVE_INTERNAL_SETUP 1

Then function INIT_Derivative will be called in startup files.

It is necessary to change the base address and size. In the original code, base address is 0x4000_0000. You need to change it to end of your RAM image. Align the address to 128 bytes. And then change also the size.

stmw instruction is used for initialization - it writes all 32 general purpose core registers to SRAM.

 

When reading the description, I guess that it's really caused by the ECC.

And also be aware that core watchdog is enabled:

lukaszadrapa_1-1611327085854.png

It's necessary to refresh it or disable it.

Regards,

Lukas

 

0 Kudos
1,132 Views
jasonhd
Contributor III

Thanks. When I initialized ram and disabled the core watchdog, it worked.

 
 
0 Kudos