# 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
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:
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 = []
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