A RISC-V single board computer


I finally have a RISC-V based single board computer (SBC) – the Nezha from RV Boards shipped to me directly from China.

It’s tiny (about the same form-factor as a Raspberry Pi though) and relatively expensive (it cost me just over £100 to order and get it shipped here) but whilst I was slightly concerned I was being a bit naïve in buying it (as it was either a scam or it wouldn’t work), it boots (slowly) into Linux (see image) and works (slowly).

Can RISC-V cores (which are ‘open source hardware’ and free from licensing fees) break ARM’s grip on SBCs and similar devices? A year ago the answer looked like a very clear negative as, despite years of hype, RISC-V designs just weren’t moving off the page and into silicon. Now it looks much more uncertain as the Nezha is actually the second RISC-V SBC to ship (the other, the Beagle-V, has only been distributed to a select group of developers so far – and this didn’t include me despite my application – but is expected to be available globally in the autumn).

The plans are for RISC-V SBCs retailing for less than $20 inside a year and – crucially – for the RISC-V cores to feature vector extensions which could mean some interesting use-cases being opened up.

(If you want to know more about RISC-V or if you are thinking of starting a RISC-V assembly project I cannot recommend The RISC-V Reader highly enough.)

Right now I am trying to get Riscyforth to run on my machine.

Coming soon: RISCYFORTH


When I was much younger FORTH fascinated me as an alternative interpreted language for the Z80 eight-bit processor machines I was typically using.

Compared to BASIC – the language that the Sinclair ZX80, ZX81 and Spectrum came with – FORTH was reputedly lightening fast and very powerful.

My brother and I even obtained a tape copy of somebody’s FORTH for the ZX80 and we ran it – and it certainly was fast. But it also lacked the simplicity of BASIC and the tape was soon handed back.

But I’m back on the case again, inspired by this (long out of print but widely available on the web) book – Threaded Interpretive Languages – and by the prospect of a single board RISC-V computer – the BeagleV – coming out this year.

Currently I am targeting the PK proxy kernel on the Spike Risc-V emulator for RISCYFORTH but if and when I get a real BeagleV I’ll immediately switch to that (I applied to be an early user but have heard nothing so while the signs are that the project itself is making good progress it looks like I’ll have to wait to get my hands on one.)

I struggled with getting the mechanics of RISCYFORTH right for a long time but in the last week I’ve finally started to make serious progress and it actually does things (only in immediate mode for now). The picture shows my very first success with a multi-token command line from a couple of evenings ago and it’s come on a fair bit since then.

It’s nowhere near a releasable state but it’s rapidly improving.

Why bother? Well I think it’s important that RISC-V succeeds as a disruptor of what is starting to look like an ARM monopoly and so contributing to the ecosystem of the first single board seriously affordable RISC-V device matters. And, of course, because it’s there.

Always yield to the hands-on imperative (from this classic).

Update: My brother actually thinks we borrowed somebody’s Jupiter Ace which was a Z80-based FORTH computer of a very similar size to a ZX81 – and I think he might be right.

Running BASIC on the Raspberry Pi


Actually, I ran BINSIC, my very own dialect of BASIC on the Raspberry Pi – it is very slow (a bit slower even than a ZX81 back in the day) but it does work.Raspberry Pi running

Haven’t had a chance to investigate what happens if I tweak the settings on the thing – possibly I might be able to speed execution up. Could be that Java and Groovy is just too much bloat, could be that BINSIC just demands a lot of computation (I refuse to consider that it might be poorly designed and executed).

Dmesg from Raspberry Pi


Sadly could not get it to work with the video cable I had, so work colleagues will have to wait to see this thing put through its paces, but it boots headless.

[ 0.000000] Initializing cgroup subsys cpu
[ 0.000000] Linux version 3.1.9+ (dc4@dc4-arm-01) (gcc version 4.5.1 (Broadcom-2708) ) #168 PREEMPT Sat Jul 14 18:56:31 BST 2012
[ 0.000000] CPU: ARMv6-compatible processor [410fb767] revision 7 (ARMv7), cr=00c5387d
[ 0.000000] CPU: VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
[ 0.000000] Machine: BCM2708
[ 0.000000] Memory policy: ECC disabled, Data cache writeback
[ 0.000000] On node 0 totalpages: 49152
[ 0.000000] free_area_init_node: node 0, pgdat c05f7c4c, node_mem_map c06c8000
[ 0.000000] Normal zone: 384 pages used for memmap
[ 0.000000] Normal zone: 0 pages reserved
[ 0.000000] Normal zone: 48768 pages, LIFO batch:15
[ 0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[ 0.000000] pcpu-alloc: [0] 0
[ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 48768
[ 0.000000] Kernel command line: dma.dmachans=0x3c bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708.boardrev=0x2 bcm2708.serial=0x5321aa64 smsc95xx.macaddr=B8:27:EB:21:AA:64 dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
[ 0.000000] PID hash table entries: 1024 (order: 0, 4096 bytes)
[ 0.000000] Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
[ 0.000000] Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
[ 0.000000] Memory: 192MB = 192MB total
[ 0.000000] Memory: 187880k/187880k available, 8728k reserved, 0K highmem
[ 0.000000] Virtual kernel memory layout:
[ 0.000000] vector : 0xffff0000 – 0xffff1000 ( 4 kB)
[ 0.000000] fixmap : 0xfff00000 – 0xfffe0000 ( 896 kB)
[ 0.000000] DMA : 0xffc00000 – 0xffe00000 ( 2 MB)
[ 0.000000] vmalloc : 0xcc800000 – 0xd8000000 ( 184 MB)
[ 0.000000] lowmem : 0xc0000000 – 0xcc000000 ( 192 MB)
[ 0.000000] modules : 0xbf000000 – 0xc0000000 ( 16 MB)
[ 0.000000] .text : 0xc0008000 – 0xc05943d0 (5681 kB)
[ 0.000000] .init : 0xc0595000 – 0xc05c7000 ( 200 kB)
[ 0.000000] .data : 0xc05c8000 – 0xc05f93b8 ( 197 kB)
[ 0.000000] .bss : 0xc05f93dc – 0xc06c7504 ( 825 kB)
[ 0.000000] NR_IRQS:245
[ 0.000000] timer_set_mode: unhandled mode:1
[ 0.000000] timer_set_mode: unhandled mode:3
[ 0.000000] Console: colour dummy device 80×30
[ 0.000000] console [tty1] enabled
[ 3.008944] Calibrating delay loop… 697.95 BogoMIPS (lpj=3489792)
[ 3.067898] pid_max: default: 32768 minimum: 301
[ 3.068528] Mount-cache hash table entries: 512
[ 3.069184] Initializing cgroup subsys cpuacct
[ 3.069298] Initializing cgroup subsys devices
[ 3.069349] Initializing cgroup subsys freezer
[ 3.069394] Initializing cgroup subsys blkio
[ 3.069512] CPU: Testing write buffer coherency: ok
[ 3.069646] ftrace: allocating 14801 entries in 44 pages
[ 3.142643] hw perfevents: enabled with v6 PMU driver, 3 counters available
[ 3.144629] devtmpfs: initialized
[ 3.152379] NET: Registered protocol family 16
[ 3.154308] vc-mem: mm_vc_mem_phys_addr = 0x00000000
[ 3.154373] vc-mem: mm_vc_mem_size = 0x10000000 (256 MiB)
[ 3.154891] hw-breakpoint: found 6 breakpoint and 1 watchpoint registers.
[ 3.154964] hw-breakpoint: maximum watchpoint size is 4 bytes.
[ 3.155013] mailbox: Broadcom VideoCore Mailbox driver
[ 3.155125] bcm2708_vcio: mailbox at f200b880
[ 3.155233] bcm_power: Broadcom power driver
[ 3.155281] bcm_power_open() -> 0
[ 3.155314] bcm_power_request(0, 8)
[ 3.656009] bcm_mailbox_read -> 00000080, 0
[ 3.656055] bcm_power_request -> 0
[ 3.656088] Serial: AMBA PL011 UART driver
[ 3.656281] dev:f1: ttyAMA0 at MMIO 0x20201000 (irq = 83) is a PL011 rev3
[ 3.961991] console [ttyAMA0] enabled
[ 3.987793] bio: create slab at 0
[ 3.993362] SCSI subsystem initialized
[ 3.997412] usbcore: registered new interface driver usbfs
[ 4.003206] usbcore: registered new interface driver hub
[ 4.008839] usbcore: registered new device driver usb
[ 4.014995] Switching to clocksource stc
[ 4.024054] Switched to NOHz mode on CPU #0
[ 4.037751] FS-Cache: Loaded
[ 4.041143] CacheFiles: Loaded
[ 4.062678] NET: Registered protocol family 2
[ 4.067628] IP route cache hash table entries: 2048 (order: 1, 8192 bytes)
[ 4.076225] TCP established hash table entries: 8192 (order: 4, 65536 bytes)
[ 4.083753] TCP bind hash table entries: 8192 (order: 3, 32768 bytes)
[ 4.090454] TCP: Hash tables configured (established 8192 bind 8192)
[ 4.096838] TCP reno registered
[ 4.100049] UDP hash table entries: 256 (order: 0, 4096 bytes)
[ 4.105942] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[ 4.112808] NET: Registered protocol family 1
[ 4.118168] RPC: Registered named UNIX socket transport module.
[ 4.124352] RPC: Registered udp transport module.
[ 4.129129] RPC: Registered tcp transport module.
[ 4.133858] RPC: Registered tcp NFSv4.1 backchannel transport module.
[ 4.140699] bcm2708_dma: DMA manager at cc808000
[ 4.145463] bcm2708_gpio: bcm2708_gpio_probe c05d00e0
[ 4.151132] vc-mem: Videocore memory driver
[ 4.156232] audit: initializing netlink socket (disabled)
[ 4.161794] type=2000 audit(0.780:1): initialized
[ 4.273943] VFS: Disk quotas dquot_6.5.2
[ 4.278154] Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
[ 4.286181] FS-Cache: Netfs ‘nfs’ registered for caching
[ 4.292889] msgmni has been set to 366
[ 4.299441] io scheduler noop registered
[ 4.303417] io scheduler deadline registered (default)
[ 4.308775] io scheduler cfq registered
[ 4.313091] BCM2708FB: registering framebuffer (656×416@16)
[ 4.319455] bcm2708_fb_set_par info(cb8ec400) 656×416 (656×416), 0, 16
[ 4.324300] BCM2708FB: start = cc900000,4d385000 width=656, height=416, bpp=16, pitch=1312 size=545792 success=0
[ 4.328226] Console: switching to colour frame buffer device 82×26
[ 4.363081] BCM2708FB: register framebuffer (0)
[ 4.370756] kgdb: Registered I/O driver kgdboc.
[ 4.389840] brd: module loaded
[ 4.401655] loop: module loaded
[ 4.408070] vcos: [1]: vchiq_init_state: slot_zero = 0xffd80000, is_master = 0
[ 4.417984] vcos: [1]: vchiq_init_state: called
[ 4.425920] vcos: [1]: vchiq: initialised – version 2 (min 2), device 253.0
[ 4.436157] usbcore: registered new interface driver smsc95xx
[ 4.444401] cdc_ncm: 04-Aug-2011
[ 4.450190] usbcore: registered new interface driver cdc_ncm
[ 4.458183] dwc_otg: version 2.90b 6-MAY-2010 (platform bus)
[ 4.466607] Core Release: 2.80a
[ 4.472190] Setting default values for core params
[ 4.479410] Finished setting default values for core params
[ 4.487660] cc840008 -> 1
[ 4.692730] Using Buffer DMA mode
[ 4.698348] Periodic Transfer Interrupt Enhancement – disabled
[ 4.706568] Multiprocessor Interrupt Enhancement – disabled
[ 4.714606] dwc_otg bcm2708_usb: DWC OTG Controller
[ 4.722035] dwc_otg bcm2708_usb: new USB bus registered, assigned bus number 1
[ 4.731718] dwc_otg bcm2708_usb: irq 75, io mem 0x00000000
[ 4.739565] Init: Port Power? op_state=1
[ 4.745661] Init: Power Port (0)
[ 4.751275] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[ 4.760478] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 4.770048] usb usb1: Product: DWC OTG Controller
[ 4.776999] usb usb1: Manufacturer: Linux 3.1.9+ dwc_otg_hcd
[ 4.784974] usb usb1: SerialNumber: bcm2708_usb
[ 4.792912] hub 1-0:1.0: USB hub found
[ 4.798875] hub 1-0:1.0: 1 port detected
[ 4.805829] Module dwc_common_port init
[ 4.806233] usbcore: registered new interface driver uas
[ 4.813839] Initializing USB Mass Storage driver…
[ 4.821204] usbcore: registered new interface driver usb-storage
[ 4.829462] USB Mass Storage support registered.
[ 4.836535] usbcore: registered new interface driver libusual
[ 4.845075] mousedev: PS/2 mouse device common for all mice
[ 4.853041] cpuidle: using governor ladder
[ 4.859428] cpuidle: using governor menu
[ 4.865595] sdhci: Secure Digital Host Controller Interface driver
[ 4.874016] sdhci: Copyright(c) Pierre Ossman
[ 4.880758] bcm_power_open() -> 1
[ 4.886491] Registered led device: mmc0::
[ 4.887001] mmc0: SDHCI controller on BCM2708_Arasan [platform] using platform’s DMA
[ 4.899412] mmc0: BCM2708 SDHC host at 0x20300000 DMA 2 IRQ 77
[ 4.907624] sdhci-pltfm: SDHCI platform and OF driver helper
[ 4.915932] Registered led device: led0
[ 4.916420] usbcore: registered new interface driver usbhid
[ 4.925516] usbhid: USB HID core driver
[ 4.933397] TCP cubic registered
[ 4.938859] Initializing XFRM netlink socket
[ 4.945587] NET: Registered protocol family 17
[ 4.954648] Registering the dns_resolver key type
[ 4.967050] VFP support v0.3: implementor 41 architecture 1 part 20 variant b rev 5
[ 4.989569] Waiting for root device /dev/mmcblk0p2…
[ 5.022690] mmc0: problem reading SD Status register.
[ 5.047824] mmc0: new high speed SDHC card at address 0215
[ 5.069785] mmcblk0: mmc0:0215 APPSD 30.6 GiB
[ 5.078236] mmcblk0: p1 p2
[ 5.209561] usb 1-1: new high speed USB device number 2 using dwc_otg
[ 5.439438] usb 1-1: New USB device found, idVendor=0424, idProduct=9512
[ 5.448581] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[ 5.459482] hub 1-1:1.0: USB hub found
[ 5.465852] hub 1-1:1.0: 3 ports detected
[ 5.749161] usb 1-1.1: new high speed USB device number 3 using dwc_otg
[ 5.869564] usb 1-1.1: New USB device found, idVendor=0424, idProduct=ec00
[ 5.879263] usb 1-1.1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[ 5.892256] smsc95xx v1.0.4
[ 5.954590] smsc95xx 1-1.1:1.0: eth0: register ‘smsc95xx’ at usb-bcm2708_usb-1.1, smsc95xx USB 2.0 Ethernet, b8:27:eb:21:aa:64
[ 10.705547] EXT4-fs (mmcblk0p2): recovery complete
[ 10.715781] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[ 10.729063] VFS: Mounted root (ext4 filesystem) on device 179:2.
[ 10.738931] Freeing init memory: 200K
[ 24.983111] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
[ 25.326722] ### snd_bcm2835_alsa_probe c05d07a0 ############### PROBING FOR bcm2835 ALSA device (0):(1) ###############
[ 25.349304] Creating card…
[ 25.354678] Creating device/chip ..
[ 25.369822] Adding controls ..
[ 25.375202] Registering card ….
[ 25.396456] bcm2835 ALSA CARD CREATED!
[ 25.408425] ### BCM2835 ALSA driver init OK ###
[ 32.799926] smsc95xx 1-1.1:1.0: eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
[ 38.998740] Adding 102396k swap on /var/swap. Priority:-1 extents:1 across:102396k SS