Programming the TinyFPGA BX with Arduino


#1

Getting bored with using that difficult Verilog stuff?

Why not program your TinyFPGA BX with Arduino using the USB port instead?

Here is a blinky script:

You need to build top.bin from:

So on Linux do:

git clone https://github.com/lawrie/tiny_usb_examples
cd tiny_usb_examples/arduino
make

Or you can build it with apio on Windows - It builds in Atom. I haven’t tried MAC OSX.

You then need to install an FPGA Arduino board from

Follow the instructions to install the package.

You will need to edit boards.txt to change the line:

fpga_generic.menu.protocol.hex.upload.flags=-P{serial.port} -ra

to

fpga_generic.menu.protocol.hex.upload.flags=-D 1 -P{serial.port} -ra

This is because I haven’t got the USB receive code to receive characters at full speed, so a delay between characters is needed.

My boards.txt file on Linux was at:

~/.arduino15/packages/FPGArduino/hardware/f32c/1.0.0/boards.txt

On Windows in was at:

C:\Users\lawri\AppData\Local\Arduino15\packages\FPGArduino\hardware\f32c\1.0.0\boards.txt

Then, with the binary ruunning on the TinyFPGA BX, in the Arduino IDE, select:

Tools>Board>"Generic FPGA Board"
      Port>/dev/ttyACM0 (ow whatever it is on Windows)
      Protocol: "Hex 115.2 kbit/s no verify RS232"
      CPU Architecture: "RISC-V"
      CPU Speed: "25Mhz"
      RAM Size:"8 KB BRAM Internal"

Use the blink.ino script above, and upload the sketch. The LED should blink.

The system is incomplete and fragile at the moment.

Problems include:

  • The upload process sometimes doesn’t return
  • There is not much you can currently do apart from blink the LED
  • PinMode, digitalWrite etc. are not currently supported
  • You need the “-D 1” flag as I haven’t got receiving data at full speed over USB working.
  • The board is running at 24Mhz, not 25Mhz
  • There is only a total of 8KB of RAM available
  • You need to upload top.bin again, or press reset and do “tinyprog -b” before you can upload another script

But, hey, you can program your TinyFPGA with Arduino. :grinning:

My project builds on the work of @uxe for the BlackIce board, and this project from the Zagreb ulx3s team.


Bootloader resources
#2

My latest version supports pinMode and digitalWrite but only for output on pins 8 - 15. It also supports serial output, but not yet using the Serial class.