|
From: Ricardo R. D. <ric...@gm...> - 2015-03-25 13:28:35
|
Hello?
On Thu, Jun 12, 2014 at 12:07 PM, Ricardo Ribalda Delgado
<ric...@gm...> wrote:
> BPI files are generated with:
>
> promgen -p bin -u 0 in.bit
>
> They are the equivalent of the BIN files for Parallel flash devices
>
> This patch add support for such files
>
> Signed-off-by: Ricardo Ribalda Delgado <ric...@gm...>
> ---
> bitfile.cpp | 19 ++++++++++++++++---
> bitfile.h | 4 ++--
> bitparse.cpp | 4 ++--
> xc2c_warp.cpp | 4 ++--
> xc3sprog.1 | 1 +
> xc3sprog.cpp | 3 ++-
> 6 files changed, 25 insertions(+), 10 deletions(-)
>
> diff --git a/bitfile.cpp b/bitfile.cpp
> index e6e3198..1cae4d3 100644
> --- a/bitfile.cpp
> +++ b/bitfile.cpp
> @@ -88,7 +88,7 @@ int BitFile::readBitfile(FILE *fp)
>
> /* Read in whole file with bitflip */
>
> -int BitFile::readBIN(FILE *fp)
> +int BitFile::readBIN(FILE *fp, bool do_bitrev)
> {
> unsigned int i;
>
> @@ -100,6 +100,10 @@ int BitFile::readBIN(FILE *fp)
> if (buffer == 0)
> return 1;
> fread(buffer,1, length, fp);
> +
> + if (!do_bitrev)
> + return 0;
> +
> for(i=0; i<length; i++)
> {
> unsigned char data = buffer[i];
> @@ -318,7 +322,9 @@ int BitFile::readFile(FILE *fp, FILE_STYLE in_style)
> case STYLE_HEX_RAW:
> return readHEXRAW(fp);
> case STYLE_BIN:
> - return readBIN(fp);
> + return readBIN(fp, true);
> + case STYLE_BPI:
> + return readBIN(fp, false);
> default: fprintf(stderr, " Unhandled style %s\n",styleToString(in_style));
> return 1;
> }
> @@ -477,6 +483,7 @@ uint32_t BitFile::saveAs(FILE_STYLE style, const char *device,
> {
> case STYLE_BIT:
> case STYLE_BIN:
> + case STYLE_BPI:
> if(style == STYLE_BIT)
> {
> uint8_t buffer[256] = {0x00, 0x09, 0x0f, 0xf0, 0x0f, 0xf0, 0x0f, 0xf0,
> @@ -522,7 +529,11 @@ uint32_t BitFile::saveAs(FILE_STYLE style, const char *device,
> }
> for(i=0; i<clip; i++)
> {
> - byte b=bitRevTable[buffer[i]]; // Reverse bit order
> + byte b;
> + if (style != STYLE_BPI)
> + b = bitRevTable[buffer[i]]; // Reverse bit order
> + else
> + b = buffer[i];
> fwrite(&b,1,1,fp);
> }
> break;
> @@ -678,6 +689,8 @@ int BitFile::styleFromString(const char *stylestr, FILE_STYLE *style)
> *style = STYLE_BIT;
> else if (!strncasecmp(stylestr, "BIN", len))
> *style = STYLE_BIN;
> + else if (!strncasecmp(stylestr, "BPI", len))
> + *style = STYLE_BPI;
> else if (!strncasecmp(stylestr, "HEX", len))
> *style = STYLE_HEX;
> else if (!strncasecmp(stylestr, "HEXRAW", len))
> diff --git a/bitfile.h b/bitfile.h
> index 8d45f83..1cfbf4c 100644
> --- a/bitfile.h
> +++ b/bitfile.h
> @@ -72,7 +72,7 @@ word. */
>
> typedef unsigned char byte;
>
> -enum FILE_STYLE { STYLE_BIT, STYLE_BIN, STYLE_HEX, STYLE_HEX_RAW,
> +enum FILE_STYLE { STYLE_BIT, STYLE_BIN, STYLE_BPI, STYLE_HEX, STYLE_HEX_RAW,
> STYLE_MCS, STYLE_IHEX , STYLE_JEDEC, STYLE_AUTO};
>
> class BitFile
> @@ -96,7 +96,7 @@ class BitFile
> void readField(std::string &field, FILE *fp);
> void processData(FILE *fp);
> int readBitfile(FILE *fp);
> - int readBIN(FILE *fp);
> + int readBIN(FILE *fp, bool do_bitrev);
> int readHEXRAW(FILE *fp);
> int readMCSfile(FILE *fp);
> unsigned char checksum(char * buf);
> diff --git a/bitparse.cpp b/bitparse.cpp
> index 30e75f6..d28c6a5 100644
> --- a/bitparse.cpp
> +++ b/bitparse.cpp
> @@ -36,8 +36,8 @@ void usage() {
> "\nUsage:bitparse [-i input format] [-o output format ][-O outfile] infile\n" " -h\t\tprint this help\n"
> " -v\t\tverbose output\n"
> " -O\t\toutput file (parse input file only if not given\n"
> - " -i\t\tinput file format (BIT|BIN|HEX|MCS|IHEX)\n"
> - " -o\t\toutput file format (BIT|BIN|HEX|MCS|IHEX)\n");
> + " -i\t\tinput file format (BIT|BIN|BPI|HEX|MCS|IHEX)\n"
> + " -o\t\toutput file format (BIT|BIN|BPI|HEX|MCS|IHEX)\n");
> exit(255);
> }
>
> diff --git a/xc2c_warp.cpp b/xc2c_warp.cpp
> index c2c8eec..0b3a55f 100644
> --- a/xc2c_warp.cpp
> +++ b/xc2c_warp.cpp
> @@ -14,8 +14,8 @@ void usage() {
> " -v\t\tverbose output\n"
> " -m\t\tDirectory containg Map files\n"
> " -O\t\toutput file (parse input file only if not given\n"
> - " -i\t\tintput file format (BIT|BIN|HEX)\n"
> - " -o\t\toutput file format (BIT|BIN|HEX)\n");
> + " -i\t\tintput file format (BIT|BIN|BPI|HEX)\n"
> + " -o\t\toutput file format (BIT|BIN|BPI|HEX)\n");
> exit(255);
> }
>
> diff --git a/xc3sprog.1 b/xc3sprog.1
> index d3fce4d..686c83c 100644
> --- a/xc3sprog.1
> +++ b/xc3sprog.1
> @@ -208,6 +208,7 @@ Xilinx \.BIT file format.
> Default for FPGA, XCF and SPI devices.
> T}
> BIN@Raw binary file.
> +BPI@Raw binary file not bit reversed.
> MCS@Xilinx .MCS file format.
> IHEX@T{
> Intel HEX format.
> diff --git a/xc3sprog.cpp b/xc3sprog.cpp
> index 129ebd3..e6eabca 100644
> --- a/xc3sprog.cpp
> +++ b/xc3sprog.cpp
> @@ -346,9 +346,10 @@ void usage(bool all_options)
> fprintf(stderr, "\tR: Read from device and write to file, overwrite existing file\n");
> fprintf(stderr, "\tDefault action is 'w'\n\n");
> fprintf(stderr, "\tDefault offset is 0\n\n");
> - fprintf(stderr, "\tstyle: One of BIT|BIN|MCS|IHEX|HEX\n");
> + fprintf(stderr, "\tstyle: One of BIT|BIN|BPI|MCS|IHEX|HEX\n");
> fprintf(stderr, "\tBIT: Xilinx .bit format\n");
> fprintf(stderr, "\tBIN: Binary format\n");
> + fprintf(stderr, "\tBPI: Binary format not bit reversed\n");
> fprintf(stderr, "\tMCS: Intel Hex File, LSB first\n");
> fprintf(stderr, "\tIHEX: INTEL Hex format, MSB first (Use for Xilinx .mcs files!)\n");
> fprintf(stderr, "\tHEX: Hex dump format\n");
> --
> 2.0.0
>
--
Ricardo Ribalda
|