2025-01-07 06:28 PM
Hello,
I'm developing RTOS environment of dual-core in STM32H757.
To write the data, I'm using function "HAL_FLASH_Program".
The stack size of the task : 512 * 4
float32_t g_temp_data[70]; // the data
1. Is it common for data to be written to Flash Bank2 from CM7?
2-1. When I write the data to Flash, Is the stack size of the task enough?
2-2. How do I calculate the stack size being used by a task?
Solved! Go to Solution.
2025-01-08 07:12 AM
Hi @StrangeTau
1. It is OK for the CM7 to write on the other bank, this even allows the application to do RWW. If you wanted to write the data in Bank 1 and assuming the CM7 is tied to the Bank 1, it wouldn't be able to perform the RWW.
2. Since you are using HAL_FLASH_Program, the stack size is OK because the temp_data (floating with 70 elements) will use 280 bytes and you have 2048 (512*4) in the stack, but of course, that will depend on what else this task does.
3. for the stack size, you could enable the stack checking on FreeRTOS, this can be done in the freertosconfig.h and then you could use the resources to see the current size being used or even implement a hook to see if that task had a stack overflow. If you are using CubeIDE, it has the RTOS-awareness, which can help during debug sessions to see the usage so you can allocate a larger stack, check the usage and reduce it later on.
(Just highlight, the H7 Flash memory programming by 256 bits, so you will have to write 4 positions at a time
and since you have 70 elements, you will have to add some padding or lose part of the efficiency).
There is this an article that talks about stack usage which might help you, and here are two other links Link1 and Link2 that might also be helpful.
Thank you.
ELABI.1
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-01-08 07:12 AM
Hi @StrangeTau
1. It is OK for the CM7 to write on the other bank, this even allows the application to do RWW. If you wanted to write the data in Bank 1 and assuming the CM7 is tied to the Bank 1, it wouldn't be able to perform the RWW.
2. Since you are using HAL_FLASH_Program, the stack size is OK because the temp_data (floating with 70 elements) will use 280 bytes and you have 2048 (512*4) in the stack, but of course, that will depend on what else this task does.
3. for the stack size, you could enable the stack checking on FreeRTOS, this can be done in the freertosconfig.h and then you could use the resources to see the current size being used or even implement a hook to see if that task had a stack overflow. If you are using CubeIDE, it has the RTOS-awareness, which can help during debug sessions to see the usage so you can allocate a larger stack, check the usage and reduce it later on.
(Just highlight, the H7 Flash memory programming by 256 bits, so you will have to write 4 positions at a time
and since you have 70 elements, you will have to add some padding or lose part of the efficiency).
There is this an article that talks about stack usage which might help you, and here are two other links Link1 and Link2 that might also be helpful.
Thank you.
ELABI.1
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-01-08 04:29 PM