pic18f4550 Heap too large

argo777 wrote on Monday, December 31, 2007:

Hi,
i’ve tried to build FreeRtos for pic 18f4550 but I faced the following problem:

Using the following modified linker script and FreeRTOSConfig.h from the demo:

// File: 18f4550.lkr
// Sample linker script for the PIC18F4550 processor

LIBPATH .

FILES c018i.o
FILES clib.lib
FILES p18f4550.lib

CODEPAGE   NAME=vectors    START=0x0            END=0x29           PROTECTED
CODEPAGE   NAME=page       START=0x2A           END=0x7FFF
CODEPAGE   NAME=idlocs     START=0x200000       END=0x200007       PROTECTED
CODEPAGE   NAME=config     START=0x300000       END=0x30000D       PROTECTED
CODEPAGE   NAME=devid      START=0x3FFFFE       END=0x3FFFFF       PROTECTED
CODEPAGE   NAME=eedata     START=0xF00000       END=0xF000FF       PROTECTED

ACCESSBANK NAME=accessram  START=0x0            END=0x5F
DATABANK   NAME=gpr0       START=0x60           END=0x2FF
DATABANK   NAME=gpr3       START=0x300          END=0x3FF
DATABANK   NAME=usb4       START=0x400          END=0x4FF          PROTECTED
DATABANK   NAME=usb5       START=0x500          END=0x5FF          PROTECTED
DATABANK   NAME=usb6       START=0x600          END=0x6FF          PROTECTED
DATABANK   NAME=usb7       START=0x700          END=0x7FF          PROTECTED
ACCESSBANK NAME=accesssfr  START=0xF60          END=0xFFF          PROTECTED

SECTION    NAME=CONFIG     ROM=config

STACK SIZE=0x100 RAM=gpr3

and setting the Heap Size to 512 in  FreeRTOSConfig.h

#define configTOTAL_HEAP_SIZE            ( ( size_t ) 512 )

I get this error:
Error - section ‘.udata_heap_1.o’ can not fit the section. Section ‘.udata_heap_1.o’ length=0x00000404

I can’t understand why the heap is still at 0x404 since i configured it to be 512 bytes long

Moreover if i use the following linker script:

// File: 18f4550.lkr
// Sample linker script for the PIC18F4550 processor

LIBPATH .

FILES c018i.o
FILES clib.lib
FILES p18f4550.lib

CODEPAGE   NAME=vectors    START=0x0            END=0x29           PROTECTED
CODEPAGE   NAME=page       START=0x2A           END=0x7FFF
CODEPAGE   NAME=idlocs     START=0x200000       END=0x200007       PROTECTED
CODEPAGE   NAME=config     START=0x300000       END=0x30000D       PROTECTED
CODEPAGE   NAME=devid      START=0x3FFFFE       END=0x3FFFFF       PROTECTED
CODEPAGE   NAME=eedata     START=0xF00000       END=0xF000FF       PROTECTED

ACCESSBANK NAME=accessram  START=0x0            END=0x5F
DATABANK   NAME=BIG_BLOCK  START=0x60        END=0x5FF         
DATABANK   NAME=usb6       START=0x600          END=0x6FF          PROTECTED
DATABANK   NAME=usb7       START=0x700          END=0x7FF          PROTECTED
ACCESSBANK NAME=accesssfr  START=0xF60          END=0xFFF          PROTECTED

SECTION    NAME=CONFIG     ROM=config

STACK SIZE=0x60 RAM=BIG_BLOCK

(always with the heap set at 512)

The program links correctly and the map file still shows a lenght of 1024 for the heap.

Can anyone help me? Thanks and happy new year.

Stefano

argo777 wrote on Monday, December 31, 2007:

Sorry of course, the first linker script is wrong, here is the correct one:

ACCESSBANK NAME=accessram  START=0x0            END=0x5F
DATABANK   NAME=gpr0       START=0x60           END=0x3FF
DATABANK   NAME=usb4       START=0x400          END=0x4FF          PROTECTED
DATABANK   NAME=usb5       START=0x500          END=0x5FF          PROTECTED
DATABANK   NAME=usb6       START=0x600          END=0x6FF          PROTECTED
DATABANK   NAME=usb7       START=0x700          END=0x7FF          PROTECTED
ACCESSBANK NAME=accesssfr  START=0xF60          END=0xFFF          PROTECTED

That still not work.

The fact seems to be that the data section of the heap is alwais 1024 long despite what i write in FreeRTOSConfig.h

picmeup wrote on Monday, December 31, 2007:

I just tried using heaps of 1024 and 512 bytes and got a size of 0x404 and 0x204 respectively. Are you sure you are editing the file that is actually being built? Try adding a syntax error into FreeRTOSConfig.h where the heap size is set to check that the build breaks.

argo777 wrote on Monday, December 31, 2007:

Confirmed with the sintax error the compilation fails.
Thank anyway.
Stefano

picmeup wrote on Monday, December 31, 2007:

I know this is a daft suggestion but I can not think of anything else. Can you check that portCHAR is defined as char in portmacro.h. What value is returned from sizeof(unsigned portCHAR)?

argo777 wrote on Monday, December 31, 2007:

Sorry you were right there was a problem in the include paths
Thanks for your help.
Happy new Year.

Stefano