Compilation of FreeRTOS demo for RISC-V-Qemu-sifive_e-Eclipse-GCC fails

Hello,
I am trying to compile the FreeRTOS demo for RISC-V-Qemu-sifive_e-Eclipse-GCC based on instructions provided in the link RTOS-RISC-V-FreedomStudio-QMEU
But the build fails with following error

19:38:02 **** Incremental Build of configuration Debug for project RTOSDemo ****
make -j8 all 
Building file: C:/Users/aryan/Downloads/FreeRTOSv202212.01/FreeRTOS/Demo/Common/Minimal/EventGroupsDemo.c
Building file: C:/Users/aryan/Downloads/FreeRTOSv202212.01/FreeRTOS/Demo/Common/Minimal/TaskNotify.c
Building file: C:/Users/aryan/Downloads/FreeRTOSv202212.01/FreeRTOS/Demo/Common/Minimal/TimerDemo.c
Building file: C:/Users/aryan/Downloads/FreeRTOSv202212.01/FreeRTOS/Demo/Common/Minimal/blocktim.c
Invoking: Cross GCC Compiler
Invoking: Cross GCC Compiler
riscv64-unknown-elf-gcc -DDONT_USE_PLIC -DDONT_USE_M_TIME -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Demo\RISC-V-Qemu-sifive_e-Eclipse-GCC" -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Demo\Common\include" -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Demo\RISC-V-Qemu-sifive_e-Eclipse-GCC\freedom-e-sdk\env" -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Demo\RISC-V-Qemu-sifive_e-Eclipse-GCC\freedom-e-sdk\include" -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Demo\RISC-V-Qemu-sifive_e-Eclipse-GCC\freedom-e-sdk\env\freedom-e300-hifive1" -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Source\include" -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Source\portable\GCC\RISC-V" -O0 -g3 -Wall -Wextra -c -fmessage-length=0 -march=rv32imac -mabi=ilp32 -mcmodel=medlow -ffunction-sections -fdata-sections --specs=nano.specs -fno-builtin-printf  -Wno-unused-parameter -MMD -MP -MF"full_demo/standard_demo_tasks/EventGroupsDemo.d" -MT"full_demo/standard_demo_tasks/EventGroupsDemo.o" -o "full_demo/standard_demo_tasks/EventGroupsDemo.o" "C:/Users/aryan/Downloads/FreeRTOSv202212.01/FreeRTOS/Demo/Common/Minimal/EventGroupsDemo.c"
Invoking: Cross GCC Compiler
Invoking: Cross GCC Compiler
riscv64-unknown-elf-gcc -DDONT_USE_PLIC -DDONT_USE_M_TIME -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Demo\RISC-V-Qemu-sifive_e-Eclipse-GCC" -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Demo\Common\include" -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Demo\RISC-V-Qemu-sifive_e-Eclipse-GCC\freedom-e-sdk\env" -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Demo\RISC-V-Qemu-sifive_e-Eclipse-GCC\freedom-e-sdk\include" -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Demo\RISC-V-Qemu-sifive_e-Eclipse-GCC\freedom-e-sdk\env\freedom-e300-hifive1" -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Source\include" -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Source\portable\GCC\RISC-V" -O0 -g3 -Wall -Wextra -c -fmessage-length=0 -march=rv32imac -mabi=ilp32 -mcmodel=medlow -ffunction-sections -fdata-sections --specs=nano.specs -fno-builtin-printf  -Wno-unused-parameter -MMD -MP -MF"full_demo/standard_demo_tasks/TaskNotify.d" -MT"full_demo/standard_demo_tasks/TaskNotify.o" -o "full_demo/standard_demo_tasks/TaskNotify.o" "C:/Users/aryan/Downloads/FreeRTOSv202212.01/FreeRTOS/Demo/Common/Minimal/TaskNotify.c"
riscv64-unknown-elf-gcc -DDONT_USE_PLIC -DDONT_USE_M_TIME -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Demo\RISC-V-Qemu-sifive_e-Eclipse-GCC" -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Demo\Common\include" -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Demo\RISC-V-Qemu-sifive_e-Eclipse-GCC\freedom-e-sdk\env" -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Demo\RISC-V-Qemu-sifive_e-Eclipse-GCC\freedom-e-sdk\include" -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Demo\RISC-V-Qemu-sifive_e-Eclipse-GCC\freedom-e-sdk\env\freedom-e300-hifive1" -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Source\include" -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Source\portable\GCC\RISC-V" -O0 -g3 -Wall -Wextra -c -fmessage-length=0 -march=rv32imac -mabi=ilp32 -mcmodel=medlow -ffunction-sections -fdata-sections --specs=nano.specs -fno-builtin-printf  -Wno-unused-parameter -MMD -MP -MF"full_demo/standard_demo_tasks/TimerDemo.d" -MT"full_demo/standard_demo_tasks/TimerDemo.o" -o "full_demo/standard_demo_tasks/TimerDemo.o" "C:/Users/aryan/Downloads/FreeRTOSv202212.01/FreeRTOS/Demo/Common/Minimal/TimerDemo.c"
riscv64-unknown-elf-gcc -DDONT_USE_PLIC -DDONT_USE_M_TIME -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Demo\RISC-V-Qemu-sifive_e-Eclipse-GCC" -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Demo\Common\include" -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Demo\RISC-V-Qemu-sifive_e-Eclipse-GCC\freedom-e-sdk\env" -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Demo\RISC-V-Qemu-sifive_e-Eclipse-GCC\freedom-e-sdk\include" -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Demo\RISC-V-Qemu-sifive_e-Eclipse-GCC\freedom-e-sdk\env\freedom-e300-hifive1" -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Source\include" -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Source\portable\GCC\RISC-V" -O0 -g3 -Wall -Wextra -c -fmessage-length=0 -march=rv32imac -mabi=ilp32 -mcmodel=medlow -ffunction-sections -fdata-sections --specs=nano.specs -fno-builtin-printf  -Wno-unused-parameter -MMD -MP -MF"full_demo/standard_demo_tasks/blocktim.d" -MT"full_demo/standard_demo_tasks/blocktim.o" -o "full_demo/standard_demo_tasks/blocktim.o" "C:/Users/aryan/Downloads/FreeRTOSv202212.01/FreeRTOS/Demo/Common/Minimal/blocktim.c"

