-
Notifications
You must be signed in to change notification settings - Fork 280
C6/H2: flip-link feature #1008
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
C6/H2: flip-link feature #1008
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome! Really cool that we can achieve this without double linking too, neat!
I have a few comments, mostly around docs just because linker scripts are insanely hard to reason about, so the more docs and info on what they're doing and why the better.
"ld/riscv/hal-defaults.x", | ||
out.join("hal-defaults.x"), | ||
)?; | ||
preprocess_file(&config_symbols, "ld/riscv/asserts.x", out.join("asserts.x"))?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think these two files need preprocessing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. I just thought applying it everywhere is easier than having some files pre-processed and some not 🤔 but not sure what is better
I also wonder if we can improve the error message, if we are in the trap handler and we know SP is out of bounds, we can reason that a stack overflow was detected 🤔. |
We might re-use e.g. exception code 14 to signal that - probably worth a try. Then esp-backtrace could give a definitive hint that it was a stack overflow. Need to try if that would work |
That works! Now we get |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I've only tested a few examples so far, I will test some more soon.
In the meantime, I tested with esp-wifi .... looks good so far |
0d97101
to
71a9f9a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for exploring this, it's a really cool feature to have!
LGTM
Can we please try to remember to update the CI workflow when new features are added, especially when linker scripts are involved. |
Ah true ... |
* C6/H2: flip-link feature * CHANGELOG.md entry * Include .wifiextrairam in .rwtext.wifi * Set exception code 14 if SP was out of bounds
Since on C6/H2 the caches are not residing in the start of RAM we can move the stack to start of RAM to get zero-cost stack overflow protection (inspired by flip-link)
I will probably add some code in esp-backtrace to give a hint when there is an access fault slightly below
_stack_end
to make things a bit more obvious.Currently a stack overflow with the flip-link feature looks like this
An access fault trying to access memory near the start of RAM indicates a stack overflow
This needs a lot of testing before it's fine to merge.