Flash Magic Forum

In-System Programming Support => LPC9xx/LPC9xxx => Topic started by: EdH on September 14, 2006, 03:27:25 pm

Title: Command Line ERASE Problem
Post by: EdH on September 14, 2006, 03:27:25 pm
I'm using Flash Magic (V3.27.130) in conjuction with the External Programming feature of Keil uVision, and when I try to program my MCB900 board using Keil example MCB900 projects (HELLO, BLINKY or MEASURE) I get:

Flash Magic Version 3.27.130
8051/XA Driver Version 2.14.130
ARM Driver Version 1.13.128
(C) Embedded Systems Academy 2000-2006 All rights reserved
Connected
Device selected
Erase failed: invalid command (DEVICE)

The command line looks like this:

"FM.EXE" "DEVICE(P89LPC935,12.0) ERASE(DEVICE,PROTECTISP) HEXFILE("C:\Keil\C51\EXAMPLES\Philips LPC9xx\Measure\measure.HEX",NOCHECKSUMS,NOFILL,PROTECTISP) COM(1,9600) HARDWARE(KEILMCB900)"

I know this worked on earlier versions of Flash Magic, but I don't remember which version it was.

If I remove the "ERASE(DEVICE,PROTECTISP)" section, I no longer get the error, but, of course, flash is not erased.

I can erase and program the device successfully by running Flash Magic from the Windows dialog, but I would really like to get this working again  via command line from within uVision.  I tried moving the commands into a text file, but was unsuccessful there also.

Do you have any ideas on how to get this to work?
Title: Re: Command Line ERASE Problem
Post by: Andy Ayre on September 14, 2006, 03:32:20 pm
You have nested quote marks. Try moving all the directives to a text file, for example testboard1.txt:

DEVICE(P89LPC935,12.0)
ERASE(DEVICE,PROTECTISP)
HEXFILE("C:\Keil\C51\EXAMPLES\Philips LPC9xx\Measure\measure.HEX",NOCHECKSUMS,NOFILL,PROTECTISP)
COM(1,9600)
HARDWARE(KEILMCB900)

then call with:

FM.EXE @testboard1.txt

Title: Re: Command Line ERASE Problem
Post by: EdH on September 14, 2006, 03:53:33 pm
Thanks for the quick response , Andy.

I just tried using a text file with your changes, ran it from the command prompt, and got exactly the same error as before (I used fm.txt):

fm.exe @fm.txt

Flash Magic Version 3.27.130
8051/XA Driver Version 2.14.130
ARM Driver Version 1.13.128
(C) Embedded Systems Academy 2000-2006 All rights reserved
Connected
Device selected
Erase failed: invalid command (DEVICE)

Any other ideas?

Ed
Title: Re: Command Line ERASE Problem
Post by: Andy Ayre on September 14, 2006, 03:58:42 pm
That is odd. Here is my test:

>fm.exe @lpc932test.txt
Flash Magic Version 3.27.130
8051/XA Driver Version 2.20.130
ARM Driver Version 1.14.128
(C) Embedded Systems Academy 2000-2006 All rights reserved
Connected
Device selected
Manufacturer ID: 0x15
Device ID 1: 0xDD
Device ID 2: 0x1E
Erase complete (DEVICE)
Erase complete (BLOCK 1)
Erase complete (USED)
Hex file programming complete (lpc932blinky.hex)

and here is the lpc932test.txt file:

DEVICE(89LPC935,7.3728)
READSIGNATURE
COM(1,7200) HARDWARE(KEILMCB900, 50, 100)
ERASE(DEVICE, PROTECTISP)
ERASE(1, PROTECTISP)
ERASEUSED(lpc932blinky.hex, PROTECTISP)
HEXFILE(lpc932blinky.hex, NOCHECKSUMS, NOFILL, PROTECTISP)

I guess try adding a space after the comma, but that shouldn't have any effect. If that doesn't help then try cutting and pasting my directive and remove the ERASEUSED and HEXFILE ones.