<--------------- Till here everything looks fine, from below point, the script is trying to pick the gcc from /bin/sh which doesnt exist, as the path should have end at bin.--------->

c:/users/aryan/downloads/freedomstudio-win_x86_64-20180122/freedomstudio/build-tools/bin/sh: riscv64-unknown-elf-gcc: not found
c:/users/aryan/downloads/freedomstudio-win_x86_64-20180122/freedomstudio/build-tools/bin/sh: riscv64-unknown-elf-gcc: not found
c:/users/aryan/downloads/freedomstudio-win_x86_64-20180122/freedomstudio/build-tools/bin/sh: riscv64-unknown-elf-gcc: not found
make: *** [full_demo/standard_demo_tasks/subdir.mk:35: full_demo/standard_demo_tasks/EventGroupsDemo.o] Error 127
make: *** Waiting for unfinished jobs....
make: *** [full_demo/standard_demo_tasks/subdir.mk:42: full_demo/standard_demo_tasks/TaskNotify.o] Error 127
make: *** [full_demo/standard_demo_tasks/subdir.mk:49: full_demo/standard_demo_tasks/TimerDemo.o] Error 127
c:/users/aryan/downloads/freedomstudio-win_x86_64-20180122/freedomstudio/build-tools/bin/sh: riscv64-unknown-elf-gcc: not found
Building file: C:/Users/aryan/Downloads/FreeRTOSv202212.01/FreeRTOS/Demo/Common/Minimal/dynamic.c
make: *** [full_demo/standard_demo_tasks/subdir.mk:56: full_demo/standard_demo_tasks/blocktim.o] Error 127
Invoking: Cross GCC Compiler
riscv64-unknown-elf-gcc -DDONT_USE_PLIC -DDONT_USE_M_TIME -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Demo\RISC-V-Qemu-sifive_e-Eclipse-GCC" -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Demo\Common\include" -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Demo\RISC-V-Qemu-sifive_e-Eclipse-GCC\freedom-e-sdk\env" -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Demo\RISC-V-Qemu-sifive_e-Eclipse-GCC\freedom-e-sdk\include" -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Demo\RISC-V-Qemu-sifive_e-Eclipse-GCC\freedom-e-sdk\env\freedom-e300-hifive1" -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Source\include" -I"C:\Users\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Source\portable\GCC\RISC-V" -O0 -g3 -Wall -Wextra -c -fmessage-length=0 -march=rv32imac -mabi=ilp32 -mcmodel=medlow -ffunction-sections -fdata-sections --specs=nano.specs -fno-builtin-printf  -Wno-unused-parameter -MMD -MP -MF"full_demo/standard_demo_tasks/dynamic.d" -MT"full_demo/standard_demo_tasks/dynamic.o" -o "full_demo/standard_demo_tasks/dynamic.o" "C:/Users/aryan/Downloads/FreeRTOSv202212.01/FreeRTOS/Demo/Common/Minimal/dynamic.c"
c:/users/aryan/downloads/freedomstudio-win_x86_64-20180122/freedomstudio/build-tools/bin/sh: riscv64-unknown-elf-gcc: not found
make: *** [full_demo/standard_demo_tasks/subdir.mk:63: full_demo/standard_demo_tasks/dynamic.o] Error 127

