-
Notifications
You must be signed in to change notification settings - Fork 223
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
address 0x801468 of .elf
section '.data' is not within region 'data'
#398
Comments
.elf
section .data' is not within region
data'.elf
section '.data' is not within region 'data'
Hi, what chip are you compiling for? |
arduino uno, atmega328p |
btw, I'm also getting unstable behavior, e.g.:
and compiling with
also, declaring extra stuff on stack causes weird/unexpected behavior. in my code, if I add let var_i_wont_use = num::new(); my program won't return the same output, depending on the variation, sometimes it's garbage output and sometimes it's program re-starting over and over. (I'm testing in also I can't debug with |
Without knowing more, this looks a lot like you are using way too much memory and thus corrupting your stack and data in cases where it does compile and overflowing available program flash when it doesn't compile. Maybe you are using a crate in your project which needs way too much space? |
Yeah, it looks like it. I think I'm overflowing stack, however original issue still remains, I can't add panic when creating a struct on stack which only takes ~200 bytes. If I check Unless adding a panic_handler takes 1000+ bytes, I don't see how that should not work. |
Can you maybe prepare a minimal reproducer project? It's easier to troubleshoot this when I can also reproduce the exact error.
This may happen when your panicking with a message. In such situations, a lot of the rust standard library formatting code is pulled in which is huge. But right now it is hard for me to tell whether this is what is happening in your case... |
I moved a lot of stuff around to optimize and now I can't re-produce it. I guess struct having less impl made it possible to compile. Still, I'm very close to the limit, already using 2040 bytes of ram! I've tried other targets just to have more ram, such as:
But I can't run any of them in How do your normally debug an avr program? |
To be perfectly honest, I usually don't bother with a real debugger. Due to LTO, the debug info is often not quite accurate and for me, this just eats more time than it saves. I prefer going with primitive "printf debugging" over the serial line. |
I don't know how to do that. I couldn't extract the type into an static value. Can you add an example? |
Sorry, this issue got lost in my inbox... I assume you mean how to put the UART object into a static so it can be accessed everywhere? If yes, I pushed an example here: https://github.com/Rahix/avr-hal/blob/main/examples/arduino-uno/src/bin/uno-println.rs |
Thanks, this is what I wanted. -- For anyone coming across this issue, this error means your compiled elf is bigger than target's flash size. You can get a more detailed message if you add
|
That's a nice trick, maybe we should just include that by default? |
Yes, as this is a common problem in embedded projects. Specially with small devices such as the AVR. |
@kallemooo, can you maybe send a PR to integrate it into our https://github.com/Rahix/avr-hal/blob/main/avr-specs/sync-from-upstream.py script (and then regenerate the specs files)? I'm super short on time right now so it'd take a while until I can sit down to take care of it. |
I have a main that creates a struct using a 3rd crate, e.g.
other_crate::new()
then immediately callspanic!("")
with nothing else on stack.I have copied the
panic_handler
from this example. It compiles but then I get:something doesn't fit in the ram? or in the static area? or do I need to supply a linker parameter?
The text was updated successfully, but these errors were encountered: