]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tools/tinyos/misc/tos-build-deluge-image
Merge TinyOS 2.1.1 into master.
[tinyos-2.x.git] / tools / tinyos / misc / tos-build-deluge-image
index 085424011b42e7cccfec016c81ff3a3b68e7e435..0dddf828cc76d74acf23a145d628e63e7dd99d8c 100755 (executable)
@@ -20,8 +20,8 @@
 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 # THE POSSIBILITY OF SUCH DAMAGE.
 
-# @author Chieh-Jan Mike Liang <cliang4@cs.jhu.edu>
 # @author Razvan Musaloiu-E. <razvanm@cs.jhu.edu>
+# @author Chieh-Jan Mike Liang <cliang4@cs.jhu.edu>
 
 import sys, struct, operator
 from xml.dom.minidom import parse
@@ -130,10 +130,11 @@ except:
 all = []
 section = []
 end_addr = None
+offset = 0
 for line in image.split():
     #print "DEBUG:", line
     length = int(line[1:3], 16)
-    addr = int(line[3:7], 16)
+    addr = int(line[3:7], 16) + offset
     rectype = int(line[7:9], 16)
     data = []
     if len(line) > 11:
@@ -147,14 +148,16 @@ for line in image.split():
             all.append((start_addr, section))
             if rectype == 0x03:
                 # This last record updates the first 4 bytes which
-                # holds some some low level configuration. They are
-                # the same all the time so I guess that's why they are
+                # holds some low level configuration. They are the
+                # same all the time so I guess that's why they are
                 # skipped.
                 break
             section = []
             start_addr = addr
         section += data
         end_addr = addr + length
+    elif rectype == 0x02:
+        offset = int(line[9:9+4], 16) << 4
     elif rectype == 0x01:
         all.append((start_addr, section))
         section = []
@@ -173,6 +176,7 @@ for (addr, data) in all:
   all_data += encode(addr, 4) + \
               encode(len(data), 4) + \
               data
+all_data += encode(0, 4) + encode(0, 4) # Add the marker for the end of an image
 padding = [0] * (DELUGE_BYTES_PER_PAGE - len(all_data) % DELUGE_BYTES_PER_PAGE)
 if len(padding) < DELUGE_BYTES_PER_PAGE:
   all_data += padding