19:38:02 Build Finished (took 662ms)

The above line indicates an issue with the installation - the compiler binary is not found. Can you check your installation?

Hello Gaurav,
The executable distributed by SIFIVE is not installable, its simple click and launch.
Thus, i don’t foresee installation issues. if you notice the logs, during the first pass of make file, it has found the tool chain correctly.
Thanks,
Aryan

I tried this and I needed to set the toolchain path in the project properties like the following:

Can you try the same and let me know if that works for you?

Thanks.

1 Like

Hello Gaurav,

Thanks for the suggestion. It did work.
May be it’s good to update in the web page where we have about running freertos on Qemu using Frredom studio

Thank you! I will pass on the feedback to our documentation team.

Hi ,
I see now the documentation is updated, and i could start the demo and i could also notice that in QEMU’s serial terminal the print displaying “starting” is printed but the demo abruptly crashes with below stack frame, i couldn’t understand if this is fault caused by QEMU or the demo.

i also notice an error while launching QEMU, may be this is the reason for crash?
Any pointers around this would be helpful.

qemu-system-riscv32 -kernel C:\aryan\Downloads\FreeRTOSv202212.01\FreeRTOS\Demo\RISC-V-Qemu-sifive_e-Eclipse-GCC\Debug\RTOSDemo.elf -S -s -machine sifive_e
qemu-system-riscv32: warning: disabling zca extension for hart 0x00000000 because privilege spec version does not match

Thanks,
Aryan

The image that you shared does not indicate a crash - the debugger is stopped at a breakpoint. Why do you think that it is a crash?

I forgot to attach an image which is as follows.
riscv_freertos_demo_crash_2

Also i see QEMU session is getting terminated with "qemu: QEMU: Terminated via GDBstub"

**And on QEMU serial terminal i see the print as **
Demotrap and program has exited with code:0x80000008

The issue is that mtvec is not programmed correctly. It is fixed in this PR - Install FreeRTOS trap handler by aggarg · Pull Request #1087 · FreeRTOS/FreeRTOS · GitHub

After applying the above change, I am able to follow the instructions on this page to run the demo.