RISC-V: Stack pointer initialization in crt0

Christian Herber christian.herber@nxp.com
Thu Jan 2 14:00:43 GMT 2025


Newlib works great when building a linux user space executable.
However, if you want to run something baremetal in M-mode, the standard startup is a roadblock because of the lack of stack pointer initialization.

I see there had been discussion on this topic here: https://github.com/riscvarchive/riscv-newlib/issues/39

I dislike the current situation as it puts an unnecessary obstacle for users e.g. switching from Arm to RISC-V.
As a user, especially if I build with -spec=nosys.spec, it is strange if the startup assumes an operating system has initialized the stack pointer.

This recent reddit thread shows the situation quite well: https://www.reddit.com/r/RISCV/comments/1hjbxyd/running_an_mmode_rv32_cprogram_on_qemu/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/newlib/attachments/20250102/55f93592/attachment.htm>


More information about the Newlib mailing list