V1.0.1 of Arduino Board Support Package Released

If you’re an Arduino IDE user, we’ve released v1.0.1 of the Board Support Package, and made the repository public.

If you’ve already installed v1.0.0, you should see an “Update” button when you do Tools-> Boards-> Board Manager and search for the SiFive boards.

What’s changed?

  • Bumped the version of OpenOCD, which means this package now works on macOS.
  • Updated the delay(), millis(), and micros() functions to use 64-bit values, to avoid glitches at 32-bit rollover.

The public repo can be found here:

1 Like

I am working here in a VirtualBox installation of Ubuntu 16.04 on Windows7_64. I have never used Arduino before. Following the README in the target repo I get the following error with “Upload Using Programmer” to the Arty using “SiFive OpenOCD” as the programmer:

Arduino: 1.8.1 (Linux), Board: “Freedom E300 Arty DevKit, Default, 65MHz FPGA Clock”

Sketch uses 6056 bytes (0%) of program storage space. Maximum is 8388608 bytes.
/home/donnie/.arduino15/packages/sifive/tools/openocd/193f63094891cd3fe6a5032fef2c71d09f063ff4/bin/openocd -f /home/donnie/.arduino15/packages/sifive/hardware/riscv/1.0.1/freedom-e-sdk/bsp/env/freedom-e300-arty/openocd.cfg -c program /tmp/arduino_build_997318/sketch_jan14a.ino.elf verify; resume 0x20400000; exit
An error occurred while uploading the sketch
Open On-Chip Debugger 0.10.0-dev-g193f630 (2017-01-03-22:36)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
adapter speed: 10000 kHz
/home/donnie/.arduino15/packages/sifive/hardware/riscv/1.0.1/freedom-e-sdk/bsp/env/freedom-e300-arty/openocd.cfg:3: Error: Can’t find interface/ftdi/olimex-arm-usb-tiny-h.cfg
in procedure ‘script’
at file “embedded:startup.tcl”, line 60
at file “/home/donnie/.arduino15/packages/sifive/hardware/riscv/1.0.1/freedom-e-sdk/bsp/env/freedom-e300-arty/openocd.cfg”, line 3

If I try with programmer “Manual SiFive openOCD” with only the debugger attached to the Arty, I am getting this error:

Arduino: 1.8.1 (Linux), Board: “Freedom E300 Arty DevKit, Default, 65MHz FPGA Clock”

Sketch uses 6056 bytes (0%) of program storage space. Maximum is 8388608 bytes.
openocd -f /home/donnie/.arduino15/packages/sifive/hardware/riscv/1.0.1/freedom-e-sdk/bsp/env/freedom-e300-arty/openocd.cfg -c program /tmp/arduino_build_997318/sketch_jan14a.ino.elf verify; resume 0x20400000; exit
Open On-Chip Debugger 0.9.0 (2015-09-02-10:42)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
adapter speed: 10000 kHz
Info : auto-selecting first available session transport “jtag”. To override use 'transport select '.
embedded:startup.tcl:21: Error: Unknown target type riscv, try one of arm7tdmi, arm9tdmi, arm920t, arm720t, arm966e, arm946e, arm926ejs, fa526, feroceon, dragonite, xscale, cortex_m, cortex_a, cortex_r4, arm11, mips_m4k, avr, dsp563xx, dsp5680xx, testee, avr32_ap7k, hla_target, nds32_v2, nds32_v3, nds32_v3m, or1k, or quark_x10xx
in procedure ‘script’
at file “embedded:startup.tcl”, line 60
in procedure ‘target’ called at file “/home/donnie/.arduino15/packages/sifive/hardware/riscv/1.0.1/freedom-e-sdk/bsp/env/freedom-e300-arty/openocd.cfg”, line 9
in procedure ‘ocd_bouncer’
at file “embedded:startup.tcl”, line 21
the selected serial port in procedure ‘ocd_bouncer’
does not exist or your board is not connected

If I connect the USB serial port I get:

Arduino: 1.8.1 (Linux), Board: “Freedom E300 Arty DevKit, Default, 65MHz FPGA Clock”

Sketch uses 6056 bytes (0%) of program storage space. Maximum is 8388608 bytes.
openocd -f /home/donnie/.arduino15/packages/sifive/hardware/riscv/1.0.1/freedom-e-sdk/bsp/env/freedom-e300-arty/openocd.cfg -c program /tmp/arduino_build_997318/sketch_jan14a.ino.elf verify; resume 0x20400000; exit
Open On-Chip Debugger 0.9.0 (2015-09-02-10:42)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
adapter speed: 10000 kHz
An error occurred while uploading the sketch
Info : auto-selecting first available session transport “jtag”. To override use 'transport select '.
embedded:startup.tcl:21: Error: Unknown target type riscv, try one of arm7tdmi, arm9tdmi, arm920t, arm720t, arm966e, arm946e, arm926ejs, fa526, feroceon, dragonite, xscale, cortex_m, cortex_a, cortex_r4, arm11, mips_m4k, avr, dsp563xx, dsp5680xx, testee, avr32_ap7k, hla_target, nds32_v2, nds32_v3, nds32_v3m, or1k, or quark_x10xx
in procedure ‘script’
at file “embedded:startup.tcl”, line 60
in procedure ‘target’ called at file “/home/donnie/.arduino15/packages/sifive/hardware/riscv/1.0.1/freedom-e-sdk/bsp/env/freedom-e300-arty/openocd.cfg”, line 9
in procedure ‘ocd_bouncer’
at file “embedded:startup.tcl”, line 21

>

Uploading with openOCD from the command line using “make upload PROGRAM= …” works fine.

What am doing wrong in the Arduino IDE?

I have managed to get the IDE to recognize the programmer, but I still am not able to upload “blinky” to the Arty using the IDE:

I would like to look into the embedded:startup.tcl file to see what it is looking for, but I am not able to locate it.

Any help?

Ah, the problem is that it’s trying to load the flash, but the flash is protected. Our script is supposed to lift the protection before attempting to program it.

Error: Flash sector 64 protected

This looks like it could be a bug in our OpenOCD script for the Arty. Let me give you a local fix and we can get it into the 1.0.2 version

Can you please uncomment the last line in

/home/donnie/.arduino15/packages/sifive/hardware/riscv/1.0.1/freedom-e-sdk/bsp/env/freedom-e300-arty/openocd.cfg

flash protect 0 64 last off

Thanks Megan,

I removed the line you specified, but I still get the flash protection error. Do I need to initialize something? I did restart the IDE after deleting the line.

Did you remove the line, or uncomment it? You need the line without the ‘#’ in front.

Oh silly me! I indeed deleted it :blush: Sorry. I set the line back uncommented and no longer get the flash protection error. Still getting some errors, though:

donnie@SiFive:~$ /opt/arduino-1.8.1/arduino
Picked up JAVA_TOOL_OPTIONS:
Sketch uses 6664 bytes (0%) of program storage space. Maximum is 8388608 bytes.
openocd -f /home/donnie/.arduino15/packages/sifive/hardware/riscv/1.0.1/freedom-e-sdk/bsp/env/freedom-e300-arty/openocd.cfg -c program /tmp/arduino_build_264012/Blink.ino.elf verify; resume 0x20400000; exit
Open On-Chip Debugger 0.10.0-dev-ge31dd22 (2016-12-15-21:08)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
adapter speed: 10000 kHz
Info : auto-selecting first available session transport “jtag”. To override use 'transport select '.
Info : ftdi: if you experience problems at higher adapter clocks, try the command "ftdi_tdo_sample_edge falling"
Info : clock speed 10000 kHz
Info : JTAG tap: riscv.cpu tap/device found: 0x10e31913 (mfg: 0x489 (), part: 0x0e31, ver: 0x1)
halted at 0x404 due to software breakpoint
Info : Examined RISCV core; XLEN=32, misa=0x40001105
Info : Found flash device ‘micron n25q128’ (ID 0x0018ba20)
cleared protection for sectors 64 through 255 on flash bank 0
Info : JTAG tap: riscv.cpu tap/device found: 0x10e31913 (mfg: 0x489 (), part: 0x0e31, ver: 0x1)
riscv.cpu: target state: halted
halted at 0x404 due to software breakpoint
** Programming Started **
auto erase enabled
Error: Algorithm timed out after 10000 ms.
Info : dtmcontrol_idle=5, dbus_busy_delay=0, interrupt_high_delay=1
Error: Timed out waiting for debug int to clear.
Error: Debug interrupt didn’t clear.
Error: Debug RAM 0x0: 0x7b046073
Error: Debug RAM 0x1: 0xf1402473
Error: Debug RAM 0x2: 0x10802623
Error: Debug RAM 0x3: 0x3f80006f
Error: Debug RAM 0x4: 0x4000f063
Error: Debug RAM 0x5: 0x20405a88
Error: Debug RAM 0x6: 0x00000000
Error: Debug RAM 0x7: 0x00000000
Error: Debug RAM 0x8: 0x00000000
Error: Debug RAM 0x9: 0x00000000
Error: Debug RAM 0xa: 0x00000000
Error: Debug RAM 0xb: 0x00000000
Error: Debug RAM 0xc: 0x00000000
Error: Debug RAM 0xd: 0x00000000
Error: Debug RAM 0xe: 0x00000000
Error: Debug RAM 0xf: 0x00000000
Error: cache_write() failed.
Error: Failed to execute algorithm at 0x80000000: -302
Info : dtmcontrol_idle=5, dbus_busy_delay=0, interrupt_high_delay=2
Error: Timed out waiting for debug int to clear.
Error: Debug interrupt didn’t clear.

Hmm, you may need to RESET your Arty (sorry to give the “unplug and replug” answer…)

Yes, I tried power cycling the Arty, but got some strange “memory already being used” errors, also when trying to upload using make, so powered down the arty and the olimex debugger, re-booted Linux and tried again. I can now again upload using make, but the Linux reboot seems to lost something in the IDE environment. Now I get this:

It’s late and I gotta work tomorrow, so I am calling it quits for today. Just making mistakes anyway :dizzy_face:

It looks like you are using the “Manual SiFive OpenOCD”, but the Freedom E SDK version of openocd is not at the front of your $PATH variable. I am saying that because the second line is just using openocd, so it doesn’t know about riscv. So I’m guessing you have some other version of openocd installed on your Linux system, which it is trying to use.

You should either:

  • use the “SiFive OpenOCD” programmer instead of “Manual SiFive OpenOCD” (This will use the version from the Board Support Package, and is the preferred way to do it)

or

  • make sure that the freedom-e-sdk version of openocd is on your $PATH at the beginning. You can use ‘which openocd’ (before launching the Arduino IDE from the command line) to make sure it’s using the right one

Hi Megan,

Yes, I am using the “Manual SiFive OpenOCD” because it was finding my Olimex, and when trying to use"SiFiveOpenOCD" it was not (and still is not) being found:

“which openocd” returned /home/donnie/freedom-e-sdk/toolchain/bin/openocd after plutting /home/donnie/freedom-e-sdk/toolchain/bin in the beginning of $PATH, and I can now upload “Blink” using the Arduino IDE with “Manual SiFive OpenOCD” :slight_smile:

Any idea why I am getting that error with the preferred way?

Also, I have to use “Upload Using Programmer” and not “Upload” - not sure if that is the preferred way or not. I go with anything that works.

Ah, I see the problem. Sorry, the packaged flow for the Arty got a bit behind (we do most of our dev with the “Manual” option).

The problem is:

Error: Can't find interface/ftdi/olimex-arm-usb-tiny-h.cfg.

That depends on other files that should be installed with OpenOCD, but they aren’t making it into the Board Support Package. HiFive1 doesn’t have this problem because we just put the relevant parts of the cfg into our file rather than including one.

Hi Megan,

Now that I can upload from the Arduino IDE I am not sure that things are working as they should. A few of the “Basic” examples, like Blink and Fade, will compile but some others will not, for instance the first in the Basic list: “AnalogReadSerial”:

In another thread you wrote: “The Arduino IDE is really just a wrapper around the compiled toolchains.”. Does that mean I should not expect standard Arduino IDE libraries/functionality work properly (using Arty?), or is there still something wrong with my (and/or “the”) Arty toolchain?

The HiFive1 does not have any analogue inputs. If you want some you’ll have to add them on a shield, talking to I2C or something.

There are digital inputs, digital outputs, and “analogue” outputs (via PWM, as on normal Arduinos).

If I am not mistaking, the Arty does.

Ah, you are right that the Arty does have analog inputs, but the current Arty image just attempts to model the HiFive1, and that isn’t really exposed in the Arduino Library.

Ok, with you so far. But keeping on the examples and going on to “Digital” why does “toneMelody” fail to compile?

Oh, fun! I didn’t know about that library. https://www.arduino.cc/en/Reference/Tone. That library can certainly be implement it for FE310 using the PWM hardware, but it’s not currently part of our Package.

So, if I were to place that library in /home/donnie/freedom-e-sdk/toolchain/riscv32-unknown-elf/include, then it should compile and work?