Title: Re: Command Line ERASE Problem
Post by: EdH on September 15, 2006, 07:03:56 am
I tried your text file and it still failed with the same error.  After experimenting a little using your text file, I found that the ERASEUSED and the ERASE(1, PROTECTISP) work OK.  I only get the error when the ERASE(DEVICE, PROTECTISP) command is included.

This text file works:

DEVICE(89LPC935,7.372)
READSIGNATURE
COM(1,7200) HARDWARE(KEILMCB900, 50, 100) ERASE(1, PROTECTISP)
ERASEUSED(blinky.hex, PROTECTISP) HEXFILE(blinky.hex, NOCHECKSUMS, NOFILL, PROTECTISP)

Here is the result:

>fm @fm.txt

Flash Magic Version 3.27.130
8051/XA Driver Version 2.14.130
ARM Driver Version 1.13.128
(C) Embedded Systems Academy 2000-2006 All rights reserved
Connected
Device selected
Manufacturer ID: 0x15
Device ID 1: 0xDD
Device ID 2: 0x1E
Erase complete (BLOCK 1)
Erase complete (USED)
Hex file programming complete (blinky.hex)


This text file gives the "Erase failed: invalid commend (DEVICE)" error:

DEVICE(89LPC935,7.372)
READSIGNATURE
COM(1,7200) HARDWARE(KEILMCB900, 50, 100) ERASE(DEVICE, PROTECTISP) ERASE(1, PROTECTISP)
ERASEUSED(blinky.hex, PROTECTISP) HEXFILE(blinky.hex, NOCHECKSUMS, NOFILL, PROTECTISP)

Here is the result:

>fm @fm.txt

Flash Magic Version 3.27.130
8051/XA Driver Version 2.14.130
ARM Driver Version 1.13.128
(C) Embedded Systems Academy 2000-2006 All rights reserved
Connected
Device selected
Manufacturer ID: 0x15
Device ID 1: 0xDD
Device ID 2: 0x1E
Erase failed: invalid command (DEVICE)


I tried this on another PC (both are running WinXP, SP2) with the same results.

I noticed that you are using:

8051/XA Driver Version 2.20.130
ARM Driver Version 1.14.128

These drivers (especially the 8051/XA) are newer than what I downloaded yesterday:

8051/XA Driver Version 2.14.130
ARM Driver Version 1.13.128

Could this make a difference?

Ed
Title: Re: Command Line ERASE Problem
Post by: Andy Ayre on September 15, 2006, 08:19:30 am
Hmm. This is very odd. I tested this with the exact same version of FM that you are using:

C:\Program Files\Flash Magic>fm.exe @lpc935test.txt
Flash Magic Version 3.27.130
8051/XA Driver Version 2.14.130
ARM Driver Version 1.13.128
(C) Embedded Systems Academy 2000-2006 All rights reserved
Connected
Device selected
Manufacturer ID: 0x15
Device ID 1: 0xDD
Device ID 2: 0x1E
Erase complete (DEVICE)
Erase complete (BLOCK 1)
Erase complete (USED)
Hex file programming complete (lpc932blinky.hex)

and it worked fine. Please email me the directives file and hex file you are using so I can try it myself. My email address is at the bottom of this post and in the Help -> About window.

Title: Re: Command Line ERASE Problem
Post by: EdH on September 15, 2006, 09:35:32 am
Andy,

The 2 files should be in your inbox...

Thanks, again.

Ed
Title: Re: Command Line ERASE Problem
Post by: Andy Ayre on September 15, 2006, 11:18:56 am
Your files worked fine for me:

C:\Program Files\Flash Magic>fm.exe @fm.txt
Flash Magic Version 3.27.130
8051/XA Driver Version 2.14.130
ARM Driver Version 1.13.128
(C) Embedded Systems Academy 2000-2006 All rights reserved
Connected
Device selected
Manufacturer ID: 0x15
Device ID 1: 0xDD
Device ID 2: 0x1E
Erase complete (DEVICE)
Erase complete (BLOCK 1)
Erase complete (USED)
Hex file programming complete (blinky.hex)

