[Solved] FPGA boot loader recovery

Thanks @sandeepmistry. Works fine now. Sketch upload to board seems to work now most of the time. Still having trouble with VidorGraphics but thats another problem.

Hi @loopmasta,

Thanks for the update, there's a new v1.0.2 version of VidorGraphics in the library manager, it should resolve the issues with VidorDrawLogo not working (there was a SPI flash misconfiguration in the previous version).

Thank you for update.

My board is working now.

Sigh Mine is still not working. :frowning:

Hi @ronsoul,

Could you please try the new releases from this thread: http://forum.arduino.cc/index.php?topic=563513.0

Let us know in that thread if after you’ve updated the SAMD21 boot loader if loading sketches that contain bitstreams still hang.

@sandeepmistry

thank you for the update to the bootloader. I also updated the libraries. I was able to update the bootloader successfully. I then tried to upload a VidorDrawlogo and it failes to upload at the same spot (37%). I then tried to do the fpga recovery and when I got to step 6 I see the arduino logo on the screen. I then ran step 9 and it failed at the same spot, 49%. So it seems like the hardware is ok (maybe). What should I try next?

so there are some error messages now.

Arduino: 1.8.5 (Windows 10), Board: "Arduino MKR Vidor 4000"

Build options changed, rebuilding all WARNING: library SPI claims to run on (samd) architecture(s) and may be incompatible with your current board which runs on (samd_beta) architecture(s). C:\Users\Ron\Documents\Arduino\libraries\VidorGraphics\src\jtag.c: In function 'jtagWriteBuffer':

C:\Users\Ron\Documents\Arduino\libraries\VidorGraphics\src\jtag.c:618:18: warning: passing argument 2 of 'ReadTDOBuf' from incompatible pointer type [-Wincompatible-pointer-types]

ReadTDOBuf(32, &address, 0, 0);

^

C:\Users\Ron\Documents\Arduino\libraries\VidorGraphics\src\jtag.c:202:13: note: expected 'char *' but argument is of type 'unsigned int *'

static void ReadTDOBuf(int bit_count, char *txbuf, char *rxbuf, int inst)

^~~~~~~~~~

C:\Users\Ron\Documents\Arduino\libraries\VidorGraphics\src\jtag.c:619:26: warning: passing argument 2 of 'ReadTDOBuf' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]

ReadTDOBuf(32 * len+2, data, 0, 0);

^~~~

C:\Users\Ron\Documents\Arduino\libraries\VidorGraphics\src\jtag.c:202:13: note: expected 'char *' but argument is of type 'const uint8_t * {aka const unsigned char *}'

static void ReadTDOBuf(int bit_count, char *txbuf, char *rxbuf, int inst)

^~~~~~~~~~

C:\Users\Ron\Documents\Arduino\libraries\VidorGraphics\src\jtag.c: In function 'jtagReadBuffer':

C:\Users\Ron\Documents\Arduino\libraries\VidorGraphics\src\jtag.c:633:18: warning: passing argument 2 of 'ReadTDOBuf' from incompatible pointer type [-Wincompatible-pointer-types]

ReadTDOBuf(32, &address, 0, 0);

^

C:\Users\Ron\Documents\Arduino\libraries\VidorGraphics\src\jtag.c:202:13: note: expected 'char *' but argument is of type 'unsigned int *'

static void ReadTDOBuf(int bit_count, char *txbuf, char *rxbuf, int inst)

^~~~~~~~~~

C:\Users\Ron\Documents\Arduino\libraries\VidorGraphics\src\jtag.c:637:19: warning: passing argument 2 of 'ReadTDOBuf' from incompatible pointer type [-Wincompatible-pointer-types]

ReadTDOBuf(4, &address, 0, 1);

^

C:\Users\Ron\Documents\Arduino\libraries\VidorGraphics\src\jtag.c:202:13: note: expected 'char *' but argument is of type 'unsigned int *'

