Freedom Studio Qemu stack limit for function local array

  1. The function use a local array. When the size of the array increase
    Freedom Studio (Qemu wlthout board) crash. If I use the same array as global
    every thing work fine. What is the Freedom Studio stack limit for local variables ?
    The same code (with local array) work correctly using gcc on SiFive board.

  2. Any way to remove the break point at the first instruction of main() in Freedom Studio Qemu ?

Hi Alain,

Regarding #1: Stack Size. Try editing the bps/ file (that is the default linker script used to build the ELF, if you are using a different one, you’ll want to edit it instead, or as well). The stack size is defined by the _stack_size variable. In the QEMU BSP this defaults to 0x400 (1024) bytes. I see the Unmatched BSP defaults to 0x800 (2048) bytes. Change the QEMU linker script to match, rebuild, and you should be good to go.

Regarding #2: Look at the Debug Configuration Dialog for your launch configuration. On the Startup tab there is a check labeled “Set breakpoint at [main]”. Uncheck it.


Grow from 0x400 to 0x4000 and now everything work well.
Why default is so low ? Stack size for OS count in MB…

Yes! Make more easy to run/debug…

I really appreciate your help.
Thank you.

Why default is so low ? Stack size for OS count in MB…

It’s impossible to come up with a one size fits all default for all possible uses. It’s common practice for users/developers to have to tune linker scripts for their specific needs.

Which toolchain were you using? Bare metal or Linux? The former will generally have a small default stack size specified in the example linker scripts because it’s generally targeting resource constrained embedded systems.