heap_#.c switch issue and xPortGetFreeHeapSize

jeff29nj wrote on Wednesday, May 06, 2015:


I have seen mention that you can change the heap file that is used.

I am confused about how to do that.

I am using Xilinx SDK with the FreeRTOS install that also included LWIP socket apps.
I looked in the FreeRTOS repository directory and I think heap_3.c is being used. I think when I generate the BSP and compile my application, heap_3.c gets copied to my application subfolder.

When I try to delete heap_3.c and replace with heap_4.c, I get errors when attempting to generate a new BSP or create a new one. Something seems to still be looking for heap_3.c

Is there intructions anywhere on the proper way to switch what heap file is used?

I really want to use xPortGetFreeHeapSize and it seems that doesn’t compile with heap_3.c


rtel wrote on Thursday, May 07, 2015:

If you are building FreeRTOS as part of the BSP then the BSP will probably copy heap_3 back into the BSP directory even if you delete or replace it manually. You can change that behaviour, but only by going into the repository and manually editing the scripts that do the copying.

An alternative is to build FreeRTOS as part of the application, rather than as part of the BSP. That way you can use whichever heap_n you choose to include. The demo described on the following link does that. The link describes where to locate the demo in the main FreeRTOS download, as well as providing instructions on importing and building the demo. http://www.freertos.org/RTOS-Xilinx-Zynq.html

jeff29nj wrote on Thursday, May 07, 2015:

Thanks for your reply. Yes, I had been including FreeRTOS as part of the BSP.
I’m not sure where the scripts are exactly that do the copying?

I have the FreeRTOS demo, but am confused how to integrate FreeRTOS into a NEW application in my own workspace as opposed to using the demo which tells us to leave the code where it is and use as-is.


jeff29nj wrote on Thursday, May 07, 2015:

sorry, looks like this is informative…will read this:

jeff29nj wrote on Friday, May 08, 2015:

I was able to bring FreeRTOS out of the BSP and into the main application using linked folders, however I did not have luck bringing the LWIP files into the main application, possibly because they are built to use FreeRTOS (this was from the sample application XAPP1026). I never was able to get the includes resolved.

Is it possible for you to tell me how to switch the heap implementation manually in the BSP so that when it is copied to the main application, it is using heap_4.c instead of heap_3.c?


rtel wrote on Friday, May 08, 2015:

Just a quick reply for now, but the official demo in the download builds both FreeRTOS and lwIP as part of the application. It is provided to allow people to start with a know working configuration that they can then adapt to their own application.

jeff29nj wrote on Monday, May 11, 2015:

Just so I know we are talking about the same thing, the demo I had downloaded was for Xilinx Zynq (XAPP1026) and builds the FreeRTOS and LWIP as part of the BSP which then gets copied over into an application. I think it is part of the “contributed code” on FreeRTOS site under Xilinx.

Maybe it can’t be modified easily to use heap_4.c

rtel wrote on Monday, May 11, 2015:

Please review the following pages:


jeff29nj wrote on Wednesday, May 13, 2015:

Thanks! I am attempting to use the official Xilinx Zynq Cortex demo as you mentioned, but am having trouble with 1 thing. The demo works on my ZC706 but the LWIP has issues with my BSP which implements Ethernet differently than the ZC706 does. Now that the LWIP is part of the application, as opposed to the BSP, is there a preferred method to link up properly to my PL file/HWP/xparameters etc? For example, I noticed that the xtopology_g.c file under the LWIP_port folder was still referring to a base address corresponding to XPAR_PS7_ETHERNET_0_BASEADDR when it should be XPAR_PS7_ETHERNET_1_BASEADDR. Seems like a disconnect. Should I be manually copying LWIP files over from when I included LWIP in the BSP?


rtel wrote on Wednesday, May 13, 2015:

I would suggest creating an lwIP BSP for your hardware using the SDK,
then copy any relevant hardware files that are different between the two
hardware platforms into the project (maybe only the xparameters.h file
is needed?).


jeff29nj wrote on Thursday, May 14, 2015:

I got it working thanks. I needed to rip out the full demo because it referenced some IP that was not included in our PL. Also, needed to copy over a LWIP generated topology file. Thanks!