Giter VIP home page Giter VIP logo

matrix-io / xc3sprog Goto Github PK

View Code? Open in Web Editor NEW
118.0 13.0 55.0 3 MB

xc3sprog is a suite of utilities for programming Xilinx FPGAs, CPLDs, and EEPROMs with the Xilinx Parallel Cable and other JTAG adapters under Linux. Used to program the FPGA of the MATRIX Creator/Voice via Raspberry Pi.

License: Other

CMake 2.07% C++ 83.12% C 8.59% Verilog 1.63% VHDL 2.51% BitBake 0.06% Roff 1.91% Smarty 0.11%

xc3sprog's Introduction

Installation

# Add repo and key
curl https://apt.matrix.one/doc/apt-key.gpg | sudo apt-key add -
echo "deb https://apt.matrix.one/raspbian $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/matrixlabs.list

# Update packages and install
sudo apt-get update
sudo apt-get upgrade

#Installation
sudo apt install matrixio-xc3sprog

Spartan3, XCF and CPLD JTAG programmer and other utilities

Copyright (C) 2004 Andrew Rogers (C) 2005-2011 Uwe Bonnes [email protected]

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Please also read the file "COPYING" which is a copy of the GNU General Public License

Prerequisites

This program should run without installation. For accessing USB cables, libusb0 is required as runtime dynamic linked library.

To compile, you need CMAKE, the static libftdi library and usb.h.

Compilation

$ mkdir build; cd build; cmake ..; make

To crosscompile for Win32 with mingw:

$ mkdir build-win32; cd build-win32; 
$ cmake -DCMAKE_TOOLCHAIN_FILE=../Toolchain-mingw32.cmake ..

Options

####Get a description:

$ ./xc3sprog -h

Note: This will also list the supported cables.

####Get a chain description:

$ ./xcs3prog -j

Device description is searched in the file pointed to by the XCDB environment variable, or when not found the built-in list is used.

####Test the chain integrity:

$ ./xc3sprog -T -j

Here "-j" stops xc3sprog from entering the program/verify/read the part. If things go wrong, an endless loop is entered to facilitate hardware degugging with the scope. Stop with ^C.

###Programming The Platform Flash PROM of the Xilinx Spartan3 Starter Kit can be programmed by specifying it's location in the JTAG chain. Example command line below.

$ ./xc3sprog -c pp -p 1 <bitfile.bit>

Program the flash of an XC3S50AN by loading the bscan_spi bitfile first. Aassume the XC3S50AN as single part in the jtag chain

$ ./xc3sprog  ../bscan_spi/xc3s50an.bit

Now program the flash

$ ./xc3sprog -I <your_bitfile.bit>

Verify the flash content against a file

$ ./xc3sprog -I -C <your_bitfile.bit>

You can readout XCF/ISF flash and CPLD

ISF flash probably mean Incircuit Serial Flash, as internal to XC3SAN or external connected to XC3SA/XC3SA or XC6S

First load an appropriate bitfile. Some bitfiles are in bscan_spi. Otherwise use the appropriate HDL file from bscan_spi and a fitting UCF file to create a ISE Project and run the Xilinx tools to generate the bitfile.

Load the bitfile, like

$ ./xc3sprog bscan_spi/xc6s_cs324.ucf

After loading the ISF Bitfile, you can now talk to the ISF Flash. When writing to the ISF, at the end the FPGA tries to reconfigure from flash and the ISF Bitfile is lost.

$ ./xc3sprog -r (-I) <file to store>

xc3sprog handles XC3, XCF0x and XC95xxxXx. XC4 should work but is untested.

There is also a utility program included that parses and prints the header of a Xilinx .bit file.

$ ./bitparse echo_out.bit

Jedecfiles for CPLD programming can be parsed with

$ ./jedecparse <jedecfile.jed>

When using a FT2232D|L programmer, speed is noticely enhance with a USB-2.0 Hub between the adapter and the PC. Some effort has been made to concatenate as many JTAG actions as possible.

Example fallback multi boot setup on XC6S

Load intermediate BSCAN_SPI bitfile:

$ ./xc3sprog -I <package specific bscan_spi bitfile>

Eventually erase (not really needed):

$ ./xc3sprog -I -e

Prepare the Multiboot header from the Template. Adapt GENERAL2 and GENERAL4 for your setup. Here a 32 MiBit Flash and a XC6SLX45 is used. The Bitstream length is about 1484404 = 0x16a674 bytes, so with placing the golden image at 0x10000 the golden image ends at 0x17a674 and with placing the normal image at 0x190000, there should be enough spacing between both. Double check that GENERAL2 and GENERAL4 match the offsets.

Write the header

$ ./xc3sprog -I<boot_header_only_SPI_x1.hex> 

Write golden image

$ ./xc3sprog -I <golden image>:w:0x10000

Write normal image

$ ./xc3sprog -I <normal image>:w:0x190000

Reboot

$ ./xc3sprog -R

All all in one

$ ./xc3sprog -R -I<boot_header_only_SPI_x1.hex> <golden image>:w:0x10000 \
   <normal image>:w:0x190000

