Flash Magic Forum

In-System Programming Support => LPC2xxx => Topic started by: preraksheth on July 20, 2011, 11:47:21 PM

Title: LPC2138 responds using terminal, but unable to communicate using flash magic
Post by: preraksheth on July 20, 2011, 11:47:21 PM
I seem to have a peculiar problem with a prototype board that I have made
microcontroller: LPC2138
Flash Magic version: 5.87.2331 (Same problem with older version as well)
Baud rate: 9600
Crystal: 12 MHz
Communication: Serial (no USB conversion)

When I use a terminal (Putty or in built flash magic terminal), I am able to communicate.
I have tried:

?
Response> Synchronized
Synchronized
Response>OK
12000
Response>OK
J
Response>
0
196839
K
Response>
0
13
2

But if I try to read device signature, it keeps failing (and so obviously it can not program either)
I have put P0.14 to ground, and reset it before trying this everytime

Apart from this, if I want to program using terminal, what Unlock code do I have to use?
Thanks to all - I am new to the forum, and may have missed if this is already replied - in which case you can just point me to the right link
Title: Re: LPC2138 responds using terminal, but unable to communicate using flash magic
Post by: Andy Ayre on July 21, 2011, 01:42:07 AM
Please generate a debug file and send it to me and see what is happening:

http://www.flashmagictool.com/debugfile.html

Andy
Title: Re: LPC2138 responds using terminal, but unable to communicate using flash magic
Post by: preraksheth on July 21, 2011, 01:58:03 AM
Thanks - here is it.
Title: Re: LPC2138 responds using terminal, but unable to communicate using flash magic
Post by: preraksheth on July 21, 2011, 09:05:09 PM
Andy - is the file good enough? Do I provide more info? Your help is greatly appreciated. Thanks
Title: Re: LPC2138 responds using terminal, but unable to communicate using flash magic
Post by: Andy Ayre on July 22, 2011, 01:00:11 AM
rx> Synchronized\d\a
tx> Synchronized\d\a
rx> \fd\bf\7f\9f\ff\fb\ef\fb\ff\aOK\d\a

This shows Flash Magic received "Synchronized" followed by CR-LF. It then sends "Synchronized" back to the device and the device responds however the baudrate seems to have changed. Note that \fd = 0xFD. Oddly "OK" is correctly returned.

I am not sure why it works in a terminal but not for Flash Magic. Please put a logic analyzer on the TxD pin of the microcontroller and try to measure the baudrate through the process to see if it really does change.

I see you are using DTR/RTS to place the device into programming mode. Are you doing that with PuTTY somehow? Can you disable that and use switches on the board instead?

Another thought is that something disturbed the microcontroller. Check the sine waves on the XTAL pins and check the power supply.

Andy
Title: Re: LPC2138 responds using terminal, but unable to communicate using flash magic
Post by: preraksheth on July 22, 2011, 03:20:18 AM
Thanks so much Andy.

