-
Notifications
You must be signed in to change notification settings - Fork 11
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
Stack pointer not correctly initialized #17
Comments
That is indeed very strange. The bootloader main() puts nothing on the stack so when leaving main it should be at the end of RAM. It just seems odd that the pre iso software would run like that as it also uses almost the entire RAM |
Maybe the bootloader is designed for smaller RAM, and its end of RAM is 20004fff or something. |
Of course! The bootloader uses a linker file with 20k RAM |
Yes, seems it was a lot of luck. In the DIN-only software, the stack at 0x2000'4fff and below overlaps with the large exi decoder structure, which starts at 0x2000'21d8 and has a size of 0x63d8.
Most of this structure is not used while decoding, because the structure contains all possible elements, but in reality only less than the half is used (because Clara never decodes the own transmit messages, and the chargers does not fill all optional fields of the Claras receive messages). Seems this lead to never hurting something important on the stack. |
For the iso-test branch, updated the libopencm3 to fix the issue: 875fe0b |
Main also updated |
Clara crashes when added the ISO schema. One suspect was a potential collision of the stack with the RAM. And bingo:
The stack pointer points "somewhere" into the middle of the available RAM, and collides with variables which are placed there.
A test function, called in the main() after the serial is available, reveals that the stack variables got strange addresses. It seems that the stack pointer is not initialized in the application, and maybe has just a "random" value left over by the bootloader.
Proposed solution:
In the begin of the reset_handler(), add the described initialization of the stack pointer.
This is a change in the shared libopencm3.
Questions:
The text was updated successfully, but these errors were encountered: