Skip to content

Commit

Permalink
added support for Gowin GWU2X USB (JTAG mode) (#434)
Browse files Browse the repository at this point in the history
  • Loading branch information
trabucayre committed May 20, 2024
1 parent 7e90d07 commit 5357887
Show file tree
Hide file tree
Showing 6 changed files with 580 additions and 0 deletions.
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ else()
option(ENABLE_UDEV "use udev to search JTAG adapter from /dev/xx" ON)
endif()
option(ENABLE_CMSISDAP "enable cmsis DAP interface (requires hidapi)" ON)
option(ENABLE_GOWIN_GWU2X "enable Gowin GWU2X interface" ON)
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
option(ENABLE_LIBGPIOD "enable libgpiod bitbang driver (requires libgpiod)" ON)
option(ENABLE_REMOTEBITBANG "enable remote bitbang driver" ON)
Expand Down Expand Up @@ -218,6 +219,16 @@ target_link_libraries(openFPGALoader
${LIBFTDI_LIBRARIES}
)

# Gowin GWU2X JTAG interface
if(ENABLE_GOWIN_GWU2X)
target_sources(openFPGALoader PRIVATE src/gwu2x_jtag.cpp)
list (APPEND OPENFPGALOADER_HEADERS src/gwu2x_jtag.hpp)
add_definitions(-DENABLE_GOWIN_GWU2X=1)
message("Gowin GWU2X support enabled")
else()
message("Gowin GWU2X support disabled")
endif()

if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
# winsock provides ntohs
target_link_libraries(openFPGALoader ws2_32)
Expand Down
7 changes: 7 additions & 0 deletions doc/cable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ gatemate_evb_spi:
URL: https://colognechip.com/programmable-logic/gatemate/


gwu2x:

- Name: gwu2x
Description: Gowin GWUX2X
URL: https://www.gowinsemi.com/en/product/detail/55/


dfu:

- Name: DFU interface
Expand Down
4 changes: 4 additions & 0 deletions src/cable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ enum communication_type {
MODE_JETSONNANO_BITBANG, /*! Bitbang gpio pins */
MODE_REMOTEBITBANG, /*! Remote Bitbang mode */
MODE_CH347, /*! CH347 JTAG mode */
MODE_GWU2X, /*! Gowin GWU2X JTAG mode */
};

/*!
Expand Down Expand Up @@ -77,6 +78,8 @@ struct cable_t {
/* Others cable configuration */
#define CABLE_DEF(_type, _vid, _pid) \
{_type, _vid, _pid, 0, 0, {}}
#define CABLE_DEF_FULL(_type, _vid, _pid, _blv, _bld, _bhv, _bhd) \
{_type, _vid, _pid, 0, 0, {0, _blv, _bld, _bhv, _bhd, 0, -1}}

static std::map <std::string, cable_t> cable_list = {
// last 4 bytes are ADBUS7-0 value, ADBUS7-0 direction, ACBUS7-0 value, ACBUS7-0 direction
Expand Down Expand Up @@ -110,6 +113,7 @@ static std::map <std::string, cable_t> cable_list = {
{"ft4232", FTDI_SER(0x0403, 0x6011, FTDI_INTF_A, 0x08, 0x0B, 0x08, 0x0B)},
{"ft4232hp", FTDI_SER(0x0403, 0x6043, FTDI_INTF_A, 0x08, 0x0B, 0x00, 0x00)},
{"ft4232hp_b", FTDI_SER(0x0403, 0x6043, FTDI_INTF_B, 0x08, 0x0B, 0x00, 0x00)},
{"gwu2x", CABLE_DEF_FULL(MODE_GWU2X, 0x33AA, 0x0120, 0x02, 0x07, 0x0, 0x0)},
{"ecpix5-debug", FTDI_SER(0x0403, 0x6010, FTDI_INTF_A, 0xF8, 0xFB, 0xFF, 0xFF)},
{"jlink", CABLE_DEF(MODE_JLINK, 0x1366, 0x0105 )},
{"jlink_base", CABLE_DEF(MODE_JLINK, 0x1366, 0x0101 )},
Expand Down
Loading

0 comments on commit 5357887

Please sign in to comment.