static void ReadTDOBuf(int bit_count, char *txbuf, char *rxbuf, int inst)

^~~~~~~~~~

In file included from C:\Users\Ron\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/samd21/include/samd21.h:69:0,

from C:\Users\Ron\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/samd.h:105,

from C:\Users\Ron\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/sam.h:540,

from c:\users\ron\appdata\local\arduino15\packages\arduino\hardware\samd_beta\1.6.23\cores\arduino\arduino.h:48,

from C:\Users\Ron\AppData\Local\Arduino15\packages\arduino\hardware\samd_beta\1.6.23\cores\arduino\USB\samd21_host.c:24:

C:\Users\Ron\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/samd21/include/samd21g18a.h:226:0: warning: "LITTLE_ENDIAN" redefined

define LITTLE_ENDIAN 1

In file included from c:\users\ron\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\sys\types.h:67:0,

from c:\users\ron\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\stdio.h:61,

from C:\Users\Ron\AppData\Local\Arduino15\packages\arduino\hardware\samd_beta\1.6.23\cores\arduino\USB\samd21_host.c:20:

c:\users\ron\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\machine\endian.h:17:0: note: this is the location of the previous definition

define LITTLE_ENDIAN _LITTLE_ENDIAN

In file included from C:\Users\Ron\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/samd21/include/samd21.h:69:0,

from C:\Users\Ron\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/samd.h:105,

from C:\Users\Ron\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/sam.h:540,

from C:\Users\Ron\AppData\Local\Arduino15\packages\arduino\hardware\samd_beta\1.6.23\cores\arduino\Arduino.h:48,

from C:\Users\Ron\AppData\Local\Arduino15\packages\arduino\hardware\samd_beta\1.6.23\cores\arduino\Print.cpp:23:

C:\Users\Ron\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/samd21/include/samd21g18a.h:226:0: warning: "LITTLE_ENDIAN" redefined

define LITTLE_ENDIAN 1

In file included from c:\users\ron\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\sys\types.h:67:0,

from c:\users\ron\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\stdio.h:61,

from C:\Users\Ron\AppData\Local\Arduino15\packages\arduino\hardware\samd_beta\1.6.23\cores\arduino\Print.cpp:20:

c:\users\ron\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\machine\endian.h:17:0: note: this is the location of the previous definition

define LITTLE_ENDIAN _LITTLE_ENDIAN

In file included from C:\Users\Ron\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/samd21/include/samd21.h:69:0,

from C:\Users\Ron\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/samd.h:105,

from C:\Users\Ron\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/sam.h:540,

from C:\Users\Ron\AppData\Local\Arduino15\packages\arduino\hardware\samd_beta\1.6.23\cores\arduino\SERCOM.h:22,

from C:\Users\Ron\AppData\Local\Arduino15\packages\arduino\hardware\samd_beta\1.6.23\cores\arduino\Uart.h:22,

from C:\Users\Ron\AppData\Local\Arduino15\packages\arduino\hardware\samd_beta\1.6.23\cores\arduino\Uart.cpp:19:

C:\Users\Ron\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/samd21/include/samd21g18a.h:226:0: warning: "LITTLE_ENDIAN" redefined

define LITTLE_ENDIAN 1

In file included from c:\users\ron\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\sys\types.h:67:0,

from c:\users\ron\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\stdio.h:61,

from C:\Users\Ron\AppData\Local\Arduino15\packages\arduino\hardware\samd_beta\1.6.23\cores\arduino\Print.h:23,

from C:\Users\Ron\AppData\Local\Arduino15\packages\arduino\hardware\samd_beta\1.6.23\cores\arduino\Stream.h:26,

from C:\Users\Ron\AppData\Local\Arduino15\packages\arduino\hardware\samd_beta\1.6.23\cores\arduino\HardwareSerial.h:24,

from C:\Users\Ron\AppData\Local\Arduino15\packages\arduino\hardware\samd_beta\1.6.23\cores\arduino\Uart.h:21,

