Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why not set stack-pointer to end of stack? #37

Open
cobratbq opened this issue Feb 24, 2024 · 1 comment
Open

Why not set stack-pointer to end of stack? #37

cobratbq opened this issue Feb 24, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@cobratbq
Copy link

I noticed that the stack-pointer is initialized to just below the end of the stack. Is there a specific reason for this? My understanding is that the stack-pointer is decremented upon each use of the stack, so setting it to TK1_RAM_BASE+TK1_RAM_SIZE (or ORIGIN(RAM) + LENGTH(RAM) in terms of the linker-script), should be optimal.

libcrt0/crt0.S:

/* init stack below 0x40020000 (TK1_RAM_BASE+TK1_RAM_SIZE) */
li sp, 0x4001fff0

Am I missing something?

@mchack-work mchack-work added the bug Something isn't working label Apr 25, 2024
@mchack-work
Copy link
Member

mchack-work commented May 15, 2024

I marked this as a potential bug a while ago. It's not serious and doesn't affect much, possibly just wasting a few bytes of RAM.

We have different behaviour in firmware's crt0 and tkey-libs, at least.

This needs some investigation. Maybe it's just a misreading of the RISC-V spec of stack alignment, or maybe it's something else, like I replied in e-mail earlier.

Since we plan on using tkey-libs in firmware, too, this needs to be looked at before that. See tillitis/tillitis-key1#129

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants