Hi,
I am working with a MC9S12XEP100 CAN bootloader project. After compiled the project I found the bootloader used two function, _COPY and _CASE_CHECKED_BYTE. These two functions are generated from rtshc12.c.o (ansixbi.lib). Because my bootloader uses these two functions. I can't erase the NON_BANKED segment, where these two functions located. Or my bootloader will die. That means I can't update the NON_BANKED segment.
I want to ask is there any way to avoid my bootloader using these two functions. In order to let me update NON_BANKED segment as well as user application.
Thanks.
Here's some segment of my project.
void CanStatusAck(UINT8 sta)
{
TxMsg.ID = UpLoadID;
TxMsg.DtLen = 1;
TxData[0] = sta;
TxMsg.data=(UINT8 *)&TxData[0];/*It looks like the _COPY function is called there*/
(void)CanTxFrame(TxMsg);
}UINT8 CanTxFrame(CanMsg_t msg)
{
unsigned char send_buf, sp;
if(msg.DtLen > 8)
return(FALSE);if(CAN0CTL0_SYNCH==0)
return(FALSE);send_buf = 0;
do
{
CAN0TBSEL=CAN0TFLG;
send_buf=CAN0TBSEL;
}
while(!send_buf);
CAN0TXIDR0 = (unsigned char)(msg.ID>>3);
CAN0TXIDR1 = (unsigned char)(msg.ID<<5);
for(sp = 0; sp < msg.DtLen; sp++)
*((&CAN0TXDSR0)+sp) = msg.data[sp];
CAN0TXDLR = msg.DtLen;
CAN0TFLG = send_buf;
return(TRUE);
}
解決済! 解決策の投稿を見る。
Hi XY,
Thank you for testing and results.
The “case” command might be replaced by set of “if” conditions.
How did you move bootloader code from flash to RAM?
The first principle is defining code directly at RAM by #pragma CODE_SEG linker commands. The code is automatically loaded into RAM during startup.
The second principle is creating code on Flash and move it into RAM by some copy function. Te example might be for example AN4258 software.
The compiler might be configured for generating position-independent code by -Pic compiler option. However I suppose, that it will not solve this issue.
I hope it helps you.
Have a great day,
Radek
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi XY,
Unfortunately, I was not able replicate it on my side yet. I guess, that different compiler settings might be a reason.
for(sp = 0; sp < msg.DtLen; sp++)
{
*((&CAN0TXDSR0)+sp) = msg.data[sp];
asm NOP;
}
The assembler code blocks compiler optimizations.
If nothing helps, please send us your project for review. If it is not public, you may create a ticket for us:
https://community.nxp.com/docs/DOC-329745
I hope it helps you.
Have a great day,
Radek
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi
I have tried all the possible solutions you wrote, but none of them works. I think it's when a big struck to be sent into another function as a parameter that the project call the _COPY. In the code I posted earlier. When the TxMsg (it's a struct like ) being sent into CanTxFrame(TxMsg) as a parameter, the _COPY was called (by compiler). In order to remove the parameter transfer process. I put the CanTxFrame's code directly in CanStatusAck function and it works. The _COPY function was removed from my bootloader successfully.
But there is also another named _CASE_CHECKED_BYTE being called when I use "case". I can't find solutions to remove _CASE_CHECKED_BYTE yet.
Thank you anyway.
Hi XY,
Thank you for testing and results.
The “case” command might be replaced by set of “if” conditions.
How did you move bootloader code from flash to RAM?
The first principle is defining code directly at RAM by #pragma CODE_SEG linker commands. The code is automatically loaded into RAM during startup.
The second principle is creating code on Flash and move it into RAM by some copy function. Te example might be for example AN4258 software.
The compiler might be configured for generating position-independent code by -Pic compiler option. However I suppose, that it will not solve this issue.
I hope it helps you.
Have a great day,
Radek
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi
My bootloader code was written on the flash and moved to ram by a copy function. I removed _COPY function yesterday. I changed "case" command into "if else" condition just now and the _CASE_CHECKED_BYTE was removed successfully! So these two functions will not be called anymore. I can put the NON_BANKED segment into ROM_C000 finally. I think the NON_BANKED can be updated by bootloader too.
Thank you for your help.
You are welcome.
I am glad that it works now.
Have a great day,
Radek
Now I am ready to use the can_bootloader to upload program ,And where to download the project of can_bootloader .Can you send the project ,Involved in the data to me? My email is 407214944@qq.com.3ks!