Freedom Metal Register Addresses Header File

Sorry for the noob questions in advance. Although Freedom Metal is very convenient to use and a great framework, I figured, that a couple of things are not (yet?) implemented. For instance, there is no API for hardware PWM. Now, I cannot find the header file in the freedom-e-sdk, that defines the register addresses. I guess there is one, right? Can you point me to it? Manual definitions as I have em right now are kind of stupid:

#define FAN_GPIO_SPEEDO 23
#define GPIO_PUE_ADDR (int*)(0x10012000 + 0x10)

Yes, there are some things that have been added after the last release, and PWM should be one of them: Hopefully this will show up in the next release :slight_smile:

As for headers, those are generated from the device trees using the freedome-devicetree-tools and freedom-metal, and my guess is the PWM support was also missing (hence no presence in the headers).

I’ve had decent luck using the master branch of freedom-e-sdk if you do need either the API or header definitions.


Thanks for your reply. I do not necessarily want to switch the branch. The code is supposed to run reliably. Can I find all the PWM registers in a file on the web?

Totally understandable, and for sure. They are documented in the SoC’s manual.

HiFive1 (FE310-G000, Chapter 19)
HiFive1-RevB (FE310-G002, Chapter 20)

Thanks. I meant a header file. Like “platform.h” in here: defining the register addresses for me. I have never worked with an microcontroller, that does not ship with such file.

Very true. Aside from the both Manual and the Datasheet, sometimes helpful to find missing or undocumented features directly in the asic circuit code

For example, in the case of the SPI blocks at 0x10014000, 0x10024000, and 0x10034000 there are the two very important registers not shown in Chapter 19, Table 65 of the Manual:
extradel : 0x38
sampledel : 0x3c
Implementation of sampledel and extradel adjustments to SPI

Suggestion @m3x1m0m when you find there’s a header file missing, make one (!) and put it out there for all to use–true power of community development.

1 Like

I think there was a point where they pivoted to focus on freedom-metal as the basis for the SDK. My guess would be they thought it would be a better use of time as they are trying to start a “silicon as a service” approach and I imagine generating BSPs automatically from DTS would be a boon. I did look through the PWM PR to see if there was a header you can use, but it seems very metal API oriented and only #defines the base/size of the PWM blocks.

Having said that, I agree it would be nice to have just registers defined in standalone headers for those who do not wish to use metal. It might be a good feature request for their freedom-devicetree-tools.

Funny enough, I was just trying a gpio project tonight and hit a problem with needing to enable a certain feature not exposed through freedom-metal and found for the gpio they defined all the bases and offsets in a platform.h fashion (metal-platform.h). It just seems the same thoroughness may not be used for all HW blocks, especially pwm, but that might be a good feature request as well.

1 Like

I found what I was looking for. I should have used grep and find in the first place.

#include <metal/machine/platform.h>

Two gists for a working example for a super stupid 8 bit PWM (bare and freedom metal mix).

May it be a time saver for others to come.

1 Like