Problem in code move

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Problem in code move

跳至解决方案
1,673 次查看
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 项奖励
回复
1 解答
1,470 次查看
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 项奖励
回复
5 回复数
1,470 次查看
wangzhongyuan
Contributor I

My MCU is MC9S12ZVCA192.

1524039172(1).jpg1524039243(1).jpg

0 项奖励
回复
1,470 次查看
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 项奖励
回复
1,470 次查看
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 项奖励
回复
1,471 次查看
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 项奖励
回复
1,470 次查看
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

What MCU are you using?

Can you attach the whole .prm linker file?

Regards,

Daniel

0 项奖励
回复