Special Thanks

xc3sprog's People

Contributors

arhuaco avatar brianofrokk3r avatar eljuguetero avatar gordinh avatar kdpatino avatar maciekrb avatar nicolas-robin avatar nipo avatar rcooke-warwick avatar wasv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xc3sprog's Issues

O_NONBLOCK and O_SYNC not declared [mingw]

Hi,

probably something simple I am missing here. Getting the following error when trying to compile with mingw:

C:\MinGW\msys\1.0\home\i7\xc3sprog\sysfs.cpp: In member function 'int IOSysFsGPI
O::setup_gpio(int, int)':
C:\MinGW\msys\1.0\home\i7\xc3sprog\sysfs.cpp:132:31: error: 'O_NONBLOCK' was not
declared in this scope
int fd = open(buf, O_RDWR | O_NONBLOCK | O_SYNC);
^~~~~~~~~~
~\xc3sprog\sysfs.cpp:132:44: error: 'O_SYNC' was not dec
lared in this scope
int fd = open(buf, O_RDWR | O_NONBLOCK | O_SYNC);
^~~~~~
CMakeFiles\xc3sproglib.dir\build.make:70: recipe for target 'CMakeFiles/xc3sprog
lib.dir/sysfs.cpp.obj' failed

O_NONBLOCK and O_SYNC should be defined in fcntl.h - yet my mingw installation does not. Is there an easy workaround for this?

Thanks a lot!

GPIO Pin Change

before i was able to change Pi GPIO pin-outs from sysfs.cpp. can you tell me how you do it now as i cant find it. since the changes you have made for Pi-4.

Thanks

SYSFS_GPIO Removed?

In commit 87ea51d you seemed to remove SYSFS_GPIO cable support... Why? This worked amazingly for most of my customers in using a Pi to update the firmwares on their Amiga accelerators.

Is there an alternative? If not please restore this cable. It was awesome

Not really an issue.

Hi, Thanks very much for this great piece of software! I had a few minor problems installing it on Ubuntu Intel. I documented the steps at: https://www.mcs.sdsmt.edu/lpyeatt/courses/ceng342/xc3sprog.txt so feel free to add that to your README.md or whatever.

The only real issue was adding some libraries to the link step. Other than that, it was just making sure all the dependencies were there. Thanks again for the great code!

Add compatibility for more devices

I need to program some (older) FPGAs that are not included in the device list. I tried adding the devices to device_list.txt and I was able to detect it, but I was not able to assign the -X parallel option when I tried programming the PROM.

Specifically, I am using Virtex E: XCV600E with XC18V04 PROM. I also need to program a Spartan XCS40XL with XC18V01 PROM. I was able to program PROMs in parallel mode for Spartan 6: XC6SLX150 with XCF32P and XCF08P PROMs successfully. In Xilinx iMPACT I am able to use the parallel bus option with all of the FPGA-PROM combinations. I really only need to program the PROMs, but I need to use the parallel mode. What else do I need to do to add this compatibility?

I would be happy to add the entire device families once I get it working if that is wanted by others. Otherwise, any help for how I can get this to work for my project would be very appreciated.

build failed: error: reference to ‘byte’ is ambiguous

Using arch linux.

Please let me know if i'm missing something.
Thanks,
Dave

-> cmake ..
CMake Error: The source directory "/home/dmacias/Downloads/test" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.


-> cmake ../
CMake Error: The source directory "/home/dmacias/Downloads/test" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
-> cmake ../xc3sprog
-- The C compiler identification is GNU 11.1.0
-- The CXX compiler identification is GNU 11.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Deprecation Warning at CMakeLists.txt:8 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


CMake Warning (dev) at /usr/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (PkgConfig)
  does not match the name of the calling package (libftdi).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  /usr/share/cmake-3.20/Modules/FindPkgConfig.cmake:70 (find_package_handle_standard_args)
  Findlibftdi.cmake:19 (include)
  CMakeLists.txt:21 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found PkgConfig: /usr/bin/pkg-config (found version "1.7.3") 
-- Checking for module 'libftdi'
--   Found libftdi, version 0.20
CMake Warning (dev) at /usr/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (LIBFTDI)
  does not match the name of the calling package (libftdi).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  Findlibftdi.cmake:55 (find_package_handle_standard_args)
  CMakeLists.txt:21 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found LIBFTDI: /usr/lib/libftdi.so  
CMake Warning (dev) at /usr/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (PkgConfig)
  does not match the name of the calling package (libFTD2XX).  This can lead
  to problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  /usr/share/cmake-3.20/Modules/FindPkgConfig.cmake:70 (find_package_handle_standard_args)
  FindlibFTD2XX.cmake:16 (include)
  CMakeLists.txt:25 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Checking for module 'libftd2xx'
--   Package 'libftd2xx', required by 'virtual:world', not found
CMake Warning (dev) at /usr/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (LIBFTD2XX)
  does not match the name of the calling package (libFTD2XX).  This can lead
  to problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  FindlibFTD2XX.cmake:44 (find_package_handle_standard_args)
  CMakeLists.txt:25 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found LIBFTD2XX: /usr/lib/libftd2xx.so  
