EmbeddedRelated.com
Forums

Bootloader: Wrong answer on Prepare-Command (2) (Sector 2) CMD_SUCCESS

Started by Andreas Schwarz April 1, 2004
Hello,

I'm using lpc21isp to program my LPC2106. When I try to download the
test2 hex file from the Aeolus newlib example, I get the following output:

(...)
Writing Sector 0: ....(...)
Sector 0 written
Writing Sector 1: ....(...)
Sector 1 written
Writing Sector 2: ....(...)...Wrong answer on Prepare-Command (2) (Sector 2)
CMD_SUCCESS

...and the program doesn't work (no traffic on TXD). If I change "#if 1" to
"#if 0" and vice-versa (to disable the UART echo example), the program loads
ok, and I can receive the "hello world"-message over the UART.

What's wrong here?

Thanks
Andreas



An Engineer's Guide to the LPC2100 Series

At 06:41 PM 4/1/04 +0000, you wrote:
>Hello,
>
>I'm using lpc21isp to program my LPC2106. When I try to download the
>test2 hex file from the Aeolus newlib example, I get the following output:
>
>(...)
>Writing Sector 0: ....(...)
>Sector 0 written
>Writing Sector 1: ....(...)
>Sector 1 written
>Writing Sector 2: ....(...)...Wrong answer on Prepare-Command (2) (Sector 2)
>CMD_SUCCESS
>
>...and the program doesn't work (no traffic on TXD). If I change "#if 1" to
>"#if 0" and vice-versa (to disable the UART echo example), the program loads
>ok, and I can receive the "hello world"-message over the UART.
>
>What's wrong here?

Can you run the Philips ISP program? If so, does it work?

" 'Freedom' has no meaning of itself. There are always restrictions,
be they legal, genetic, or physical. If you don't believe me, try to
chew a radio signal. "

Kelvin Throop, III


At 01:53 PM 4/1/04 -0500, you wrote:
>At 06:41 PM 4/1/04 +0000, you wrote:
> >Hello,
> >
> >I'm using lpc21isp to program my LPC2106. When I try to download the
> >test2 hex file from the Aeolus newlib example, I get the following output:
> >
> >(...)
> >Writing Sector 0: ....(...)
> >Sector 0 written
> >Writing Sector 1: ....(...)
> >Sector 1 written
> >Writing Sector 2: ....(...)...Wrong answer on Prepare-Command (2) (Sector 2)
> >CMD_SUCCESS
> >
> >...and the program doesn't work (no traffic on TXD). If I change "#if 1" to
> >"#if 0" and vice-versa (to disable the UART echo example), the program loads
> >ok, and I can receive the "hello world"-message over the UART.
> >
> >What's wrong here?

I tracked down the error message. It's coming from this piece of code

sprintf((char *)tmpString, "P %ld %ld\r\n", Sector, Sector);
SendComPort(tmpString);

ReceiveComPort(Answer, sizeof(Answer)-1, &realsize, 2,5000);

sprintf((char *)tmpString, "P %ld %ld\r\n0\r\n", Sector, Sector);
if(strcmp((const char *)Answer, (const char *)tmpString) != 0)
{
printf("Wrong answer on Prepare-Command (2) (Sector
%ld)\n", Sector);
OutputErrorMessage(GetErrorNumber(Answer));
exit(4);
}

The prepare command is documented as taking a start sector and an end
sector number and so something like

P 2 2

should be sent to the micro. Unless echo is turned off then that should be
echoed back followed by the return code number (which should be 0 for
CMD_SUCCESS).

It's apparently not getting that but the code is converting whatever is
received to a number and then to an error message. If you can compile the
code try inserting the following line

printf("Expected [%s] -- Received [%s]\n", tmpString, Answer);

That may help track down what is actually happening.

Robert

" 'Freedom' has no meaning of itself. There are always restrictions,
be they legal, genetic, or physical. If you don't believe me, try to
chew a radio signal. "

Kelvin Throop, III


Robert Adsett wrote:
> At 06:41 PM 4/1/04 +0000, you wrote:
>>Hello,
>>
>>I'm using lpc21isp to program my LPC2106. When I try to download the
>>test2 hex file from the Aeolus newlib example, I get the following output:
>>
>>(...)
>>Writing Sector 0: ....(...)
>>Sector 0 written
>>Writing Sector 1: ....(...)
>>Sector 1 written
>>Writing Sector 2: ....(...)...Wrong answer on Prepare-Command (2) (Sector 2)
>>CMD_SUCCESS
>>
>>...and the program doesn't work (no traffic on TXD). If I change "#if 1" to
>>"#if 0" and vice-versa (to disable the UART echo example), the program loads
>>ok, and I can receive the "hello world"-message over the UART.
>>
>>What's wrong here?
>
> Can you run the Philips ISP program? If so, does it work?

I just tried it, works perfectly.



At 07:39 PM 4/1/04 +0000, you wrote:
>Robert Adsett wrote:
> > Can you run the Philips ISP program? If so, does it work?
>
>I just tried it, works perfectly.

OK, that narrows it down to the download program which is probably a
simpler problem. Consider the debug print I suggested. Martin, do you
want to jump in here?

Robert

" 'Freedom' has no meaning of itself. There are always restrictions,
be they legal, genetic, or physical. If you don't believe me, try to
chew a radio signal. "

Kelvin Throop, III


Yes, i can reproduce the problem on my PC.
LPC sends me "P 2 2 RESEND", so i think the last transmitted block is wrong
(fill block...).

I do a comparison to the original ISP

Martin

----- Original Message -----
From: "Robert Adsett" <>
To: <>
Sent: Thursday, April 01, 2004 9:47 PM
Subject: Re: [lpc2000] Re: Bootloader: Wrong answer on Prepare-Command (2)
(Sector 2) CMD_SUCCESS > At 07:39 PM 4/1/04 +0000, you wrote:
> >Robert Adsett wrote:
> > > Can you run the Philips ISP program? If so, does it work?
> >
> >I just tried it, works perfectly.
>
> OK, that narrows it down to the download program which is probably a
> simpler problem. Consider the debug print I suggested. Martin, do you
> want to jump in here?
>
> Robert
>
> " 'Freedom' has no meaning of itself. There are always restrictions,
> be they legal, genetic, or physical. If you don't believe me, try to
> chew a radio signal. "
>
> Kelvin Throop, III > Yahoo! Groups Links




Robert Adsett wrote:
> printf("Expected [%s] -- Received [%s]\n", tmpString, Answer);

Expected [P 2 2
0
] -- Received [P 2 2
RESEND
]



At 07:53 PM 4/1/04 +0000, you wrote:
>Robert Adsett wrote:
> > printf("Expected [%s] -- Received [%s]\n", tmpString, Answer);
>
>Expected [P 2 2
>0
>] -- Received [P 2 2
>RESEND
>]

That fits with Martins description (and exhausts my knowledge of the
program). I'll leave it to Martin for the moment to fix. At least you can
use the Philips Utility as a work around.

Robert

" 'Freedom' has no meaning of itself. There are always restrictions,
be they legal, genetic, or physical. If you don't believe me, try to
chew a radio signal. "

Kelvin Throop, III