Porting Arduino MKR Vidor 4000

I was trying to write simple porting for the Arduino Vidor 4000. It has a Samd21 processor and Intel FPGA. Leaving the FPGA part aside at this moment, I just created a new board and created the required files for a new board. I followed the other MKR boards and pasted the makefiles, include/files.h etc. for samd21 based boards.

https://store-usa.arduino.cc/products/arduino-mkr-vidor-4000?selectedStore=us

Then I created a simple application to turn on the GPIO pin on the board. It has failed.!! The example build successfully and flashed but the LED didn’t turn on

For MKR board there is most of the board-specific code inside a boards/comman/arduino_mkr folder. The board itself has only makefile and board.h files. I am not sure what has gone wrong. BTW the board is working when I flash with make flash.

It is hard to tell without looking at the code. Could you share your branch development for this board ? It will be easier to spot a mistake this way.

I will fork the project and then let you know!!

I have created simple boards files for Arduino-mkrVidor4000, I followed the other samd21 based arduino boards file structure. I have skipped the Kconfig file, it is necessary?

If you plan to upstream this board to RIOT, yes.

Did you create your application for turn on the LED ? Or did you use RIOT tests application, like tests/leds for this purpose ?

If your plan is only to turn on the board LED, you need to change your LED0_* macros. Looking at the schematic of this board, the LED will be ON if GPIO is LOW. Thus, LED0_ON should call OUTCLR register, not OUTSET.

Hi, I wrote a line of code for turning LED On, I have connected an LED on the pin PA11 of the board. I have tried different configurations too. Let me check again by changing some Macros, but my thought us that it should work with GPIO_PIN set inside a code.

#define RGBLED GPIO_PIN(PA,11)

gpio_init(RGBLED,GPIO_OUT); gpio_write(RGBLED,0); //gpio_clear(RGBLED);

I plant to do write code for other peripherals also but first thing was to create something simple.

Did the onboard LED on PB8 light on when you set PB8 to low ?

Sorry! It does not.

I’m wondering if you flash the board properly. Are you using JLINK as flasher ? Please update your Makefile.include for your board, this board doesn’t feature a SAMW25 but a SAMD21. Could you also compile and flash tests/periph_gpio on your board, connect to RIOT shell and play with your GPIOs ? You can type “help” in the RIOT shell to get the list of available commands. Then, you could try to switch on/off all GPIOs you want for testing purpose.

Could you also share the command you are using for compile and flash your board with their outputs ?

I use the following command to flash the board

make BOARD=arduino-mkrvidor4000 -C examples/blinky/ flash

I have updated the processor in Makefile.include as samd21 still there is no change. I also tried the test/periph_gpio example but no change. Yes, I am using JLINK as flasher

Here is the cmd output for test/periph_gpio example

  text	   data	    bss	    dec	    hex	filename
  30128	    132	   5808	  36068	   8ce4	/user/RIOT/tests/periph_gpio/bin/arduino-mkrvidor4000/tests_periph_gpio.elf
stty -F /dev/ttyACM0 raw ispeed 1200 ospeed 1200 cs8 -cstopb ignpar eol 255 eof 255
sleep 2
/user/RIOT/dist/tools/bossa-1.9/bossac -p /dev/ttyACM0  -o 0x2000 -e -i -w -v -b -R /user/RIOT/tests/periph_gpio/bin/arduino-mkrvidor4000/tests_periph_gpio.bin
Device       : ATSAMD21x18
Version      : v2.0 [Arduino:XYZ] Aug  9 2018 11:17:30
Address      : 0x0
Pages        : 4096
Page Size    : 64 bytes
Total Size   : 256KB
Planes       : 1
Lock Regions : 16
Locked       : none
Security     : false
BOD          : true
BOR          : true
Erase flash

Done in 0.841 seconds
Write 30260 bytes to flash (473 pages)
[==============================] 100% (473/473 pages)
Done in 0.200 seconds
Verify 30260 bytes of flash
[==============================] 100% (473/473 pages)
Verify successful
Done in 0.271 seconds
Set boot flash true
make: Leaving directory

Looks like BOSSA is used here instead of JLINK, might explained the issue.

Please try to add PROGRAMMER=jlink in your make command. e.g PROGRAMMER=jlink make BOARD=arduino-mkrvidor4000 -C examples/blinky/ flash

Why would it use JLink ? The MKR boards have an on-board Arduino bootloader and it seems that flashing it with bossa worked.

Was just asking. I know I had several issues with BOSSA on custom board which frustrate me so much that I migrate every board to riotboot_dfu.

Moreover, JLINK can be used with make debug to do some step by step debugging and understand what is going on here.

There are several things to be aware of before flashing this kind of board with JLink:

  • you need an on-board jtag connector. If it’s not available you have to solder it (AFAICT, only the mkr1000 has the jtag connector available by default)
  • more important: flashing with JLink doesn’t take into account the ROM space used by the Arduino bootloader. As a result, it will be overwritten and bossa cannot be used afterwards unless an Arduino bootloader is reflashed, using JLink.
1 Like

True. Arduino-mkrvidor4000 does not have JLink onboard interface. Need to do it with pin soldering and external chip. Will come up with something.