0

I'm using Microchips XC32 C compiler and tools to build an executable for a SAM E70 processor.

I have to create a function that is executed from RAM and not ROM/Flash because this function uses special instructions to read a unique 128 bits at the beginning of Flash.

So I've defined the beginning of the function like this:

__ramfunc__ void ReadUniqueID(uint32_t *pdwUniqueID)
{
    uint32_t status;

    if (pdwUniqueID == NULL)
        return;
    printf("ReadUniqueID begin\r\n", pdwUniqueID[0]);

According to the documentation __ramfunc__ is supposed to ensure that the function is executed from ram.

However, when linking, the following errors occur.

c:\program files\microchip\xc32\v3.01\bin\bin\..\..\lib\gcc\pic32c\8.3.1\..\..\..\..\bin\bin/pic32c-ld.exe: Link Warning: attributes for input section '.RAMFUNC$.__stub' conflict with output section '.RAMFUNC$'
c:\program files\microchip\xc32\v3.01\bin\bin\..\..\lib\gcc\pic32c\8.3.1\..\..\..\..\bin\bin/pic32c-ld.exe: section .text.Reset_Handler%184 LMA [0044ba08,0044bb8b] overlaps section .text%180 LMA [0044b3bc,0044ba0f]
c:\program files\microchip\xc32\v3.01\bin\bin\..\..\lib\gcc\pic32c\8.3.1\..\..\..\..\bin\bin/pic32c-ld.exe: section .bss%44 VMA [2045fff4,2045ffff] overlaps section .RAMFUNC$ VMA [2045ff58,20460007]
Link Error: can't load section .RAMFUNC$ contents

Any help or pointers would be greatly appreciated.

Chimera
  • 5,884
  • 7
  • 49
  • 81

1 Answers1

0

Problem turned out to be that I was using printf() in the "ramfunc" function. Removed the printf()'s and all is working as expected.

Chimera
  • 5,884
  • 7
  • 49
  • 81
  • The real problem is that the linker freaks out if a function in RAM calls a function in flash, in this case printf. The call tree from a RAMFUNC function may only contain other RAMFUNC. – Greg Young May 01 '23 at 16:48