from C:\Users\Ron\AppData\Local\Arduino15\packages\arduino\hardware\samd_beta\1.6.23\cores\arduino\Uart.cpp:19:

c:\users\ron\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\machine\endian.h:17:0: note: this is the location of the previous definition

define LITTLE_ENDIAN _LITTLE_ENDIAN

This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.

Thanks Ron

Hi @ronsoul,

At this point, I think we get your board swapped out. Please contact support@arduino.cc and link to this forum post to get the process started.

I was certain your board was reparable via software, but it does not seem to be the case.

@sandeepmistry

Thank you for the help.

Ron

@sandeepmistry

I received my replacement board last night. After updating the bootloader everything works as perfectly.

Ron

I got the board today and after I tried VidorDrawLogo example, I cannot upload any sketch in Normal mode to the board. So I tried the FPGA recovery procedure on Windows 10 and after I finished step 7, the red light keeps lit up, I wait for few more minutes, still lit up. So I keep doing the following steps and as the result, I still cannot upload sketch in normal mode.

And I also tried upload "SAMD_BootloaderUpdater" in DFU mode and it shows no need to update.

Hi, One thing most people don't notice is that some sketches such as Vidor draw logo wait for serial terminal to be open before doing anything, including initializing FPGA (there's a while loop waiting for serial to be opened). Also, we saw that some PCs tend to not be able to put the board in bootloader mode and this is something we are investigating. Please try uploading the board by manually entering bootloader by doubletapping the button. That should work.

DarioPennisi: including initializing FPGA (there's a while loop waiting for serial to be opened). Also, we saw that some PCs tend to not be able to put the board in bootloader mode and this is something we are investigating. Please try uploading the board by manually entering bootloader by doubletapping the button. That should work.

Dario,

Any news on the bootloader issue and the wait on serial port open issue?

Thanks, John W.

jwestmoreland: Any news on the bootloader issue and the wait on serial port open issue?

I think these were already fixed. I had serious problems with bootloader that come with vidor. After updating my bootloader my problems solved.

Also for vidor for waiting serial port to open is few lines in examples (draw logo). Just comment all lines that have "Serial" in it. Recommend to set IO pin for FPGA.begin failing indicator.

 void setup() {
  Serial.begin(9600);

  // wait for the serial monitor to open,
  // if you are powering the board from a USB charger remove the next line
  while (!Serial);

  // Initialize the FPGA
  if (!FPGA.begin()) {
    Serial.println("Initialization failed!");
    while (1) {}
  }

  delay(4000);
}

Limba,

I think the way to handle this has been suggested - I just hadn’t seen it yet - I’ve coded up something like this so if the serial port is connected it can still be used:

#define SERIAL_COUNTER_TIME_OUT 5000 // so serial port doesn’t hang the board

in setup():

unsigned int counter_main = 0;

Serial.begin(115200);

// in case serial port isn’t connected:
do {
counter_main++;

} while ( !Serial && ( counter_main < SERIAL_COUNTER_TIME_OUT) );

Maybe not the most efficient code but works for me.

Regards,
John W.

Hi.

It seems that fpga boot image's design sources was never released.

I'm considering replacing the boot image with own design, leaving more flash space for the application resources. But going through boot image recovery each time to enable uploading the new image/sketches is not really a good option. So I'm wondering, what IP and/or software must be present in my design to allow SAMD' bootloader to access the flash for uploading purposes? Any chances boot image design will be published, or there's some licensed IP?

Thanks! This worked for me.

Previously I had a SAM-BA error while uploading the blink-sketch code: https://hackaday.com/2018/11/01/hands-on-with-the-arduino-fpga/

Write 407667 bytes to flash (6370 pages) [================== ] 62% (3968/6370 pages) SAM-BA operation failed

I downloaded the VidorFPGARecovery.zip and followed the steps in the instruction.txt file. (I was amazed how long the activity log produced was, for the 3rd step.)

Now the previous code uploads and runs successfully. Thanks a lot!