freeRTOS dsPIC demo : what files can I remove

johnbaker10 wrote on Monday, August 10, 2009:

On the dsPIC demo, what files can I remove? I want to replace the demo files with my own files but can’t figure out which ones can be removed. The manual says to “strip out the source files that define the demo tasks” but I don’t know which ones I can remove. I started removing files and then got into a mess with lots of errors that some functions couldn’t be found. Is there a list of the files that are required?

johnbaker10 wrote on Monday, August 10, 2009:

Grumble grumble. It looks like I can safely remove blocktim, crflash, lcd, ParTest, serial and timertest but when I add one (1) of my C files and a header, I start getting errors: …\…\compile_rules.o: Link Error: Could not allocate section .nbss, size = 2194 bytes, attributes = bss near
Link Error: Could not allocate data memory

So this doesn’t look promising. Is there any way to fix this up? Thanks for any help!

rtel wrote on Monday, August 10, 2009:

See http://www.freertos.org/a00017.html - anything that is in the FreeRTOS/Source directory is part of FreeRTOS and required - anything that is in the FreeRTOS/Demo directory is part of the demo app and is not required.

A quick and simple way is to remove anything that is in the FreeRTOS/Demo directory other than main(), then delete the whole of main() other than vTaskStartScheduler(), finally create your own tasks before vTaskStartScheduler() is called.

If you run out of RAM then reduce configTOTAL_HEAP_SIZE in FreeRTOSConfig.h.  I think this is an FAQ.

Regards.

johnbaker10 wrote on Monday, August 10, 2009:

Thanks Richard. Unfortunately, when I remove blocktim, crflash, lcd, ParTest, serial and timertest and add one (1) of my C files and a header, I start getting the Link errors: “…\…\compile_rules.o: Link Error: Could not allocate section .nbss, size = 2194 bytes, attributes = bss near  Link Error: Could not allocate data memory.” I haven’t removed any header files and still have croutine.c and .h, heap_1.c, list.c, main.c, port.c, portasm_dsPIC.s, queue.c and .h, tasks.c, FreeRTOSConfig.h, semphr.h and task.h in addition to my .c and .h files. Is that correct?

rtel wrote on Monday, August 10, 2009:

Did you try the suggestion from my previous post of decreasing the configTOTAL_HEAP_SIZE setting?

Regards.

johnbaker10 wrote on Tuesday, August 11, 2009:

No, I missed that about the configTOTAL_HEAP_SIZE. I didn’t see that in the FAQ. I have made a guess at decreasing it and now have another error for my function that I call only one time on start up and right now, it’s the only function that I’ve included in the project:
c:\program files\microchip\mplab c30\bin\bin\pic30-coff-ld.exe Error: A heap is required, but has not been specified.
It looks like I’ve gotten in over my head on this as I have no idea what to do. I see chapter 5 in the eBook and I see heap_1.c. Is the kernel expecting to find and call pvPortMalloc to do the memory allocation or do I have to call it from my function?

davedoors wrote on Tuesday, August 11, 2009:

The linker will require a heap if functions you have added use calls to malloc(). FreeRTOS does not call malloc but instead calls pvPortMalloc(). This allows the malloc implementation to be replaced and this is what heap_1, heap_2 and heap_3 do. Does your code call malloc()? If so try replacing it with pvPortMalloc() instead.

johnbaker10 wrote on Tuesday, August 11, 2009:

No, my code doesn’t call malloc. My code so far is just a function that will be called from main on startup but I don’t have the call in main yet for this function. Maybe that’s my problem?

johnbaker10 wrote on Thursday, August 13, 2009:

Ah, my mistake. I didn’t have the heap setup in the Linker and needed it for some printf’s. I had forgotten that a heap is required for printf’s. I found the answer in http://www.microchip.com/forums/tm.aspx?m=250151&mpage=1&key=&#250151. So now can compile and link. Thanks Richard.