SparkFun Forums 

Where electronics enthusiasts find answers.

Open source ARM Debugger
By the-moog
Is there a bugtrack system for OpenOCD??? I can't fine one so I am reporting this here.....

Looking at svf.c, the code wrongly assumes that there is always a space delimiter e.g. TDI<space>(123) when it can be TDI(123).

This is a fundamental mistake. See the spec for SVF, here this makes no such assumption about the use of spaces and does not use them in it's examples.

The code is written such that every keyword is paired with a value with a space delimiter in between but this is not always the case. I was going to fix it, but so far as I can see the parser needs a complete rewrite to remove this fixed pairing and I have not got time to do that right now.

BTW: I noticed this as Actel's SVF output does not have spaces.

For now I will write a post processor that will convert non-space delimited to space delimited.
By the-moog
The parser also assumes that both a semicolon ';' and a LF are both line endings when only the semicolon should be considered (or why bother with it at all).
By the-moog
import sys
import os

""" a simple python script to fixup (in my case Actel) SVF files to
work with OpenOCD v0.2-0.4.0"""

"""by Jason Morgan - jason dot morgan at vpnsolutions dot uk dot com"""

"""OpenOCD now contains an SVF player, but is's implementation is not very solid
e.g. it interprets LF as a line end as well as a semicolon, meaning
lines can't be split.
It also requires a space between TDI, TDO, MASK and SMASK, and its paramater in
brackets even though that is not required by the specification.
e.g. TDI(123) and TDI(123) should both work, but they do not.

This program is a quick hack to reformat SVF scripts into the correct form.


if len(sys.argv)!=3:
print "Usage OOCDfixupxvf <inputfile> <outputfile>"

if os.path.exists(infile):
print "Input file %s not found"%infile

if infile==outfile:
print "Can't use the same file name for input and output"







##If the line is a comment or is empty write it out
if len(li)==0 or li[0]=="!":
#if the end of the line is not semicolon append another line
print "Joining line \n%s\n"%repr(li)

#Join lines, if the end of a line is a bracket, then add a space
#otherwise don't add a space
if li[-1]==")":
pad=" "

#Now we have a complete, terminated line, replace the keywords
for kw in kwds:
li=li.upper().replace("%s("%kw,"%s ("%kw)

#replace tabs with spaces
li=li.replace("\t"," ")

#replace multiple spaces with single spaces
li=li.replace(" "," ")
if len2!=len1:print "Removed %d extra spaces"%(len2-len1)

#then write out the line, insert \n after each semicolon for readability

if(linecount%100==0):print ".",

print "\ndone"
print "in : %s"%infile
print "out: %s"%outfile
print "Processed %d lines"%linecount
By SimonQian
Yes, you are right.
I implemented SVF support according to the SVF file generated by Altera, and there IS a space.
But it can be fixed by a simple patch instead of rewrite the whole parser.
I'll try to fix it.

checking LR for line ending is ONLY because that it will provide a position in the file where the command is parsing.
By the-moog
I tried a file that as altered with spaces but where long TDI sequences are split over several lines this also failed due to line ending. When I removed the line ends it then worked (but then failed for another reason, I think there is also a bug in the libftdi driver that makes the jtagkey hardware give up after a few thousand lines)
By SimonQian
Can you provide me the SVF file for test?
I tested it OK to use:
SIR 10 TDI (2
SIR 10 TDI (2CC);
SIR 10 TDI(2CC);
By SimonQian
Can you try this patch:

diff --git a/src/svf/svf.c b/src/svf/svf.c
index 7cb2200..9a62933 100644
--- a/src/svf/svf.c
+++ b/src/svf/svf.c
@@ -504,7 +504,8 @@ static int svf_read_command_from_file(int fd)
if (!comment)
- if (cmd_pos >= svf_command_buffer_size - 1)
+ // ensure there are 2 bytes available
+ if ((cmd_pos + 1) >= svf_command_buffer_size - 1)
tmp_buffer = (char*)malloc(svf_command_buffer_size + SVFP_CMD_INC_CNT); // 1 more byte for '\0'
if (NULL == tmp_buffer)
@@ -524,6 +525,11 @@ static int svf_read_command_from_file(int fd)
svf_command_buffer_size += SVFP_CMD_INC_CNT;
tmp_buffer = NULL;
+ // insert a space before '('
+ if ('(' == ch)
+ {
+ svf_command_buffer[cmd_pos++] = ' ';
+ }
svf_command_buffer[cmd_pos++] = (char)toupper(ch);
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]