CommunityGD32Cores / ArduinoCore-GD32

Arduino core for GD32 devices, community developed, based on original GigaDevice's core
Other
85 stars 33 forks source link

Stack size #89

Closed Candas1 closed 1 year ago

Candas1 commented 1 year ago

Hi,

Thanks again for this project. I am testing same arduino code on similar boards with STM32F103C8 and GD12F130C6 chips. As I am adding more code/features, I am getting this message on the GD32 board: image

Then I commented out some of the code, and I see this usage on the GD32: image And this usage on the STM32: image

It looks like a fixed 2K size stack is used for GD32s ? It seems on the STM32 they use a minimum size for the stack and heap in the ldscript.

It's probably not a big problem on chips having a lot of ram, but this GD32 has only 4K of ram unfortunately.

maxgerhardt commented 1 year ago

It looks like a fixed 2K size stack is used for GD32s ?

Yes,

stack_size = DEFINED(__stack_size) ? stack_size : 2K;

Okay, good point about low-RAM chips, though.. I'm wondering if anything useful can be done with them in the Arduino framework with such low resources :( You might need SPL to get less overhead.

Candas1 commented 1 year ago

I am actually porting this code you know from SPL to arduino lol I am exploring, didn't think Arduino would have that overhead.

Candas1 commented 1 year ago

I will just use a custom ldscript in platformio.ini with parameter board_build.ldscript and a reduce stack size to something like 1K and see where I am getting.

There are hoverboard splitboards with those chips, they somehow managed to fit in motor control and reading data from an IMU.

maxgerhardt commented 1 year ago

I've adapted the generator script to only use 512 bytes of RAM for every chip that has 4K or less RAM.

https://github.com/CommunityGD32Cores/platform-gd32/commit/3424e663a97445312855c8b8b5ac25f55ebf0577 https://github.com/CommunityGD32Cores/ArduinoCore-GD32/commit/d0cf8578ca720b778dc1acd4b56094e580d0bf2b

Candas1 commented 1 year ago

Thanks a lot!!! Much appreciated