I've found another minor bug in bsl.py.  In the programData function, 
the code keeps track of the "count" and "total" bytes programmed (or 
verified, etc.) for a progress_update() function.  In the current code, 
count is zeroed for each segment - it should be zeroed once at the start 
of the function.  It made little difference with earlier MSP430's, since 
these used mostly one segment.  But with newer devices with more than 
64K flash, there will be two large segments, and the progress indicator 
will get messed up.  Putting "count = 0" at the start of the function 
fixes this.

mvh.,

David


On 29/10/2010 14:56, David Brown wrote:
> Hi,
>
> There is a bug in the file python-mspgcc-tools/mspgcc/memory.py - the
> Intel Hex file loader can interpret line type 0x02 for extended memory
> addressing, but not line type 0x04.  Code Composer Studio uses type 0x04
> ("Extended Linear Address Record") rather than type 0x02 ("Extended
> Segment Address Record") in the hex files it generates.  Since the
> "loadIHex" function in memory.py currently ignores type 0x04 records, it
> effectively relocates addresses 0x10000... to 0x00000..., and
> programming via msp430-bsl.py fails.
>
> The fix is very simple.  I'm afraid I don't know anything about bazaar
> (it took me longer to figure out how to get the latest copy of the code
> via bazaar than it took me to find and fix the bug...).  But I hope that
> by posting the fix here, someone will add it to the repository.
>
>
> The corrected "loadIHex" function is shown below.  Email mangles the
> line endings and white spaces, but it's easy to see the two additional
> lines at about line 78 in "memory.py" that handle type 0x04 records.
>
> I haven't looked at any other files in the project that may read Intel
> Hex files, in case anything else needs to be changed.
>
> mvh.,
>
> David
>
>
>
>       def loadIHex(self, file):
>           """load data from a (opened) file in Intel-HEX format"""
>           segmentdata = []
>           currentAddr = 0
>           startAddr   = 0
>           extendAddr  = 0
>           lines = file.readlines()
>           for l in lines:
>               if not l.strip(): continue  #skip empty lines
>               if l[0] != ':': raise FileFormatError("line not valid intel
> hex data: '%s...'" % l[0:10])
>               l = l.strip()               #fix CR-LF issues...
>               length  = int(l[1:3],16)
>               address = int(l[3:7],16) + extendAddr
>               type    = int(l[7:9],16)
>               check   = int(l[-2:],16)
>               if type == 0x00:
>                   if currentAddr != address:
>                       if segmentdata:
>                           self.segments.append( Segment(startAddr,
> ''.join(segmentdata)) )
>                       startAddr = currentAddr = address
>                       segmentdata = []
>                   for i in range(length):
>                       segmentdata.append( chr(int(l[9+2*i:11+2*i],16)) )
>                   currentAddr = length + currentAddr
>               elif type == 0x02:
>                   extendAddr =  int(l[9:13],16)<<  4
>               elif type == 0x04 :
>                   extendAddr = int(l[9:13], 16)<<  16
>               elif type in (0x01, 0x03, 0x04, 0x05):
>                   pass
>               else:
>                   sys.stderr.write("Ignored unknown field (type 0x%02x)
> in ihex file.\n" % type)
>           if segmentdata:
>               self.segments.append( Segment(startAddr,
> ''.join(segmentdata)) )
>


------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Mspgcc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to