.svd file for Unmatched's U74-MC processor?

Hi,

I am a Rust developer looking to work on a bare-metal project on the U74-MC. I’ve not been able to find an .svd file for the processor or .svd files for its U74+S1 cores (the Rust ecosystem uses these to build zero-overhead typesafe bindings to the processor’s peripherals).

Can anyone provide guidance on where I might find .svd file(s) for this processor or its cores?

Thanks in advance,
U007D

1 Like

There are SVD files in our bare metal bsp, freedom-e-sdk, but unfortunately we haven’t done a port of that to Unmatched yet. The focus for Unmatched work has been on Linux support only so far. Meanwhile, the best I can offer are DTS files in u-boot and the linux kernel ports. These are maintained as patches for upstream sources, so you would have to apply the patches and extract the DTS file. See for instance
https://github.com/sifive/meta-sifive/tree/2021.05/recipes-bsp/u-boot/files
https://github.com/sifive/meta-sifive/tree/2021.05/recipes-kernel/linux/files

1 Like

Thanks, @jimw. I’ll see what I can do with the DTS files for now.

Meanwhile, would it be fair to say that .svd support for Unmatched is weeks away or months away (as a rough guess, of course)?

I have no idea when there will be a freedom-e-sdk port.

Thanks, Jim.

I have applied the linux/patches to the latest in linux.git master as of yesterday–a good many of the changes were already there, which was nice to see.

I am assuming I don’t also need to apply the u-boot patches in order to have a usable .svd description of the device, can anyone confirm?

I am using GitHub - sifive/cmsis-svd-generator: Generates CMSIS-SVD xml files from DTS info and Register templates on the resulting .dts file at /arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts as follows:

./generate_svd.py -d ~/Development/3rd_party/torvalds/linux/arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts -o ../sifive-unmatched

But am getting an error:

Traceback (most recent call last):
  File "/Users/sergibli/Development/bg/sifive-riscv/cmsis-svd-generator/./generate_svd.py", line 139, in <module>
    main(sys.argv[1:])
  File "/Users/sergibli/Development/bg/sifive-riscv/cmsis-svd-generator/./generate_svd.py", line 132, in main
    dts = pydevicetree.Devicetree.parseFile(parsed_args.dts, followIncludes=True)
  File "/Users/sergibli/Library/Python/3.9/lib/python/site-packages/pydevicetree/ast/node.py", line 468, in parseFile
    return parseTree(contents, dirname, followIncludes)
  File "/Users/sergibli/Library/Python/3.9/lib/python/site-packages/pydevicetree/source/parser.py", line 185, in parseTree
    return Devicetree(parseElements(dts, pwd, followIncludes))
  File "/Users/sergibli/Library/Python/3.9/lib/python/site-packages/pydevicetree/source/parser.py", line 177, in parseElements
    elements = grammar.devicetree.parseString(dts, parseAll=True)
  File "/usr/local/lib/python3.9/site-packages/pyparsing.py", line 1955, in parseString
    raise exc
  File "/usr/local/lib/python3.9/site-packages/pyparsing.py", line 3814, in parseImpl
    raise ParseException(instring, loc, self.errmsg, self)
pyparsing.ParseException: Expected end of text, found '#'  (at char 83), (line:4, col:1)
▶ head -20 ~/Development/3rd_party/torvalds/linux/arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts
// SPDX-License-Identifier: (GPL-2.0 OR MIT)
/* Copyright (c) 2020 SiFive, Inc */

#include "fu740-c000.dtsi"
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/leds/common.h>
#include <dt-bindings/pwm/pwm.h>

/* Clock frequency (in Hz) of the PCB crystal for rtcclk */
#define RTCCLK_FREQ		1000000

/ {
	#address-cells = <2>;
	#size-cells = <2>;
	model = "SiFive HiFive Unmatched";
	compatible = "sifive,hifive-unmatched-a00", "sifive,fu740-c000",
		     "sifive,fu740";

	chosen {

Any ideas why generate_svd.py is expecting an EOF where it’s receiving the first # from #include?

Thanks in advance for any clues.

I’ve had some success converting the .dts files to .svd, thanks, @jimw. I learned that the .dts files need to be preprocessed by a C-compiler. That output then seems to need to be transpiled by a device tree compiler utility, dtc. And finally that output needs to be converted to .svd using cmsis-svd-generator.

All seemed to work fine, but the resulting .svd file’s “peripherals” section is empty. A helpful person thought that perhaps I need the fu740 register map definitions. Does anyone know where I could find these?

For more context, I posted the steps I took here: https://www.reddit.com/r/RISCV/comments/obmtmn/looking_for_or_want_to_generate_svd_for/h3rf68k?utm_source=share&utm_medium=web2x&context=3.

Thanks in advance–it looks like I’m getting close!

Turns out that there is an open pull request to add Unmatched support to freedom-e-sdk. This has an svd file that you can try.
https://github.com/sifive/freedom-e-sdk/pull/607

1 Like

I tried running it through svd2rust yesterday, but the tool choked. :frowning:

The good news is that the .svd looks like exactly what I need (as opposed to the one I generated with an empty peripherals section), so my next steps are to poke at the Rust tool to see why it’s crashing while attempting to parse the .svd file.

I’ve used svd2rust before without issue (including on the SiFive E310), so I have hope this will work. I’ll keep you posted on my progress…

Thanks again, @jimw!

The SiFive-generated file seems to work (still awaiting a PSU for my Unmatched for full confirmation, but from the toolchain’s perspective, all seems good)! :tada:

For anyone interested, I posted both the .svd (slightly updated with a header consistent with the FU-540 and a 64-bit bus width) and the generated Rust bindings here.