Can anyone guide me on porting FreeRTOS to STM32F411CEU6

@Umesh Lokhande sorry for mentioning. As you work with FreeRTOS a lot can you please guide me how should I can port one for my STM32F411CEU6
37 Replies
undefined.elf
undefined.elf2d ago
I am currently facing issues regarding the ISR's
ZacckOsiemo
ZacckOsiemo2d ago
wait this is easy what are you struggling with?
undefined.elf
undefined.elf2d ago
so I was able go compile my program just fine but i think there is some issues related to porting
undefined.elf
undefined.elf2d ago
so when I try to start the scheduler it goes into hardfault
Umesh Lokhande
If you can compile code fine without any error that means you successfully ported FreeRTOS. For the second part of question, the issue could be anything from configuration parameters to code itself. As far as the issue with ISRs and scheduler. I think you need to provide more information about the exact error.
undefined.elf
undefined.elf2d ago
I was compiling the project making freeRTOS as a library but due to that it has some issues to find my ISR's needed for context switching so even the code was compiling fine when the scheduler starts it was looking for the first task with the help of and ISR since those ISR wasn't detected due to compiling freeRTOS as a library it went into hardfault
Marvee Amasi
Marvee Amasi2d ago
Okay happy it was fixed
undefined.elf
undefined.elf2d ago
attachment 0
undefined.elf
undefined.elf2d ago
The issue is fixed and also I have implemented own printk
undefined.elf
undefined.elf2d ago
now it is ready to work on
undefined.elf
undefined.elf2d ago
FreeRTOS has some trace debug function
undefined.elf
undefined.elf2d ago
I have to deep dive a bit i think
Marvee Amasi
Marvee Amasi2d ago
Now that the basics are working, have you considered adding any additional features or optimizations to your project
undefined.elf
undefined.elf2d ago
Not yet I am trying to understand all the configuration in FreeRTOSCOnfig.h file
undefined.elf
undefined.elf2d ago
After that I can focus on optimization
undefined.elf
undefined.elf2d ago
can you please give me some basic idea where it can be optimized?
Marvee Amasi
Marvee Amasi2d ago
If so check if configMAX_PRIORITIES is set to an appropriate value based on how many priority levels your tasks need. Too many can waste resources, and too few can limit flexibility
Marvee Amasi
Marvee Amasi2d ago
And you can even use configMINIMAL_STACK_SIZE to keep task stack sizes minimal but still adequate
Marvee Amasi
Marvee Amasi2d ago
Just avoid oversized stacks, that one can consume a lot of memory
undefined.elf
undefined.elf2d ago
it was 130 before but I was facing overlfow issue so I made it 255
Marvee Amasi
Marvee Amasi2d ago
You might be able to reduce stack overflow risk without increasing configMAX_PRIORITIES by adjusting individual task stack sizes. Try using uxTaskGetStackHighWaterMark() to see each task’s actual stack usage
Marvee Amasi
Marvee Amasi2d ago
If any task is using more than expected, increase iits own specific stack size and there will be no overflow
undefined.elf
undefined.elf2d ago
I was using vsnprintf and stargs in printk i think for that also
undefined.elf
undefined.elf2d ago
those funciton's are quite memory hungry
Marvee Amasi
Marvee Amasi2d ago
Ah, that makes sense , that vsnprintf and similar functions can definitely use a lot of stack, especially with longer strings or complex formatting
undefined.elf
undefined.elf2d ago
I limited it to 100 characters
Marvee Amasi
Marvee Amasi2d ago
There are still prolly ways to optimize memory usage
undefined.elf
undefined.elf2d ago
I thing that is more than enough to print some info at a time
undefined.elf
undefined.elf2d ago
Yeah let's explore a bit :excusemewhat:
Marvee Amasi
Marvee Amasi2d ago
Yh yh , that should help keep memory usage in check while still getting useful output
undefined.elf
undefined.elf2d ago
also using my ram usage is 62% out of 128KB i think that is due the heap region also right?
undefined.elf
undefined.elf2d ago
heap region is treated as occupied memory as far as i know
Marvee Amasi
Marvee Amasi2d ago
Exactly as you said . The heap wil take up part of the RAM, so any dynamically allocated memory adds to that usage
undefined.elf
undefined.elf2d ago
attachment 0
Marvee Amasi
Marvee Amasi2d ago
Keeping an eye on both stack and heap allocations can help manage overall memory use efficiently ✅
undefined.elf
undefined.elf2d ago
for sure I am gonna try that after a bit exploring the basics
Marvee Amasi
Marvee Amasi2d ago
That wil be great
Want results from more Discord servers?
Add your server