Noob: boot from flash on TinyFPGA-bx


#1

Hello,

I wrote my first program for the TinyFPGA and I am able to upload it to the board (and flash). How to I automatically switch to boot the program after poweroff(and a delay to allow for programming? I currently need to type tinyprob -b to boot to the user flash program

With kind regards


#2

I am going to start answering this question myself.

The ICE40 FPGA family has documentation here.
https://www.latticesemi.com/Products/FPGAandCPLD/iCE40

One document is the iCE40 Programming and Configuration manual
https://www.latticesemi.com/view_document?document_id=46502

This document talks about the warm boot configuration

A special design primitive, SB_WARMBOOT, allows an FPGA application to choose between four configuration
images using two internal signal ports, S1 and S0, as shown in Figure 10.1. These pins S1 and S0 are used to detect a warm or cold boot.

For TinyFPGA I think these flasgs can only be obtained in two ways:

Using the programmer e.g. invoke tinyprog -b to send “\x00” to the board
https://github.com/tinyfpga/TinyFPGA-Bootloader/blob/master/programmer/tinyprog/init.py#L386
This caused the bootloader to enter op_boot state in configure boot_to_user
https://github.com/tinyfpga/TinyFPGA-Bootloader/blob/master/common/usb_spi_bridge_ep.v#L151
and later set boot_to_user_design to true/one
https://github.com/tinyfpga/TinyFPGA-Bootloader/blob/master/common/usb_spi_bridge_ep.v#L162

The bootloader intself


defines “boot to user design” if no host is detected or boot_to_user_design is true

Causing the S1 and S0 pins to be set
https://github.com/tinyfpga/TinyFPGA-Bootloader/blob/master/common/tinyfpga_bootloader.v#L27 and
https://github.com/tinyfpga/TinyFPGA-Bootloader/blob/master/boards/TinyFPGA_BX/bootloader.v#L63

Perhaps an additional entry can be added to force the user program after a certain timeout?


#3

Interesting - I’m fairly sure mine does that anyway… I’d kind of assumed it was the default behaviour. The only time it seems to stay in the bootloader is if I press the bootloader button. You can see an example of it doing this here with the Game SoC that a few of us are working on:

… but maybe in my case the host presence timeout is causing that (my programming environment is in a VM, so maybe that contributes to delays)…

D.


#4

The timeout is about 1 second. If I slowly insert the usb on the host side indeed I can get it to directly boot into the user application. This is because the usb plugs are designed to first give power to the board before the data lines are connected. @gundy with the setup you have programming the board might be difficult no?


#5

I haven’t found it to be particularly difficult - whenever I want to program the board I just push the bootloader button. In fact, I think I prefer the idea that the board by default boots to the user program and only goes into “flash” mode when you press the button… I’m pretty sure that’s how other microcontroller boards I have work too.

D.