Which version of Windows are you using and which language?
Does reinstalling FM help?

Title: Re: Command Line ERASE Problem
Post by: EdH on September 15, 2006, 03:25:01 pm
I'm using Windows XP Professional, Version 2002, Service Pack 2, English(US) version.

I did try uninstalling FM, re-downloading, and re-installing FM but still get the same error.

It's odd that the only command that causes an error is:

ERASE(DEVICE, PROTECTISP)

I have tried moving this command after the ERASE(1, PROTECTISP) and after the ERASEUSED(blinky.hex, PROTECTISP).  Those commands always work, but ERASE(DEVICE,  PROTECTISP) still gives the error.
Title: Re: Command Line ERASE Problem
Post by: Andy Ayre on September 18, 2006, 08:27:49 am
I'm using the same version of Windows, so this has me stumped. I'm not sure why it would work ok for me and not for you. The logic to decode the command line is the same for both of us and so is the input.

If you are interested in helping me out with this by testing a series of DLLs with additional debug information added, please let me know by Email and we can do that. I'm not sure of another way to attack the problem.

Title: Re: Command Line ERASE Problem
Post by: Rick on December 03, 2007, 09:08:24 am
I realise this is an old topic, but I'm having the EXACT same problems.

MCB900 board.

Loads fine on the computers at university, but not at home.

University PCs are running uVision 3.02c, FM 1.95

I'm on uVision 3.03c, FM 3.33

"FM.EXE" "DEVICE(P89LPC935,12.0) ERASE(DEVICE,PROTECTISP) HEXFILE("C:\Keil\C51\Examples\LPC9xx\Blinky\Blinky.HEX",NOCHECKSUMS,NOFILL,PROTECTISP) COM(1,9600) HARDWARE(KEILMCB900)"
Flash Magic Version 3.33.157
8051/XA Driver Version 2.22.156
ARM Driver Version 1.17.157
(C) Embedded Systems Academy 2000-2006 All rights reserved
Connected
Device selected
Erase failed: invalid command (DEVICE)

That's the output I get when I try to compile on the machine at home.

The board is connected via COM1, with the same cable as used at university, and no USB converters are being used.

I'm on XP SP2, UK (International) English.

I'd be grateful if anyone could offer some help, since this is a major obstacle to ease of working on my thesis project.

Many thanks in advance.


EDIT: Just to add to this post, I've checked my port by shorting the pins on the cable, and the PC COM port is working fine (no echo without short, input echoed with short). The board also appears to be fine (all Hyperterminal input echoed when connected, nothing echoed when cable disconnected)

EDIT AGAIN: If I try to program the file directly in FM, I get a popup saying

"Failed to read the device signature (Operation Failed. (reading signature)). Accessing a device using the wrong protocol could render the device unusable. Do you want to continue?"

I always click no, since this is a university board, and I'd rather not risk damaging it!
Title: Re: Command Line ERASE Problem
Post by: Andy Ayre on December 04, 2007, 08:11:19 am
Please download the latest version and give that a try. Post back if it does not help.

Andy
Title: Re: Command Line ERASE Problem
Post by: Rick on December 04, 2007, 09:41:10 am
I shall, many thanks. Due to other commitments I won't be able to try it until late Thursday or Friday, I shall post back on here regardless of the result.

Thanks for your reply.
Title: Re: Command Line ERASE Problem
Post by: Rick on December 07, 2007, 01:50:35 am
I have now repeated with version 4.01, and I still have problems, but I have a more helpful error message for you :).

I would like to add, that it STILL works perfectly on the computers in the lab, so I am somewhat confused as to the potential hardware implications of this message?


"FM.EXE" "DEVICE(P89LPC935,12.0) ERASE(DEVICE,PROTECTISP) HEXFILE("C:\Blinky\Blinky.HEX",NOCHECKSUMS,NOFILL,PROTECTISP) COM(1,9600) HARDWARE(KEILMCB900)"
Flash Magic Version 4.01.259
8051/XA Driver Version 2.41.258
ARM Driver Version 1.31.258
(C) Embedded Systems Academy 2000-2007 All rights reserved
NON PRODUCTION USE ONLY
Connected
Device selected
Erase failed: invalid command - Operation Failed. (Unable to erase page 112 - erase disabled via security bits) (DEVICE)


EDIT: Oh, I meant to add, I try to Read the security bits in FM itself, but I cannot connect at any baud rate, it always says that it can't connect at the specified baud rate. I tried installing FM 1.71, and managed to read them (all unset), but I was still unable to program it.
Title: Re: Command Line ERASE Problem
Post by: Andy Ayre on December 07, 2007, 07:48:37 am
OK, please add the directive "DEBUG", rerun and send me via email C:\flashmagic.fmd. This will let me see the comms.

Thanks, Andy
Title: Re: Command Line ERASE Problem
Post by: Rick on December 07, 2007, 08:16:15 am
Sorry, I'm a novice to FM and uVision, where do I add the DEBUG directive?

Many thanks
Title: Re: Command Line ERASE Problem
Post by: Andy Ayre on December 07, 2007, 08:18:45 am
On the command line with the other directives you are using, like DEVICE, HEXFILE, etc. The DEBUG directive doesn't have any parameters.

Andy
Title: Re: Command Line ERASE Problem
Post by: Rick on December 07, 2007, 08:27:26 am
File sent now, please let me know if you don't receive it :).

Many thanks for your help.
Title: Re: Command Line ERASE Problem
Post by: Andy Ayre on December 07, 2007, 08:58:21 am
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:

Code: [Select]
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
Title: Re: Command Line ERASE Problem
Post by: Andy Ayre on December 07, 2007, 09:02:27 am
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
Title: Re: Command Line ERASE Problem
Post by: Rick on December 07, 2007, 09:16:28 am
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.
Title: Re: Command Line ERASE Problem
Post by: Andy Ayre on December 07, 2007, 09:21:07 am
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
Title: Re: Command Line ERASE Problem
Post by: Rick on December 07, 2007, 09:25:38 am
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."
Title: Re: Command Line ERASE Problem
Post by: Andy Ayre on December 07, 2007, 10:09:53 am
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
Title: Re: Command Line ERASE Problem
Post by: Andy Ayre on December 07, 2007, 10:13:01 am
Sorry, I have it a bit backwards.

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

Andy
Title: Re: Command Line ERASE Problem
Post by: Rick on December 07, 2007, 10:32:26 am
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 :)

Title: Re: Command Line ERASE Problem
Post by: Andy Ayre on December 07, 2007, 10:35:06 am
In the GUI version go to File -> Save Command Line Directives

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

Andy
Title: Re: Command Line ERASE Problem
Post by: Rick on December 07, 2007, 10:40:01 am
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.

Title: Re: Command Line ERASE Problem
Post by: Andy Ayre on December 07, 2007, 10:46:31 am
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
Title: Re: Command Line ERASE Problem
Post by: Rick on December 07, 2007, 10:51:13 am
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.
Title: Re: Command Line ERASE Problem
Post by: Andy Ayre on December 07, 2007, 11:17:50 am
I don't know why those security bits are set. They are unset when the device is shipped from the factory, for example my test LPC935 here has them unset.

If you continue to only erase the blocks used by the hex file then that will work fine, unless your code grows and needs some space in the top most block in memory. This is the section you are unable to erase.

If version 1.95 is ignoring the error then it would be dangerous to keep using it. One day your code may need space in the top block. You might not realize this and the only symptom will be that your code now mysteriously stops working. At this point you will either remember or waste a day or two fiddling with your code to try and see a pattern (been there, done that).

Your other option is to get a new LPC935 if you don't have the ability to erase the security bits AND you need that section of flash.

Andy