This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

msp430f5438 region text is full

Other Parts Discussed in Thread: MSP430F5438

Hello everybody.

I am trying to port code written for the AVR platform over to the MSP430 one.

Specifically, I am targeting MSP430f5438 and compiling with mspgcc.

I keep getting a linkage error, saying :

C:\mspgcc\bin\..\lib\gcc-lib\msp430\3.2.3\..\..\..\..\msp430\bin\ld.exe: region text is full (Com.elf section .text)
C:\mspgcc\bin\..\lib\gcc-lib\msp430\3.2.3\..\..\..\..\msp430\bin\ld.exe: region text is full (Com.elf section .text)
C:\mspgcc\bin\..\lib\gcc-lib\msp430\3.2.3\..\..\..\..\msp430\bin\ld.exe: section .text [00005c00 -> 0001afc7] overlaps section .data [00005c00 -> 00005c21]
C:\mspgcc\bin\..\lib\gcc-lib\msp430\3.2.3\..\..\..\..\msp430\bin\ld.exe: section .vectors [0000ff80 -> 0000ffff] overlaps section .text [00005c00 -> 0001afc7]

The flash usage (0x005c00 to 0x1afc7) is about 87kBytes, and the MCU has 256kB available.

I have compiled with -O0 -mmcu=msp430x5438 , and I have also tried to manually define the __MSP430_5438__ macro, to no avail.

Any ideas on what I might be doing wrong?

  • Hi mihaigalos,

    Try to include msp430.h. In this case the __MSP430F5438__ helps. Some compiler needs a special setting to use FlashPROM above 64K like CCS and IAR. Keep in mind that interrupt routines need alway be placed in the first 64K segment.

    Regards

    Guenther

  • Thanks for the speedy answer.

    Actually, I am not using neither IAR, CCS nor interrupts.

    The code is 87 kB, I still can't imagine why it won't fit into 256kB...

     

    Regards,

    M

     

  • Hello Mihaigalos,

    According to you linker error message your compiler tries to loacte the code within the first 64 kB. This conflicts with other reserved address areas like interrupt vector table. I'm not familar with gcc on MSP430, so I can give you just rougth directions:

    - switch on the extended adress usage. This is normally a compiler flag. It could be that you need to select a different runtime library for this extended memory addressing as well.

    - change your linker command file to put the "text" segment on address 0x10000 and above.

    Keep in mind MSP430 has a 16bit CPU. 16bit can only address 64k. TI made an extension to address 24bit, but this must be switched on and configured.

    Regards

    Guenther

  • It's a good explanation, but I still believe the problem lies elsewhere.

    What is the purpose of the -mmcu=msp430x5438 if not? gcc should know this needs 24 bit addressing and proceed accordingly.

    According to the datasheet, Main code memory starts @ 0x5C00 and is 4 banks of 64K each. I tryed compiling with a newer version of mspgcc: version 4.

    The problem is still there:

     

    Invoking: Cygwin C Linker
    msp430-gcc -mmcu=msp430x5438 -static ........... <input files go here> 
    c:\mspgcc4\bin\msp430-ld.exe: Com.exe section `.text' will not fit in region `text'
    c:\mspgcc4\bin\msp430-ld.exe: section .vectors loaded at [0000ff80,0000ffff] overlaps section .text loaded at [00005c00,0001307d]
    c:\mspgcc4\bin\msp430-ld.exe: region `text' overflowed by 12544 bytes
    collect2: ld returned 1 exit status
    make: *** [Com.exe] Error 1

     

    So A) there is a space (-age :))problem

         B) the vectors (I'm guessing interrupt vectors) get put in the same region as text( not odd for me, I know they have to exist somewhere).

    I'm guessing that the two errors are interconnected? If not, maybe that is the default region for the vectors and I somehow need to remap them

     

  • Hi Mihaigalos,

    Well your code "text" must be contigous. However the interrupt table ".vectors" is fix at 0xff80. Try to move the "text" segment up to 0x10000. This should solve your problem.

    Regards

    Guenther

  • I think I know what's going on.

    You were right when you said it is better to put the code starting from 0x10000.

    According to this thread : http://old.nabble.com/section-.text-will-not-fit-in-region-text-td27091721.html

    the vectors always get put at the end of the first 64K bank. So, either you have an application that is less (or equal to) than 64K - sizeof(vectors),

    either you deploy your original solution.

    Do you, by any chance, know how to force code relocation to a specidic address? I'm guessing a linker rule maybe?!

     

    Cheers!

  • Hi,

    On CCS it is in file lnk_msp430fxxxx:

    SECTIONS
    {

    ...

       .text      : {} > FLASH2             /* CODE                              */

     

    on IAR it is in file lnk430Fxxxx:

    -Z(CODE)CODE=10000-2B400

    The end adress (2B400) depends on your MSP430 version.

    I hope this helps

    Regards

    Guenther


  • Actually, because my app requires the use of pointers(and I don't want to use inline assembly(-yet!)), I'm going to split it into two sections.

    One that will rezide in bank0(pointer-critical part), and the rest in the upper banks.

    So I won't relocate the whole text region starting from bank1.

     

    Now, from what little info I gathered from the internet, I need to use the __attribute__((__far__)) prefix for functions, for example:

    __attribute__((__far__)) uint16_t  foo(uint8_t x). It does not get relocated, but a waring is thrown: '__far__' attribute directive ignored.

     

    If you have any experience with mspgcc on this topic, please help.

     

    Thank you!

    M

     

  • I had the same problem described in the first post. The solution is simple. Just invoke the linker with parameter -T msp430x5438.x which adds linker script with definitions of memory sizes for specified microcontroller.

**Attention** This is a public forum