Problem in code move

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

Problem in code move

Jump to solution
1,672 Views
wangzhongyuan
Contributor I

Hi eveyone

I have some question in Flash Program. I segemented non-paged FLASHs named BOOT_MEM and relocated this segement to RAM (in .prm file). So i need to copy my function code in RAM. But something wrong in this step. When run my program, it was paused in move code function and reminder me that "No source available for "0x000001 (0x000001)() "

this is main function

void main(void)
{
    word sector = 0;
    dword addr = 0xFD8000;
    word databuffer[4] = {0x1234, 0x2344, 0x4562, 0x4525};
    DrSys_Cpu_Lock();
    INIT_PLL_64M();    // 
    Flash_Init();
    DrSys_Cpu_Unlock();
    Code_Move((dword*)0x00FD6400, (dword*)0x00003c00,0x400);
    PFlash_Write(addr, databuffer);
    while(1)
    {
    Dalay();
 
    }
}

this is Code_Move function

void Code_Move(dword *source, dword *desk, dword size)
{
    while (size--)
    {
        *desk++ = *source++;
    }   
}

0 Kudos
Reply
1 Solution
1,469 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,
You want to copy from segment
BOOT_MEM = READ_ONLY 0xFD6400 TO 0xFD67FF;
which is 0x400 wide
to
RAM_BOOT = READ_WRITE 0x003C00 TO 0x003FFF;
which is also 0x400 wide.

But the code you are using copies 0x1000 of data, because both the pointers desk and source increment by 4 bytes while the size variable decrements by 1.
So, if you change the size argument to 0x100, it should work.
Code_Move((dword*)0x00FD6400, (dword*)0x00003c00, 0x100);

Regards,
Daniel

View solution in original post

0 Kudos
Reply
5 Replies
1,469 Views
wangzhongyuan
Contributor I

My MCU is MC9S12ZVCA192.

1524039172(1).jpg1524039243(1).jpg

0 Kudos
Reply
1,469 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

Please step the code and watch size, source and desk variables.

The size variable decrements by 1 whereas desk and source by 4.

So after 100 iterations, you reach address RAM_BOOT 0x4000.

Regards,

Daniel 

0 Kudos
Reply
1,469 Views
wangzhongyuan
Contributor I

Hi

Thanks for your apply.

Do you have any document about this? I want to know about this detailed.

I also donnot understand what about you say.

0 Kudos
Reply
1,470 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,
You want to copy from segment
BOOT_MEM = READ_ONLY 0xFD6400 TO 0xFD67FF;
which is 0x400 wide
to
RAM_BOOT = READ_WRITE 0x003C00 TO 0x003FFF;
which is also 0x400 wide.

But the code you are using copies 0x1000 of data, because both the pointers desk and source increment by 4 bytes while the size variable decrements by 1.
So, if you change the size argument to 0x100, it should work.
Code_Move((dword*)0x00FD6400, (dword*)0x00003c00, 0x100);

Regards,
Daniel

0 Kudos
Reply
1,469 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

What MCU are you using?

Can you attach the whole .prm linker file?

Regards,

Daniel

0 Kudos
Reply