After keeping the flash magic in "Half Duplex" mode and disabling any default behavior for DTS/DTR/RTS etc, I am able to read device signature. (Don't know why)
But it still could not program (failed to send data).
Then I tried to put in debug mode, and suddenly it could program!
This has repeated multiple times - 70% times, it is able to program in debug mode. Never outside debug mode.
But now, it did not create a debug file :-(
I am totally zapped at what's going on. Will be great if you could shade some light based on above. Meanwhile I will try to get a debug file
Regards,
Prerak
Title: Re: LPC2138 responds using terminal, but unable to communicate using flash magic
Post by: Andy Ayre on July 25, 2011, 12:51:50 AM
The only influence debug mode would have is to slow things down. The same is true with half-duplex mode if you don't really need it (which you don't). My guess is that there is something strange with your Windows installation or the microcontroller, but I don't know what.

We've seen symptoms like yours a couple of times before over the last 11 years but we were never able to pin down what was going on. We don't have anyone else reporting this issue.

Can you try a different microcontroller?

Andy
Title: Re: LPC2138 responds using terminal, but unable to communicate using flash magic
Post by: Klaus Jäger on July 29, 2011, 02:26:48 AM
Hello,

I have the same problem with the LPC2378 and LPC1768. Keil evolution boards.
I get a new laptop Dell M6600 with docking station for serial communication.
I cannot flash the controller. The message autobaud came.
I can communicate with the controller with your terminal.
When I use in the laptop a pcie serial card from Exys EX-1372 it works.
My old laptop T60p IBM works too over the docking station.
It could be a hardware problem of the laptops or docking stations.
Perhaps the FIFO.

Klaus
Title: Re: LPC2138 responds using terminal, but unable to communicate using flash magic
Post by: Andy Ayre on August 02, 2011, 01:39:35 AM
Klaus,

If possible, the following test would be interesting:

Using the same Flash Magic settings and the same micrcontroller and target board, use a scope and logic analyser to capture the serial comms in both directions for an attempt to read the signature with the PCIe card and the docking station.

We should then be able to compare the waveforms side by side and see what the difference is. It may be possible to modify Flash Magic to compensate for what is going on.

Andy
Title: Re: LPC2138 responds using terminal, but unable to communicate using flash magic
Post by: Klaus Jäger on August 10, 2011, 12:41:21 AM
Hello Andy,

I am sorry that I answer so late.

I have no logic analyzer, so I cannot make the measurements for you.

I have a similar problem with program that I write with C# 2005.
There use the RS232 from C# and I must raise the buffer for write and read.


Klaus
Title: Re: LPC2138 responds using terminal, but unable to communicate using flash magic
Post by: Andy Ayre on August 10, 2011, 01:22:01 AM
What did you raise the buffers to? Flash Magic attempts to use 16k although not all PCs support that for some unknown reason.

Andy
Title: Re: LPC2138 responds using terminal, but unable to communicate using flash magic
Post by: preraksheth on October 15, 2011, 03:42:18 AM
Andy,

I am back with the problem. Originally, my problem was solved by putting the flash magic in debug mode and programming in debug mode.
Unfortunately, now even that does not work.
I can say that the serial communication line is working fine, as the previously loaded program does communicate with the PC properly (although sometimes with glitches).
I wonder what I could do next. I don't have logic analyzer to provide you with the hard baud rate info.

Any help would be greatly appreciated.
Regards,
Prerak
Title: Re: LPC2138 responds using terminal, but unable to communicate using flash magic
Post by: preraksheth on October 15, 2011, 03:43:08 AM
Again, I am able to communicate thru terminal and the protocol seems to be ok in terminal
Regards,
Prerak
Title: Re: LPC2138 responds using terminal, but unable to communicate using flash magic
Post by: preraksheth on October 16, 2011, 10:14:44 PM
After putting the flash magic in Debug mode and communication in Half Duplex mode, it worked for some time.
But then again, it started failing - now with an error "failed to send data to device" after successfully erasing sectors
This is now getting weird!
Please, please help
Regards,
Prerak
Title: Re: LPC2138 responds using terminal, but unable to communicate using flash magic
Post by: Andy Ayre on October 17, 2011, 01:00:32 AM
My suspicion based on all the information so far is something to do with your Windows installation and perhaps the COM port driver. The other person never responded to my last question unfortunately.

Please generate two debug files and send them to me. One using the Start button and one using the terminal. Perhaps this time there will be more of a clue.

Andy
Title: Re: LPC2138 responds using terminal, but unable to communicate using flash magic
Post by: Madarali on November 18, 2013, 04:24:11 AM
Hi all.
I have the same problem as Prerak with LPC2103.
I will communicate with LPC2103 through terminal and it will respond. but with Flash Magic it doesn't work. i can't read Device Signature with FM.
This is the output of terminal [Baud-Rate=38400_doesn't work with 57600. I'm using Proteus as terminal. Putty can't work because it is asserting the RTS and DTR pins while opening comport]:

?Synchronized
Synchronized
OK
12000
OK
J
0
327441
K
0
21
2

- I'm spend more than a weak and corrupted an LPC2103 and a PCB to achieve these results.
- I try with another computer that have another hardware with win7, it failed. [my PC is Win7-64bit]
- I use Flash Magic for program LPC1768 in ISP mode and it worked.
- I tried any possible setting in Flash Magic. it failed.
- I tried several version of Flash Magic.
- I'm using my PC's comport with several boards and microcontrollers.
I connect 2 LEDs to RESET and P0.14 to monitor the reset and ISP signals. they are working. [it seems that FM uese DTR and RTS for reset/ISP and then ISP/reset]

I can't read the debug file from FM. It seems that it is a binary file. I'm attached the debug file. i'm reading signature and security in debug mode then I'm tying to use terminal to send some commands.
The second debug file is FM with Half-Duplex communication enabled. sometimes it is working. It will able to read signature and security.

If there are any other tests that i can do, please tell me.

Regards
Thanks.
Title: Re: LPC2138 responds using terminal, but unable to communicate using flash magic
Post by: Andy Ayre on November 19, 2013, 01:26:26 AM
Here is a section of your debug file:

tx> ?
rx> Synchronized\d\a
tx> Synchronized\d\a
rx> S^{\df\cf\ef?\edw\fe\fOK\d\a


\d\a = carriage return and line feed.

Flash Magic expects the device to echo "Synchronized" back. This is quite strange. It is almost as if the baudrate has suddenly changed or there are glitches appearing on the Tx line from microcontroller to PC.

Half-duplex works better. In that mode Flash Magic sends one character at a time and waits for an echo. The only idea that comes to mind right now is that a burst of data from the microcontroller is not working.

One difference between the terminal and ISP is that the terminal is being used at human speeds. By the time you have typed in one character it has already been echoed back by the microcontroller before you type in the next character. I.e. it is much slower and similar to half-duplex.

I suggest to put a scope on various points along the transmit path between the microcontroller and the PC and examine the waveform. As you can see the first "Synchronized" is transmitted OK so you will need to compare that with the second transmission. Also compare with using the terminal.

My guess is that you will see more noise and glitches when the data transfer is faster and this is enough to confuse the COM port driver in Windows into thinking it is getting junk.

There is nothing in your problem description or debug files that indicate a way to corrupt a LPC2103 or a PCB. The bootloader is in ROM so it cannot be changed. The PCB is electrical so unless you used DTR/RTS to short circuit the power supply it's not possible for Flash Magic to damage it.

Andy
Title: Re: LPC2138 responds using terminal, but unable to communicate using flash magic
Post by: Madarali on November 27, 2013, 09:43:06 AM
Hi Andy, and thanks for replay.
I corrupt the PCB and LPC2103 when i was changing the LPC2103 with a new one. because i was thinking that maybe my LPC2103 was corrupted already, for example with ESD.
so you are saying that may be there are some glitches. I will modify the power supply and my RS232 cable to see what happens. but currently I'm using JTAG interface to programming. I'm attached some wires to pins of LPC on the board to make this interface.