PN7462 RTOS Problem with Global Large Array Definitions

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

PN7462 RTOS Problem with Global Large Array Definitions

跳至解决方案
2,379 次查看
EE_Ark
Contributor II

Hi,

If I define these two arrays 

uint8_t testArr[300];

uint8_t testArr[300];

in source file and try to use this source file in RTOS tasks firmware execution stops. But if I define them with size of 150 i'm not facing any problem.

 

I tried to increase stack size of RTOS tasks without success. 

 

What I need to change? (I'm using PN7462AU_ex_phExCcid sample project)

0 项奖励
1 解答
2,227 次查看
danielchen
NXP TechSupport
NXP TechSupport

PN7462 only equipped with 12 KB of SRAM.  Heap, stack and global data (BSS) and some revered memory will be stored in this region.   I would not suggest you add  so large array.

 

Regards

Daniel

在原帖中查看解决方案

0 项奖励
9 回复数
2,371 次查看
ErichStyger
Senior Contributor V

Do you have this on the task stack (local variable?).

The both have the same name, are they in different scopes?

And you would need to have a task stack for this with at least 600 bytes (plus for everything else you have, probably around 1 KByte.

And where does it stop? Did you check it with the debugger?

0 项奖励
2,365 次查看
EE_Ark
Contributor II

They are global static variables.

They have different names.

If I increase task stack size when using 'phRtos_TaskCreate' I end up with Hard page fault error.

If I debug it, firmware stops somewhere and if I try to pause debugging to see where it stops IDE gives an error like ''Can't halt processor'.

0 项奖励
2,362 次查看
ErichStyger
Senior Contributor V

If they are global variables, you don't have to increase the task stack size(s), as they are not allocated on the (task) stack memory.

Have you turned on the error hooks (e.g. for malloc failed)? If you try to create a task with a stack too large, and you don't have enough memory, this would be an error condition you have to catch.

So in essence: if the variables are global, you don't need to increase stack sizes. If you increase stack sizes, you might be running out of memory.

0 项奖励
2,357 次查看
EE_Ark
Contributor II

Thank you for your response.

So If I don't need to increase task stack sizes what's the couse of this problem? 

As I said before I'm modifying 'PN7462AU_ex_phExCcid' example and problem arises when i add these 2 array definitions to 'phExCcid_UsbCcid_Process.c' file and try to read & write something on it.

0 项奖励
2,351 次查看
ErichStyger
Senior Contributor V

I  have no experience with your device (I don't have one), so cannot comment if this is something related to it. Adding global arrays (as said again) should not have an impact on what you do.

So I think your problem is something different. Maybe you copy these arrays somewhere and you don't check if the destination is large enough.

I recommend you turn on the compiler warnings if there is anything reported. But at the end you would have to step through your code and try to find out what is going in.

If you suspect things are writing to a location where it should not, you could use watchpoints (data breakpoints) to find out who is making the write.

In case you are not familiar with this: I wrote an article about it here: https://mcuoneclipse.com/2018/08/11/tutorial-catching-rogue-memory-accesses-with-eclipse-and-gdb-wat...

 

I hope this helps,

Erich

0 项奖励
2,348 次查看
EE_Ark
Contributor II

I just debugged my project line by line and I saw that it freezes at "phRtos_TaskCreate" function. It never returns from it. When I try to pause debugging it says 'Cannot halt processor'. 

 

0 项奖励
2,345 次查看
ErichStyger
Senior Contributor V

can you step into the RTOS task create function?

标记 (1)
0 项奖励
2,342 次查看
EE_Ark
Contributor II

In 'freeRtos/tasks.c' file in 'prvInitialiseNewTask' function

 

/* Ensure the name string is terminated in the case that the string length
was greater or equal to configMAX_TASK_NAME_LEN. */


pxNewTCB->pcTaskName[ configMAX_TASK_NAME_LEN - 1 ] = '\0';     //It freezes on this line.

0 项奖励
2,228 次查看
danielchen
NXP TechSupport
NXP TechSupport

PN7462 only equipped with 12 KB of SRAM.  Heap, stack and global data (BSS) and some revered memory will be stored in this region.   I would not suggest you add  so large array.

 

Regards

Daniel

0 项奖励