QuickLogic-Corp / TinyFPGA-Programmer-Application

Desktop application for programming TinyFPGA boards and now QuickFeather
GNU General Public License v3.0
7 stars 3 forks source link

TinyFPGA-Programmer-Application

Desktop application for programming TinyFPGA boards. Updated to python3 and to support QuickLogic's QuickFeather.

Installation

Note: This repository uses sub-modules for some of the functionality. Using the "Download ZIP" functionality does not package these necessary sub-modules. To use this project, please follow the instatllation instructions given below.

  1. Clone the repository and install the tinyfpgab dependency ::

    git clone --recursive https://github.com/QuickLogic-Corp/TinyFPGA-Programmer-Application.git
    pip3 install tinyfpgab

  2. | Connect the QuickFeather board, and set it to flash mode. | To put it into flash mode, press the RST button, and the LED should turn blue and start flashing.
    | Press the USR button within 5 seconds of pressing the RST button. The LED will turn green and go into breathing mode.
    | At this point, run :code:lsusb on the terminal.
    | :code:lsusb should contain an entry similar to the following:

    ::

    Bus 002 Device 029: ID 1d50:6140 OpenMoko, Inc.

    | or

    ::

    Bus 002 Device 029: ID 1d50:6130 OpenMoko, Inc.

    | If the OpenMoko device is not present, then run the following commands.

    ::

    pip3 install apio apio drivers --serial-enable

    | You should see:

    ::

    Serial drivers enabled Unplug and reconnect your board

    | and then check the output of :code:lsusb contains an entry as shown above.

  3. | It is recommended to set up an alias to simplify programming using the editor of your choice to edit :code:~/.bashrc: | Change /PATH/TO/BASE/DIR/ to wherever you cloned this git repo.

    ::

    alias qfprog="python3 /PATH/TO/BASE/DIR/TinyFPGA-Programmer-Application/tinyfpga-programmer-gui.py" source ~/.bashrc

Programming

This version of tinyfpga-programmer-gui.py is restricted to CLI mode. CLI mode allows you to specify which port to use, and thus works even when the system does not report USB VID and PID. This document focuses on CLI mode.

NOTE

If the use-case involves loading the appfpga binary (with or without the m4app binary) which is now supported in this programmer application, then the bootloader needs to be updated on the QuickFeather first The latest version of the bootloader can be built in the qorc-sdk (qf_apps/qf_bootloader or qf_apps/qf_bootloader_uart). This needs to be first flashed using the programmer application to ensure support for load of the appfpga binary and the operating-mode spec (detailed below). :code:qfprog --port /dev/ttyX --bootloader /path/to/latest/qorc-sdk/qf_bootloader.bin --mode m4
If the original bootloader is continued to be used, the :code:--mode and the :code:--appfpga options will have no effect.
The (original)bootloader will always try to load the m4app binary only.

Help is available by running with the --help parameter:

::

python3 tinyfpga-programmer-gui --help

or, if you have already setup the alias

::

qfprog --help

::

usage: tinyfpga-programmer-gui.py [-h] --mode [fpga-m4] [--m4app app.bin]
                                [--appfpga appfpga.bin]
                                [--bootloader boot.bin]
                                [--bootfpga fpga.bin] [--reset]
                                [--port /dev/ttySx] [--crc] [--checkrev]
                                [--update] [--mfgpkg qf_mfgpkg/]

optional arguments:
-h, --help            show this help message and exit
--mode [fpga-m4]      operation mode - m4/fpga/fpga-m4
--m4app app.bin       m4 application program
--appfpga appfpga.bin
                        application FPGA binary
--bootloader boot.bin, --bl boot.bin
                        m4 bootloader program WARNING: do you really need to
                        do this? It is not common, and getting it wrong can
                        make you device non-functional
--bootfpga fpga.bin   FPGA image to be used during programming WARNING: do
                        you really need to do this? It is not common, and
                        getting it wrong can make you device non-functional
--reset               reset attached device
--port /dev/ttySx     use this port
--crc                 print CRCs
--checkrev            check if CRC matches (flash is up-to-date)
--update              program flash only if CRC mismatch (not up-to-date)
--mfgpkg qf_mfgpkg/   directory containing all necessary binaries

The programmer allows you to specify various options:

Danger Zone

Flash Memory Map

| The TinyFPGA programmer has a flash memory map for 5 bin files, and corresponding metadata (including CRC) for each of them. | The flash memory map is defined for 2MB (16Mb) of flash memory (as in QuickFeather)

The 5 bin files are:

| The bootloader is loaded by a reset. | It handles either communicating with the TinyFPGA-Programmer to load new bin files into the flash, or it loads appfpga and/or m4app and transfers control to it. | The bootfpga area contains the binary for the fpga image that the bootloader uses.

The flash memory map defined for q-series devices is:

.. image:: qorc-flash-memory-map-addresses.svg