From 1a24987cc1d58699945aaef79b0b1a1c2aeee378 Mon Sep 17 00:00:00 2001 From: Jose Lopez Date: Thu, 20 Oct 2016 11:08:41 +0200 Subject: [PATCH] New script 'lmkconf' converts raw Codeloader reg file to a C struct. --- lmkconf/example.txt | 23 +++++++++++++++++++++++ lmkconf/lmkconf | 29 +++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 lmkconf/example.txt create mode 100755 lmkconf/lmkconf diff --git a/lmkconf/example.txt b/lmkconf/example.txt new file mode 100644 index 0000000..1d9179e --- /dev/null +++ b/lmkconf/example.txt @@ -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 diff --git a/lmkconf/lmkconf b/lmkconf/lmkconf new file mode 100755 index 0000000..e9c4414 --- /dev/null +++ b/lmkconf/lmkconf @@ -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+"}};") + + + +