System Task ***OVERFLOW***

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

System Task ***OVERFLOW***

Jump to solution
3,277 Views
JaimeR
Contributor III

Hi, I wonder if anyone knows what does this mean and how could I solve it.

I do not have a task named System task. I have search for those words into the kernel libraries without any luck. My application is crashing and this has brought my project to halt. Thank you in advanced.

 

 

0 Kudos
1 Solution
1,008 Views
PetrL
NXP Employee
NXP Employee

Hi,

function lwmem_alloc returns NULL in case that it can not allocate requsted memory. 

 

Probably your are sometimes out of memory - there is no 4K memory space to allocate.

You can check all allocated block in MQX Task Aware Debugging menu: MQX/Lw memory blocks.

 

 

PetrL

View solution in original post

0 Kudos
9 Replies
1,008 Views
EAI
Contributor IV

The System TD is used when there is no other task to run. It is not actually a task - the kernel executes a STOP instruction.

There is a small stack associated with it, defined by PSP_MINSTACKSIZE. 

 

Your problem may be caused by either an overflow of this stack, or a bad pointer corrupting the stack, making it appear like an overflow.

 

0 Kudos
1,008 Views
JaimeR
Contributor III

Yes, another task was running out of stack. When I added more stack to that task the System task overflow was solved. Now the problem is that I have a function that writes to flash memory and since the flash memory is erasable in 4k blocks, this function has a 4k buffer. Thus, each task that calls this function automatically requires 4k of RAM, therefore, I am running out of RAM. What options do I have to avoid this huge RAM leakage I am having. I tried to look into light weight memory functions in order to share this 4k resource, but it seems those only work with ROM.

0 Kudos
1,008 Views
bkatt
Contributor IV

Jaime R wrote:

.... Now the problem is that I have a function that writes to flash memory and since the flash memory is erasable in 4k blocks, this function has a 4k buffer...


The cfm hardware requires no buffer at all for erase, and can write flash in units of 4 bytes at a time. While the speed can be improved by writing 8 or more bytes at once, your 4K buffer seems to be a colossal waste of memory.

0 Kudos
1,008 Views
JaimeR
Contributor III

Mmm... Suppose I want to CHANGE the value of 2 bytes in the same flash memory sector. Obviously

this sector has more information that I need and I cannot lose that information.

 

Therefore, I need to erase these 2 bytes(so that I can write new information in them) but since flash

is only eraseable by 4k blocks... I will have to erase the whole 4k...

Now, If I dont want to lose the other 4094 bytes of information in this sector I need to have a place

to store  this bytes. This is what I am calling buffer.

 

Please, let me know if there is a better and more efficient way of doing what I need to do without 

wasting that amount of memory.

0 Kudos
1,008 Views
CarlFST60L
Senior Contributor II
Can you use a flash swap space so you will be wasting 4K flash instead of 4K ram. So, erase one block, copy your other block over to the erased block, you can modifiy just the data you need... Would that work?
0 Kudos
1,008 Views
JaimeR
Contributor III
I will use _lwmem_alloc for now and see how it behaves. If I find anything that I dont like I will go either for a preallocated buffer and semaphores to share this resource or a flash swap. Flash swap might be suitable for my application since I will have an external big flash memory.
0 Kudos
1,008 Views
JaimeR
Contributor III

Sometimes, the function   _lwmem_alloc   returns a NULL pointer.  This is how I am using it:

 

   flash_buffer = _lwmem_alloc( 4096);
   if (flash_buffer == NULL){
         printf("\nError al obtener buffer en eraseBottomPage");
       return;
   }

 

Any clues about what is going on? , Why does it only happen sometimes?

 

 

0 Kudos
1,009 Views
PetrL
NXP Employee
NXP Employee

Hi,

function lwmem_alloc returns NULL in case that it can not allocate requsted memory. 

 

Probably your are sometimes out of memory - there is no 4K memory space to allocate.

You can check all allocated block in MQX Task Aware Debugging menu: MQX/Lw memory blocks.

 

 

PetrL
0 Kudos
1,008 Views
EAI
Contributor IV

lw mem functions work on ram.  

 

You have a few options for solving your problem. It may depend on how frequently you write to flash.  if you are doing this most of the time, you could preallocate one buffer. You would want to protect your flash write routines with a semaphore so that multiple tasks can share the single buffer.  If you write to flash occasionally, just use _lwmem_alloc( 4096) and free it once done.

0 Kudos