READ and WRITE isp commands + checksum computation

Started by deeeed, July 17, 2007, 04:10:43 AM

Previous topic - Next topic

deeeed

Hello,
i'm using flash magic to program my lpc2368 and it works very good.
Actually i would like to write my own embedded programmer but when I analyze how flash magic program the mcu there is something i don't understand.
First it sends the write command and wait for CMD_SUCCESS:
57 20 31 30 37 33 37 34 32 33 33 36 20 35 31 32 0D 0A                                               W 1073742336 512..
Then it can send the 61 uuencoded data + \r\n :
4D 24 30 60 60 5A 41 33 50 47 5E 34 34 5C 29 5F 45 5F 5F 5F 5F 5F 5F 5F 5F 5F 5F 5F 2B 27           M$0``ZA3PG^44\)_E___________+'
5C 21 2A 5F 5F 5F 5F 5F 5F 5F 5F 5F 5F 5F 5F 5F 5F 5F 5F 5F 5F 5F 5F 5F 5F 5F 5F 5F 5F 5F           \!*___________________________
5F 0D 0A   
     
                                                                                                                                    _..

I just don't understand the first byte of the data 4D, i think it's something relative to the size the data but i don't know how to compute it. I also think it is used for computing the final checksum after sending uuencoded data.
So here my questions are: how to guess the first byte of data ? and how to compute the final checksum ?
Arthur

ps: Sorry for my really bad english

Andy Ayre

We don't usually comment on the working of Flash Magic at the ISP level, however this is simply UUencoding stuff.

There are 45 encoded bytes on that line. To encode the value 45 itself you add 32 to it. 32 + 45 = 77 = 4DH.

See this Wikipedia article on UUencoding:

  http://en.wikipedia.org/wiki/Uuencode

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

deeeed


deeeed

I have another checksum problem  :'(, i don't know how to determin the last checksum after a read or a write command.

ISP command:
57 20 31 30 37 33 37 34 32 33 33 36 20 35 31 32 0D 0A                                               W 1073742336 512..

Then send the data after CMD_SUCCESS.
*** Sending the uuencoded data ***

Finally we send the checksum:
31 32 33 31 36 35 0D 0A                                                                             123165..

For example the checksum for "W addr 512" seems to be always 123165, how do you compute this number ?
I read the datasheet but they don't explain how to determin this number.

deeeed

I finally found how to compute the final checksum, it's just the sum of all the non encoded data.