Commit d08f7c80 authored by Theodor-Adrian Stana's avatar Theodor-Adrian Stana

Added catbstream Python script

The script can be used to concatenate two bitstreams together. See
README for more details.
Signed-off-by: Theodor-Adrian Stana's avatarTheodor Stana <t.stana@cern.ch>
parent b2a08835
catbstream.py
=============
This is a simple program that allows for concatenating two FPGA bitstreams
into one contiguous bitstream. It is intended for applications where two
bitstreams are stored on a Flash chip for applications such as MultiBoot.
The script asks the user for the bitstream file names (two input and one
output) and stores the concatenated version of the two bitstreams to the
output file. The second second bitstream starts on a sector boundary. If the
first bitstream is smaller than the second, the script pads with zeroes until
the sector boundary.
The output bitstream of two concatenated bitstreams would look like this:
0x000000 ================================
bitstream 1
bitstream 1
bitstream 1
[end bs1] ...................0000000000000
00000000000000000000000000000000
[next sect] ================================
bitstream 2
================================
At the time of writing of this readme, the file is designed for M25P flash
chips, which have 64kB sectors. To change the sector boundaries, all one needs
to do is change line 17 in the file for the sector boundary on his or her
flash of choice:
# 0x10000 is the sector boundary in the M25P flash
lt = 0x10000 - (len(a1)%0x10000)
if __name__ == "__main__":
# open files
fn1 = raw_input("file 1: ")
fn2 = raw_input("file 2: ")
fn3 = raw_input("outfile: ")
f1 = open(fn1,'rb')
f2 = open(fn2,'rb')
f3 = open(fn3,'wb')
a1 = []
a2 = []
# read contents
a1 = f1.read()
a2 = f2.read()
# get sector boundary and fill with zeroes up to next sector
lt = 0x10000 - (len(a1)%0x10000)
for i in range(0, lt):
a1 += '\0'
# write output files
f3.write(a1+a2)
f1.close()
f2.close()
f3.close()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment