Dash's RISC-y business
19 Jul 2022
The Dart 2.17 announcement included adding (experimental) support for the RISC-V architecture and this was for me, one of the highlights of the release.
For those that may not have heard of it before, RISC-V is relatively new CPU architecture, that importantly has an open standard instruction set architecture (ISA) and that after more than a decade, is finally now showing up in real hardware products.
Choosing the right acronym
While there have already been a handful of RISC-V SoC development boards released, one of the first that is both reasonably priced and widely available is the Sipeed Lichee RV with the Allwinner D1 SoC.
After ordering one from their online store, I recently recieved a Lichee RV board and was keen to test out using Dart on it!
One important thing to be aware of is that Dart only supports running on a RISC-V rv32gc and rx64gc on Linux and there are other variations of the RISC-V ISA such as the much more lower powered RV32IMC that is starting to appear in micro-controllers such as the Espressif ESP32-C3.
Of course hardware is nothing more than a paper weight without software. Vendors of these kinds of development boards will normally provide an operating system to run on the board as a part of a Board Support Package (BSP). However these BSPs, while almost always based on Linux (or an Android flavour) will usually be based on a out dated (or even ancient) version of the Linux kernel and a similiarly out dated mainstream Linux distribution (eg. Ubuntu or Debian) and will likely contain binary blobs or other dependencies on proprietary software. Hardly the ideal starting point for our adventures in running Dart on a embedded device!
Installing on the D1
While an alternative option to using Vendor BSPs is to build yourself a Linux kernel and or Linux distro from scratch, luckily for me, others had already done a lot of work on this and had paved the way here.
So I ended up using the prebuilt Linux kernel and rootfs from Andreas to put on a SD card. Once you pop that into the Lichee boards sdcard slot, you get a Debian distribution running on the board without any real problems. The instructions on the web page are very comprehensive, so I won't repeat them here, other than to note that I wasn't able to get the board to get onto my wifi AP straight away, so I ended up connecting a USB UART adapter to it and my laptop to get a serial console access to the board.
Once Debian is up and running on the Lichee, it's a pretty straight forward matter of getting the Wifi setup and then, with SSH available, using
scp to copy across the Dart SDK for RISC-V (RV64GC) which you can now get from either the Beta or Dev Dart channels.
Once the Dart SDK is installed, using it is the same as on any other machine running Linux.
Given it's Dart "experimental" status for RISC-V, there are of course still a number of known issues with the RISC-V port. These include incomplete FFI support and rather low performance in non-AOT modes. The second issue is the most limiting right now and really means that only AOT provides good enough performance for running Dart applications on the Lichee board.
Of course getting Dart command line programs working in a SSH session is just the beginning and not that exciting when it comes to small embedded development boards, so in the next article I will be looking at how to get your Dart application talking to some of the hardware I/O thats available on the Lichee board.
I hope this has been of help to you and if it has or you have any other handy tips to share, please let me know in the comments below or via Twitter.