-
Notifications
You must be signed in to change notification settings - Fork 1
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
not enough memory? or How to create Resource object directly in heap w/o using Stack #1
Comments
Not sure, I tried to build it, it seems to build OK. Maybe this? rust-lang/rust#65391
|
Hello Abelykh0, No problem with compilation this is a dynamic bug with heap/stack overlap. Not sure rust compiler check that. Memory heap start at 0x20000000 and stack start at 0x20005000. LateResources pre-allocate memory for display, vga_draw and others at 0x20000004 (14972 bytes len for display, then 24 bytes len for vgadraw then ...) so minimal Resource len is 14996 bytes. as you can calculate : 0x20000004+14996 = 0x20003A98 main() allocate local stack variable between 0x20001544 and 0x20005000 including So we have an overlap of 0x20003A98-0x20001544 = 0x2554 bytes. I suppose this is the problem because in idle() loop i added a small code to blink led to check stm32 HardFault. When i remove Resource display variable to stop overlap: All work fine, my blink is fine else gdb return with an HardFault. Do you try code with a real-screen recently? Thank you. |
Hello Abelykh0, an other information:
As I said before, space is ok but we must find solution to stop pre-allocate display in stack. Maybe we can remove Initialize VGA part from
|
Thank you for your interest. |
Yes, debug compilation test is a bad idea, I think debug build can work with the same method (removing or modifying init::LateResources but how...) |
I tried it but memcpy between stack and heap always here. |
may be a problem related to LLVM optimizations see rust-lang/rust#56333 issue? |
see #2 |
For your information, I just tried on a real board and the demo is working. Thanks again for your contribution! |
Hello,
I tried to test your example. Very interesting!
Nevertheless i can't make it work. It seems to be a memory problem :
stm32f103 is 20KB only.
14972 bytes + some reserved types rust bytes
let mut display = VgaDisplay {
create a 14972 bytes stack entry theninit::LateResources {
seems to do a memcpy at fixed Resources space in memory heap as we can see directly in ghidra :So we have an overlap between heap and stack.
A solution can be not to create stack
display
.The text was updated successfully, but these errors were encountered: