Flash Programming: CW-Debugger vs. TCL vs. TTF

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

Flash Programming: CW-Debugger vs. TCL vs. TTF

1,868 Views
barakmanos
Contributor III

Here is a problem that I’ve been struggling with unsuccessfully (as of yet).

 

I am using CW Target Tasks in order to burn (program) an image to flash.

 

My target MCU is MC9S08QG4.

 

I have configured the task (TTF file) to execute the following operations:
– Unprotect all sectors
– Erase all sectors
– Program image

 

Flash address range is 0xF000 thru 0xFFFF.

 

For all it matters (though I don’t think that it has anything to do with the problem at hand), the security bits (SEC01:SEC00) are located at 0xFFBF.

 

Now, this task occasionally fails.
The output I get in the console varies.
Here are a few examples:
– Error: Erase sector failed. Operation timeout.
– Error: Protect Command Failed. Operation timeout.Failed to erase sector data.
– Error: Detect frequence Loop count suspended
– Error: Can’t resume target HC/RS/S12Z GDI Protocol Adapter : An error occurred while trying to write registers. The Debugger can not write one register.

 

If it helps, then you can see the entire output (successful and non-successful cases) at:

https://community.freescale.com/thread/391365.

 

Now, I would normally suspect the HW (power supply, cable length, CPU clock / oscillator, physical connections, etc).

However, when I program the same image via the debugger (i.e., Run Configuration –> Debug), it always completes successfully.

 

So there is definitely a “soft” way to resolve the problem that I am experiencing, and I am left to conclude that the CW debugger performs additional operations during the image-download procedure (operations which I have skipped in my task).

 

The question is – what exactly are these operations?

 

I have searched through my project’s Run/Debug settings, but I have not found anything to explain it. In fact, I feel quite limited in the ability to even compare the two methods, as they seem to be using a different interface and/or language:
– The target task uses TCL (though the TTF file is in XML format, so I don’t quite see how I can add TCL commands to it anyway).
– The CW image-download procedure runs via some other functionality, which I do not fully understand.

 

One way to see what CW is actually doing “behind the scene”, is by enabling the Flash Programming Dialog option (in the project’s launch-configuration).
This is a very clumsy utility (dialog-box) which disappears automatically as soon as the image-download process completes, so I need to disconnect the MCU during the process, and be extremely lucky in order to see the entire log up to the point when it’s done.
To make it worse, it doesn’t even allow you to copy the text (though I could “live with that”).

 

In any case, here is what I’ve managed to get from that dialog-box (not including what I believe is just “status messages”):
CMD>RE
CMD>CM C:\Freescale\CW MCU v10.6\MCU\bin\Plugins\support\hc08\gdi\P&E\9s08gq4.s8p
CMD>EM
CMD>PM

 

I suppose that the above is equivalent to Reset, Erase, Program (and that an additional Verify or something similar would probably follow). But how can I emulate that using TCL (or if possible, how can I add it in the TTF file)?

 

The following description in the MCU’s data-sheet provides me with a good reason to suspect that CW sets the FCDIV register during the process:
“Before any program or erase command can be accepted, the FLASH clock divider register (FCDIV) must be written to set the internal clock for the FLASH module to a frequency between 150 kHz and 200 kHz. This register can be written only once, so normally this write is done during reset initialization.”.

 

However, I can’t see how to access chip registers via TCL (and most certainly via TTF).

 

I have also posted this question on Erich Styger's blog, at:

https://mcuoneclipse.com/2012/08/03/codewarrior-flash-programming-from-a-dos-shell/

 

Thank you very much for reading through

Labels (1)
0 Kudos
Reply
4 Replies

1,361 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi,

One possible cause of your problem is clock trim.

one difference between debugging from Simple Flash/Task   and debugger is that:  TRIM can work for debug while not for Simple Flash/Task.

that's to say, We can only use debugger to perform trim but can’t with CW standalone programmer in the same way. CW is a professional development tool(edit, built, debug), but not professional standalone programmer.  If user need advance feature in standalone programmer, we need other 3rd programmer software.

http://www.pemicro.com/products/product_viewDetails.cfm?product_id=27

Hope this helps!

Jennie Zhang

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

0 Kudos
Reply

1,361 Views
barakmanos
Contributor III

Just to complete this post - the PROGHCS08 utility (from P&E-Micro) indeed resolves the problem.

Here is a usage example:

C:\PEMicro\PROGHCS08\cproghcs08.exe prog.cfg INTERFACE=USBMULTILINK PORT=USB1 /logfile prog.log

Where file prog.cfg contains the flash-programming sequence.

For example:

RE ;Reset the MCU

CM C:\Freescale\CW MCU v10.6\MCU\bin\Plugins\support\hc08\gdi\P&E\9s08qg4.s8p ;Choose Flash Module

EM ;Erase the module

SS ImageFileName.s19 ;Specify the S19 to use

PM ;Program the module with the S19

VC ;Verify CRC of Object File to Module

PT ;Program trim value

RE ;Reset the MCU

Thanks again for your help :smileyhappy:

0 Kudos
Reply

1,361 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi,

the P&E utility you mentioned coming with CW install can not work standalone. it can only work inside CW but can't work as PROGHCS08 utility you ordered from P&E.

this is commercial issue and market decision.

Hope this helps!


Have a great day,
Jennie Zhang

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

0 Kudos
Reply

1,361 Views
barakmanos
Contributor III

Hi Jennie

Funny enough, the two issues that you've mentioned (TRIM value and PE-Micro product) are the exact same conclusions that I've reached during my investigation:

1. I have noticed the TRIM in the Advanced Options configuration window (below), and I suspected that it could be the difference between the debugger operation and a standalone task... But I did not suspect it to the point where I thought I should bring it up to your attention.

adv_opt_win.png

2. I have already (yesterday) ordered PE-Micro's Command-Line Flash-Programming utility (well, to be precise, I ordered PROG08SZ by mistake, and then had to change it to PROGHCS08).

However, there is one thing left unclear to me.

By enabling the Flash-Programming Dialog (in the window above), I can clearly see the operations executed by this utility.

As I have previously described, I see the following text:

CMD>RE
CMD>CM C:\Freescale\CW MCU v10.6\MCU\bin\Plugins\support\hc08\gdi\P&E\9s08gq4.s8p
CMD>EM
CMD>PM

So one way or another, this utility is already installed on my computer.

I'm not sure whether it comes along with CW installation or with PE-Micro drivers, but common sense tells me that it's "gotta be there".

Would you be able to explain why I need to purchase a product that appears to be running on my PC every time I download (burn) my program with CW?

Thanks again for your help.

0 Kudos
Reply