bios: Reserve a 2.5KB stack size.
This ensures that the build tools throw an error if there is not enough ram for the stack.
Note: If we do end up with ram issues, the bios may want to transition to the stack in dram after init, but that can be done at a later time.
This builds on !39 (merged) and should be merged after.
assigned to @tpearson
- Resolved by Raptor Engineering Development Team
Correct, this is an arbitrary number.
IT was determined by looking at the free space before adding the reservation Previously the code was using all free space for the stack, which could change whenever someone added more ram data. This is undesirable as it results in the stack space shrinking, which could cause the new data to become corrupt if the code was on the edge before.
The value of 2.5KB was choose as this results in a free space of 152 bytes remaining in sram - almost the same as before this change. From a quick parsing of the code, I didn't see anything extremely large being allocated on the stack, and so this seemed reasonable.
As a result, a small amount of data can be added still without issues, but if a developer needs to add more, they either need to profile the stack and ensure it is sufficient, or move data to dram or reduce data usage.
I can work on implementing a stack checker that reports the max stack usage as a firmware images is booted (or readable via a command), but it'll take a small amount of time to do. That'd probably be the best option for tuning the stack size (assuming most code paths are executed).
added 9 commits
-
42fdbd2c...9a700e45 - 3 commits from branch
master
- 610b30be - libbase: Fix stack end locaiton form fstack (first) to estack (end)
- 7da75905 - libbase: Only allocate the minimum stack from for crt1.
- b69c100f - bios: Force a 2.5KB iniital stack size.
- 5f116c5e - stack_checker: Add an initial stack checker implimentation.
- 883eafd0 - tests: Check that there is sufficient stack space to get to the console.
- ca1525d6 - bios: Allocate space for the stack in the linker script.
Toggle commit list-
42fdbd2c...9a700e45 - 3 commits from branch
Adding a quick reminder to @raptor-development take a look at this.