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.

MSP430FR6043: IQmathLib and GCC with -mlarge

Part Number: MSP430FR6043
Other Parts Discussed in Thread: MSP430WARE, MSP-IQMATHLIB

Hello,

we cannot take in use the IQmathLib_CCS_MPY32_5xx_6xx_CPUX_large_code_small_data.lib with gcc-9.3.1 on MSP430FR6043.

Steps:

1. started a CCS project using latest GNU v9.3.1.11 for MSP430FR6043

2. in project properties -> Build -> GNU Compiler -> Miscellaneous ensure that these are set:

-mlarge

-mcode-region=none

-mdata-region=lower

3. in project properties -> Build -> Gnu Linker -> Libraries add library name and path:

IQmathLib_CCS_MPY32_5xx_6xx_CPUX_large_code_small_data.lib

C:\ti\msp430ware_3_80_14_01\iqmathlib\libraries\CCS\MPY32\5xx_6xx

4. try to build, but it fails with:

IQmathLib_CCS_MPY32_5xx_6xx_CPUX_large_code_small_data.lib(_IQNdiv.o) uses the small data model whereas d:/tools/gcc-msp430/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/lib/large/crt0.o uses the large data model

Other versions tried:

-mdata-region=lower with IQmathLib_CCS_MPY32_5xx_6xx_CPUX_large_code_restricted_data.lib  =>  same msp430-elf\lib\large\crt0.o uses the large data model

-mdata-region=lower with IQmathLib_CCS_MPY32_5xx_6xx_CPUX_large_code_large_data.lib  =>  IQmathLib can use the upper region for data, but test_GCC.out assumes data is exclusively in lower memory

-mdata-region=none with IQmathLib_CCS_MPY32_5xx_6xx_CPUX_large_code_small_data.lib  =>  msp430-elf\lib\large\crt0.o uses the large data model

-mdata-region=none with IQmathLib_CCS_MPY32_5xx_6xx_CPUX_large_code_restricted_data.lib  =>  msp430-elf\lib\large\crt0.o uses the large data model

The only combination which seems to work is -mcode-region=either plus -mdata-region=none with IQmathLib_CCS_MPY32_5xx_6xx_CPUX_large_code_large_data.lib  =>  builds but with lots of linkage warnings:

But using large_data model brings lots of overhead as all the data pointers will be far instead of near... which means it will slow down the math operations, right? Confused

Was anyone able to got the IQmathLib building fine with GCC? Specifically when the code is large and data is small (IQmathLib_CCS_MPY32_5xx_6xx_CPUX_large_code_small_data.lib)?

Is there a msp430-elf/lib/large/crt0.o which uses large code model but small data model?

Thank you,

Daniel

  • GCC only provides -mlarge and -msmall. There is no option for large code and small data.

  • Thank you David, great finding! Indeed removing the float there, reduces IQmath timing drastically:

    • 0.17s vs 2.2s with GCC

    and for reference: 0.16s vs 0.37s with TI-compiler:

    With GCC remain the questions how to get IQmathLib_CCS_MPY32_5xx_6xx_CPUX_large_code_small_data.lib linking or, if not possible, why large_code_large_data.lib throw lots of linkage warnings.

    Thank you,

    Daniel

    PS: the code corrected with David's suggestion is:

    static _iq20 xm[TEST_SIZE];
    static void math_test(void)
    {
        _iq20 f1 = _IQ20(2.103f);
        _iq20 f2 = _IQ20(1.135f);
        xm[0] = _IQ20(1.0f);
        for (uint16_t i = 2; i <= TEST_SIZE; i++) {
            if (xm[i - 2U] > _IQ20(1.0f)) {
                xm[i - 1U] = _IQ20div((_IQ20mpy(f1, _IQ20(i + 1U)) + _IQ20mpy(f2, _IQ20(i - 1U))), xm[i - 2U]);
            } else {
                xm[i - 1U] = _IQ20mpy((_IQ20mpy(f1, _IQ20(i + 1U)) + _IQ20mpy(f2, _IQ20(i - 1U))), xm[i - 2U]);
            }
        }
    }

  • Sorry: posted the "float" reply to the wrong thread...

  • Hi David, Thanks for your support

    Hi Daniel, Please check MSP IQMath Users Guide on MSP-IQMATHLIB page: https://www.ti.com/tool/MSP-IQMATHLIB

    Thanks

  • Thank you, but that guide doesn't help at all with GCC... Our MSP430FR6043 project needs

    • -mlarge
    • -mcode-region=none or either
    • -mdata-region=none or lower

    And with these, GCC doesn't link with iqmathlib\libraries\CCS\MPY32\5xx_6xx\IQmathLib_CCS_MPY32_5xx_6xx_CPUX_large_code_small_data.lib: it complains that /msp430-elf/lib/large/crt0.o uses the large data model ?! As David explained seems to be a GCC issue, not delivering all lib versions.

    It builds only with _large_code_largel_data.lib (even with that it throws 66 linker warnings!) but at least it works somehow... Unfortunately due the mentioned linker warnings we cannot continue with this combination too.

  • The region options have distinct effects depending on if the compiler is producing code or linking. You haven't shown your link options...

    Looking at the GCC compiler guide, getting -mdata-region-lower to do anything requires an extra option. It would seem pretty much useless since there isn't a GCC library to match. Which is odd because except on FRAM parts data in upper memory isn't even a possibility.

    As for IQMath itself, unless you need some of the fancier functions, you might be able to skip it. Fixed point addition and subtraction are simple. Multiplication and division are a little harder because you have to fix up the binary point.

**Attention** This is a public forum