.. _gowin:

Gowin notes
###########

GOWIN GW1N
==========

.. NOTE::

  * Trenz TEC0117
  * Sipeed Tang Nano
  * Sipeed Tang Nano 4K
  * Honeycomb
  * RUNBER

``.fs`` file is the default format generated by *Gowin IDE*, so nothing special must be done to generates this file.

Since the same file is used for SRAM and Flash a CLI argument is used to specify the destination.

Flash SRAM
----------

with ``-m``:

.. code-block:: bash

    openFPGALoader -m -b BOARD_NAME impl/pnr/*.fs

where ``BOARD_NAME`` is:

* ``tec0117``
* ``tangnano``
* ``tangnano1k``
* ``tangnano4k``
* ``tangnano9k``
* ``tangnano20k``
* ``tangprimer20k``
* ``runber``

Flash
-----

.. ATTENTION::
  Only with Trenz TEC0117 and runber.

with ``-f``, file load:

.. code-block:: bash

    openFPGALoader -f -b BOARD_NAME impl/pnr/*.fs

where ``BOARD_NAME`` is:

* ``tec0117``
* ``runber``

It's possible to flash external SPI Flash (connected to MSPI) in bscan mode by using ``--external-flash`` instead of
``-f``.

.. NOTE::

  Gowin's FPGA may fails to be detected if **JTAGSEL_N** (pin 08 for *GW1N-4K*) is used as a GPIO.
  To recover you have to pull down this pin (before power up) to recover JTAG interface (*UG292 - JTAGSELL_N section*).

User Flash
----------

.. ATTENTION::
  User Flash support is based on reverse engineering of the JTAG protocol. This functionality should be considered
  experimental as it hasn't been thoroughly tested, and may in some circumstances destroy your device.

Gowin FPGA come with extra flash space that can be read and written from the programmable logic ("User Flash"). This
flash section can also be programmed via the JTAG interface:

.. code-block:: bash

    openFPGALoader --write-flash /path/to/bitstream.fs --user-flash /path/to/flash.bin