CMake Warning (dev) at /usr/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (PkgConfig)
  does not match the name of the calling package (libusb).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  /usr/share/cmake-3.20/Modules/FindPkgConfig.cmake:70 (find_package_handle_standard_args)
  Findlibusb.cmake:20 (include)
  CMakeLists.txt:99 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Checking for module 'libusb'
--   Found libusb, version 0.1.12
CMake Warning (dev) at /usr/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (LIBUSB)
  does not match the name of the calling package (libusb).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  Findlibusb.cmake:56 (find_package_handle_standard_args)
  CMakeLists.txt:99 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found LIBUSB: /usr/lib/libusb.so  
-- Configuring done
-- Generating done
-- Build files have been written to: /home/dmacias/Downloads/test/build
-> make
[  1%] Building CXX object CMakeFiles/jedecparse.dir/jedecparse.cpp.o
[  3%] Building CXX object CMakeFiles/jedecparse.dir/jedecfile.cpp.o
[  5%] Linking CXX executable jedecparse
[  5%] Built target jedecparse
[  6%] Building CXX object CMakeFiles/srecparse.dir/srecparse.cpp.o
[  8%] Building CXX object CMakeFiles/srecparse.dir/srecfile.cpp.o
/home/dmacias/Downloads/test/xc3sprog/srecfile.cpp: In member function ‘int SrecFile::readSrecFile(const char*, unsigned int)’:
/home/dmacias/Downloads/test/xc3sprog/srecfile.cpp:258:13: error: reference to ‘byte’ is ambiguous
  258 |   buffer = (byte*)malloc(bufsize);
      |             ^~~~
In file included from /usr/include/c++/11.1.0/bits/stl_algobase.h:61,
                 from /usr/include/c++/11.1.0/bits/char_traits.h:39,
                 from /usr/include/c++/11.1.0/string:40,
                 from /home/dmacias/Downloads/test/xc3sprog/srecfile.h:27,
                 from /home/dmacias/Downloads/test/xc3sprog/srecfile.cpp:25:
/usr/include/c++/11.1.0/bits/cpp_type_traits.h:404:30: note: candidates are: ‘enum class std::byte’
  404 |   enum class byte : unsigned char;
      |                              ^~~~
In file included from /home/dmacias/Downloads/test/xc3sprog/srecfile.cpp:25:
/home/dmacias/Downloads/test/xc3sprog/srecfile.h:30:23: note:                 ‘typedef unsigned char byte’
   30 | typedef unsigned char byte;
      |                       ^~~~
/home/dmacias/Downloads/test/xc3sprog/srecfile.cpp:258:18: error: expected primary-expression before ‘)’ token
  258 |   buffer = (byte*)malloc(bufsize);
      |                  ^
make[2]: *** [CMakeFiles/srecparse.dir/build.make:90: CMakeFiles/srecparse.dir/srecfile.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:142: CMakeFiles/srecparse.dir/all] Error 2
make: *** [Makefile:156: all] Error 2

Sysfsgpio_creator for Pi B REV 1 Boards

Would you be able to make a sysfsgpio_creator specifically for the raspberry pi B rev 1 boards, that uses GPIO21 instead of GPIO27, because rev 1 boards don’t have a GPIO27 :( . I really want to flash my Amiga accelerator cpld! Thanks in advance for any assistance.

Building wants wiringpi.h on a AMD build host

I don't see anything configurable for the building process....

When building on a Debian 11.1 AMD64 host it stops at:

[ 66%] Building CXX object CMakeFiles/xc3sproglib.dir/iowiringpi.cpp.o /home/me/develop/fpga/xc3sprog/iowiringpi.cpp:3:10: fatal error: wiringPi.h: No such file or directory 3 | #include <wiringPi.h> | ^~~~~~~~~~~~ compilation terminated. make[2]: *** [CMakeFiles/xc3sproglib.dir/build.make:441: CMakeFiles/xc3sproglib.dir/iowiringpi.cpp.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:212: CMakeFiles/xc3sproglib.dir/all] Error 2 make: *** [Makefile:171: all] Error 2

Redefine GPIO Pins in Pi

Is there a way to redefine the GPIO pins. The Pins you use are occupied in my setup

i require the use of

cable gpio tdi=13 tdo=19 tck=26 tms=6

is this definable

Sparse IHEX files cause out of bounds memory access, segfault

I have an MCS file (big endian Intel HEX format). It contains 12868 bytes, but those start (via the "4" command) at address 0x200000 (2MB into the flash).

The code in the MCS parser allocates a buffer the size of the file (so, 35424 bytes), and then uses the calculated address (2MB) to index into it. This creates an out of bounds access which results in a segmentation fault.

The difference in buffer size (based on the size of the textual MCS file) vs. the data size gives some leeway, but if the offset is too big, the code is completely broken for handling files that don't have all of their data right at the beginning of the flash.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.