Skip to content

Commit

Permalink
New script 'lmkconf' converts raw Codeloader reg file to a C struct.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jose Lopez committed Oct 20, 2016
1 parent bd0686c commit 1a24987
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lmkconf/example.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
R0 (INIT) 0x80020140
R0 0x00001F40
R1 0x800001C1
R2 0x80001EA2
R3 0x000000A3
R4 0x80000C84
R5 0x80000145
R6 0xC0010006
R7 0x01C00007
R8 0x04000008
R9 0x55555549
R10 0x9142400A
R11 0x3761100B
R12 0x130C006C
R13 0x3B03826D
R14 0x0300000E
R16 0xC1550410
R24 0x00200018
R26 0xAFA8001A
R28 0x0020001C
R29 0x0080015D
R30 0x0500015E
R31 0x001F001F
29 changes: 29 additions & 0 deletions lmkconf/lmkconf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env python

import sys
import argparse

parser = argparse.ArgumentParser(description='Converts a raw register file from Texas Instruments CodeLoader\nto a C struct ready to be copypasted in Zynq-based HW first-stage bootloaders')

parser.add_argument("inputfile", help="Input file from CodeLoader")
parser.add_argument("outputfile", help="Output file")

args = parser.parse_args()

infile, outfile = args.inputfile, args.outputfile

with open(infile,"r") as inf, open(outfile,"w") as outf:
outf.write("const struct {int reg; uint32_t val;} tilmk03086_regs_WR[] = {\n")
for line in inf:
tmp=line.split("\t")
reg=tmp[0].partition(' ')[0][1:]
int_reg=int(reg)
val=tmp[1].rstrip()
if int_reg<31 :
outf.write("{"+reg+", "+val+"},\n")
else :
outf.write("{"+reg+", "+val+"}};")




0 comments on commit 1a24987

Please sign in to comment.