Skip to content

Commit

Permalink
boards: riscv: icev_wireless: add fpga flashing instructions
Browse files Browse the repository at this point in the history
Add instructions on flashing the FPGA via the shell.

Signed-off-by: Chris Friedt <[email protected]>
  • Loading branch information
cfriedt committed Nov 29, 2022
1 parent 6b12b64 commit 89812a9
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 3 deletions.
78 changes: 75 additions & 3 deletions boards/riscv/icev_wireless/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ features:
+-----------+------------+------------------+
| ADC | on-chip | |
+-----------+------------+------------------+
| FPGA | off-chip | fpga_ice40 |
+-----------+------------+------------------+

Other hardware features have not been enabled yet for this board.

Expand Down Expand Up @@ -108,9 +110,9 @@ For the :code:`Hello, world!` application, follow the instructions below.
Since the Zephyr console is by default on the `usb_serial` device, we use
the espressif monitor to view.

.. code-block:: console
.. code-block:: bash
$ west espressif monitor
west espressif monitor
Debugging
=========
Expand All @@ -119,7 +121,7 @@ As with much custom hardware, the ESP32C3 modules require patches to
OpenOCD that are not upstreamed. Espressif maintains their own fork of
the project. The custom OpenOCD can be obtained by running the following extension:

.. code-block:: console
.. code-block:: bash
west espressif install
Expand Down Expand Up @@ -149,12 +151,82 @@ You can debug an application in the usual way. Here is an example for the
:maybe-skip-config:
:goals: debug

Programming the FPGA
====================

Download and save the ICE-V Wireless `default bitstream`_ to the current working directory.

.. code-block:: bash
curl -L -o bitstream.bin 'https://github.com/ICE-V-Wireless/ICE-V-Wireless/blob/main/Firmware/spiffs/bitstream.bin?raw=true'
printf "Bitstream size is 0x%x\n" $(wc -c bitstream.bin | awk '{print $1}')
printf "Bitstream CRC is %x\n" $(crc bitstream.bin)
truncate -s %4 bitstream.bin
printf "Rounded bitstream size is 0x%x\n" $(wc -c bitstream.bin | awk '{print $1}')
Build and flash the :ref:`flash_shell` application.

.. zephyr-app-commands::
:zephyr-app: samples/drivers/flash_shell
:board: icev_wireless
:maybe-skip-config:
:goals: flash

Open a terminal to the device via USB:

.. code-block:: bash
minicom -D /dev/tty.usbmodem101 -b 115200
Clear the `image-scratch` partition:

.. code-block:: console
flash erase flash-controller@60002000 0x00210000 0x20000
Prepare to load the ICE-V Wireless bitstream to the `image-scratch` partition:

.. note::

Use the rounded bitstream size (0x1969c below), as `flash load` needs every
image padded to a multiple of 4 bytes.

.. code-block:: console
flash load flash-controller@60002000 0x00210000 0x1969c
Transmit the ICE-V Wireless bitstream to the `image-scratch` partition:

.. code-block:: bash
dd if=bitstream.bin of=/dev/tty.usbmodem101 bs=32 count=32
Although unlikely, it may be possible that the bitstream was corrupted
transferring serially, so it's a good idea to check the CRC value.

.. code-block:: console
crc 0x3c210000 104090
Load the bitstream from flash:

.. note::

Use the unpadded bitstream size (104090 below) for `fpga load`.

.. code-block:: console
fpga load fpga@0 0x00210000 104090
References
**********

.. _ICE-V Wireless Github Project:
https://github.com/ICE-V-Wireless/ICE-V-Wireless

.. _ICE-V Wireless Default Bitstream:
https://github.com/ICE-V-Wireless/ICE-V-Wireless/blob/main/Firmware/spiffs/bitstream.bin

.. _ESP32-C3-MINI-1 Datasheet:
https://www.espressif.com/sites/default/files/documentation/esp32-c3-mini-1_datasheet_en.pdf

Expand Down
23 changes: 23 additions & 0 deletions boards/riscv/icev_wireless/icev_wireless.dts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,29 @@
#size-cells = <0>;
pinctrl-0 = <&spim2_default>;
pinctrl-names = "default";

cs-gpios = <&gpio0 6 (GPIO_PUSH_PULL | GPIO_ACTIVE_LOW)>;

fpga0: fpga@0 {
status = "okay";
compatible = "lattice,ice40-fpga";

reg = <0>;
spi-max-frequency = <1000000>;

load-mode = <1>;
cdone-gpios = <&gpio0 0 0>;
creset-gpios = <&gpio0 1 (GPIO_PUSH_PULL | GPIO_ACTIVE_LOW)>;
clk-gpios = <&gpio0 5 (GPIO_PUSH_PULL | GPIO_ACTIVE_LOW)>;
pico-gpios = <&gpio0 7 (GPIO_PUSH_PULL | GPIO_ACTIVE_LOW)>;
mhz-delay-count = <4>;
gpios-set-reg = <0x60004008>;
gpios-clear-reg = <0x6000400c>;
config-delay-us = <2000>;
creset-delay-ns = <200>;
leading-clocks = <8>;
trailing-clocks = <160>;
};
};

&gpio0 {
Expand Down

0 comments on commit 89812a9

Please sign in to comment.