Re: RISC-V: Stack pointer initialization in crt0
Kito Cheng <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <CA+yXCZCkOkfoOiLP=qE3KSqbufQzG72UsN63N0BNXjTYVXCdBg@mail.gmail.com> |
So the question becomes: what should the sp be initialized to? __stack_pointer$? the end of the data section? Or another random address? This crt0.S is indeed missing some essential initializations, like `mstatus` and various other CSRs. But, just like Jim Wilson’s view back then, I also prefer leaving this to the BSP to handle. On Thu, Jan 2, 2025 at 10:01 PM Christian Herber <[email protected]> wrote: > > 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/