IntFlash Processor Expert component in CW10, Coldfire V1

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

IntFlash Processor Expert component in CW10, Coldfire V1

Jump to solution
2,606 Views
antoniomagrì
Contributor II

I am developing a project with MCF51AC256A, using Codewarrior 10.7 with Processor Expert.

I use a IntFlash component to store some data in the device (calibration settings, little bits of diagnostic information) that must survive between power cycles.

I recently discovered that whenever my application tried to write to flash the CPU would reset. I had changed nothing in the software related to flash management, and moreover the actual code that manages the writes is generated by Processor Expert so I was a little puzzled.

When I started debugging I could see that something was wrong with the FnCmdInRam_ routine that the PE code copies to the stack and executes to actually perform operations with the Flash controller.

I could see that something was different between the original function in flash and the copy in the stack. I will spare you all the investigation and jump to the conclusion:

the PE code creates a structure in the stack with a fixed size:

typedef struct {
  byte code[0x36];                     /* Structure required to copy code to ram memory */
  /* Size of this structure needs to be at least (but best) the size of the FnCmdInRam_ */
} TFnCmdInRamStruct;
but when I changed the Optimization setting for the Coldfire compiler from "size" to "speed" the size of the function jumped from 
00000410 0000002C .text   FnCmdInRam_    (IFsh1_c.obj)

to

00000410 00000038 .text   FnCmdInRam_    (IFsh1_c.obj)


so the function would not fit into the RAM structure any longer!

I was able to solve this issue by disabling code generation for the component and manually increasing the structure size.

But! I have a question for the PE folks... would it be possible to have a correct behavior out of the box? It seems strange to me that changing the optimization setting would break the component, without at least a warning...

Bye,

Antonio

0 Kudos
Reply
1 Solution
2,406 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hello Antonio,

Thanks for your clarification. I was informed by processor expert developer that the processor expert generated code is only tested and verified by default compiler setting level.

Your are right there is no interface to change the size of FnCmdInRam. If user wants to change the size, the solution is to set the IntFLASH by right clicking the component, "Code Generation", "Don't write generated component modules". they modify the code manually.

pastedImage_1.png


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

5 Replies
2,406 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hello Antonio,

I just tested IntFlash on my side under CW10.7 and 51ac256 demo board. but I didn't see any problem. see attached video.


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply
2,406 Views
antoniomagrì
Contributor II

Hello Jennie,

I am afraid my explanation was not very clear...

there is no problem with the component in itself: it works perfectly if the size of the FnCmdInRam routine does not exceed the size of the buffer that is allocated in the stack. With the default compiler settings this never happens.

I am using Far (32bit) Code Model.

With the default Size Optimization the size of FnCmdInRam is 0x2C, that fits in the 0x36 byte buffer.

But with Speed Optimization the size of FnCmdInRam becomes 0x38. So it is bigger than the buffer and stack corruption will happen.

So my question really was if the PE code generator could adjust the buffer size depending on project settings, because I know that the generated code will not work correctly in at least this case.

Thank you very much for your attention,

Antonio

0 Kudos
Reply
2,407 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hello Antonio,

Thanks for your clarification. I was informed by processor expert developer that the processor expert generated code is only tested and verified by default compiler setting level.

Your are right there is no interface to change the size of FnCmdInRam. If user wants to change the size, the solution is to set the IntFLASH by right clicking the component, "Code Generation", "Don't write generated component modules". they modify the code manually.

pastedImage_1.png


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

2,406 Views
antoniomagrì
Contributor II

Thanks Jennie for the clarification, I will do as you say!

Antonio

0 Kudos
Reply
2,406 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

You are welcome Antonio.

Jennie Zhang

0 Kudos
Reply