Please include the following information, in order for us to help you as effectively as possible.
-
What product do you wish to discuss? RAK4631
-
What firmware are you using? VSCode/Platformio
-
What firmware version? it is Arduino BSP
-
Computer OS? (MacOS, Linux, Windows) Windows
-
What Computer OS version? Windows 11
-
How often does the problem happen? it is not a problem, it is a memory management best practice
-
How can we replicate the problem? it is not a problem, it is a memory management best practice
-
Provide source code if custom firmware is used or link to example if RAKwireless example code is used.
I have a code working fine for RAK1904, RAK1906, RAK5801 and RAK12500. Now I became to create a RTOS (FreeRTOS) version.
Now I am looking for some kind of “memory management Best Practice”. Why? Because I spent a good time to find the root cause about a strange behavior right after to create a task. Well, the problem it was the amount of memory that I was reserving, it wasn´t enough. I began with the minimum described in the FreeRTOSConfig.h (configMINIMAL_STACK_SIZE = 100), and I was increasing step-by-step and now the behavior is normal with 512 manually configured.
FreeRTOSConfig.h
#define configMAX_PRIORITIES ( 5 )
#define configMINIMAL_STACK_SIZE ( 100 )
#define configTOTAL_HEAP_SIZE ( 4096 ) /* not used since we use malloc */
#define configMAX_TASK_NAME_LEN ( 8 )
main.cpp
#include <main.h>
void setup()
{
xTaskCreate(IniciaRAK4631,"IniciaRAK4631",configMINIMAL_STACK_SIZE,NULL,1,&OperadorIniciaRAK4631);
IniciaRAK1906(); // Inicia RAK1906 BME680 sensor de variáveis ambientais
IniciaRAK12500(); // Inicia RAK12500 sensor de geo-posicionamento
IniciaRAK1904(); // Inidiq RAK1904 sensor de movimento
IniciaRAK5801(); // Inicial o sensor de variação de corrente 4-20Ma WisBLOCK 5801
}
Now “xTaskCreate(IniciaRAK4631,“IniciaRAK4631”,512,NULL,1,&OperadorIniciaRAK4631);”
A quick question:
- The path for FreeRTOSConfig.h is C:\Users\Claudio Rosa.platformio\packages\framework-arduinoadafruitnrf52\cores\nRF5\freertos\config\FreeRTOSConfig.h. Is the FreeRTOSConfig.h configured for capacity/performance for Nordic nRF52840 inside of RAK4631? If it is not optimized, does RAKWireless has a guide with these numbers?
I am looking a better way to do Memory Management to help in some questions:
- How to know the memory size required for a task?
- How to know how much free memory the nRF52840 has available to be allocated for a task?
- Where could I have a “guide” for the FreeRTOSConfig parameters?
Regards,
Cláudio