PN7462 RTOS Problem with Global Large Array Definitions

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

PN7462 RTOS Problem with Global Large Array Definitions

Jump to solution
2,330 Views
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 Kudos
1 Solution
2,178 Views
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

View solution in original post

0 Kudos
9 Replies
2,322 Views
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 Kudos
2,316 Views
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 Kudos
2,313 Views
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 Kudos
2,308 Views
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 Kudos
2,302 Views
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 Kudos
2,299 Views
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 Kudos
2,296 Views
ErichStyger
Senior Contributor V

can you step into the RTOS task create function?

Tags (1)
0 Kudos
2,293 Views
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 Kudos
2,179 Views
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 Kudos