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.

Optimization prevents access to extended addresses

Other Parts Discussed in Thread: MSP430FR6989, MSP430FR5989

Hi,

MCU: MSP430FR6989 
IDE: Code Composer Studio 6.1.1
Compiler version: v4.4.6

I am working with the MSP430FR6989  and am using a large portion of the onboard FRAM for data storage. This ticket gives some background into how I updated the linker file in order to store data in the FRAM segment starting at address 0x10000:

MSP430FR6989, Unable to use FRAM2 with #pragma PERSISTENT


For the extended address range, I have declared a single uint8_t array (m_stepData2) as PERSISTENT and set its length so that it occupies all of the space from 0x10000 - 0x24000:

#define STEP_DATA_BUF_2_SIZE_BYTES  0x14000U

#pragma PERSISTENT
uint8_t SMemory::m_stepData2[STEP_DATA_BUF_2_SIZE_BYTES] = {0};

I also have a function called WriteStepData that writes to this array. When testing in my debug build with the optimization level set to 0, everything works fine and if I look in the Memory Allocation GUI I can see that m_stepData2 is taking up all of the DATA_FRAM2 segment we declared in the linker:

The problem I have now is if I change the optimization level from 0 to level 4 (Whole Program Optimizations), my calls to WriteStepData result in this warning:

I seem to have narrowed it down to changing the optimization level that generates this warning. The problem is that I need to be able to use a high level of optimization to reduce the code size to a manageable level. 

Do you have any insight into how I can still use the extended address space AND still keep the optimization level 4 enabled?

  • That error message says the tools cannot encode the call instruction from main to the function SMemory::m_stepData2.  Does that make sense?

    Are you building with the compiler option --code_model=large?  If you are, then I have to suspect a bug in the compiler or linker.

    Thanks and regards,

    -George

  • Hi George. Yeah, that's how I interpreted it. And so I did make sure that both the large code and large memory compiler options were set. Even with both of them set, I still get the error.

    Here is my compiler option summary:
    -vmspx --abi=eabi --code_model=large --data_model=large --near_data=none -O4 --opt_for_speed=0 --use_hw_mpy=F5 --include_path="C:/ti/ccsv6/ccs_base/msp430/include" --include_path="C:/Foucault/Firmware/src" --include_path="C:/Foucault/Firmware/src/TI_DriverLib" --include_path="C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.6/include" --advice:power="all" --advice:hw_config=all --define=__MSP430FR5989__ --define=_MPU_ENABLE --display_error_number --diag_wrap=off --diag_warning=225 --small_enum --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 --printf_support=minimal

    Here is my linker option summary:
    -vmspx --abi=eabi --code_model=large --data_model=large --near_data=none -O4 --opt_for_speed=0 --use_hw_mpy=F5 --advice:power="all" --advice:hw_config=all --define=__MSP430FR5989__ --define=_MPU_ENABLE --display_error_number --diag_wrap=off --diag_warning=225 --small_enum --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 --printf_support=minimal -z -m"Foucault.map" --stack_size=250 --heap_size=0 --cinit_hold_wdt=on -i"C:/ti/ccsv6/ccs_base/msp430/include" -i"C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.6/lib" -i"C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.6/include" -i"C:/ti/ccsv6/ccs_base/msp430/lib/5xx_6xx_FRxx" -i"C:/ti/ccsv6/ccs_base/msp430/lib/FR59xx" --reread_libs --priority --define=_MPU_ENABLE --diag_wrap=off --warn_sections --display_error_number --xml_link_info="Foucault_linkInfo.xml" --use_hw_mpy=F5 --rom_model

    A side note is that I also tried playing with the --near_data option. But it didn't make any difference whether I set it to "none" or "globals"
  • I think the only way to figure this out is for you to send us your CCS project.  Please create a project zip file as described here, and attach that to your next post.

    Thanks and regards,

    -George

  • Hi George,

    I had to cut the project down and remove some sensitive names, but it compiles fine and still throws the same error. In main I make a single call to a function that tries to access the offending array.

    Let me know if you have any questions. Anxiously looking forward to what you can find!

    Thanks!

    Test_Project.zip

  • Thank you for the test case.  I can reproduce the same results.  I filed SDSCM00052683 in the SDOWP system to have this investigated.  You are welcome to follow it with the SDOWP link below in my signature.

    A workaround is to build with --opt_level=3 or lower.  Hopefully, that makes code size small enough.

    Another idea to consider ... See if using Optimizer Assistant can help you find a better setting for the compiler options --opt_level or --opt_for_speed (which also affects size).

    Thanks and regards,

    -George

  • Hi George,

    Thanks for submitting that bug report. Not being able to use optimization level 4 is going to be rough. Our code size grows by about 3k when going from level 4 to level 3. 

    Hopefully this can be resolved soon!