|
1 | 1 | Bootloader
|
2 | 2 | ##########
|
3 | 3 |
|
4 |
| -Interface |
5 |
| ---------- |
| 4 | +User Interface |
| 5 | +-------------- |
6 | 6 |
|
7 | 7 | The bootloader allows you to arbitrarily select from one of 8 bitstreams after the Tiliqua powers on, without needing to connect a computer. In short:
|
8 | 8 |
|
9 | 9 | - When Tiliqua boots, you can select a bitstream with the encoder (either using the display output, or by reading the currently lit LED if no display is connected).
|
10 |
| -- When you select a bitstream (press encoder), the FPGA reconfigures itself and enters the selected bitstream. |
| 10 | +- When you select a bitstream (press encoder), the bootloader bitstream: |
| 11 | + - Loads any required firmware to PSRAM and sets up any other settings requested in the bitstream manifest. |
| 12 | + - Commands the RP2040 over UART to issue a bitstream reconfiguration. |
| 13 | + - The RP2040 then commands the ECP5 (over JTAG) to reconfigure itself and enter the selected bitstream (loaded from the SPI flash local to the ECP5). |
11 | 14 | - From any bitstream, you can always go back to the bootloader by holding the encoder for 3sec (this is built into the logic of every bitstream).
|
12 | 15 |
|
13 |
| -Setup and implementation |
14 |
| ------------------------- |
15 |
| - |
16 |
| -The bitstream selector consists of 2 key components that work together: |
17 |
| - |
18 |
| -- The RP2040 firmware (`apfbug - fork of dirtyJTAG <https://github.com/apfaudio/apfbug>`_) |
19 |
| -- The `bootloader <https://github.com/apfaudio/tiliqua/tree/main/gateware/src/top/bootloader>`_ top-level bitstream. |
20 |
| - |
21 |
| -First-time setup |
22 |
| -^^^^^^^^^^^^^^^^ |
23 |
| - |
24 |
| -1. Flash the RP2040. Use the latest pre-built binaries `found here <https://github.com/apfaudio/apfbug/releases>`_. To flash them, hold RP2040 BOOTSEL (golden button on the Tiliqua motherboard) before applying power, then copy the :code:`build/*.uf2` to the usb storage device and power cycle Tiliqua again. If you don't want to remove Tiliqua from your rack, you can also enter the RP2040 bootloader by opening a serial port at 1200 baud. |
25 |
| - |
26 |
| -2. Build and flash the bootloader bitstream using the built-in flash tool (alternatively just download the latest bootloader archive from the CI artifacts): |
27 |
| - |
28 |
| -.. code-block:: bash |
29 |
| -
|
30 |
| - # Flash bootloader to start of flash, build assuming XIP (execute directly from SPI flash, not PSRAM) |
31 |
| - # Be careful to replace `--hw r4` with your hardware revision! |
32 |
| - pdm bootloader build --hw r4 --fw-location=spiflash --resolution 1280x720p60 |
33 |
| - pdm flash archive build/bootloader-r4/bootloader-*.tar.gz |
34 |
| -
|
35 |
| -3. Build and flash any other bitstreams you want to slots 0..7 (you can also download these archives from CI artifacts): |
36 |
| - |
37 |
| -.. code-block:: bash |
38 |
| -
|
39 |
| - # assuming the archive has already been built / downloaded |
40 |
| - pdm flash archive build/xbeam-r4/xbeam-*.tar.gz --slot 2 |
41 |
| -
|
42 |
| -2. Check what is currently flashed in each slot (by reading out the flash manifests): |
43 |
| - |
44 |
| -.. code-block:: bash |
45 |
| -
|
46 |
| - pdm flash status |
47 |
| -
|
48 |
| -3. Before using the new bitstreams, disconnect the USB port and power cycle Tiliqua. (note: for the latest RP2040 firmware, this is not necessary and you can use them straight away). |
49 |
| - |
50 |
| -.. warning:: |
51 |
| - |
52 |
| - Before ``apfbug`` beta2 firmware, the bootloader would NOT reboot correctly (just show a blank screen) if you have |
53 |
| - the :py:`dbg` USB port connected WITHOUT a tty open. You HAD to have the |
54 |
| - ``/dev/ttyACM0`` open OR have the ``dbg`` USB port disconnected for it to work correctly. |
55 |
| - `Tracking issue (linked) <https://github.com/apfaudio/apfbug/issues/2>`_ (resolved in beta2 FW). |
56 |
| - |
57 |
| - |
58 |
| -4. Now when Tiliqua boots you will enter the bootloader. Use the encoder to select an image. Hold the encoder for >3sec in any image to go back to the bootloader. |
59 |
| - |
60 | 16 | Bitstream Archives and Flash Memory Layout
|
61 |
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 17 | +------------------------------------------ |
62 | 18 |
|
63 |
| -Each bitstream archive contains: |
| 19 | +Tiliqua user projects are packaged into *Bitstream Archives*, which are ``.tar.gz`` files that contain everything the bootloader needs to start a custom bitstream. Each bitstream archive contains: |
64 | 20 |
|
65 | 21 | - Bitstream file (top.bit)
|
66 | 22 | - Firmware binary (if applicable)
|
67 | 23 | - Any extra resources to be loaded into PSRAM (if applicable)
|
68 |
| -- Manifest file describing the contents |
| 24 | +- Manifest file (human-readable ``.json``) describing the contents |
69 | 25 |
|
70 |
| -The flash tool manages the following memory layout on the SoldierCrab's 128Mbit SPI flash: |
| 26 | +Tiliqua's ``pdm flash`` command manages the memory layout on the SoldierCrab's SPI flash, ensuring that the components of a bitstream archive end up in the correct place. A picture of how the SPI flash is organized: |
71 | 27 |
|
72 | 28 | .. code-block:: text
|
73 | 29 |
|
@@ -129,13 +85,64 @@ If an image requires firmware loaded to PSRAM, the SPI flash source address (in
|
129 | 85 | That is, the value of ``spiflash_src`` is not preserved by the flash tool and instead depends on the slot number.
|
130 | 86 | This allows a bitstream that requires firmware to be loaded to PSRAM to be flashed to any slot, and the bootloader will load the firmware from the correct address.
|
131 | 87 |
|
132 |
| -Implementation details: ECP5 |
133 |
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 88 | +Flashing the RP2040 and bootloader bitstream |
| 89 | +-------------------------------------------- |
| 90 | + |
| 91 | +During normal use, it should not be necessary to flash the RP2040 or bootloader bitstream. However the instructions here may be useful for unbricking a device if you accidentally erased the bootloader, or want to update the bootloader on older hardware revisions. The bootloader is composed of 2 components that work together: |
| 92 | + |
| 93 | +- The RP2040 firmware (`apfbug - fork of dirtyJTAG <https://github.com/apfaudio/apfbug>`_) |
| 94 | +- The `bootloader <https://github.com/apfaudio/tiliqua/tree/main/gateware/src/top/bootloader>`_ top-level bitstream. |
| 95 | + |
| 96 | +Flashing Steps |
| 97 | +^^^^^^^^^^^^^^ |
| 98 | + |
| 99 | +1. Flash the RP2040. Use the latest pre-built binaries `found here <https://github.com/apfaudio/apfbug/releases>`_. To flash them, hold RP2040 BOOTSEL (golden button on the Tiliqua motherboard) before applying power, then copy the :code:`build/*.uf2` to the usb storage device and power cycle Tiliqua again. If you don't want to remove Tiliqua from your rack, you can also enter the RP2040 bootloader by opening a serial port at 1200 baud. |
| 100 | + |
| 101 | +2. Build and flash the bootloader bitstream using the built-in flash tool (alternatively just download the latest bootloader archive from the CI artifacts): |
| 102 | + |
| 103 | +.. code-block:: bash |
| 104 | +
|
| 105 | + # Flash bootloader to start of flash, build assuming XIP (execute directly from SPI flash, not PSRAM) |
| 106 | + # Be careful to replace `--hw r4` with your hardware revision! |
| 107 | + pdm bootloader build --hw r4 --fw-location=spiflash --resolution 1280x720p60 |
| 108 | + pdm flash archive build/bootloader-r4/bootloader-*.tar.gz |
| 109 | +
|
| 110 | +3. Build and flash any other bitstreams you want to slots 0..7 (you can also download these archives from CI artifacts): |
| 111 | + |
| 112 | +.. code-block:: bash |
| 113 | +
|
| 114 | + # assuming the archive has already been built / downloaded |
| 115 | + pdm flash archive build/xbeam-r4/xbeam-*.tar.gz --slot 2 |
| 116 | +
|
| 117 | +2. Check what is currently flashed in each slot (by reading out the flash manifests): |
| 118 | + |
| 119 | +.. code-block:: bash |
| 120 | +
|
| 121 | + pdm flash status |
| 122 | +
|
| 123 | +3. Before using the new bitstreams, disconnect the USB port and power cycle Tiliqua. (note: for the latest RP2040 firmware, this is not necessary and you can use them straight away). |
| 124 | + |
| 125 | +.. warning:: |
| 126 | + |
| 127 | + Before ``apfbug`` beta2 firmware, the bootloader would NOT reboot correctly (just show a blank screen) if you have |
| 128 | + the :py:`dbg` USB port connected WITHOUT a tty open. You HAD to have the |
| 129 | + ``/dev/ttyACM0`` open OR have the ``dbg`` USB port disconnected for it to work correctly. |
| 130 | + `Tracking issue (linked) <https://github.com/apfaudio/apfbug/issues/2>`_ (resolved in beta2 FW). |
| 131 | + |
| 132 | + |
| 133 | +4. Now when Tiliqua boots you will enter the bootloader. Use the encoder to select an image. Hold the encoder for >3sec in any image to go back to the bootloader. |
| 134 | + |
| 135 | + |
| 136 | +Technical Details |
| 137 | +----------------- |
| 138 | + |
| 139 | +Bootloader bitstream: ECP5 |
| 140 | +^^^^^^^^^^^^^^^^^^^^^^^^^^ |
134 | 141 |
|
135 | 142 | The ECP5 :code:`bootloader` bitstream copies firmware from SPI flash to PSRAM before jumping to user bitstreams by asking the RP2040 to execute a stub bitstream replay (load a special bitstream to SRAM that jumps to the new bitstream). The request is issued over UART from the ECP5 to the RP2040, so it is visible if you have the ``/dev/ttyACMX`` open. User bitstreams are responsible for asserting PROGRAMN when the encoder is held to reconfigure back to the bootloader.
|
136 | 143 |
|
137 |
| -Implementation details: RP2040 |
138 |
| -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 144 | +`apfbug` debugger firmware: RP2040 |
| 145 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
139 | 146 |
|
140 | 147 | :code:`apfbug` firmware includes the same features as :code:`pico-dirtyjtag` (USB-JTAG and USB-UART bridge), with some additions:
|
141 | 148 |
|
|
0 commit comments