dadamachines / doppler

Arduino compatible – Cortex M4F & FPGA Development Board
81 stars 9 forks source link

"Load the bitstream on the FPGA" example in README is wrong #8

Open mcclure opened 1 year ago

mcclure commented 1 year ago

Hello, I am getting into FPGA programming and have pulled out my old Doppler to test my builds.

Once I had a binary, I tried uploading it using the sample code in this repository's README:

  #include <ICEClass.h>
  #include "[PATHTO]/top.bin.h" // set up the path to doppler_simple_io or custom firmware
  ICEClass ice40;   // subclass ICEClass to implement custom spi protocol

  void setup() {
    ice40.upload(top_bin,sizeof(top_bin)); // Upload BitStream Firmware to FPGA -> see variant.h
    ice40.upload(); // Upload BitStream Firmware to FPGA -> see variant.h
    ice40.initSPI();  // start SPI runtime Link to FPGA
  }

  void loop() {

    static uint16_t x = 0;
    ice40.sendSPI16(x++);   delay(50);
  }

It did not work. After some experimentation, I found the problem was

    ice40.upload(top_bin,sizeof(top_bin)); // Upload BitStream Firmware to FPGA -> see variant.h
    ice40.upload(); // Upload BitStream Firmware to FPGA -> see variant.h

If I remove the ice40.upload();, this code works. But with the ice40.upload();, it does not. What I believe is happening is that .upload(top_bin, sizeof(top_bin)) uploads the "top" array, whereas .upload with no arguments uploads some sort of default (possibly the SPI LED command program). It seems the .upload() should be removed from the example.

In addition, it would be helpful at this point to link to the ICEClass / ice40 documentation, or to whatever repo contains the classes so we can read whatever code or documentation is there. Because I am using the Arduino SDK gui app I do not understand where the header files I am loading during a compile are located.