Linux Risc V Platform

I installed the Linux RISC V platform from the following link

I am trying to create a new project with Linux RISC V platform but I get an error,

…Well there has to be an entry point to the program. The code you write isn’t just assumed to be “the code to the main function”, you have to create a (global) label so that the symbol (function name) is found. If you don’t want the C runtime initialization, the entry point is usually _start instead of main.

The platform you linked to does have a starting example. Please use it and go from there.

I can run the example hello.s program. So, this golbal label is the platformio requirement or the RISC V assembly program requirement. And also, do I have to create any other files besides the source code file?
Thank you.

It’s a requirement of the linker to have a defined entry point to the program / executable file. The assembler does not care.

In terms of assembly source files no, one file can hold all the code if you want, but of course you can also split code among multiple files. As for PlatformIO project files, I would just copy-paste every file from the hellow-world-asm, especially the platformio.ini and the two .py files.

1 Like

I did copy the platform.ini file but I didn’t copy the two .py files. I will try that.

I am working on this edx course.

Thank you

I copied all the files from the example folder to a new folder but I still get the following error

A space in the project path (“My Project”) is causing problems with the string escaping of shell arguments with the custom option for the map file.

You can try replacing line 16 with -Wl,-Map="$BUILD_DIR/linker.txt" instead, or just deleting it. The .map file is not crucial, it’s just for analyzing how big a certain symbol / function is in post-analysis.

I deleted line 16 from platform.ini

Yeah the has the same type of bug with the path escaping. It seems the original author of this third-party platform didn’t take string escaping at all into account.

Replace the file with the following content:

import os

def make_something(source, target, env):
#    print(projenv.Dump())
    builddir = env['PROJECT_BUILD_DIR']+"/"+env['PIOPLATFORM']
    srcdir = env['PROJECT_SRC_DIR']+"/"
    for x in source:
        name, ext = os.path.splitext(
        objfile = builddir+"/src/"
        lssfile = srcdir+name+".lss"
        env.Execute('riscv64-unknown-elf-objdump -d "%s" -l > "%s"' % (objfile, lssfile))

env.AddPostAction("$BUILD_DIR/${PROGNAME}.elf", make_something)

    env.VerboseAction("riscv64-unknown-elf-objdump -Mno-aliases,numeric -h -S \"$BUILD_DIR/${PROGNAME}.elf\" > \"$BUILD_DIR/${PROGNAME}.lss\"",
    "Creating $BUILD_DIR/${PROGNAME}.lss")

Alternative, again, disassembling the output files is not crucial either, since they will be pretty much equal to your original source file… So you can also delete line 20 of the platformio.ini that makes PlatformIO call into the script.

It worked!! Thank you for your help.

1 Like