Command Line ERASE Problem

Started by EdH, September 14, 2006, 03:27:25 PM

Previous topic - Next topic

Rick

Sorry, I'm a novice to FM and uVision, where do I add the DEBUG directive?

Many thanks

Andy Ayre

On the command line with the other directives you are using, like DEVICE, HEXFILE, etc. The DEBUG directive doesn't have any parameters.

Andy
Embedded Systems Academy, Inc.
support at esacademy dot com

Rick

File sent now, please let me know if you don't receive it :).

Many thanks for your help.

Andy Ayre

When you perform a full device erase with the Protect ISP option turn on (like you are), Flash Magic modifies the erase as follows. It erases all blocks except the last one. It then erases the pages in the last block up to the start of the bootloader.

Before it starts the page erase in the last block it checks the security bits. In your case this is the command and response:

tx> :010000030FED
rx> :010000030FED07.


If the security bits are set then it cannot erase the pages and the erase fails. As you can see the security bits for the last block are 07H, which means that all three security bits are set.

If you switch to the GUI version of Flash Magic and go to ISP -> Read Security Bits... you should see the same thing.

I believe it is possible to erase the security bits using either a parallel programmer or ICP.

If an older version of Flash Magic with the exact same device is showing that the erase completed, then I think it is likely that the erase is still failing but it isn't telling you. However without going back and testing old versions I cannot be sure what is happening there.

Andy
Embedded Systems Academy, Inc.
support at esacademy dot com

Andy Ayre

If you really are using an external clock/crystal at 12MHz then 9600 baud should work fine. However if you are using the internal RC oscillator, which is the default for the MCB900 board, then 9600 is not reliable. Instead you should use 7200. This is because of the watchdog resets in the bootloader.

So if you switch to 7200 does it also work in the GUI version as well?

The bottom line is that the command line version and the GUI version use the exact same DLL to communicate with the device, so what works in one should work in the other.

Also double-check in the GUI version in Options -> Advanced Options that you have enabled the DTR and RTS option.

Andy
Embedded Systems Academy, Inc.
support at esacademy dot com

Rick

#20
Regardless of the Baud rate I select in FM, it cannot read the security bits, it simply says that it cannot connect at the specified baud rate.

In uVision, even if I change the directive to 7200 instead of 9600, it gives the same error (I should mention that the lab at university, where it DOES work, DOES connect at 9600).
I don't know what the erase is meant to achieve, but at the working machine at university, I CAN load different programs to the board, so at the very least even if the erase fails it's still managing to overwrite the code.

EDIT: I should add, I'm a novice to this, I'm just trying to use it for my university project, and have no guru-level understanding of what's going on, and the settings. All the current directives etc are specified automatically since I installed uVision and FM from the LPC900 development kit disc.

Andy Ayre

It is successfully erasing all blocks except the last one, so as long as your code does not go into the last block it will work.

Delete C:\flashmagic.fmd
Start the GUI version of FM
Press F1 to enter debug mode (Debug appears at the top)
Go to ISP -> Read Security Bits...

wait for the error that it can't connect and close the error window.
Press F2 to exit debug mode.

Email me C:\flashmagic.fmd. Thanks.

Andy
Embedded Systems Academy, Inc.
support at esacademy dot com

Rick

Emailed.

I also added an edit into my previous post, but you posted back first.

"EDIT: I should add, I'm a novice to this, I'm just trying to use it for my university project, and have no guru-level understanding of what's going on, and the settings. All the current directives etc are specified automatically since I installed uVision and FM from the LPC900 development kit disc."

Andy Ayre

You don't have the option enabled to place the device into ISP mode.

Go to Options -> Advanced Options -> Hardware Config tab
Tick "Use DTR and RTS to enter ISP mode"
Click on OK

Next select the correct device in step 1 in the main window. It will be "89LPC935". Using the wrong device won't work and could cause problems.

Next enter the correct oscillator frequency into the box in step 1. For example "7.3728" if you are using the internal RC oscillator. You should also use this on the command line as well if that is what you are using.

Now give it a try.

Andy
Embedded Systems Academy, Inc.
support at esacademy dot com

Andy Ayre

Sorry, I have it a bit backwards.

Select the correct device FIRST before going to the advanced options. Sorry.

Andy
Embedded Systems Academy, Inc.
support at esacademy dot com

Rick

#25
Andy, you're invaluable, not only can I read the security bits,I can now program using FM and selecting the FM file. I can't even begin to express my gratitude.

However, I am still unable to program it in uVision, which since FM now works, I can only attribute to not passing the correct parameters?

My thanks once again.

EDIT: Having read the security bits in FM, all the bits for Block 7 are set. Is there a reason for this? Are they protecting something important? Or can I just toggle the bit protecting it from erase? Presumably then I also have to toggle the read bit? I DO NOT want to risk damaging this board in any way, since as I said it is not mine, but being able to program directly from uVision would be a great help :)


Andy Ayre

In the GUI version go to File -> Save Command Line Directives

Then examine the file and compare it with what you are using.

Andy
Embedded Systems Academy, Inc.
support at esacademy dot com

Rick

Right, there are 3 blocks of code following. The reason being, that the new one uses a different erase command, which presumably "does the job"?


Original line from uni lab, works correctly

"FM.EXE" "DEVICE(P89LPC935,12.0) ERASE(DEVICE,PROTECTISP) HEXFILE("U:\Blinky\Blinky.HEX",NOCHECKSUMS,NOFILL,PROTECTISP) COM(1,9600) HARDWARE(KEILMCB900)"


Original line from my pc, does not work

"FM.EXE" "DEVICE(P89LPC935,12.0) ERASE(DEVICE,PROTECTISP) HEXFILE("C:\Blinky\Blinky.HEX",NOCHECKSUMS,NOFILL,PROTECTISP) COM(1,7200) HARDWARE(KEILMCB900)"


Save Command Line from FM, new, DOES work

COM(1, 7200)
DEVICE(89LPC935, 12.000000)
HARDWARE(KEILMCB900, 250, 120)
ERASEUSED(D:\Ex935_AD\AD.hex, PROTECTISP)
HEXFILE(D:\Ex935_AD\AD.hex, NOCHECKSUMS, NOFILL, PROTECTISP)


I should state that I've tried both 7200 and 9600 in uVision on my PC with no difference.
The differences I've spotted are the different ERASE commands used, and also the extra HARDWARE parameters passed in the new FM code.


Andy Ayre

Over time the directives change, so if you are still using an old version at Uni then it will be different. My suggestion is to keep things simple upgrade all copies to the latest version so you are using the same command line and taking advantage of bug fixes and new features.

ERASEUSED is generated because in step 2 of the main window you have the checkbox "Erase Blocks Used by Hex File" ticked. Try ticking "Erase All Flash" and re-generated the command line directives.

All directives are fully documented in the Flash Magic manual, so you can see what the new parameters are for.

Andy
Embedded Systems Academy, Inc.
support at esacademy dot com

Rick

#29
Aha!

Right. When I change to Erase All Flash in FM, I get a popup warning me that it will change the parameters to protect the device ISP, fine, good.

When I then try to program the device though, I get a popup error, stating that it can't erase that same page 112 as stated in uVision, because of the settings of the security bits.

So...

The way I see it, my options are...

1) Disable those security bits - but what are they protecting? Am I risking damaging the device? Why were they enabled in the first place?
2) Only program using "erase blocks used by hex file" - will this be sufficient?
3) Find an older version of the program like the 1.95 at the uni, that seems to ignore the error.