vApplicationMallocFailedHook(void) hits every time on PN7462.

cancel
Showing results for 
Search instead for 
Did you mean: 

vApplicationMallocFailedHook(void) hits every time on PN7462.

Jump to solution
555 Views
jayeshj
Contributor III

Hi, All.

I am developing a solution in which based on the PN7462 NFC solution. Now as per my requirement. I have created a lib(.a) file which for internal API which we don't want to provide to the third party. Now if I develop all the code in a single project it works fine. But after creating lib of all the APIs and creating another project for application code I am unable to run the project it hits "void vApplicationMallocFailedHook( void )" every time. I have checked that firmware goes to scheduler start but it does not enter the thread. I have looked into some thread and it could be the issue of linker file but I am unable to find a solution. I am attaching screenshots for MCU Linker and default linker file. I have checked with default LPC expresso style

 

jayeshj_0-1598943715138.png

 

jayeshj_1-1598943777982.png

 

Any help would be helpful.

 

Thanks

0 Kudos
1 Solution
455 Views
jayeshj
Contributor III

As it turns out heap_2.c is not used in the example. So I should exclude heap_2.c from the above library so this solved my issue.

Thanks @estephania_mart  for the support.

View solution in original post

0 Kudos
6 Replies
467 Views
estephania_mart
NXP TechSupport
NXP TechSupport

Hello,

 

As this is a library is has also to do with how the compiler manages it well as you application code

Please , check this post and verify if this helps you

 

https://mcuoneclipse.com/2019/08/17/tutorial-how-to-optimize-code-and-ram-size/

 

Regards,
Estephania

 

0 Kudos
490 Views
estephania_mart
NXP TechSupport
NXP TechSupport

Hello,

You can try checking this

 

https://www.nxp.com/docs/en/application-note/AN11342.pdf

https://community.nxp.com/t5/NFC-Knowledge-Base/Using-NFC-Reader-Library-with-LPC845-With-Reduced-Si...

 

To verify if this works for your purposes, still you will need to test it and verify that it works as intended when implementing in your code.

 

Hope this helps.

Regards,

Estephania

 

 

0 Kudos
477 Views
jayeshj
Contributor III

Thanks, @estephania_mart  for the response.

I think the issue is not because if NxpNfcRdLib As if trying to build a program using only application code.

Let me tell you something about my project first it was one project. Which works fine and it uses utilizes SRAM 3180bytes as shown in the image.

jayeshj_4-1600149693261.png

 

Now I want to create an application project which is built on my project. So this can be achieved if I create a static library of the project. Now I have two projects one is lib and another is application. Now the first step would be to create static lib of my project and call API from the application project as required. But this increases size SRAM size by 5kb. Code size is not the issue here. Please look at the attached image below.

jayeshj_3-1600148992073.png

I have attached a partial build log of the lib project. Where heap_2.o contains a very large portion of bss. Other files(which are removed from a text file) does not contain much of the bss.

I think heap_2.c is using 5kb of SRAM what could be the reason?

 

 

 

0 Kudos
456 Views
jayeshj
Contributor III

As it turns out heap_2.c is not used in the example. So I should exclude heap_2.c from the above library so this solved my issue.

Thanks @estephania_mart  for the support.

View solution in original post

0 Kudos
521 Views
estephania_mart
NXP TechSupport
NXP TechSupport

Hello,

 

Could you please check this post and verify if this helps you ?

 

https://community.nxp.com/t5/MCUXpresso-IDE-Knowledge-Base/How-to-create-and-use-static-library-in-M...

 

Regards,

Estephania

0 Kudos
503 Views
jayeshj
Contributor III

Thanks for the reply.

As it turns out I am able to build library combining all the source code freeRTOS and my code. And it is working. But now I have realized that the size of utilized SRAM is increased by around 5kb while I was using only application code.

As I looked into the building of lib it turns out heap_2.o the file uses 5120bytes of bss which turns out saved on SRAM. While using the same code without creating lib SRAM utilized is very less.

How can reduce this SRAM utilization while creating lib?

0 Kudos