Closed ogulcan90 closed 2 years ago
Hello. Please increase FREERTOS heap size and try again.
Here is my FreeRTOS heap size:
I also increased tasks' stack sizes a little more:
But still I have the same problem...
Do you have any other suggestions?
Thanks. Ogulcan
Hi @ogulcan90 According to the assertion you are trying to free the memory that was not allocated before.
Why it is happening is very interesting issue to dive in 🙂
First of all it could be because you are trying to free the memory twice. If you are trying to free the memory twice most likely that you are using this already freed memory in other places that would lead to heap memory corruption. Thats why it is very good programming practice to set all the pointers to NULL after they were freed.
Also you can try step by step debugging and make yourself sure that memory was allocated well and pointer holds actual value to this memory. If memory was allocated well save the value where the pointer is pointing to. Then at vPortFree call compare saved value with actual value that is passing as a parameter to vPortFree. If they are different most likely you faced with stack memory corruption and the pointer value was overwritten somewhere in the stack.
Hi @nimaltd and @d-serj ,
I solved the problem by increasing _ATC_SEARCH_CMD_MAX from 5 to 10.
The thing is in atc_command() function, there are these line:
if (items >= _ATC_SEARCH_CMD_MAX)
break;
in which the memory is allocated but it breaks before freeing.
I suggest you to free the memory before this break.
Also you might want to find a way to address this lack of number of _ATC_SEARCH_CMD_MAX.
Thank you for your interest.
Regards, Ogulcan
Hi,
I tried the library and I can send sms properly, but when I try to make phone call, the program stucks in a way that all tasks stop working.
Here is my FreeRTOS configuration:![image](https://user-images.githubusercontent.com/24295105/130228731-61595fcf-a83f-4e2a-9628-db8cc7fbdf93.png)
Here is my gsmTask:![image](https://user-images.githubusercontent.com/24295105/130228931-bcb5a057-41d7-4010-b582-4eea62e2afbb.png)
Here is my GSMRun Task:![image](https://user-images.githubusercontent.com/24295105/130229149-1c53ad4e-dead-4206-a25c-a06b735d7242.png)
It sends the AT command, my phone rings, so when I debug, I see that the PC comes here (line 39 of call.c, inside gsm_call_dial() function):![image](https://user-images.githubusercontent.com/24295105/130229439-5f985d1f-daa8-40df-b436-79eb97466d54.png)
Then it goes to atc_command() function and spends some time in this loop (located between line 195 & line 198 of atc.c):![image](https://user-images.githubusercontent.com/24295105/130229667-4c4f46ae-2426-4707-8c3a-69ef6ba0c1e9.png)
Then I press resume to see where it stucks, and I see that it stucks in line 278 of heap_4.c: configASSERT( ( pxLink->xBlockSize & xBlockAllocatedBit ) != 0 );![image](https://user-images.githubusercontent.com/24295105/130229755-42058b5d-85b4-414b-9218-9ec9bba61bdb.png)
which is in vPortFree function.
This means the FreeRTOS somehow cannot deallocate the memory that it allocated before.
Does anyone has any idea on the solution of this problem?
Thank you. Cheers, Ogulcan