RISC-V assembly language tutorial


(Bruce Hoult) #1

Our friends at Western Digital have just released a series of videos on YouTube in which their CTO Martin Fink shows how to use VS Code to write an assembly language “SuperBlink” program for the HiFive1.

Martin covers tools setup, HIFive1 documentation including reading memory maps to find addresses of GPIO ports and registers, mixing C and ASM, manipulating GPIO in assembly language, building the program and downloading.

A pretty good tutorial I think.


(Donnie Agema) #2

Hi Bruce,

Sounds interesting, but Google has left me wanting. Can you share a link?

Thanks,


(Liviu Ionescu) #3

Try https://www.youtube.com/watch?list=PL6noQ0vZDAdh_aGvqKvxd0brXImHXMuLY&v=eR50d6CDOys


(Donnie Agema) #4

Great! Thanks.


(Liviu Ionescu) #5

Please note that the free version of platform.io does not include some features (like debugging); you need a paid subscription in order to be fully functional.


(Donnie Agema) #6

No problem - the paid subscription is very affordable!


(Bruce Hoult) #7

That was a link! The forum software puts it inline, but you can click on the “YouTube” in the bottom right corner to open a new window at YouTube, with the entire playlist shown.


(Bruce Hoult) #8

I’ve spotted two bugs in the code. One very very minor, but the other should be fixed. Anyone want to try find them?


(Bruce Hoult) #9

I’ve just worked through the video, following along.

You get a free 30 day trial of “pro”, so the debugger works.

It looks like gdb is a free option instead of their debugger, but I couldn’t immediately figure out how to get it to work. It certainly should be possible as it’s just using standard freedom-e-sdk tools underneath.

Annoyingly, I couldn’t find any way to get a disassembly, except to right click .pioenvs/freedom-e300-hifive1/ and choose “Open in Terminal” and then manually type “riscv64-unknown-elf-objdump -d firmware.elf | less”


(Liviu Ionescu) #10

You get a free 30 day trial of “pro”, so the debugger works.

yeah, sure, but I still prefer open source free solutions

gdb is a free option instead of their debugger

I doubt gdb will be able to show peripheral registers any time soon, like GNU MCU Eclipse and now platform.io

I couldn’t find any way to get a disassembly

this looks like a limitation of VSC debugging protocol, affecting all debug sessions, not only platform.io; I saw several issues recorded on GitHub, but Microsoft did not provide any clue if/when they’ll add it.


(Trevor) #11

The https://godbolt.org/ compiler explorer includes clang’s riscv32 compiler.