-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
rockchip64/rk3318-box: move stack further from base addr to allow bigger uboot image #6731
Conversation
Stupid uboot defaults... I agree on moving the stack pointer a bit away, but just a question: did you check it does not overlap with other areas dedicated to kernel, initd, device trees/overlays, ...? |
Interesting PR, I would like to learn more about this :)
How can you even check such things? This is very low level stuff 😄 |
You wouldn't, trust me! 😄
The hard thing is to collect all the various addresses that are sparsed among the boot script (this is for rockchip64) but mostly in the uboot header files or uboot config (like Then comes the easy part: bring on the calculator and verify there is enough space to accomodate what they should accomodate. For example, assuming the physical RAM base address is |
Please see u-boot/u-boot@008ba0d and u-boot/u-boot@f01a399 for new sane default stack and bss addresses that you can use. That fix/change is included in U-Boot If you do not want to bump U-Boot to |
I'm nowhere near uboot memory layout expert, it would be good if you can check my math. u-boot config: u-boot env: boot-rockchip64.cmd: |
Thanks! |
@alex3d It looks safe to me! I just checked against v2024.04: existing v2024.01 patches apply correctly, uboot config has no new symbols and it compiles too. I just did not check on a device if it boots. v2024.07-rc1 requires some HDMI/VOP patches rework instead. My plan would be to accept this fix right now, then rework the broken HDMI/VOP patches in this weekend and bump directly to v2024.07 as suggested by @Kwiboo, skipping v2024.04 completely. |
Ah right, rockchip64 kernels are somehow big, though they should not exceed the 32mb marker (but who knows in the future...).. I wonder if it is sensible to move kernel and initramfs >= 64Mb and reserve a vast enough amount of space for them (eg. 64Mb for the kernel, 128mb for the initramfs) just for rk3328 (perhaps rk3399 too?) From what I read in the commit, there should be ~27.5mb memory usable for the kernel since it starts at 32.5M and bss + stack starts at 60M; I guess we're really tight or even already outside the boundary with current kernel sizes |
2024.07 mainline is pretty stable actually, I've been using it for a while now on rk3588. |
Once U-Boot proper is fully loaded and running, loading kernel, initrd etc can be done to any memory starting from 2M+ and can overwrite the stack location used by prior stages in the bootflow, U-Boot is fully relocated to top of total memory (including its new stack). |
Heh, with relocation all that hunting for used address was really not needed :) Just checked it in uboot console on rk3318-box. Only 82Mb from the top of ram are reserved and all remaining ram could be rewritten by memtest without problems for uboot.
|
Description
Move stack pointer further from base address to allow bigger uboot images.
Currently uboot stack pointer located 1MiB after text base, and uboot size with defconfig is barely less than 1MiB (1001472). So any small modification in code/config/compiler-version could overflow text area (my uboot blown up after I enabled verbose logging to debug btrfs boot problem).
How Has This Been Tested?
Checklist: